PageSourceSearch

https://bestdissertationwriter.com/order/assets/plugins/jquery-fan…/fancy-file-uploader/jquery.ui.widget.js

js bestdissertationwriter.com collected 2026-10-10 01:09:45 UTC 23,547 bytes, 808 lines download raw bytes

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

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.