Mercurial > hg > orthanc
comparison OrthancExplorer/libs/jquery-file-upload/js/vendor/jquery.ui.widget.js @ 3066:5713952f60c0 update-jquery
upgraded jquery, jquery-mobile, jquery-file-upload. Everything seems to be working as before. Theme has changed !
author | am@osimis.io |
---|---|
date | Wed, 26 Dec 2018 16:58:21 +0100 |
parents | 4bc019d2f969 |
children |
comparison
equal
deleted
inserted
replaced
3065:b89a4288d605 | 3066:5713952f60c0 |
---|---|
1 /* | 1 /* |
2 * jQuery UI Widget 1.8.18+amd | 2 * jQuery UI Widget 1.10.3+amd |
3 * https://github.com/blueimp/jQuery-File-Upload | 3 * https://github.com/blueimp/jQuery-File-Upload |
4 * | 4 * |
5 * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) | 5 * Copyright 2013 jQuery Foundation and other contributors |
6 * Dual licensed under the MIT or GPL Version 2 licenses. | 6 * Released under the MIT license. |
7 * http://jquery.org/license | 7 * http://jquery.org/license |
8 * | 8 * |
9 * http://docs.jquery.com/UI/Widget | 9 * http://api.jqueryui.com/jQuery.widget/ |
10 */ | 10 */ |
11 | 11 |
12 (function (factory) { | 12 (function (factory) { |
13 if (typeof define === "function" && define.amd) { | 13 if (typeof define === "function" && define.amd) { |
14 // Register as an anonymous AMD module: | 14 // Register as an anonymous AMD module: |
17 // Browser globals: | 17 // Browser globals: |
18 factory(jQuery); | 18 factory(jQuery); |
19 } | 19 } |
20 }(function( $, undefined ) { | 20 }(function( $, undefined ) { |
21 | 21 |
22 // jQuery 1.4+ | 22 var uuid = 0, |
23 if ( $.cleanData ) { | 23 slice = Array.prototype.slice, |
24 var _cleanData = $.cleanData; | 24 _cleanData = $.cleanData; |
25 $.cleanData = function( elems ) { | 25 $.cleanData = function( elems ) { |
26 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { | 26 for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { |
27 try { | 27 try { |
28 $( elem ).triggerHandler( "remove" ); | 28 $( elem ).triggerHandler( "remove" ); |
29 // http://bugs.jquery.com/ticket/8235 | 29 // http://bugs.jquery.com/ticket/8235 |
30 } catch( e ) {} | 30 } catch( e ) {} |
31 } | 31 } |
32 _cleanData( elems ); | 32 _cleanData( elems ); |
33 }; | 33 }; |
34 } else { | |
35 var _remove = $.fn.remove; | |
36 $.fn.remove = function( selector, keepData ) { | |
37 return this.each(function() { | |
38 if ( !keepData ) { | |
39 if ( !selector || $.filter( selector, [ this ] ).length ) { | |
40 $( "*", this ).add( [ this ] ).each(function() { | |
41 try { | |
42 $( this ).triggerHandler( "remove" ); | |
43 // http://bugs.jquery.com/ticket/8235 | |
44 } catch( e ) {} | |
45 }); | |
46 } | |
47 } | |
48 return _remove.call( $(this), selector, keepData ); | |
49 }); | |
50 }; | |
51 } | |
52 | 34 |
53 $.widget = function( name, base, prototype ) { | 35 $.widget = function( name, base, prototype ) { |
54 var namespace = name.split( "." )[ 0 ], | 36 var fullName, existingConstructor, constructor, basePrototype, |
55 fullName; | 37 // proxiedPrototype allows the provided prototype to remain unmodified |
38 // so that it can be used as a mixin for multiple widgets (#8876) | |
39 proxiedPrototype = {}, | |
40 namespace = name.split( "." )[ 0 ]; | |
41 | |
56 name = name.split( "." )[ 1 ]; | 42 name = name.split( "." )[ 1 ]; |
57 fullName = namespace + "-" + name; | 43 fullName = namespace + "-" + name; |
58 | 44 |
59 if ( !prototype ) { | 45 if ( !prototype ) { |
60 prototype = base; | 46 prototype = base; |
61 base = $.Widget; | 47 base = $.Widget; |
62 } | 48 } |
63 | 49 |
64 // create selector for plugin | 50 // create selector for plugin |
65 $.expr[ ":" ][ fullName ] = function( elem ) { | 51 $.expr[ ":" ][ fullName.toLowerCase() ] = function( elem ) { |
66 return !!$.data( elem, name ); | 52 return !!$.data( elem, fullName ); |
67 }; | 53 }; |
68 | 54 |
69 $[ namespace ] = $[ namespace ] || {}; | 55 $[ namespace ] = $[ namespace ] || {}; |
70 $[ namespace ][ name ] = function( options, element ) { | 56 existingConstructor = $[ namespace ][ name ]; |
57 constructor = $[ namespace ][ name ] = function( options, element ) { | |
58 // allow instantiation without "new" keyword | |
59 if ( !this._createWidget ) { | |
60 return new constructor( options, element ); | |
61 } | |
62 | |
71 // allow instantiation without initializing for simple inheritance | 63 // allow instantiation without initializing for simple inheritance |
64 // must use "new" keyword (the code above always passes args) | |
72 if ( arguments.length ) { | 65 if ( arguments.length ) { |
73 this._createWidget( options, element ); | 66 this._createWidget( options, element ); |
74 } | 67 } |
75 }; | 68 }; |
76 | 69 // extend with the existing constructor to carry over any static properties |
77 var basePrototype = new base(); | 70 $.extend( constructor, existingConstructor, { |
71 version: prototype.version, | |
72 // copy the object used to create the prototype in case we need to | |
73 // redefine the widget later | |
74 _proto: $.extend( {}, prototype ), | |
75 // track widgets that inherit from this widget in case this widget is | |
76 // redefined after a widget inherits from it | |
77 _childConstructors: [] | |
78 }); | |
79 | |
80 basePrototype = new base(); | |
78 // we need to make the options hash a property directly on the new instance | 81 // we need to make the options hash a property directly on the new instance |
79 // otherwise we'll modify the options hash on the prototype that we're | 82 // otherwise we'll modify the options hash on the prototype that we're |
80 // inheriting from | 83 // inheriting from |
81 // $.each( basePrototype, function( key, val ) { | 84 basePrototype.options = $.widget.extend( {}, basePrototype.options ); |
82 // if ( $.isPlainObject(val) ) { | 85 $.each( prototype, function( prop, value ) { |
83 // basePrototype[ key ] = $.extend( {}, val ); | 86 if ( !$.isFunction( value ) ) { |
84 // } | 87 proxiedPrototype[ prop ] = value; |
85 // }); | 88 return; |
86 basePrototype.options = $.extend( true, {}, basePrototype.options ); | 89 } |
87 $[ namespace ][ name ].prototype = $.extend( true, basePrototype, { | 90 proxiedPrototype[ prop ] = (function() { |
91 var _super = function() { | |
92 return base.prototype[ prop ].apply( this, arguments ); | |
93 }, | |
94 _superApply = function( args ) { | |
95 return base.prototype[ prop ].apply( this, args ); | |
96 }; | |
97 return function() { | |
98 var __super = this._super, | |
99 __superApply = this._superApply, | |
100 returnValue; | |
101 | |
102 this._super = _super; | |
103 this._superApply = _superApply; | |
104 | |
105 returnValue = value.apply( this, arguments ); | |
106 | |
107 this._super = __super; | |
108 this._superApply = __superApply; | |
109 | |
110 return returnValue; | |
111 }; | |
112 })(); | |
113 }); | |
114 constructor.prototype = $.widget.extend( basePrototype, { | |
115 // TODO: remove support for widgetEventPrefix | |
116 // always use the name + a colon as the prefix, e.g., draggable:start | |
117 // don't prefix for widgets that aren't DOM-based | |
118 widgetEventPrefix: existingConstructor ? basePrototype.widgetEventPrefix : name | |
119 }, proxiedPrototype, { | |
120 constructor: constructor, | |
88 namespace: namespace, | 121 namespace: namespace, |
89 widgetName: name, | 122 widgetName: name, |
90 widgetEventPrefix: $[ namespace ][ name ].prototype.widgetEventPrefix || name, | 123 widgetFullName: fullName |
91 widgetBaseClass: fullName | 124 }); |
92 }, prototype ); | 125 |
93 | 126 // If this widget is being redefined then we need to find all widgets that |
94 $.widget.bridge( name, $[ namespace ][ name ] ); | 127 // are inheriting from it and redefine all of them so that they inherit from |
128 // the new version of this widget. We're essentially trying to replace one | |
129 // level in the prototype chain. | |
130 if ( existingConstructor ) { | |
131 $.each( existingConstructor._childConstructors, function( i, child ) { | |
132 var childPrototype = child.prototype; | |
133 | |
134 // redefine the child widget using the same prototype that was | |
135 // originally used, but inherit from the new version of the base | |
136 $.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, child._proto ); | |
137 }); | |
138 // remove the list of existing child constructors from the old constructor | |
139 // so the old child constructors can be garbage collected | |
140 delete existingConstructor._childConstructors; | |
141 } else { | |
142 base._childConstructors.push( constructor ); | |
143 } | |
144 | |
145 $.widget.bridge( name, constructor ); | |
95 }; | 146 }; |
96 | 147 |
148 $.widget.extend = function( target ) { | |
149 var input = slice.call( arguments, 1 ), | |
150 inputIndex = 0, | |
151 inputLength = input.length, | |
152 key, | |
153 value; | |
154 for ( ; inputIndex < inputLength; inputIndex++ ) { | |
155 for ( key in input[ inputIndex ] ) { | |
156 value = input[ inputIndex ][ key ]; | |
157 if ( input[ inputIndex ].hasOwnProperty( key ) && value !== undefined ) { | |
158 // Clone objects | |
159 if ( $.isPlainObject( value ) ) { | |
160 target[ key ] = $.isPlainObject( target[ key ] ) ? | |
161 $.widget.extend( {}, target[ key ], value ) : | |
162 // Don't extend strings, arrays, etc. with objects | |
163 $.widget.extend( {}, value ); | |
164 // Copy everything else by reference | |
165 } else { | |
166 target[ key ] = value; | |
167 } | |
168 } | |
169 } | |
170 } | |
171 return target; | |
172 }; | |
173 | |
97 $.widget.bridge = function( name, object ) { | 174 $.widget.bridge = function( name, object ) { |
175 var fullName = object.prototype.widgetFullName || name; | |
98 $.fn[ name ] = function( options ) { | 176 $.fn[ name ] = function( options ) { |
99 var isMethodCall = typeof options === "string", | 177 var isMethodCall = typeof options === "string", |
100 args = Array.prototype.slice.call( arguments, 1 ), | 178 args = slice.call( arguments, 1 ), |
101 returnValue = this; | 179 returnValue = this; |
102 | 180 |
103 // allow multiple hashes to be passed on init | 181 // allow multiple hashes to be passed on init |
104 options = !isMethodCall && args.length ? | 182 options = !isMethodCall && args.length ? |
105 $.extend.apply( null, [ true, options ].concat(args) ) : | 183 $.widget.extend.apply( null, [ options ].concat(args) ) : |
106 options; | 184 options; |
107 | |
108 // prevent calls to internal methods | |
109 if ( isMethodCall && options.charAt( 0 ) === "_" ) { | |
110 return returnValue; | |
111 } | |
112 | 185 |
113 if ( isMethodCall ) { | 186 if ( isMethodCall ) { |
114 this.each(function() { | 187 this.each(function() { |
115 var instance = $.data( this, name ), | 188 var methodValue, |
116 methodValue = instance && $.isFunction( instance[options] ) ? | 189 instance = $.data( this, fullName ); |
117 instance[ options ].apply( instance, args ) : | 190 if ( !instance ) { |
118 instance; | 191 return $.error( "cannot call methods on " + name + " prior to initialization; " + |
119 // TODO: add this back in 1.9 and use $.error() (see #5972) | 192 "attempted to call method '" + options + "'" ); |
120 // if ( !instance ) { | 193 } |
121 // throw "cannot call methods on " + name + " prior to initialization; " + | 194 if ( !$.isFunction( instance[options] ) || options.charAt( 0 ) === "_" ) { |
122 // "attempted to call method '" + options + "'"; | 195 return $.error( "no such method '" + options + "' for " + name + " widget instance" ); |
123 // } | 196 } |
124 // if ( !$.isFunction( instance[options] ) ) { | 197 methodValue = instance[ options ].apply( instance, args ); |
125 // throw "no such method '" + options + "' for " + name + " widget instance"; | |
126 // } | |
127 // var methodValue = instance[ options ].apply( instance, args ); | |
128 if ( methodValue !== instance && methodValue !== undefined ) { | 198 if ( methodValue !== instance && methodValue !== undefined ) { |
129 returnValue = methodValue; | 199 returnValue = methodValue && methodValue.jquery ? |
200 returnValue.pushStack( methodValue.get() ) : | |
201 methodValue; | |
130 return false; | 202 return false; |
131 } | 203 } |
132 }); | 204 }); |
133 } else { | 205 } else { |
134 this.each(function() { | 206 this.each(function() { |
135 var instance = $.data( this, name ); | 207 var instance = $.data( this, fullName ); |
136 if ( instance ) { | 208 if ( instance ) { |
137 instance.option( options || {} )._init(); | 209 instance.option( options || {} )._init(); |
138 } else { | 210 } else { |
139 $.data( this, name, new object( options, this ) ); | 211 $.data( this, fullName, new object( options, this ) ); |
140 } | 212 } |
141 }); | 213 }); |
142 } | 214 } |
143 | 215 |
144 return returnValue; | 216 return returnValue; |
145 }; | 217 }; |
146 }; | 218 }; |
147 | 219 |
148 $.Widget = function( options, element ) { | 220 $.Widget = function( /* options, element */ ) {}; |
149 // allow instantiation without initializing for simple inheritance | 221 $.Widget._childConstructors = []; |
150 if ( arguments.length ) { | |
151 this._createWidget( options, element ); | |
152 } | |
153 }; | |
154 | 222 |
155 $.Widget.prototype = { | 223 $.Widget.prototype = { |
156 widgetName: "widget", | 224 widgetName: "widget", |
157 widgetEventPrefix: "", | 225 widgetEventPrefix: "", |
226 defaultElement: "<div>", | |
158 options: { | 227 options: { |
159 disabled: false | 228 disabled: false, |
229 | |
230 // callbacks | |
231 create: null | |
160 }, | 232 }, |
161 _createWidget: function( options, element ) { | 233 _createWidget: function( options, element ) { |
162 // $.widget.bridge stores the plugin instance, but we do it anyway | 234 element = $( element || this.defaultElement || this )[ 0 ]; |
163 // so that it's stored even before the _create function runs | |
164 $.data( element, this.widgetName, this ); | |
165 this.element = $( element ); | 235 this.element = $( element ); |
166 this.options = $.extend( true, {}, | 236 this.uuid = uuid++; |
237 this.eventNamespace = "." + this.widgetName + this.uuid; | |
238 this.options = $.widget.extend( {}, | |
167 this.options, | 239 this.options, |
168 this._getCreateOptions(), | 240 this._getCreateOptions(), |
169 options ); | 241 options ); |
170 | 242 |
171 var self = this; | 243 this.bindings = $(); |
172 this.element.bind( "remove." + this.widgetName, function() { | 244 this.hoverable = $(); |
173 self.destroy(); | 245 this.focusable = $(); |
174 }); | 246 |
247 if ( element !== this ) { | |
248 $.data( element, this.widgetFullName, this ); | |
249 this._on( true, this.element, { | |
250 remove: function( event ) { | |
251 if ( event.target === element ) { | |
252 this.destroy(); | |
253 } | |
254 } | |
255 }); | |
256 this.document = $( element.style ? | |
257 // element within the document | |
258 element.ownerDocument : | |
259 // element is window or document | |
260 element.document || element ); | |
261 this.window = $( this.document[0].defaultView || this.document[0].parentWindow ); | |
262 } | |
175 | 263 |
176 this._create(); | 264 this._create(); |
177 this._trigger( "create" ); | 265 this._trigger( "create", null, this._getCreateEventData() ); |
178 this._init(); | 266 this._init(); |
179 }, | 267 }, |
180 _getCreateOptions: function() { | 268 _getCreateOptions: $.noop, |
181 return $.metadata && $.metadata.get( this.element[0] )[ this.widgetName ]; | 269 _getCreateEventData: $.noop, |
182 }, | 270 _create: $.noop, |
183 _create: function() {}, | 271 _init: $.noop, |
184 _init: function() {}, | |
185 | 272 |
186 destroy: function() { | 273 destroy: function() { |
274 this._destroy(); | |
275 // we can probably remove the unbind calls in 2.0 | |
276 // all event bindings should go through this._on() | |
187 this.element | 277 this.element |
188 .unbind( "." + this.widgetName ) | 278 .unbind( this.eventNamespace ) |
189 .removeData( this.widgetName ); | 279 // 1.9 BC for #7810 |
280 // TODO remove dual storage | |
281 .removeData( this.widgetName ) | |
282 .removeData( this.widgetFullName ) | |
283 // support: jquery <1.6.3 | |
284 // http://bugs.jquery.com/ticket/9413 | |
285 .removeData( $.camelCase( this.widgetFullName ) ); | |
190 this.widget() | 286 this.widget() |
191 .unbind( "." + this.widgetName ) | 287 .unbind( this.eventNamespace ) |
192 .removeAttr( "aria-disabled" ) | 288 .removeAttr( "aria-disabled" ) |
193 .removeClass( | 289 .removeClass( |
194 this.widgetBaseClass + "-disabled " + | 290 this.widgetFullName + "-disabled " + |
195 "ui-state-disabled" ); | 291 "ui-state-disabled" ); |
196 }, | 292 |
293 // clean up events and states | |
294 this.bindings.unbind( this.eventNamespace ); | |
295 this.hoverable.removeClass( "ui-state-hover" ); | |
296 this.focusable.removeClass( "ui-state-focus" ); | |
297 }, | |
298 _destroy: $.noop, | |
197 | 299 |
198 widget: function() { | 300 widget: function() { |
199 return this.element; | 301 return this.element; |
200 }, | 302 }, |
201 | 303 |
202 option: function( key, value ) { | 304 option: function( key, value ) { |
203 var options = key; | 305 var options = key, |
306 parts, | |
307 curOption, | |
308 i; | |
204 | 309 |
205 if ( arguments.length === 0 ) { | 310 if ( arguments.length === 0 ) { |
206 // don't return a reference to the internal hash | 311 // don't return a reference to the internal hash |
207 return $.extend( {}, this.options ); | 312 return $.widget.extend( {}, this.options ); |
208 } | 313 } |
209 | 314 |
210 if (typeof key === "string" ) { | 315 if ( typeof key === "string" ) { |
211 if ( value === undefined ) { | 316 // handle nested keys, e.g., "foo.bar" => { foo: { bar: ___ } } |
212 return this.options[ key ]; | |
213 } | |
214 options = {}; | 317 options = {}; |
215 options[ key ] = value; | 318 parts = key.split( "." ); |
319 key = parts.shift(); | |
320 if ( parts.length ) { | |
321 curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); | |
322 for ( i = 0; i < parts.length - 1; i++ ) { | |
323 curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; | |
324 curOption = curOption[ parts[ i ] ]; | |
325 } | |
326 key = parts.pop(); | |
327 if ( value === undefined ) { | |
328 return curOption[ key ] === undefined ? null : curOption[ key ]; | |
329 } | |
330 curOption[ key ] = value; | |
331 } else { | |
332 if ( value === undefined ) { | |
333 return this.options[ key ] === undefined ? null : this.options[ key ]; | |
334 } | |
335 options[ key ] = value; | |
336 } | |
216 } | 337 } |
217 | 338 |
218 this._setOptions( options ); | 339 this._setOptions( options ); |
219 | 340 |
220 return this; | 341 return this; |
221 }, | 342 }, |
222 _setOptions: function( options ) { | 343 _setOptions: function( options ) { |
223 var self = this; | 344 var key; |
224 $.each( options, function( key, value ) { | 345 |
225 self._setOption( key, value ); | 346 for ( key in options ) { |
226 }); | 347 this._setOption( key, options[ key ] ); |
348 } | |
227 | 349 |
228 return this; | 350 return this; |
229 }, | 351 }, |
230 _setOption: function( key, value ) { | 352 _setOption: function( key, value ) { |
231 this.options[ key ] = value; | 353 this.options[ key ] = value; |
232 | 354 |
233 if ( key === "disabled" ) { | 355 if ( key === "disabled" ) { |
234 this.widget() | 356 this.widget() |
235 [ value ? "addClass" : "removeClass"]( | 357 .toggleClass( this.widgetFullName + "-disabled ui-state-disabled", !!value ) |
236 this.widgetBaseClass + "-disabled" + " " + | |
237 "ui-state-disabled" ) | |
238 .attr( "aria-disabled", value ); | 358 .attr( "aria-disabled", value ); |
359 this.hoverable.removeClass( "ui-state-hover" ); | |
360 this.focusable.removeClass( "ui-state-focus" ); | |
239 } | 361 } |
240 | 362 |
241 return this; | 363 return this; |
242 }, | 364 }, |
243 | 365 |
244 enable: function() { | 366 enable: function() { |
245 return this._setOption( "disabled", false ); | 367 return this._setOption( "disabled", false ); |
246 }, | 368 }, |
247 disable: function() { | 369 disable: function() { |
248 return this._setOption( "disabled", true ); | 370 return this._setOption( "disabled", true ); |
371 }, | |
372 | |
373 _on: function( suppressDisabledCheck, element, handlers ) { | |
374 var delegateElement, | |
375 instance = this; | |
376 | |
377 // no suppressDisabledCheck flag, shuffle arguments | |
378 if ( typeof suppressDisabledCheck !== "boolean" ) { | |
379 handlers = element; | |
380 element = suppressDisabledCheck; | |
381 suppressDisabledCheck = false; | |
382 } | |
383 | |
384 // no element argument, shuffle and use this.element | |
385 if ( !handlers ) { | |
386 handlers = element; | |
387 element = this.element; | |
388 delegateElement = this.widget(); | |
389 } else { | |
390 // accept selectors, DOM elements | |
391 element = delegateElement = $( element ); | |
392 this.bindings = this.bindings.add( element ); | |
393 } | |
394 | |
395 $.each( handlers, function( event, handler ) { | |
396 function handlerProxy() { | |
397 // allow widgets to customize the disabled handling | |
398 // - disabled as an array instead of boolean | |
399 // - disabled class as method for disabling individual parts | |
400 if ( !suppressDisabledCheck && | |
401 ( instance.options.disabled === true || | |
402 $( this ).hasClass( "ui-state-disabled" ) ) ) { | |
403 return; | |
404 } | |
405 return ( typeof handler === "string" ? instance[ handler ] : handler ) | |
406 .apply( instance, arguments ); | |
407 } | |
408 | |
409 // copy the guid so direct unbinding works | |
410 if ( typeof handler !== "string" ) { | |
411 handlerProxy.guid = handler.guid = | |
412 handler.guid || handlerProxy.guid || $.guid++; | |
413 } | |
414 | |
415 var match = event.match( /^(\w+)\s*(.*)$/ ), | |
416 eventName = match[1] + instance.eventNamespace, | |
417 selector = match[2]; | |
418 if ( selector ) { | |
419 delegateElement.delegate( selector, eventName, handlerProxy ); | |
420 } else { | |
421 element.bind( eventName, handlerProxy ); | |
422 } | |
423 }); | |
424 }, | |
425 | |
426 _off: function( element, eventName ) { | |
427 eventName = (eventName || "").split( " " ).join( this.eventNamespace + " " ) + this.eventNamespace; | |
428 element.unbind( eventName ).undelegate( eventName ); | |
429 }, | |
430 | |
431 _delay: function( handler, delay ) { | |
432 function handlerProxy() { | |
433 return ( typeof handler === "string" ? instance[ handler ] : handler ) | |
434 .apply( instance, arguments ); | |
435 } | |
436 var instance = this; | |
437 return setTimeout( handlerProxy, delay || 0 ); | |
438 }, | |
439 | |
440 _hoverable: function( element ) { | |
441 this.hoverable = this.hoverable.add( element ); | |
442 this._on( element, { | |
443 mouseenter: function( event ) { | |
444 $( event.currentTarget ).addClass( "ui-state-hover" ); | |
445 }, | |
446 mouseleave: function( event ) { | |
447 $( event.currentTarget ).removeClass( "ui-state-hover" ); | |
448 } | |
449 }); | |
450 }, | |
451 | |
452 _focusable: function( element ) { | |
453 this.focusable = this.focusable.add( element ); | |
454 this._on( element, { | |
455 focusin: function( event ) { | |
456 $( event.currentTarget ).addClass( "ui-state-focus" ); | |
457 }, | |
458 focusout: function( event ) { | |
459 $( event.currentTarget ).removeClass( "ui-state-focus" ); | |
460 } | |
461 }); | |
249 }, | 462 }, |
250 | 463 |
251 _trigger: function( type, event, data ) { | 464 _trigger: function( type, event, data ) { |
252 var prop, orig, | 465 var prop, orig, |
253 callback = this.options[ type ]; | 466 callback = this.options[ type ]; |
270 } | 483 } |
271 } | 484 } |
272 } | 485 } |
273 | 486 |
274 this.element.trigger( event, data ); | 487 this.element.trigger( event, data ); |
275 | 488 return !( $.isFunction( callback ) && |
276 return !( $.isFunction(callback) && | 489 callback.apply( this.element[0], [ event ].concat( data ) ) === false || |
277 callback.call( this.element[0], event, data ) === false || | |
278 event.isDefaultPrevented() ); | 490 event.isDefaultPrevented() ); |
279 } | 491 } |
280 }; | 492 }; |
281 | 493 |
494 $.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { | |
495 $.Widget.prototype[ "_" + method ] = function( element, options, callback ) { | |
496 if ( typeof options === "string" ) { | |
497 options = { effect: options }; | |
498 } | |
499 var hasOptions, | |
500 effectName = !options ? | |
501 method : | |
502 options === true || typeof options === "number" ? | |
503 defaultEffect : | |
504 options.effect || defaultEffect; | |
505 options = options || {}; | |
506 if ( typeof options === "number" ) { | |
507 options = { duration: options }; | |
508 } | |
509 hasOptions = !$.isEmptyObject( options ); | |
510 options.complete = callback; | |
511 if ( options.delay ) { | |
512 element.delay( options.delay ); | |
513 } | |
514 if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { | |
515 element[ method ]( options ); | |
516 } else if ( effectName !== method && element[ effectName ] ) { | |
517 element[ effectName ]( options.duration, options.easing, callback ); | |
518 } else { | |
519 element.queue(function( next ) { | |
520 $( this )[ method ](); | |
521 if ( callback ) { | |
522 callback.call( element[ 0 ] ); | |
523 } | |
524 next(); | |
525 }); | |
526 } | |
527 }; | |
528 }); | |
529 | |
282 })); | 530 })); |