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