-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathjqueryui-widget.min.js
17 lines (17 loc) · 6.4 KB
/
jqueryui-widget.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*! jQuery UI - v1.10.3 - 2013-07-14
* http://jqueryui.com
* Includes: jquery.ui.widget.js
* Copyright 2013 jQuery Foundation and other contributors Licensed MIT */
(function(c,l){var p=0,n=Array.prototype.slice,q=c.cleanData;c.cleanData=function(b){for(var a=0,f;null!=(f=b[a]);a++)try{c(f).triggerHandler("remove")}catch(d){}q(b)};c.widget=function(b,a,f){var d,e,g,h,m={},k=b.split(".")[0];b=b.split(".")[1];d=k+"-"+b;f||(f=a,a=c.Widget);c.expr[":"][d.toLowerCase()]=function(a){return!!c.data(a,d)};c[k]=c[k]||{};e=c[k][b];g=c[k][b]=function(a,b){if(!this._createWidget)return new g(a,b);arguments.length&&this._createWidget(a,b)};c.extend(g,e,{version:f.version,
_proto:c.extend({},f),_childConstructors:[]});h=new a;h.options=c.widget.extend({},h.options);c.each(f,function(b,d){c.isFunction(d)?m[b]=function(){var c=function(){return a.prototype[b].apply(this,arguments)},f=function(c){return a.prototype[b].apply(this,c)};return function(){var b=this._super,a=this._superApply,e;this._super=c;this._superApply=f;e=d.apply(this,arguments);this._super=b;this._superApply=a;return e}}():m[b]=d});g.prototype=c.widget.extend(h,{widgetEventPrefix:e?h.widgetEventPrefix:
b},m,{constructor:g,namespace:k,widgetName:b,widgetFullName:d});e?(c.each(e._childConstructors,function(b,a){var d=a.prototype;c.widget(d.namespace+"."+d.widgetName,g,a._proto)}),delete e._childConstructors):a._childConstructors.push(g);c.widget.bridge(b,g)};c.widget.extend=function(b){for(var a=n.call(arguments,1),f=0,d=a.length,e,g;f<d;f++)for(e in a[f])g=a[f][e],a[f].hasOwnProperty(e)&&g!==l&&(c.isPlainObject(g)?b[e]=c.isPlainObject(b[e])?c.widget.extend({},b[e],g):c.widget.extend({},g):b[e]=g);
return b};c.widget.bridge=function(b,a){var f=a.prototype.widgetFullName||b;c.fn[b]=function(d){var e="string"===typeof d,g=n.call(arguments,1),h=this;d=!e&&g.length?c.widget.extend.apply(null,[d].concat(g)):d;e?this.each(function(){var a,e=c.data(this,f);if(!e)return c.error("cannot call methods on "+b+" prior to initialization; attempted to call method '"+d+"'");if(!c.isFunction(e[d])||"_"===d.charAt(0))return c.error("no such method '"+d+"' for "+b+" widget instance");a=e[d].apply(e,g);if(a!==
e&&a!==l)return h=a&&a.jquery?h.pushStack(a.get()):a,!1}):this.each(function(){var b=c.data(this,f);b?b.option(d||{})._init():c.data(this,f,new a(d,this))});return h}};c.Widget=function(){};c.Widget._childConstructors=[];c.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",defaultElement:"<div>",options:{disabled:!1,create:null},_createWidget:function(b,a){a=c(a||this.defaultElement||this)[0];this.element=c(a);this.uuid=p++;this.eventNamespace="."+this.widgetName+this.uuid;this.options=c.widget.extend({},
this.options,this._getCreateOptions(),b);this.bindings=c();this.hoverable=c();this.focusable=c();a!==this&&(c.data(a,this.widgetFullName,this),this._on(!0,this.element,{remove:function(b){b.target===a&&this.destroy()}}),this.document=c(a.style?a.ownerDocument:a.document||a),this.window=c(this.document[0].defaultView||this.document[0].parentWindow));this._create();this._trigger("create",null,this._getCreateEventData());this._init()},_getCreateOptions:c.noop,_getCreateEventData:c.noop,_create:c.noop,
_init:c.noop,destroy:function(){this._destroy();this.element.unbind(this.eventNamespace).removeData(this.widgetName).removeData(this.widgetFullName).removeData(c.camelCase(this.widgetFullName));this.widget().unbind(this.eventNamespace).removeAttr("aria-disabled").removeClass(this.widgetFullName+"-disabled ui-state-disabled");this.bindings.unbind(this.eventNamespace);this.hoverable.removeClass("ui-state-hover");this.focusable.removeClass("ui-state-focus")},_destroy:c.noop,widget:function(){return this.element},
option:function(b,a){var f=b,d,e,g;if(0===arguments.length)return c.widget.extend({},this.options);if("string"===typeof b)if(f={},d=b.split("."),b=d.shift(),d.length){e=f[b]=c.widget.extend({},this.options[b]);for(g=0;g<d.length-1;g++)e[d[g]]=e[d[g]]||{},e=e[d[g]];b=d.pop();if(a===l)return e[b]===l?null:e[b];e[b]=a}else{if(a===l)return this.options[b]===l?null:this.options[b];f[b]=a}this._setOptions(f);return this},_setOptions:function(b){for(var a in b)this._setOption(a,b[a]);return this},_setOption:function(b,
a){this.options[b]=a;"disabled"===b&&(this.widget().toggleClass(this.widgetFullName+"-disabled ui-state-disabled",!!a).attr("aria-disabled",a),this.hoverable.removeClass("ui-state-hover"),this.focusable.removeClass("ui-state-focus"));return this},enable:function(){return this._setOption("disabled",!1)},disable:function(){return this._setOption("disabled",!0)},_on:function(b,a,f){var d,e=this;"boolean"!==typeof b&&(f=a,a=b,b=!1);f?(a=d=c(a),this.bindings=this.bindings.add(a)):(f=a,a=this.element,d=
this.widget());c.each(f,function(f,h){function m(){if(b||!0!==e.options.disabled&&!c(this).hasClass("ui-state-disabled"))return("string"===typeof h?e[h]:h).apply(e,arguments)}"string"!==typeof h&&(m.guid=h.guid=h.guid||m.guid||c.guid++);var k=f.match(/^(\w+)\s*(.*)$/),l=k[1]+e.eventNamespace;(k=k[2])?d.delegate(k,l,m):a.bind(l,m)})},_off:function(b,a){a=(a||"").split(" ").join(this.eventNamespace+" ")+this.eventNamespace;b.unbind(a).undelegate(a)},_delay:function(b,a){var c=this;return setTimeout(function(){return("string"===
typeof b?c[b]:b).apply(c,arguments)},a||0)},_hoverable:function(b){this.hoverable=this.hoverable.add(b);this._on(b,{mouseenter:function(a){c(a.currentTarget).addClass("ui-state-hover")},mouseleave:function(a){c(a.currentTarget).removeClass("ui-state-hover")}})},_focusable:function(b){this.focusable=this.focusable.add(b);this._on(b,{focusin:function(a){c(a.currentTarget).addClass("ui-state-focus")},focusout:function(a){c(a.currentTarget).removeClass("ui-state-focus")}})},_trigger:function(b,a,f){var d,
e=this.options[b];f=f||{};a=c.Event(a);a.type=(b===this.widgetEventPrefix?b:this.widgetEventPrefix+b).toLowerCase();a.target=this.element[0];if(b=a.originalEvent)for(d in b)d in a||(a[d]=b[d]);this.element.trigger(a,f);return!(c.isFunction(e)&&!1===e.apply(this.element[0],[a].concat(f))||a.isDefaultPrevented())}};c.each({show:"fadeIn",hide:"fadeOut"},function(b,a){c.Widget.prototype["_"+b]=function(f,d,e){"string"===typeof d&&(d={effect:d});var g,h=d?!0===d||"number"===typeof d?a:d.effect||a:b;d=
d||{};"number"===typeof d&&(d={duration:d});g=!c.isEmptyObject(d);d.complete=e;d.delay&&f.delay(d.delay);if(g&&c.effects&&c.effects.effect[h])f[b](d);else if(h!==b&&f[h])f[h](d.duration,d.easing,e);else f.queue(function(a){c(this)[b]();e&&e.call(f[0]);a()})}})})(jQuery);