Blame jquery/jquery.ui-1.8.18.widget.js

Packit Service 50c9f2
/*!
Packit Service 50c9f2
 * jQuery UI Widget 1.8.18
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
Packit Service 50c9f2
 * Dual licensed under the MIT or GPL Version 2 licenses.
Packit Service 50c9f2
 * http://jquery.org/license
Packit Service 50c9f2
 *
Packit Service 50c9f2
 * http://docs.jquery.com/UI/Widget
Packit Service 50c9f2
 */
Packit Service 50c9f2
(function( $, undefined ) {
Packit Service 50c9f2
Packit Service 50c9f2
// jQuery 1.4+
Packit Service 50c9f2
if ( $.cleanData ) {
Packit Service 50c9f2
	var _cleanData = $.cleanData;
Packit Service 50c9f2
	$.cleanData = function( elems ) {
Packit Service 50c9f2
		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
Packit Service 50c9f2
			try {
Packit Service 50c9f2
				$( elem ).triggerHandler( "remove" );
Packit Service 50c9f2
			// http://bugs.jquery.com/ticket/8235
Packit Service 50c9f2
			} catch( e ) {}
Packit Service 50c9f2
		}
Packit Service 50c9f2
		_cleanData( elems );
Packit Service 50c9f2
	};
Packit Service 50c9f2
} else {
Packit Service 50c9f2
	var _remove = $.fn.remove;
Packit Service 50c9f2
	$.fn.remove = function( selector, keepData ) {
Packit Service 50c9f2
		return this.each(function() {
Packit Service 50c9f2
			if ( !keepData ) {
Packit Service 50c9f2
				if ( !selector || $.filter( selector, [ this ] ).length ) {
Packit Service 50c9f2
					$( "*", this ).add( [ this ] ).each(function() {
Packit Service 50c9f2
						try {
Packit Service 50c9f2
							$( this ).triggerHandler( "remove" );
Packit Service 50c9f2
						// http://bugs.jquery.com/ticket/8235
Packit Service 50c9f2
						} catch( e ) {}
Packit Service 50c9f2
					});
Packit Service 50c9f2
				}
Packit Service 50c9f2
			}
Packit Service 50c9f2
			return _remove.call( $(this), selector, keepData );
Packit Service 50c9f2
		});
Packit Service 50c9f2
	};
Packit Service 50c9f2
}
Packit Service 50c9f2
Packit Service 50c9f2
$.widget = function( name, base, prototype ) {
Packit Service 50c9f2
	var namespace = name.split( "." )[ 0 ],
Packit Service 50c9f2
		fullName;
Packit Service 50c9f2
	name = name.split( "." )[ 1 ];
Packit Service 50c9f2
	fullName = namespace + "-" + name;
Packit Service 50c9f2
Packit Service 50c9f2
	if ( !prototype ) {
Packit Service 50c9f2
		prototype = base;
Packit Service 50c9f2
		base = $.Widget;
Packit Service 50c9f2
	}
Packit Service 50c9f2
Packit Service 50c9f2
	// create selector for plugin
Packit Service 50c9f2
	$.expr[ ":" ][ fullName ] = function( elem ) {
Packit Service 50c9f2
		return !!$.data( elem, name );
Packit Service 50c9f2
	};
Packit Service 50c9f2
Packit Service 50c9f2
	$[ namespace ] = $[ namespace ] || {};
Packit Service 50c9f2
	$[ namespace ][ name ] = function( options, element ) {
Packit Service 50c9f2
		// allow instantiation without initializing for simple inheritance
Packit Service 50c9f2
		if ( arguments.length ) {
Packit Service 50c9f2
			this._createWidget( options, element );
Packit Service 50c9f2
		}
Packit Service 50c9f2
	};
Packit Service 50c9f2
Packit Service 50c9f2
	var basePrototype = new base();
Packit Service 50c9f2
	// we need to make the options hash a property directly on the new instance
Packit Service 50c9f2
	// otherwise we'll modify the options hash on the prototype that we're
Packit Service 50c9f2
	// inheriting from
Packit Service 50c9f2
//	$.each( basePrototype, function( key, val ) {
Packit Service 50c9f2
//		if ( $.isPlainObject(val) ) {
Packit Service 50c9f2
//			basePrototype[ key ] = $.extend( {}, val );
Packit Service 50c9f2
//		}
Packit Service 50c9f2
//	});
Packit Service 50c9f2
	basePrototype.options = $.extend( true, {}, basePrototype.options );
Packit Service 50c9f2
	$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
Packit Service 50c9f2
		namespace: namespace,
Packit Service 50c9f2
		widgetName: name,
Packit Service 50c9f2
		widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
Packit Service 50c9f2
		widgetBaseClass: fullName
Packit Service 50c9f2
	}, prototype );
Packit Service 50c9f2
Packit Service 50c9f2
	$.widget.bridge( name, $[ namespace ][ name ] );
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
$.widget.bridge = function( name, object ) {
Packit Service 50c9f2
	$.fn[ name ] = function( options ) {
Packit Service 50c9f2
		var isMethodCall = typeof options === "string",
Packit Service 50c9f2
			args = Array.prototype.slice.call( arguments, 1 ),
Packit Service 50c9f2
			returnValue = this;
Packit Service 50c9f2
Packit Service 50c9f2
		// allow multiple hashes to be passed on init
Packit Service 50c9f2
		options = !isMethodCall && args.length ?
Packit Service 50c9f2
			$.extend.apply( null, [ true, options ].concat(args) ) :
Packit Service 50c9f2
			options;
Packit Service 50c9f2
Packit Service 50c9f2
		// prevent calls to internal methods
Packit Service 50c9f2
		if ( isMethodCall && options.charAt( 0 ) === "_" ) {
Packit Service 50c9f2
			return returnValue;
Packit Service 50c9f2
		}
Packit Service 50c9f2
Packit Service 50c9f2
		if ( isMethodCall ) {
Packit Service 50c9f2
			this.each(function() {
Packit Service 50c9f2
				var instance = $.data( this, name ),
Packit Service 50c9f2
					methodValue = instance && $.isFunction( instance[options] ) ?
Packit Service 50c9f2
						instance[ options ].apply( instance, args ) :
Packit Service 50c9f2
						instance;
Packit Service 50c9f2
				// TODO: add this back in 1.9 and use $.error() (see #5972)
Packit Service 50c9f2
//				if ( !instance ) {
Packit Service 50c9f2
//					throw "cannot call methods on " + name + " prior to initialization; " +
Packit Service 50c9f2
//						"attempted to call method '" + options + "'";
Packit Service 50c9f2
//				}
Packit Service 50c9f2
//				if ( !$.isFunction( instance[options] ) ) {
Packit Service 50c9f2
//					throw "no such method '" + options + "' for " + name + " widget instance";
Packit Service 50c9f2
//				}
Packit Service 50c9f2
//				var methodValue = instance[ options ].apply( instance, args );
Packit Service 50c9f2
				if ( methodValue !== instance && methodValue !== undefined ) {
Packit Service 50c9f2
					returnValue = methodValue;
Packit Service 50c9f2
					return false;
Packit Service 50c9f2
				}
Packit Service 50c9f2
			});
Packit Service 50c9f2
		} else {
Packit Service 50c9f2
			this.each(function() {
Packit Service 50c9f2
				var instance = $.data( this, name );
Packit Service 50c9f2
				if ( instance ) {
Packit Service 50c9f2
					instance.option( options || {} )._init();
Packit Service 50c9f2
				} else {
Packit Service 50c9f2
					$.data( this, name, new object( options, this ) );
Packit Service 50c9f2
				}
Packit Service 50c9f2
			});
Packit Service 50c9f2
		}
Packit Service 50c9f2
Packit Service 50c9f2
		return returnValue;
Packit Service 50c9f2
	};
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
$.Widget = function( options, element ) {
Packit Service 50c9f2
	// allow instantiation without initializing for simple inheritance
Packit Service 50c9f2
	if ( arguments.length ) {
Packit Service 50c9f2
		this._createWidget( options, element );
Packit Service 50c9f2
	}
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
$.Widget.prototype = {
Packit Service 50c9f2
	widgetName: "widget",
Packit Service 50c9f2
	widgetEventPrefix: "",
Packit Service 50c9f2
	options: {
Packit Service 50c9f2
		disabled: false
Packit Service 50c9f2
	},
Packit Service 50c9f2
	_createWidget: function( options, element ) {
Packit Service 50c9f2
		// $.widget.bridge stores the plugin instance, but we do it anyway
Packit Service 50c9f2
		// so that it's stored even before the _create function runs
Packit Service 50c9f2
		$.data( element, this.widgetName, this );
Packit Service 50c9f2
		this.element = $( element );
Packit Service 50c9f2
		this.options = $.extend( true, {},
Packit Service 50c9f2
			this.options,
Packit Service 50c9f2
			this._getCreateOptions(),
Packit Service 50c9f2
			options );
Packit Service 50c9f2
Packit Service 50c9f2
		var self = this;
Packit Service 50c9f2
		this.element.bind( "remove." + this.widgetName, function() {
Packit Service 50c9f2
			self.destroy();
Packit Service 50c9f2
		});
Packit Service 50c9f2
Packit Service 50c9f2
		this._create();
Packit Service 50c9f2
		this._trigger( "create" );
Packit Service 50c9f2
		this._init();
Packit Service 50c9f2
	},
Packit Service 50c9f2
	_getCreateOptions: function() {
Packit Service 50c9f2
		return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
Packit Service 50c9f2
	},
Packit Service 50c9f2
	_create: function() {},
Packit Service 50c9f2
	_init: function() {},
Packit Service 50c9f2
Packit Service 50c9f2
	destroy: function() {
Packit Service 50c9f2
		this.element
Packit Service 50c9f2
			.unbind( "." + this.widgetName )
Packit Service 50c9f2
			.removeData( this.widgetName );
Packit Service 50c9f2
		this.widget()
Packit Service 50c9f2
			.unbind( "." + this.widgetName )
Packit Service 50c9f2
			.removeAttr( "aria-disabled" )
Packit Service 50c9f2
			.removeClass(
Packit Service 50c9f2
				this.widgetBaseClass + "-disabled " +
Packit Service 50c9f2
				"ui-state-disabled" );
Packit Service 50c9f2
	},
Packit Service 50c9f2
Packit Service 50c9f2
	widget: function() {
Packit Service 50c9f2
		return this.element;
Packit Service 50c9f2
	},
Packit Service 50c9f2
Packit Service 50c9f2
	option: function( key, value ) {
Packit Service 50c9f2
		var options = key;
Packit Service 50c9f2
Packit Service 50c9f2
		if ( arguments.length === 0 ) {
Packit Service 50c9f2
			// don't return a reference to the internal hash
Packit Service 50c9f2
			return $.extend( {}, this.options );
Packit Service 50c9f2
		}
Packit Service 50c9f2
Packit Service 50c9f2
		if  (typeof key === "string" ) {
Packit Service 50c9f2
			if ( value === undefined ) {
Packit Service 50c9f2
				return this.options[ key ];
Packit Service 50c9f2
			}
Packit Service 50c9f2
			options = {};
Packit Service 50c9f2
			options[ key ] = value;
Packit Service 50c9f2
		}
Packit Service 50c9f2
Packit Service 50c9f2
		this._setOptions( options );
Packit Service 50c9f2
Packit Service 50c9f2
		return this;
Packit Service 50c9f2
	},
Packit Service 50c9f2
	_setOptions: function( options ) {
Packit Service 50c9f2
		var self = this;
Packit Service 50c9f2
		$.each( options, function( key, value ) {
Packit Service 50c9f2
			self._setOption( key, value );
Packit Service 50c9f2
		});
Packit Service 50c9f2
Packit Service 50c9f2
		return this;
Packit Service 50c9f2
	},
Packit Service 50c9f2
	_setOption: function( key, value ) {
Packit Service 50c9f2
		this.options[ key ] = value;
Packit Service 50c9f2
Packit Service 50c9f2
		if ( key === "disabled" ) {
Packit Service 50c9f2
			this.widget()
Packit Service 50c9f2
				[ value ? "addClass" : "removeClass"](
Packit Service 50c9f2
					this.widgetBaseClass + "-disabled" + " " +
Packit Service 50c9f2
					"ui-state-disabled" )
Packit Service 50c9f2
				.attr( "aria-disabled", value );
Packit Service 50c9f2
		}
Packit Service 50c9f2
Packit Service 50c9f2
		return this;
Packit Service 50c9f2
	},
Packit Service 50c9f2
Packit Service 50c9f2
	enable: function() {
Packit Service 50c9f2
		return this._setOption( "disabled", false );
Packit Service 50c9f2
	},
Packit Service 50c9f2
	disable: function() {
Packit Service 50c9f2
		return this._setOption( "disabled", true );
Packit Service 50c9f2
	},
Packit Service 50c9f2
Packit Service 50c9f2
	_trigger: function( type, event, data ) {
Packit Service 50c9f2
		var prop, orig,
Packit Service 50c9f2
			callback = this.options[ type ];
Packit Service 50c9f2
Packit Service 50c9f2
		data = data || {};
Packit Service 50c9f2
		event = $.Event( event );
Packit Service 50c9f2
		event.type = ( type === this.widgetEventPrefix ?
Packit Service 50c9f2
			type :
Packit Service 50c9f2
			this.widgetEventPrefix + type ).toLowerCase();
Packit Service 50c9f2
		// the original event may come from any element
Packit Service 50c9f2
		// so we need to reset the target on the new event
Packit Service 50c9f2
		event.target = this.element[ 0 ];
Packit Service 50c9f2
Packit Service 50c9f2
		// copy original event properties over to the new event
Packit Service 50c9f2
		orig = event.originalEvent;
Packit Service 50c9f2
		if ( orig ) {
Packit Service 50c9f2
			for ( prop in orig ) {
Packit Service 50c9f2
				if ( !( prop in event ) ) {
Packit Service 50c9f2
					event[ prop ] = orig[ prop ];
Packit Service 50c9f2
				}
Packit Service 50c9f2
			}
Packit Service 50c9f2
		}
Packit Service 50c9f2
Packit Service 50c9f2
		this.element.trigger( event, data );
Packit Service 50c9f2
Packit Service 50c9f2
		return !( $.isFunction(callback) &&
Packit Service 50c9f2
			callback.call( this.element[0], event, data ) === false ||
Packit Service 50c9f2
			event.isDefaultPrevented() );
Packit Service 50c9f2
	}
Packit Service 50c9f2
};
Packit Service 50c9f2
Packit Service 50c9f2
})( jQuery );