PageSourceSearch

https://www.codwholesale.com/js/vendor/jquery.ui.widget.js?vcart=26.37.2

js codwholesale.com collected 2026-09-27 11:35:31 UTC 21,224 bytes, 770 lines download raw bytes

vendor: 5,861 bytes, lines 1-199
1/*! jQuery UI - v1.13.2 - 2023-08-10
2* http://jqueryui.com
3* Includes: widget.js
4* Copyright jQuery Foundation and other contributors; Licensed MIT */
5
6(function (factory) {
7	"use strict";
8
9	if (typeof define === "function" && define.amd) {
10
11		// AMD. Register as an anonymous module.
12		define(["jquery"], factory);
13	} else {
14
15		// Browser globals
16		factory(jQuery);
17	}
18})(function ($) {
19	"use strict";
20
21	$.ui = $.ui || {};
22
23	var version = $.ui.version = "1.13.2";
24
25
26	/*!
27	 * jQuery UI Widget 1.13.2
28	 * http://jqueryui.com
29	 *
30	 * Copyright jQuery Foundation and other contributors
31	 * Released under the MIT license.
32	 * http://jquery.org/license
33	 */
34
35	//>>label: Widget
36	//>>group: Core
37	//>>description: Provides a factory for creating stateful widgets with a common API.
38	//>>docs: http://api.jqueryui.com/jQuery.widget/
39	//>>demos: http://jqueryui.com/widget/
40
41
42	var widgetUuid = 0;
43	var widgetHasOwnProperty = Array.prototype.hasOwnProperty;
44	var widgetSlice = Array.prototype.slice;
45
46	$.cleanData = (function (orig) {
47		return function (elems) {
48			var events, elem, i;
49			for (i = 0; (elem = elems[i]) != null; i++) {
50
51				// Only trigger remove when necessary to save time
52				events = $._data(elem, "events");
53				if (events && events.remove) {
54					$(elem).triggerHandler("remove");
55				}
56			}
57			orig(elems);
58		};
59	})($.cleanData);
60
61	$.widget = function (name, base, prototype) {
62		var existingConstructor, constructor, basePrototype;
63
64		// ProxiedPrototype allows the provided prototype to remain unmodified
65		// so that it can be used as a mixin for multiple widgets (#8876)
66		var proxiedPrototype = {};
67
68		var namespace = name.split(".")[0];
69		name = name.split(".")[1];
70		var fullName = namespace + "-" + name;
71
72		if (!prototype) {
73			prototype = base;
74			base = $.Widget;
75		}
76
77		if (Array.isArray(prototype)) {
78			prototype = $.extend.apply(null, [{}].concat(prototype));
79		}
80
81		// Create selector for plugin
82		$.expr.pseudos[fullName.toLowerCase()] = function (elem) {
83			return !!$.data(elem, fullName);
84		};
85
86		$[namespace] = $[namespace] || {};
87		existingConstructor = $[namespace][name];
88		constructor = $[namespace][name] = function (options, element) {
89
90			// Allow instantiation without "new" keyword
91			if (!this || !this._createWidget) {
92				return new constructor(options, element);
93			}
94
95			// Allow instantiation without initializing for simple inheritance
96			// must use "new" keyword (the code above always passes args)
97			if (arguments.length) {
98				this._createWidget(options, element);
99			}
100		};
101
102		// Extend with the existing constructor to carry over any static properties
103		$.extend(constructor, existingConstructor, {
104			version: prototype.version,
105
106			// Copy the object used to create the prototype in case we need to
107			// redefine the widget later
108			_proto: $.extend({}, prototype),
109
110			// Track widgets that inherit from this widget in case this widget is
111			// redefined after a widget inherits from it
112			_childConstructors: []
113		});
114
115		basePrototype = new base();
116
117		// We need to make the options hash a property directly on the new instance
118		// otherwise we'll modify the options hash on the prototype that we're
119		// inheriting from
120		basePrototype.options = $.widget.extend({}, basePrototype.options);
121		$.each(prototype, function (prop, value) {
122			if (typeof value !== "function") {
123				proxiedPrototype[prop] = value;
124				return;
125			}
126			proxiedPrototype[prop] = (function () {
127				function _super() {
128					return base.prototype[prop].apply(this, arguments);
129				}
130
131				function _superApply(args) {
132					return base.prototype[prop].apply(this, args);
133				}
134
135				return function () {
136					var __super = this._super;
137					var __superApply = this._superApply;
138					var returnValue;
139
140					this._super = _super;
141					this._superApply = _superApply;
142
143					returnValue = value.apply(this, arguments);
144
145					this._super = __super;
146					this._superApply = __superApply;
147
148					return returnValue;
149				};
150			})();
151		});
152		constructor.prototype = $.widget.extend(basePrototype, {
153
154			// TODO: remove support for widgetEventPrefix
155			// always use the name + a colon as the prefix, e.g., draggable:start
156			// don't prefix for widgets that aren't DOM-based
157			widgetEventPrefix: existingConstructor ? (basePrototype.widgetEventPrefix || name) : name
158		}, proxiedPrototype, {
159			constructor: constructor,
160			namespace: namespace,
161			widgetName: name,
162			widgetFullName: fullName
163		});
164
165		// If this widget is being redefined then we need to find all widgets that
166		// are inheriting from it and redefine all of them so that they inherit from
167		// the new version of this widget. We're essentially trying to replace one
168		// level in the prototype chain.
169		if (existingConstructor) {
170			$.each(existingConstructor._childConstructors, function (i, child) {
171				var childPrototype = child.prototype;
172
173				// Redefine the child widget using the same prototype that was
174				// originally used, but inherit from the new version of the base
175				$.widget(childPrototype.namespace + "." + childPrototype.widgetName, constructor,
176					child._proto);
177			});
178
179			// Remove the list of existing child constructors from the old constructor
180			// so the old child constructors can be garbage collected
181			delete existingConstructor._childConstructors;
182		} else {
183			base._childConstructors.push(constructor);
184		}
185
186		$.widget.bridge(name, constructor);
187
188		return constructor;
189	};
190
191	$.widget.extend = function (target) {
192		var input = widgetSlice.call(arguments, 1);
193		var inputIndex = 0;
194		var inputLength = input.length;
195		var key;
196		var value;
197
198		for (; inputIndex < inputLength; inputIndex++) {
199			for (key in input[inputIndex]) {
vendor: 15,363 bytes, lines 200-770
200				value = input[inputIndex][key];
201				if (widgetHasOwnProperty.call(input[inputIndex], key) && value !== undefined) {
202
203					// Clone objects
204					if ($.isPlainObject(value)) {
205						target[key] = $.isPlainObject(target[key]) ?
206							$.widget.extend({}, target[key], value) :
207
208							// Don't extend strings, arrays, etc. with objects
209							$.widget.extend({}, value);
210
211						// Copy everything else by reference
212					} else {
213						target[key] = value;
214					}
215				}
216			}
217		}
218		return target;
219	};
220
221	$.widget.bridge = function (name, object) {
222		var fullName = object.prototype.widgetFullName || name;
223		$.fn[name] = function (options) {
224			var isMethodCall = typeof options === "string";
225			var args = widgetSlice.call(arguments, 1);
226			var returnValue = this;
227
228			if (isMethodCall) {
229
230				// If this is an empty collection, we need to have the instance method
231				// return undefined instead of the jQuery instance
232				if (!this.length && options === "instance") {
233					returnValue = undefined;
234				} else {
235					this.each(function () {
236						var methodValue;
237						var instance = $.data(this, fullName);
238
239						if (options === "instance") {
240							returnValue = instance;
241							return false;
242						}
243
244						if (!instance) {
245							return $.error("cannot call methods on " + name +
246								" prior to initialization; " +
247								"attempted to call method '" + options + "'");
248						}
249
250						if (typeof instance[options] !== "function" ||
251							options.charAt(0) === "_") {
252							return $.error("no such method '" + options + "' for " + name +
253								" widget instance");
254						}
255
256						methodValue = instance[options].apply(instance, args);
257
258						if (methodValue !== instance && methodValue !== undefined) {
259							returnValue = methodValue && methodValue.jquery ?
260								returnValue.pushStack(methodValue.get()) :
261								methodValue;
262							return false;
263						}
264					});
265				}
266			} else {
267
268				// Allow multiple hashes to be passed on init
269				if (args.length) {
270					options = $.widget.extend.apply(null, [options].concat(args));
271				}
272
273				this.each(function () {
274					var instance = $.data(this, fullName);
275					if (instance) {
276						instance.option(options || {});
277						if (instance._init) {
278							instance._init();
279						}
280					} else {
281						$.data(this, fullName, new object(options, this));
282					}
283				});
284			}
285
286			return returnValue;
287		};
288	};
289
290	$.Widget = function ( /* options, element */) { };
291	$.Widget._childConstructors = [];
292
293	$.Widget.prototype = {
294		widgetName: "widget",
295		widgetEventPrefix: "",
296		defaultElement: "<div>",
297
298		options: {
299			classes: {},
300			disabled: false,
301
302			// Callbacks
303			create: null
304		},
305
306		_createWidget: function (options, element) {
307			element = $(element || this.defaultElement || this)[0];
308			this.element = $(element);
309			this.uuid = widgetUuid++;
310			this.eventNamespace = "." + this.widgetName + this.uuid;
311
312			this.bindings = $();
313			this.hoverable = $();
314			this.focusable = $();
315			this.classesElementLookup = {};
316
317			if (element !== this) {
318				$.data(element, this.widgetFullName, this);
319				this._on(true, this.element, {
320					remove: function (event) {
321						if (event.target === element) {
322							this.destroy();
323						}
324					}
325				});
326				this.document = $(element.style ?
327
328					// Element within the document
329					element.ownerDocument :
330
331					// Element is window or document
332					element.document || element);
333				this.window = $(this.document[0].defaultView || this.document[0].parentWindow);
334			}
335
336			this.options = $.widget.extend({},
337				this.options,
338				this._getCreateOptions(),
339				options);
340
341			this._create();
342
343			if (this.options.disabled) {
344				this._setOptionDisabled(this.options.disabled);
345			}
346
347			this._trigger("create", null, this._getCreateEventData());
348			this._init();
349		},
350
351		_getCreateOptions: function () {
352			return {};
353		},
354
355		_getCreateEventData: $.noop,
356
357		_create: $.noop,
358
359		_init: $.noop,
360
361		destroy: function () {
362			var that = this;
363
364			this._destroy();
365			$.each(this.classesElementLookup, function (key, value) {
366				that._removeClass(value, key);
367			});
368
369			// We can probably remove the unbind calls in 2.0
370			// all event bindings should go through this._on()
371			this.element
372				.off(this.eventNamespace)
373				.removeData(this.widgetFullName);
374			this.widget()
375				.off(this.eventNamespace)
376				.removeAttr("aria-disabled");
377
378			// Clean up events and states
379			this.bindings.off(this.eventNamespace);
380		},
381
382		_destroy: $.noop,
383
384		widget: function () {
385			return this.element;
386		},
387
388		option: function (key, value) {
389			var options = key;
390			var parts;
391			var curOption;
392			var i;
393
394			if (arguments.length === 0) {
395
396				// Don't return a reference to the internal hash
397				return $.widget.extend({}, this.options);
398			}
399
400			if (typeof key === "string") {
401
402				// Handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } }
403				options = {};
404				parts = key.split(".");
405				key = parts.shift();
406				if (parts.length) {
407					curOption = options[key] = $.widget.extend({}, this.options[key]);
408					for (i = 0; i < parts.length - 1; i++) {
409						curOption[parts[i]] = curOption[parts[i]] || {};
410						curOption = curOption[parts[i]];
411					}
412					key = parts.pop();
413					if (arguments.length === 1) {
414						return curOption[key] === undefined ? null : curOption[key];
415					}
416					curOption[key] = value;
417				} else {
418					if (arguments.length === 1) {
419						return this.options[key] === undefined ? null : this.options[key];
420					}
421					options[key] = value;
422				}
423			}
424
425			this._setOptions(options);
426
427			return this;
428		},
429
430		_setOptions: function (options) {
431			var key;
432
433			for (key in options) {
434				this._setOption(key, options[key]);
435			}
436
437			return this;
438		},
439
440		_setOption: function (key, value) {
441			if (key === "classes") {
442				this._setOptionClasses(value);
443			}
444
445			this.options[key] = value;
446
447			if (key === "disabled") {
448				this._setOptionDisabled(value);
449			}
450
451			return this;
452		},
453
454		_setOptionClasses: function (value) {
455			var classKey, elements, currentElements;
456
457			for (classKey in value) {
458				currentElements = this.classesElementLookup[classKey];
459				if (value[classKey] === this.options.classes[classKey] ||
460					!currentElements ||
461					!currentElements.length) {
462					continue;
463				}
464
465				// We are doing this to create a new jQuery object because the _removeClass() call
466				// on the next line is going to destroy the reference to the current elements being
467				// tracked. We need to save a copy of this collection so that we can add the new classes
468				// below.
469				elements = $(currentElements.get());
470				this._removeClass(currentElements, classKey);
471
472				// We don't use _addClass() here, because that uses this.options.classes
473				// for generating the string of classes. We want to use the value passed in from
474				// _setOption(), this is the new value of the classes option which was passed to
475				// _setOption(). We pass this value directly to _classes().
476				elements.addClass(this._classes({
477					element: elements,
478					keys: classKey,
479					classes: value,
480					add: true
481				}));
482			}
483		},
484
485		_setOptionDisabled: function (value) {
486			this._toggleClass(this.widget(), this.widgetFullName + "-disabled", null, !!value);
487
488			// If the widget is becoming disabled, then nothing is interactive
489			if (value) {
490				this._removeClass(this.hoverable, null, "ui-state-hover");
491				this._removeClass(this.focusable, null, "ui-state-focus");
492			}
493		},
494
495		enable: function () {
496			return this._setOptions({ disabled: false });
497		},
498
499		disable: function () {
500			return this._setOptions({ disabled: true });
501		},
502
503		_classes: function (options) {
504			var full = [];
505			var that = this;
506
507			options = $.extend({
508				element: this.element,
509				classes: this.options.classes || {}
510			}, options);
511
512			function bindRemoveEvent() {
513				var nodesToBind = [];
514
515				options.element.each(function (_, element) {
516					var isTracked = $.map(that.classesElementLookup, function (elements) {
517						return elements;
518					})
519						.some(function (elements) {
520							return elements.is(element);
521						});
522
523					if (!isTracked) {
524						nodesToBind.push(element);
525					}
526				});
527
528				that._on($(nodesToBind), {
529					remove: "_untrackClassesElement"
530				});
531			}
532
533			function processClassString(classes, checkOption) {
534				var current, i;
535				for (i = 0; i < classes.length; i++) {
536					current = that.classesElementLookup[classes[i]] || $();
537					if (options.add) {
538						bindRemoveEvent();
539						current = $($.uniqueSort(current.get().concat(options.element.get())));
540					} else {
541						current = $(current.not(options.element).get());
542					}
543					that.classesElementLookup[classes[i]] = current;
544					full.push(classes[i]);
545					if (checkOption && options.classes[classes[i]]) {
546						full.push(options.classes[classes[i]]);
547					}
548				}
549			}
550
551			if (options.keys) {
552				processClassString(options.keys.match(/\S+/g) || [], true);
553			}
554			if (options.extra) {
555				processClassString(options.extra.match(/\S+/g) || []);
556			}
557
558			return full.join(" ");
559		},
560
561		_untrackClassesElement: function (event) {
562			var that = this;
563			$.each(that.classesElementLookup, function (key, value) {
564				if ($.inArray(event.target, value) !== -1) {
565					that.classesElementLookup[key] = $(value.not(event.target).get());
566				}
567			});
568
569			this._off($(event.target));
570		},
571
572		_removeClass: function (element, keys, extra) {
573			return this._toggleClass(element, keys, extra, false);
574		},
575
576		_addClass: function (element, keys, extra) {
577			return this._toggleClass(element, keys, extra, true);
578		},
579
580		_toggleClass: function (element, keys, extra, add) {
581			add = (typeof add === "boolean") ? add : extra;
582			var shift = (typeof element === "string" || element === null),
583				options = {
584					extra: shift ? keys : extra,
585					keys: shift ? element : keys,
586					element: shift ? this.element : element,
587					add: add
588				};
589			options.element.toggleClass(this._classes(options), add);
590			return this;
591		},
592
593		_on: function (suppressDisabledCheck, element, handlers) {
594			var delegateElement;
595			var instance = this;
596
597			// No suppressDisabledCheck flag, shuffle arguments
598			if (typeof suppressDisabledCheck !== "boolean") {
599				handlers = element;
600				element = suppressDisabledCheck;
601				suppressDisabledCheck = false;
602			}
603
604			// No element argument, shuffle and use this.element
605			if (!handlers) {
606				handlers = element;
607				element = this.element;
608				delegateElement = this.widget();
609			} else {
610				element = delegateElement = $(element);
611				this.bindings = this.bindings.add(element);
612			}
613
614			$.each(handlers, function (event, handler) {
615				function handlerProxy() {
616
617					// Allow widgets to customize the disabled handling
618					// - disabled as an array instead of boolean
619					// - disabled class as method for disabling individual parts
620					if (!suppressDisabledCheck &&
621						(instance.options.disabled === true ||
622							$(this).hasClass("ui-state-disabled"))) {
623						return;
624					}
625					return (typeof handler === "string" ? instance[handler] : handler)
626						.apply(instance, arguments);
627				}
628
629				// Copy the guid so direct unbinding works
630				if (typeof handler !== "string") {
631					handlerProxy.guid = handler.guid =
632						handler.guid || handlerProxy.guid || $.guid++;
633				}
634
635				var match = event.match(/^([\w:-]*)\s*(.*)$/);
636				var eventName = match[1] + instance.eventNamespace;
637				var selector = match[2];
638
639				if (selector) {
640					delegateElement.on(eventName, selector, handlerProxy);
641				} else {
642					element.on(eventName, handlerProxy);
643				}
644			});
645		},
646
647		_off: function (element, eventName) {
648			eventName = (eventName || "").split(" ").join(this.eventNamespace + " ") +
649				this.eventNamespace;
650			element.off(eventName);
651
652			// Clear the stack to avoid memory leaks (#10056)
653			this.bindings = $(this.bindings.not(element).get());
654			this.focusable = $(this.focusable.not(element).get());
655			this.hoverable = $(this.hoverable.not(element).get());
656		},
657
658		_delay: function (handler, delay) {
659			function handlerProxy() {
660				return (typeof handler === "string" ? instance[handler] : handler)
661					.apply(instance, arguments);
662			}
663			var instance = this;
664			return setTimeout(handlerProxy, delay || 0);
665		},
666
667		_hoverable: function (element) {
668			this.hoverable = this.hoverable.add(element);
669			this._on(element, {
670				mouseenter: function (event) {
671					this._addClass($(event.currentTarget), null, "ui-state-hover");
672				},
673				mouseleave: function (event) {
674					this._removeClass($(event.currentTarget), null, "ui-state-hover");
675				}
676			});
677		},
678
679		_focusable: function (element) {
680			this.focusable = this.focusable.add(element);
681			this._on(element, {
682				focusin: function (event) {
683					this._addClass($(event.currentTarget), null, "ui-state-focus");
684				},
685				focusout: function (event) {
686					this._removeClass($(event.currentTarget), null, "ui-state-focus");
687				}
688			});
689		},
690
691		_trigger: function (type, event, data) {
692			var prop, orig;
693			var callback = this.options[type];
694
695			data = data || {};
696			event = $.Event(event);
697			event.type = (type === this.widgetEventPrefix ?
698				type :
699				this.widgetEventPrefix + type).toLowerCase();
700
701			// The original event may come from any element
702			// so we need to reset the target on the new event
703			event.target = this.element[0];
704
705			// Copy original event properties over to the new event
706			orig = event.originalEvent;
707			if (orig) {
708				for (prop in orig) {
709					if (!(prop in event)) {
710						event[prop] = orig[prop];
711					}
712				}
713			}
714
715			this.element.trigger(event, data);
716			return !(typeof callback === "function" &&
717				callback.apply(this.element[0], [event].concat(data)) === false ||
718				event.isDefaultPrevented());
719		}
720	};
721
722	$.each({ show: "fadeIn", hide: "fadeOut" }, function (method, defaultEffect) {
723		$.Widget.prototype["_" + method] = function (element, options, callback) {
724			if (typeof options === "string") {
725				options = { effect: options };
726			}
727
728			var hasOptions;
729			var effectName = !options ?
730				method :
731				options === true || typeof options === "number" ?
732					defaultEffect :
733					options.effect || defaultEffect;
734
735			options = options || {};
736			if (typeof options === "number") {
737				options = { duration: options };
738			} else if (options === true) {
739				options = {};
740			}
741
742			hasOptions = !$.isEmptyObject(options);
743			options.complete = callback;
744
745			if (options.delay) {
746				element.delay(options.delay);
747			}
748
749			if (hasOptions && $.effects && $.effects.effect[effectName]) {
750				element[method](options);
751			} else if (effectName !== method && element[effectName]) {
752				element[effectName](options.duration, options.easing, callback);
753			} else {
754				element.queue(function (next) {
755					$(this)[method]();
756					if (callback) {
757						callback.call(element[0]);
758					}
759					next();
760				});
761			}
762		};
763	});
764
765	var widget = $.widget;
766
767
768
769
770});

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.