}
}( function( $ ) {
-var widgetUuid = 0,
- widgetSlice = Array.prototype.slice;
+var widgetUuid = 0;
+var widgetSlice = Array.prototype.slice;
$.cleanData = ( function( orig ) {
return function( elems ) {
} )( $.cleanData );
$.widget = function( name, base, prototype ) {
- var fullName, existingConstructor, constructor, basePrototype,
+ var 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 ];
+ // ProxiedPrototype allows the provided prototype to remain unmodified
+ // so that it can be used as a mixin for multiple widgets (#8876)
+ var proxiedPrototype = {};
+ var namespace = name.split( "." )[ 0 ];
name = name.split( "." )[ 1 ];
- fullName = namespace + "-" + name;
+ var fullName = namespace + "-" + name;
if ( !prototype ) {
prototype = base;
return;
}
proxiedPrototype[ prop ] = ( function() {
- var _super = function() {
- return base.prototype[ prop ].apply( this, arguments );
- },
- _superApply = function( args ) {
- return base.prototype[ prop ].apply( this, args );
- };
+ function _super() {
+ return base.prototype[ prop ].apply( this, arguments );
+ }
+
+ function _superApply( args ) {
+ return base.prototype[ prop ].apply( this, args );
+ }
+
return function() {
- var __super = this._super,
- __superApply = this._superApply,
- returnValue;
+ var __super = this._super;
+ var __superApply = this._superApply;
+ var returnValue;
this._super = _super;
this._superApply = _superApply;
// 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 );
+ $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor,
+ child._proto );
} );
// Remove the list of existing child constructors from the old constructor
};
$.widget.extend = function( target ) {
- var input = widgetSlice.call( arguments, 1 ),
- inputIndex = 0,
- inputLength = input.length,
- key,
- value;
+ var input = widgetSlice.call( arguments, 1 );
+ var inputIndex = 0;
+ var inputLength = input.length;
+ var key;
+ var value;
+
for ( ; inputIndex < inputLength; inputIndex++ ) {
for ( key in input[ inputIndex ] ) {
value = input[ inputIndex ][ key ];
$.widget.bridge = function( name, object ) {
var fullName = object.prototype.widgetFullName || name;
$.fn[ name ] = function( options ) {
- var isMethodCall = typeof options === "string",
- args = widgetSlice.call( arguments, 1 ),
- returnValue = this;
+ var isMethodCall = typeof options === "string";
+ var args = widgetSlice.call( arguments, 1 );
+ var returnValue = this;
if ( isMethodCall ) {
this.each( function() {
- var methodValue,
- instance = $.data( this, fullName );
+ var methodValue;
+ var instance = $.data( this, fullName );
+
if ( options === "instance" ) {
returnValue = instance;
return false;
}
+
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() ) :
widgetName: "widget",
widgetEventPrefix: "",
defaultElement: "<div>",
+
options: {
classes: {},
disabled: false,
// Callbacks
create: null
},
+
_createWidget: function( options, element ) {
element = $( element || this.defaultElement || this )[ 0 ];
this.element = $( element );
this._trigger( "create", null, this._getCreateEventData() );
this._init();
},
+
_getCreateOptions: $.noop,
+
_getCreateEventData: $.noop,
+
_create: $.noop,
+
_init: $.noop,
destroy: function() {
// Clean up events and states
this.bindings.off( this.eventNamespace );
},
+
_destroy: $.noop,
widget: function() {
},
option: function( key, value ) {
- var options = key,
- parts,
- curOption,
- i;
+ var options = key;
+ var parts;
+ var curOption;
+ var i;
if ( arguments.length === 0 ) {
return this;
},
+
_setOptions: function( options ) {
var key;
return this;
},
+
_setOption: function( key, value ) {
if ( key === "classes" ) {
this._setOptionClasses( value );
return this;
},
+
_setOptionClasses: function( value ) {
var classKey, elements, currentElements;
enable: function() {
return this._setOptions( { disabled: false } );
},
+
disable: function() {
return this._setOptions( { disabled: true } );
},
_classes: function( options ) {
- var full = [],
- that = this;
+ var full = [];
+ var that = this;
options = $.extend( {
element: this.element,
},
_on: function( suppressDisabledCheck, element, handlers ) {
- var delegateElement,
- instance = this;
+ var delegateElement;
+ var instance = this;
// No suppressDisabledCheck flag, shuffle arguments
if ( typeof suppressDisabledCheck !== "boolean" ) {
handler.guid || handlerProxy.guid || $.guid++;
}
- var match = event.match( /^([\w:-]*)\s*(.*)$/ ),
- eventName = match[ 1 ] + instance.eventNamespace,
- selector = match[ 2 ];
+ var match = event.match( /^([\w:-]*)\s*(.*)$/ );
+ var eventName = match[ 1 ] + instance.eventNamespace;
+ var selector = match[ 2 ];
+
if ( selector ) {
delegateElement.on( eventName, selector, handlerProxy );
} else {
},
_trigger: function( type, event, data ) {
- var prop, orig,
- callback = this.options[ type ];
+ var prop, orig;
+ var callback = this.options[ type ];
data = data || {};
event = $.Event( event );
if ( typeof options === "string" ) {
options = { effect: options };
}
- var hasOptions,
- effectName = !options ?
- method :
- options === true || typeof options === "number" ?
- defaultEffect :
- options.effect || defaultEffect;
+
+ var hasOptions;
+ var 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 ] ) {