/*! * jquery ui widget 1.10.4 * http://jqueryui.com * * copyright 2014 jquery foundation and other contributors * released under the mit license. * http://jquery.org/license * * http://api.jqueryui.com/jquery.widget/ */ (function( $, undefined ) { var uuid = 0, slice = array.prototype.slice, _cleandata = $.cleandata; $.cleandata = function( elems ) { for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { try { $( elem ).triggerhandler( "remove" ); // http://bugs.jquery.com/ticket/8235 } catch( e ) {} } _cleandata( elems ); }; $.widget = function( name, base, prototype ) { var fullname, existingconstructor, constructor, baseprototype, // proxiedprototype allows the provided prototype to remain unmodified // so that it can be used as a mixin for multiple widgets (#8876) proxiedprototype = {}, namespace = name.split( "." )[ 0 ]; name = name.split( "." )[ 1 ]; fullname = namespace + "-" + name; if ( !prototype ) { prototype = base; base = $.widget; } // create selector for plugin $.expr[ ":" ][ fullname.tolowercase() ] = function( elem ) { return !!$.data( elem, fullname ); }; $[ namespace ] = $[ namespace ] || {}; existingconstructor = $[ namespace ][ name ]; constructor = $[ namespace ][ name ] = function( options, element ) { // allow instantiation without "new" keyword if ( !this._createwidget ) { return new constructor( options, element ); } // allow instantiation without initializing for simple inheritance // must use "new" keyword (the code above always passes args) if ( arguments.length ) { this._createwidget( options, element ); } }; // extend with the existing constructor to carry over any static properties $.extend( constructor, existingconstructor, { version: prototype.version, // copy the object used to create the prototype in case we need to // redefine the widget later _proto: $.extend( {}, prototype ), // track widgets that inherit from this widget in case this widget is // redefined after a widget inherits from it _childconstructors: [] }); baseprototype = new base(); // we need to make the options hash a property directly on the new instance // otherwise we'll modify the options hash on the prototype that we're // inheriting from baseprototype.options = $.widget.extend( {}, baseprototype.options ); $.each( prototype, function( prop, value ) { if ( !$.isfunction( value ) ) { proxiedprototype[ prop ] = value; return; } proxiedprototype[ prop ] = (function() { var _super = function() { return base.prototype[ prop ].apply( this, arguments ); }, _superapply = function( args ) { return base.prototype[ prop ].apply( this, args ); }; return function() { var __super = this._super, __superapply = this._superapply, returnvalue; this._super = _super; this._superapply = _superapply; returnvalue = value.apply( this, arguments ); this._super = __super; this._superapply = __superapply; return returnvalue; }; })(); }); constructor.prototype = $.widget.extend( baseprototype, { // todo: remove support for widgeteventprefix // always use the name + a colon as the prefix, e.g., draggable:start // don't prefix for widgets that aren't dom-based widgeteventprefix: existingconstructor ? (baseprototype.widgeteventprefix || name) : name }, proxiedprototype, { constructor: constructor, namespace: namespace, widgetname: name, widgetfullname: fullname }); // if this widget is being redefined then we need to find all widgets that // are inheriting from it and redefine all of them so that they inherit from // the new version of this widget. we're essentially trying to replace one // level in the prototype chain. if ( existingconstructor ) { $.each( existingconstructor._childconstructors, function( i, child ) { var childprototype = child.prototype; // redefine the child widget using the same prototype that was // originally used, but inherit from the new version of the base $.widget( childprototype.namespace + "." + childprototype.widgetname, constructor, child._proto ); }); // remove the list of existing child constructors from the old constructor // so the old child constructors can be garbage collected delete existingconstructor._childconstructors; } else { base._childconstructors.push( constructor ); } $.widget.bridge( name, constructor ); }; $.widget.extend = function( target ) { var input = slice.call( arguments, 1 ), inputindex = 0, inputlength = input.length, key, value; for ( ; inputindex < inputlength; inputindex++ ) { for ( key in input[ inputindex ] ) { value = input[ inputindex ][ key ]; if ( input[ inputindex ].hasownproperty( key ) && value !== undefined ) { // clone objects if ( $.isplainobject( value ) ) { target[ key ] = $.isplainobject( target[ key ] ) ? $.widget.extend( {}, target[ key ], value ) : // don't extend strings, arrays, etc. with objects $.widget.extend( {}, value ); // copy everything else by reference } else { target[ key ] = value; } } } } return target; }; $.widget.bridge = function( name, object ) { var fullname = object.prototype.widgetfullname || name; $.fn[ name ] = function( options ) { var ismethodcall = typeof options === "string", args = slice.call( arguments, 1 ), returnvalue = this; // allow multiple hashes to be passed on init options = !ismethodcall && args.length ? $.widget.extend.apply( null, [ options ].concat(args) ) : options; if ( ismethodcall ) { this.each(function() { var methodvalue, instance = $.data( this, fullname ); if ( !instance ) { return $.error( "cannot call methods on " + name + " prior to initialization; " + "attempted to call method '" + options + "'" ); } if ( !$.isfunction( instance[options] ) || options.charat( 0 ) === "_" ) { return $.error( "no such method '" + options + "' for " + name + " widget instance" ); } methodvalue = instance[ options ].apply( instance, args ); if ( methodvalue !== instance && methodvalue !== undefined ) { returnvalue = methodvalue && methodvalue.jquery ? returnvalue.pushstack( methodvalue.get() ) : methodvalue; return false; } }); } else { this.each(function() { var instance = $.data( this, fullname ); if ( instance ) { instance.option( options || {} )._init(); } else { $.data( this, fullname, new object( options, this ) ); } }); } return returnvalue; }; }; $.widget = function( /* options, element */ ) {}; $.widget._childconstructors = []; $.widget.prototype = { widgetname: "widget", widgeteventprefix: "", defaultelement: "
", options: { disabled: false, // callbacks create: null }, _createwidget: function( options, element ) { element = $( element || this.defaultelement || this )[ 0 ]; this.element = $( element ); this.uuid = uuid++; this.eventnamespace = "." + this.widgetname + this.uuid; this.options = $.widget.extend( {}, this.options, this._getcreateoptions(), options ); this.bindings = $(); this.hoverable = $(); this.focusable = $(); if ( element !== this ) { $.data( element, this.widgetfullname, this ); this._on( true, this.element, { remove: function( event ) { if ( event.target === element ) { this.destroy(); } } }); this.document = $( element.style ? // element within the document element.ownerdocument : // element is window or document element.document || element ); this.window = $( this.document[0].defaultview || this.document[0].parentwindow ); } this._create(); this._trigger( "create", null, this._getcreateeventdata() ); this._init(); }, _getcreateoptions: $.noop, _getcreateeventdata: $.noop, _create: $.noop, _init: $.noop, destroy: function() { this._destroy(); // we can probably remove the unbind calls in 2.0 // all event bindings should go through this._on() this.element .unbind( this.eventnamespace ) // 1.9 bc for #7810 // todo remove dual storage .removedata( this.widgetname ) .removedata( this.widgetfullname ) // support: jquery <1.6.3 // http://bugs.jquery.com/ticket/9413 .removedata( $.camelcase( this.widgetfullname ) ); this.widget() .unbind( this.eventnamespace ) .removeattr( "aria-disabled" ) .removeclass( this.widgetfullname + "-disabled " + "ui-state-disabled" ); // clean up events and states this.bindings.unbind( this.eventnamespace ); this.hoverable.removeclass( "ui-state-hover" ); this.focusable.removeclass( "ui-state-focus" ); }, _destroy: $.noop, widget: function() { return this.element; }, option: function( key, value ) { var options = key, parts, curoption, i; if ( arguments.length === 0 ) { // don't return a reference to the internal hash return $.widget.extend( {}, this.options ); } if ( typeof key === "string" ) { // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } options = {}; parts = key.split( "." ); key = parts.shift(); if ( parts.length ) { curoption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); for ( i = 0; i < parts.length - 1; i++ ) { curoption[ parts[ i ] ] = curoption[ parts[ i ] ] || {}; curoption = curoption[ parts[ i ] ]; } key = parts.pop(); if ( arguments.length === 1 ) { return curoption[ key ] === undefined ? null : curoption[ key ]; } curoption[ key ] = value; } else { if ( arguments.length === 1 ) { return this.options[ key ] === undefined ? null : this.options[ key ]; } options[ key ] = value; } } this._setoptions( options ); return this; }, _setoptions: function( options ) { var key; for ( key in options ) { this._setoption( key, options[ key ] ); } return this; }, _setoption: function( key, value ) { this.options[ key ] = value; if ( key === "disabled" ) { this.widget() .toggleclass( this.widgetfullname + "-disabled ui-state-disabled", !!value ) .attr( "aria-disabled", value ); this.hoverable.removeclass( "ui-state-hover" ); this.focusable.removeclass( "ui-state-focus" ); } return this; }, enable: function() { return this._setoption( "disabled", false ); }, disable: function() { return this._setoption( "disabled", true ); }, _on: function( suppressdisabledcheck, element, handlers ) { var delegateelement, instance = this; // no suppressdisabledcheck flag, shuffle arguments if ( typeof suppressdisabledcheck !== "boolean" ) { handlers = element; element = suppressdisabledcheck; suppressdisabledcheck = false; } // no element argument, shuffle and use this.element if ( !handlers ) { handlers = element; element = this.element; delegateelement = this.widget(); } else { // accept selectors, dom elements element = delegateelement = $( element ); this.bindings = this.bindings.add( element ); } $.each( handlers, function( event, handler ) { function handlerproxy() { // allow widgets to customize the disabled handling // - disabled as an array instead of boolean // - disabled class as method for disabling individual parts if ( !suppressdisabledcheck && ( instance.options.disabled === true || $( this ).hasclass( "ui-state-disabled" ) ) ) { return; } return ( typeof handler === "string" ? instance[ handler ] : handler ) .apply( instance, arguments ); } // copy the guid so direct unbinding works if ( typeof handler !== "string" ) { handlerproxy.guid = handler.guid = handler.guid || handlerproxy.guid || $.guid++; } var match = event.match( /^(\w+)\s*(.*)$/ ), eventname = match[1] + instance.eventnamespace, selector = match[2]; if ( selector ) { delegateelement.delegate( selector, eventname, handlerproxy ); } else { element.bind( eventname, handlerproxy ); } }); }, _off: function( element, eventname ) { eventname = (eventname || "").split( " " ).join( this.eventnamespace + " " ) + this.eventnamespace; element.unbind( eventname ).undelegate( eventname ); }, _delay: function( handler, delay ) { function handlerproxy() { return ( typeof handler === "string" ? instance[ handler ] : handler ) .apply( instance, arguments ); } var instance = this; return settimeout( handlerproxy, delay || 0 ); }, _hoverable: function( element ) { this.hoverable = this.hoverable.add( element ); this._on( element, { mouseenter: function( event ) { $( event.currenttarget ).addclass( "ui-state-hover" ); }, mouseleave: function( event ) { $( event.currenttarget ).removeclass( "ui-state-hover" ); } }); }, _focusable: function( element ) { this.focusable = this.focusable.add( element ); this._on( element, { focusin: function( event ) { $( event.currenttarget ).addclass( "ui-state-focus" ); }, focusout: function( event ) { $( event.currenttarget ).removeclass( "ui-state-focus" ); } }); }, _trigger: function( type, event, data ) { var prop, orig, callback = this.options[ type ]; data = data || {}; event = $.event( event ); event.type = ( type === this.widgeteventprefix ? type : this.widgeteventprefix + type ).tolowercase(); // the original event may come from any element // so we need to reset the target on the new event event.target = this.element[ 0 ]; // copy original event properties over to the new event orig = event.originalevent; if ( orig ) { for ( prop in orig ) { if ( !( prop in event ) ) { event[ prop ] = orig[ prop ]; } } } this.element.trigger( event, data ); return !( $.isfunction( callback ) && callback.apply( this.element[0], [ event ].concat( data ) ) === false || event.isdefaultprevented() ); } }; $.each( { show: "fadein", hide: "fadeout" }, function( method, defaulteffect ) { $.widget.prototype[ "_" + method ] = function( element, options, callback ) { if ( typeof options === "string" ) { options = { effect: options }; } var hasoptions, effectname = !options ? method : options === true || typeof options === "number" ? defaulteffect : options.effect || defaulteffect; options = options || {}; if ( typeof options === "number" ) { options = { duration: options }; } hasoptions = !$.isemptyobject( options ); options.complete = callback; if ( options.delay ) { element.delay( options.delay ); } if ( hasoptions && $.effects && $.effects.effect[ effectname ] ) { element[ method ]( options ); } else if ( effectname !== method && element[ effectname ] ) { element[ effectname ]( options.duration, options.easing, callback ); } else { element.queue(function( next ) { $( this )[ method ](); if ( callback ) { callback.call( element[ 0 ] ); } next(); }); } }; }); })( jquery );