| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
( function( factory ) { |
| 17 |
"use strict"; |
| 18 |
|
| 19 |
if ( typeof define === "function" && define.amd ) { |
| 20 |
|
| 21 |
|
| 22 |
define( [ "jquery", "./version" ], factory ); |
| 23 |
} else { |
| 24 |
|
| 25 |
|
| 26 |
factory( jQuery ); |
| 27 |
} |
| 28 |
} )( function( $ ) { |
| 29 |
"use strict"; |
| 30 |
|
| 31 |
var widgetUuid = 0; |
| 32 |
var widgetHasOwnProperty = Array.prototype.hasOwnProperty; |
| 33 |
var widgetSlice = Array.prototype.slice; |
| 34 |
|
| 35 |
$.cleanData = ( function( orig ) { |
| 36 |
return function( elems ) { |
| 37 |
var events, elem, i; |
| 38 |
for ( i = 0; ( elem = elems[ i ] ) != null; i++ ) { |
| 39 |
|
| 40 |
|
| 41 |
events = $._data( elem, "events" ); |
| 42 |
if ( events && events.remove ) { |
| 43 |
$( elem ).triggerHandler( "remove" ); |
| 44 |
} |
| 45 |
} |
| 46 |
orig( elems ); |
| 47 |
}; |
| 48 |
} )( $.cleanData ); |
| 49 |
|
| 50 |
$.widget = function( name, base, prototype ) { |
| 51 |
var existingConstructor, constructor, basePrototype; |
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
var proxiedPrototype = {}; |
| 56 |
|
| 57 |
var namespace = name.split( "." )[ 0 ]; |
| 58 |
name = name.split( "." )[ 1 ]; |
| 59 |
if ( name === "__proto__" || name === "constructor" ) { |
| 60 |
return $.error( "Invalid widget name: " + name ); |
| 61 |
} |
| 62 |
var fullName = namespace + "-" + name; |
| 63 |
|
| 64 |
if ( !prototype ) { |
| 65 |
prototype = base; |
| 66 |
base = $.Widget; |
| 67 |
} |
| 68 |
|
| 69 |
if ( Array.isArray( prototype ) ) { |
| 70 |
prototype = $.extend.apply( null, [ {} ].concat( prototype ) ); |
| 71 |
} |
| 72 |
|
| 73 |
|
| 74 |
$.expr.pseudos[ fullName.toLowerCase() ] = function( elem ) { |
| 75 |
return !!$.data( elem, fullName ); |
| 76 |
}; |
| 77 |
|
| 78 |
$[ namespace ] = $[ namespace ] || {}; |
| 79 |
existingConstructor = $[ namespace ][ name ]; |
| 80 |
constructor = $[ namespace ][ name ] = function( options, element ) { |
| 81 |
|
| 82 |
|
| 83 |
if ( !this || !this._createWidget ) { |
| 84 |
return new constructor( options, element ); |
| 85 |
} |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
if ( arguments.length ) { |
| 90 |
this._createWidget( options, element ); |
| 91 |
} |
| 92 |
}; |
| 93 |
|
| 94 |
|
| 95 |
$.extend( constructor, existingConstructor, { |
| 96 |
version: prototype.version, |
| 97 |
|
| 98 |
|
| 99 |
|
| 100 |
_proto: $.extend( {}, prototype ), |
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
_childConstructors: [] |
| 105 |
} ); |
| 106 |
|
| 107 |
basePrototype = new base(); |
| 108 |
|
| 109 |
|
| 110 |
|
| 111 |
|
| 112 |
basePrototype.options = $.widget.extend( {}, basePrototype.options ); |
| 113 |
$.each( prototype, function( prop, value ) { |
| 114 |
if ( typeof value !== "function" ) { |
| 115 |
proxiedPrototype[ prop ] = value; |
| 116 |
return; |
| 117 |
} |
| 118 |
proxiedPrototype[ prop ] = ( function() { |
| 119 |
function _super() { |
| 120 |
return base.prototype[ prop ].apply( this, arguments ); |
| 121 |
} |
| 122 |
|
| 123 |
function _superApply( args ) { |
| 124 |
return base.prototype[ prop ].apply( this, args ); |
| 125 |
} |
| 126 |
|
| 127 |
return function() { |
| 128 |
var __super = this._super; |
| 129 |
var __superApply = this._superApply; |
| 130 |
var returnValue; |
| 131 |
|
| 132 |
this._super = _super; |
| 133 |
this._superApply = _superApply; |
| 134 |
|
| 135 |
returnValue = value.apply( this, arguments ); |
| 136 |
|
| 137 |
this._super = __super; |
| 138 |
this._superApply = __superApply; |
| 139 |
|
| 140 |
return returnValue; |
| 141 |
}; |
| 142 |
} )(); |
| 143 |
} ); |
| 144 |
constructor.prototype = $.widget.extend( basePrototype, { |
| 145 |
|
| 146 |
|
| 147 |
|
| 148 |
|
| 149 |
widgetEventPrefix: existingConstructor ? ( basePrototype.widgetEventPrefix || name ) : name |
| 150 |
}, proxiedPrototype, { |
| 151 |
constructor: constructor, |
| 152 |
namespace: namespace, |
| 153 |
widgetName: name, |
| 154 |
widgetFullName: fullName |
| 155 |
} ); |
| 156 |
|
| 157 |
|
| 158 |
|
| 159 |
|
| 160 |
|
| 161 |
if ( existingConstructor ) { |
| 162 |
$.each( existingConstructor._childConstructors, function( i, child ) { |
| 163 |
var childPrototype = child.prototype; |
| 164 |
|
| 165 |
|
| 166 |
|
| 167 |
$.widget( childPrototype.namespace + "." + childPrototype.widgetName, constructor, |
| 168 |
child._proto ); |
| 169 |
} ); |
| 170 |
|
| 171 |
|
| 172 |
|
| 173 |
delete existingConstructor._childConstructors; |
| 174 |
} else { |
| 175 |
base._childConstructors.push( constructor ); |
| 176 |
} |
| 177 |
|
| 178 |
$.widget.bridge( name, constructor ); |
| 179 |
|
| 180 |
return constructor; |
| 181 |
}; |
| 182 |
|
| 183 |
$.widget.extend = function( target ) { |
| 184 |
var input = widgetSlice.call( arguments, 1 ); |
| 185 |
var inputIndex = 0; |
| 186 |
var inputLength = input.length; |
| 187 |
var key; |
| 188 |
var value; |
| 189 |
|
| 190 |
for ( ; inputIndex < inputLength; inputIndex++ ) { |
| 191 |
for ( key in input[ inputIndex ] ) { |
| 192 |
value = input[ inputIndex ][ key ]; |
| 193 |
if ( widgetHasOwnProperty.call( input[ inputIndex ], key ) && value !== undefined ) { |
| 194 |
|
| 195 |
|
| 196 |
if ( $.isPlainObject( value ) ) { |
| 197 |
target[ key ] = $.isPlainObject( target[ key ] ) ? |
| 198 |
$.widget.extend( {}, target[ key ], value ) : |
| 199 |
|
| 200 |
|
| 201 |
$.widget.extend( {}, value ); |
| 202 |
|
| 203 |
|
| 204 |
} else { |
| 205 |
target[ key ] = value; |
| 206 |
} |
| 207 |
} |
| 208 |
} |
| 209 |
} |
| 210 |
return target; |
| 211 |
}; |
| 212 |
|
| 213 |
$.widget.bridge = function( name, object ) { |
| 214 |
var fullName = object.prototype.widgetFullName || name; |
| 215 |
$.fn[ name ] = function( options ) { |
| 216 |
var isMethodCall = typeof options === "string"; |
| 217 |
var args = widgetSlice.call( arguments, 1 ); |
| 218 |
var returnValue = this; |
| 219 |
|
| 220 |
if ( isMethodCall ) { |
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
if ( !this.length && options === "instance" ) { |
| 225 |
returnValue = undefined; |
| 226 |
} else { |
| 227 |
this.each( function() { |
| 228 |
var methodValue; |
| 229 |
var instance = $.data( this, fullName ); |
| 230 |
|
| 231 |
if ( options === "instance" ) { |
| 232 |
returnValue = instance; |
| 233 |
return false; |
| 234 |
} |
| 235 |
|
| 236 |
if ( !instance ) { |
| 237 |
return $.error( "cannot call methods on " + name + |
| 238 |
" prior to initialization; " + |
| 239 |
"attempted to call method '" + options + "'" ); |
| 240 |
} |
| 241 |
|
| 242 |
if ( typeof instance[ options ] !== "function" || |
| 243 |
options.charAt( 0 ) === "_" ) { |
| 244 |
return $.error( "no such method '" + options + "' for " + name + |
| 245 |
" widget instance" ); |
| 246 |
} |
| 247 |
|
| 248 |
methodValue = instance[ options ].apply( instance, args ); |
| 249 |
|
| 250 |
if ( methodValue !== instance && methodValue !== undefined ) { |
| 251 |
returnValue = methodValue && methodValue.jquery ? |
| 252 |
returnValue.pushStack( methodValue.get() ) : |
| 253 |
methodValue; |
| 254 |
return false; |
| 255 |
} |
| 256 |
} ); |
| 257 |
} |
| 258 |
} else { |
| 259 |
|
| 260 |
|
| 261 |
if ( args.length ) { |
| 262 |
options = $.widget.extend.apply( null, [ options ].concat( args ) ); |
| 263 |
} |
| 264 |
|
| 265 |
this.each( function() { |
| 266 |
var instance = $.data( this, fullName ); |
| 267 |
if ( instance ) { |
| 268 |
instance.option( options || {} ); |
| 269 |
if ( instance._init ) { |
| 270 |
instance._init(); |
| 271 |
} |
| 272 |
} else { |
| 273 |
$.data( this, fullName, new object( options, this ) ); |
| 274 |
} |
| 275 |
} ); |
| 276 |
} |
| 277 |
|
| 278 |
return returnValue; |
| 279 |
}; |
| 280 |
}; |
| 281 |
|
| 282 |
$.Widget = function( ) {}; |
| 283 |
$.Widget._childConstructors = []; |
| 284 |
|
| 285 |
$.Widget.prototype = { |
| 286 |
widgetName: "widget", |
| 287 |
widgetEventPrefix: "", |
| 288 |
defaultElement: "<div>", |
| 289 |
|
| 290 |
options: { |
| 291 |
classes: {}, |
| 292 |
disabled: false, |
| 293 |
|
| 294 |
|
| 295 |
create: null |
| 296 |
}, |
| 297 |
|
| 298 |
_createWidget: function( options, element ) { |
| 299 |
element = $( element || this.defaultElement || this )[ 0 ]; |
| 300 |
this.element = $( element ); |
| 301 |
this.uuid = widgetUuid++; |
| 302 |
this.eventNamespace = "." + this.widgetName + this.uuid; |
| 303 |
|
| 304 |
this.bindings = $(); |
| 305 |
this.hoverable = $(); |
| 306 |
this.focusable = $(); |
| 307 |
this.classesElementLookup = {}; |
| 308 |
|
| 309 |
if ( element !== this ) { |
| 310 |
$.data( element, this.widgetFullName, this ); |
| 311 |
this._on( true, this.element, { |
| 312 |
remove: function( event ) { |
| 313 |
if ( event.target === element ) { |
| 314 |
this.destroy(); |
| 315 |
} |
| 316 |
} |
| 317 |
} ); |
| 318 |
this.document = $( element.style ? |
| 319 |
|
| 320 |
|
| 321 |
element.ownerDocument : |
| 322 |
|
| 323 |
|
| 324 |
element.document || element ); |
| 325 |
this.window = $( this.document[ 0 ].defaultView || this.document[ 0 ].parentWindow ); |
| 326 |
} |
| 327 |
|
| 328 |
this.options = $.widget.extend( {}, |
| 329 |
this.options, |
| 330 |
this._getCreateOptions(), |
| 331 |
options ); |
| 332 |
|
| 333 |
this._create(); |
| 334 |
|
| 335 |
if ( this.options.disabled ) { |
| 336 |
this._setOptionDisabled( this.options.disabled ); |
| 337 |
} |
| 338 |
|
| 339 |
this._trigger( "create", null, this._getCreateEventData() ); |
| 340 |
this._init(); |
| 341 |
}, |
| 342 |
|
| 343 |
_getCreateOptions: function() { |
| 344 |
return {}; |
| 345 |
}, |
| 346 |
|
| 347 |
_getCreateEventData: $.noop, |
| 348 |
|
| 349 |
_create: $.noop, |
| 350 |
|
| 351 |
_init: $.noop, |
| 352 |
|
| 353 |
destroy: function() { |
| 354 |
var that = this; |
| 355 |
|
| 356 |
this._destroy(); |
| 357 |
$.each( this.classesElementLookup, function( key, value ) { |
| 358 |
that._removeClass( value, key ); |
| 359 |
} ); |
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
this.element |
| 364 |
.off( this.eventNamespace ) |
| 365 |
.removeData( this.widgetFullName ); |
| 366 |
this.widget() |
| 367 |
.off( this.eventNamespace ) |
| 368 |
.removeAttr( "aria-disabled" ); |
| 369 |
|
| 370 |
|
| 371 |
this.bindings.off( this.eventNamespace ); |
| 372 |
}, |
| 373 |
|
| 374 |
_destroy: $.noop, |
| 375 |
|
| 376 |
widget: function() { |
| 377 |
return this.element; |
| 378 |
}, |
| 379 |
|
| 380 |
option: function( key, value ) { |
| 381 |
var options = key; |
| 382 |
var parts; |
| 383 |
var curOption; |
| 384 |
var i; |
| 385 |
|
| 386 |
if ( arguments.length === 0 ) { |
| 387 |
|
| 388 |
|
| 389 |
return $.widget.extend( {}, this.options ); |
| 390 |
} |
| 391 |
|
| 392 |
if ( typeof key === "string" ) { |
| 393 |
|
| 394 |
|
| 395 |
options = {}; |
| 396 |
parts = key.split( "." ); |
| 397 |
key = parts.shift(); |
| 398 |
if ( parts.length ) { |
| 399 |
curOption = options[ key ] = $.widget.extend( {}, this.options[ key ] ); |
| 400 |
for ( i = 0; i < parts.length - 1; i++ ) { |
| 401 |
curOption[ parts[ i ] ] = curOption[ parts[ i ] ] || {}; |
| 402 |
curOption = curOption[ parts[ i ] ]; |
| 403 |
} |
| 404 |
key = parts.pop(); |
| 405 |
if ( arguments.length === 1 ) { |
| 406 |
return curOption[ key ] === undefined ? null : curOption[ key ]; |
| 407 |
} |
| 408 |
curOption[ key ] = value; |
| 409 |
} else { |
| 410 |
if ( arguments.length === 1 ) { |
| 411 |
return this.options[ key ] === undefined ? null : this.options[ key ]; |
| 412 |
} |
| 413 |
options[ key ] = value; |
| 414 |
} |
| 415 |
} |
| 416 |
|
| 417 |
this._setOptions( options ); |
| 418 |
|
| 419 |
return this; |
| 420 |
}, |
| 421 |
|
| 422 |
_setOptions: function( options ) { |
| 423 |
var key; |
| 424 |
|
| 425 |
for ( key in options ) { |
| 426 |
this._setOption( key, options[ key ] ); |
| 427 |
} |
| 428 |
|
| 429 |
return this; |
| 430 |
}, |
| 431 |
|
| 432 |
_setOption: function( key, value ) { |
| 433 |
if ( key === "classes" ) { |
| 434 |
this._setOptionClasses( value ); |
| 435 |
} |
| 436 |
|
| 437 |
this.options[ key ] = value; |
| 438 |
|
| 439 |
if ( key === "disabled" ) { |
| 440 |
this._setOptionDisabled( value ); |
| 441 |
} |
| 442 |
|
| 443 |
return this; |
| 444 |
}, |
| 445 |
|
| 446 |
_setOptionClasses: function( value ) { |
| 447 |
var classKey, elements, currentElements; |
| 448 |
|
| 449 |
for ( classKey in value ) { |
| 450 |
currentElements = this.classesElementLookup[ classKey ]; |
| 451 |
if ( value[ classKey ] === this.options.classes[ classKey ] || |
| 452 |
!currentElements || |
| 453 |
!currentElements.length ) { |
| 454 |
continue; |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
elements = $( currentElements.get() ); |
| 462 |
this._removeClass( currentElements, classKey ); |
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
elements.addClass( this._classes( { |
| 469 |
element: elements, |
| 470 |
keys: classKey, |
| 471 |
classes: value, |
| 472 |
add: true |
| 473 |
} ) ); |
| 474 |
} |
| 475 |
}, |
| 476 |
|
| 477 |
_setOptionDisabled: function( value ) { |
| 478 |
this._toggleClass( this.widget(), this.widgetFullName + "-disabled", null, !!value ); |
| 479 |
|
| 480 |
|
| 481 |
if ( value ) { |
| 482 |
this._removeClass( this.hoverable, null, "ui-state-hover" ); |
| 483 |
this._removeClass( this.focusable, null, "ui-state-focus" ); |
| 484 |
} |
| 485 |
}, |
| 486 |
|
| 487 |
enable: function() { |
| 488 |
return this._setOptions( { disabled: false } ); |
| 489 |
}, |
| 490 |
|
| 491 |
disable: function() { |
| 492 |
return this._setOptions( { disabled: true } ); |
| 493 |
}, |
| 494 |
|
| 495 |
_classes: function( options ) { |
| 496 |
var full = []; |
| 497 |
var that = this; |
| 498 |
|
| 499 |
options = $.extend( { |
| 500 |
element: this.element, |
| 501 |
classes: this.options.classes || {} |
| 502 |
}, options ); |
| 503 |
|
| 504 |
function bindRemoveEvent() { |
| 505 |
var nodesToBind = []; |
| 506 |
|
| 507 |
options.element.each( function( _, element ) { |
| 508 |
var isTracked = $.map( that.classesElementLookup, function( elements ) { |
| 509 |
return elements; |
| 510 |
} ) |
| 511 |
.some( function( elements ) { |
| 512 |
return elements.is( element ); |
| 513 |
} ); |
| 514 |
|
| 515 |
if ( !isTracked ) { |
| 516 |
nodesToBind.push( element ); |
| 517 |
} |
| 518 |
} ); |
| 519 |
|
| 520 |
that._on( $( nodesToBind ), { |
| 521 |
remove: "_untrackClassesElement" |
| 522 |
} ); |
| 523 |
} |
| 524 |
|
| 525 |
function processClassString( classes, checkOption ) { |
| 526 |
var current, i; |
| 527 |
for ( i = 0; i < classes.length; i++ ) { |
| 528 |
current = that.classesElementLookup[ classes[ i ] ] || $(); |
| 529 |
if ( options.add ) { |
| 530 |
bindRemoveEvent(); |
| 531 |
current = $( $.uniqueSort( current.get().concat( options.element.get() ) ) ); |
| 532 |
} else { |
| 533 |
current = $( current.not( options.element ).get() ); |
| 534 |
} |
| 535 |
that.classesElementLookup[ classes[ i ] ] = current; |
| 536 |
full.push( classes[ i ] ); |
| 537 |
if ( checkOption && options.classes[ classes[ i ] ] ) { |
| 538 |
full.push( options.classes[ classes[ i ] ] ); |
| 539 |
} |
| 540 |
} |
| 541 |
} |
| 542 |
|
| 543 |
if ( options.keys ) { |
| 544 |
processClassString( options.keys.match( /\S+/g ) || [], true ); |
| 545 |
} |
| 546 |
if ( options.extra ) { |
| 547 |
processClassString( options.extra.match( /\S+/g ) || [] ); |
| 548 |
} |
| 549 |
|
| 550 |
return full.join( " " ); |
| 551 |
}, |
| 552 |
|
| 553 |
_untrackClassesElement: function( event ) { |
| 554 |
var that = this; |
| 555 |
$.each( that.classesElementLookup, function( key, value ) { |
| 556 |
if ( $.inArray( event.target, value ) !== -1 ) { |
| 557 |
that.classesElementLookup[ key ] = $( value.not( event.target ).get() ); |
| 558 |
} |
| 559 |
} ); |
| 560 |
|
| 561 |
this._off( $( event.target ) ); |
| 562 |
}, |
| 563 |
|
| 564 |
_removeClass: function( element, keys, extra ) { |
| 565 |
return this._toggleClass( element, keys, extra, false ); |
| 566 |
}, |
| 567 |
|
| 568 |
_addClass: function( element, keys, extra ) { |
| 569 |
return this._toggleClass( element, keys, extra, true ); |
| 570 |
}, |
| 571 |
|
| 572 |
_toggleClass: function( element, keys, extra, add ) { |
| 573 |
add = ( typeof add === "boolean" ) ? add : extra; |
| 574 |
var shift = ( typeof element === "string" || element === null ), |
| 575 |
options = { |
| 576 |
extra: shift ? keys : extra, |
| 577 |
keys: shift ? element : keys, |
| 578 |
element: shift ? this.element : element, |
| 579 |
add: add |
| 580 |
}; |
| 581 |
options.element.toggleClass( this._classes( options ), add ); |
| 582 |
return this; |
| 583 |
}, |
| 584 |
|
| 585 |
_on: function( suppressDisabledCheck, element, handlers ) { |
| 586 |
var delegateElement; |
| 587 |
var instance = this; |
| 588 |
|
| 589 |
|
| 590 |
if ( typeof suppressDisabledCheck !== "boolean" ) { |
| 591 |
handlers = element; |
| 592 |
element = suppressDisabledCheck; |
| 593 |
suppressDisabledCheck = false; |
| 594 |
} |
| 595 |
|
| 596 |
|
| 597 |
if ( !handlers ) { |
| 598 |
handlers = element; |
| 599 |
element = this.element; |
| 600 |
delegateElement = this.widget(); |
| 601 |
} else { |
| 602 |
element = delegateElement = $( element ); |
| 603 |
this.bindings = this.bindings.add( element ); |
| 604 |
} |
| 605 |
|
| 606 |
$.each( handlers, function( event, handler ) { |
| 607 |
function handlerProxy() { |
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
if ( !suppressDisabledCheck && |
| 613 |
( instance.options.disabled === true || |
| 614 |
$( this ).hasClass( "ui-state-disabled" ) ) ) { |
| 615 |
return; |
| 616 |
} |
| 617 |
return ( typeof handler === "string" ? instance[ handler ] : handler ) |
| 618 |
.apply( instance, arguments ); |
| 619 |
} |
| 620 |
|
| 621 |
|
| 622 |
if ( typeof handler !== "string" ) { |
| 623 |
handlerProxy.guid = handler.guid = |
| 624 |
handler.guid || handlerProxy.guid || $.guid++; |
| 625 |
} |
| 626 |
|
| 627 |
var match = event.match( /^([\w:-]*)\s*(.*)$/ ); |
| 628 |
var eventName = match[ 1 ] + instance.eventNamespace; |
| 629 |
var selector = match[ 2 ]; |
| 630 |
|
| 631 |
if ( selector ) { |
| 632 |
delegateElement.on( eventName, selector, handlerProxy ); |
| 633 |
} else { |
| 634 |
element.on( eventName, handlerProxy ); |
| 635 |
} |
| 636 |
} ); |
| 637 |
}, |
| 638 |
|
| 639 |
_off: function( element, eventName ) { |
| 640 |
eventName = ( eventName || "" ).split( " " ).join( this.eventNamespace + " " ) + |
| 641 |
this.eventNamespace; |
| 642 |
element.off( eventName ); |
| 643 |
|
| 644 |
|
| 645 |
this.bindings = $( this.bindings.not( element ).get() ); |
| 646 |
this.focusable = $( this.focusable.not( element ).get() ); |
| 647 |
this.hoverable = $( this.hoverable.not( element ).get() ); |
| 648 |
}, |
| 649 |
|
| 650 |
_delay: function( handler, delay ) { |
| 651 |
function handlerProxy() { |
| 652 |
return ( typeof handler === "string" ? instance[ handler ] : handler ) |
| 653 |
.apply( instance, arguments ); |
| 654 |
} |
| 655 |
var instance = this; |
| 656 |
return setTimeout( handlerProxy, delay || 0 ); |
| 657 |
}, |
| 658 |
|
| 659 |
_hoverable: function( element ) { |
| 660 |
this.hoverable = this.hoverable.add( element ); |
| 661 |
this._on( element, { |
| 662 |
mouseenter: function( event ) { |
| 663 |
this._addClass( $( event.currentTarget ), null, "ui-state-hover" ); |
| 664 |
}, |
| 665 |
mouseleave: function( event ) { |
| 666 |
this._removeClass( $( event.currentTarget ), null, "ui-state-hover" ); |
| 667 |
} |
| 668 |
} ); |
| 669 |
}, |
| 670 |
|
| 671 |
_focusable: function( element ) { |
| 672 |
this.focusable = this.focusable.add( element ); |
| 673 |
this._on( element, { |
| 674 |
focusin: function( event ) { |
| 675 |
this._addClass( $( event.currentTarget ), null, "ui-state-focus" ); |
| 676 |
}, |
| 677 |
focusout: function( event ) { |
| 678 |
this._removeClass( $( event.currentTarget ), null, "ui-state-focus" ); |
| 679 |
} |
| 680 |
} ); |
| 681 |
}, |
| 682 |
|
| 683 |
_trigger: function( type, event, data ) { |
| 684 |
var prop, orig; |
| 685 |
var callback = this.options[ type ]; |
| 686 |
|
| 687 |
data = data || {}; |
| 688 |
event = $.Event( event ); |
| 689 |
event.type = ( type === this.widgetEventPrefix ? |
| 690 |
type : |
| 691 |
this.widgetEventPrefix + type ).toLowerCase(); |
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
event.target = this.element[ 0 ]; |
| 696 |
|
| 697 |
|
| 698 |
orig = event.originalEvent; |
| 699 |
if ( orig ) { |
| 700 |
for ( prop in orig ) { |
| 701 |
if ( !( prop in event ) ) { |
| 702 |
event[ prop ] = orig[ prop ]; |
| 703 |
} |
| 704 |
} |
| 705 |
} |
| 706 |
|
| 707 |
this.element.trigger( event, data ); |
| 708 |
return !( typeof callback === "function" && |
| 709 |
callback.apply( this.element[ 0 ], [ event ].concat( data ) ) === false || |
| 710 |
event.isDefaultPrevented() ); |
| 711 |
} |
| 712 |
}; |
| 713 |
|
| 714 |
$.each( { show: "fadeIn", hide: "fadeOut" }, function( method, defaultEffect ) { |
| 715 |
$.Widget.prototype[ "_" + method ] = function( element, options, callback ) { |
| 716 |
if ( typeof options === "string" ) { |
| 717 |
options = { effect: options }; |
| 718 |
} |
| 719 |
|
| 720 |
var hasOptions; |
| 721 |
var effectName = !options ? |
| 722 |
method : |
| 723 |
options === true || typeof options === "number" ? |
| 724 |
defaultEffect : |
| 725 |
options.effect || defaultEffect; |
| 726 |
|
| 727 |
options = options || {}; |
| 728 |
if ( typeof options === "number" ) { |
| 729 |
options = { duration: options }; |
| 730 |
} else if ( options === true ) { |
| 731 |
options = {}; |
| 732 |
} |
| 733 |
|
| 734 |
hasOptions = !$.isEmptyObject( options ); |
| 735 |
options.complete = callback; |
| 736 |
|
| 737 |
if ( options.delay ) { |
| 738 |
element.delay( options.delay ); |
| 739 |
} |
| 740 |
|
| 741 |
if ( hasOptions && $.effects && $.effects.effect[ effectName ] ) { |
| 742 |
element[ method ]( options ); |
| 743 |
} else if ( effectName !== method && element[ effectName ] ) { |
| 744 |
element[ effectName ]( options.duration, options.easing, callback ); |
| 745 |
} else { |
| 746 |
element.queue( function( next ) { |
| 747 |
$( this )[ method ](); |
| 748 |
if ( callback ) { |
| 749 |
callback.call( element[ 0 ] ); |
| 750 |
} |
| 751 |
next(); |
| 752 |
} ); |
| 753 |
} |
| 754 |
}; |
| 755 |
} ); |
| 756 |
|
| 757 |
return $.widget; |
| 758 |
|
| 759 |
} ); |