PageSourceSearch

http://www.britishdesigninnovation.org/Resources/javascript/JQuery…/development-bundle/ui/jquery.ui.widget.js

js britishdesigninnovation.org collected 2026-10-02 11:44:54 UTC 7,725 bytes, 283 lines download raw bytes

1var _____WB$wombat$assign$function_____=function(name){return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name))||self[name];};if(!self.__WB_pmw){self.__WB_pmw=function(obj){this.__WB_source=obj;return this;}}{
2let window = _____WB$wombat$assign$function_____("window");
3let self = _____WB$wombat$assign$function_____("self");
4let document = _____WB$wombat$assign$function_____("document");
5let location = _____WB$wombat$assign$function_____("location");
6let top = _____WB$wombat$assign$function_____("top");
7let parent = _____WB$wombat$assign$function_____("parent");
8let frames = _____WB$wombat$assign$function_____("frames");
9let opens = _____WB$wombat$assign$function_____("opens");
10/*!
11 * jQuery UI Widget 1.8.17
12 *
13 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
14 * Dual licensed under the MIT or GPL Version 2 licenses.
15 * http://jquery.org/license
16 *
17 * http://docs.jquery.com/UI/Widget
18 */
19(function( $, undefined ) {
20
21// jQuery 1.4+
22if ( $.cleanData ) {
23	var _cleanData = $.cleanData;
24	$.cleanData = function( elems ) {
25		for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) {
26			try {
27				$( elem ).triggerHandler( "remove" );
28			// http://bugs.jquery.com/ticket/8235
29			} catch( e ) {}
30		}
31		_cleanData( elems );
32	};
33} else {
34	var _remove = $.fn.remove;
35	$.fn.remove = function( selector, keepData ) {
36		return this.each(function() {
37			if ( !keepData ) {
38				if ( !selector || $.filter( selector, [ this ] ).length ) {
39					$( "*", this ).add( [ this ] ).each(function() {
40						try {
41							$( this ).triggerHandler( "remove" );
42						// http://bugs.jquery.com/ticket/8235
43						} catch( e ) {}
44					});
45				}
46			}
47			return _remove.call( $(this), selector, keepData );
48		});
49	};
50}
51
52$.widget = function( name, base, prototype ) {
53	var namespace = name.split( "." )[ 0 ],
54		fullName;
55	name = name.split( "." )[ 1 ];
56	fullName = namespace + "-" + name;
57
58	if ( !prototype ) {
59		prototype = base;
60		base = $.Widget;
61	}
62
63	// create selector for plugin
64	$.expr[ ":" ][ fullName ] = function( elem ) {
65		return !!$.data( elem, name );
66	};
67
68	$[ namespace ] = $[ namespace ] || {};
69	$[ namespace ][ name ] = function( options, element ) {
70		// allow instantiation without initializing for simple inheritance
71		if ( arguments.length ) {
72			this._createWidget( options, element );
73		}
74	};
75
76	var basePrototype = new base();
77	// we need to make the options hash a property directly on the new instance
78	// otherwise we'll modify the options hash on the prototype that we're
79	// inheriting from
80//	$.each( basePrototype, function( key, val ) {
81//		if ( $.isPlainObject(val) ) {
82//			basePrototype[ key ] = $.extend( {}, val );
83//		}
84//	});
85	basePrototype.options = $.extend( true, {}, basePrototype.options );
86	$[ namespace ][ name ].prototype = $.extend( true, basePrototype, {
87		namespace: namespace,
88		widgetName: name,
89		widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name,
90		widgetBaseClass: fullName
91	}, prototype );
92
93	$.widget.bridge( name, $[ namespace ][ name ] );
94};
95
96$.widget.bridge = function( name, object ) {
97	$.fn[ name ] = function( options ) {
98		var isMethodCall = typeof options === "string",
99			args = Array.prototype.slice.call( arguments, 1 ),
100			returnValue = this;
101
102		// allow multiple hashes to be passed on init
103		options = !isMethodCall && args.length ?
104			$.extend.apply( null, [ true, options ].concat(args) ) :
105			options;
106
107		// prevent calls to internal methods
108		if ( isMethodCall && options.charAt( 0 ) === "_" ) {
109			return returnValue;
110		}
111
112		if ( isMethodCall ) {
113			this.each(function() {
114				var instance = $.data( this, name ),
115					methodValue = instance && $.isFunction( instance[options] ) ?
116						instance[ options ].apply( instance, args ) :
117						instance;
118				// TODO: add this back in 1.9 and use $.error() (see #5972)
119//				if ( !instance ) {
120//					throw "cannot call methods on " + name + " prior to initialization; " +
121//						"attempted to call method '" + options + "'";
122//				}
123//				if ( !$.isFunction( instance[options] ) ) {
124//					throw "no such method '" + options + "' for " + name + " widget instance";
125//				}
126//				var methodValue = instance[ options ].apply( instance, args );
127				if ( methodValue !== instance && methodValue !== undefined ) {
128					returnValue = methodValue;
129					return false;
130				}
131			});
132		} else {
133			this.each(function() {
134				var instance = $.data( this, name );
135				if ( instance ) {
136					instance.option( options || {} )._init();
137				} else {
138					$.data( this, name, new object( options, this ) );
139				}
140			});
141		}
142
143		return returnValue;
144	};
145};
146
147$.Widget = function( options, element ) {
148	// allow instantiation without initializing for simple inheritance
149	if ( arguments.length ) {
150		this._createWidget( options, element );
151	}
152};
153
154$.Widget.prototype = {
155	widgetName: "widget",
156	widgetEventPrefix: "",
157	options: {
158		disabled: false
159	},
160	_createWidget: function( options, element ) {
161		// $.widget.bridge stores the plugin instance, but we do it anyway
162		// so that it's stored even before the _create function runs
163		$.data( element, this.widgetName, this );
164		this.element = $( element );
165		this.options = $.extend( true, {},
166			this.options,
167			this._getCreateOptions(),
168			options );
169
170		var self = this;
171		this.element.bind( "remove." + this.widgetName, function() {
172			self.destroy();
173		});
174
175		this._create();
176		this._trigger( "create" );
177		this._init();
178	},
179	_getCreateOptions: function() {
180		return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ];
181	},
182	_create: function() {},
183	_init: function() {},
184
185	destroy: function() {
186		this.element
187			.unbind( "." + this.widgetName )
188			.removeData( this.widgetName );
189		this.widget()
190			.unbind( "." + this.widgetName )
191			.removeAttr( "aria-disabled" )
192			.removeClass(
193				this.widgetBaseClass + "-disabled " +
194				"ui-state-disabled" );
195	},
196
197	widget: function() {
198		return this.element;
199	},
200
201	option: function( key, value ) {
202		var options = key;
203
204		if ( arguments.length === 0 ) {
205			// don't return a reference to the internal hash
206			return $.extend( {}, this.options );
207		}
208
209		if  (typeof key === "string" ) {
210			if ( value === undefined ) {
211				return this.options[ key ];
212			}
213			options = {};
214			options[ key ] = value;
215		}
216
217		this._setOptions( options );
218
219		return this;
220	},
221	_setOptions: function( options ) {
222		var self = this;
223		$.each( options, function( key, value ) {
224			self._setOption( key, value );
225		});
226
227		return this;
228	},
229	_setOption: function( key, value ) {
230		this.options[ key ] = value;
231
232		if ( key === "disabled" ) {
233			this.widget()
234				[ value ? "addClass" : "removeClass"](
235					this.widgetBaseClass + "-disabled" + " " +
236					"ui-state-disabled" )
237				.attr( "aria-disabled", value );
238		}
239
240		return this;
241	},
242
243	enable: function() {
244		return this._setOption( "disabled", false );
245	},
246	disable: function() {
247		return this._setOption( "disabled", true );
248	},
249
250	_trigger: function( type, event, data ) {
251		var prop, orig,
252			callback = this.options[ type ];
253
254		data = data || {};
255		event = $.Event( event );
256		event.type = ( type === this.widgetEventPrefix ?
257			type :
258			this.widgetEventPrefix + type ).toLowerCase();
259		// the original event may come from any element
260		// so we need to reset the target on the new event
261		event.target = this.element[ 0 ];
262
263		// copy original event properties over to the new event
264		orig = event.originalEvent;
265		if ( orig ) {
266			for ( prop in orig ) {
267				if ( !( prop in event ) ) {
268					event[ prop ] = orig[ prop ];
269				}
270			}
271		}
272
273		this.element.trigger( event, data );
274
275		return !( $.isFunction(callback) &&
276			callback.call( this.element[0], event, data ) === false ||
277			event.isDefaultPrevented() );
278	}
279};
280
281})( jQuery );
282
283}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.