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