| 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( [ |
| 23 |
"jquery", |
| 24 |
"./jquery-var-for-color", |
| 25 |
"./vendor/jquery-color/jquery.color", |
| 26 |
"./version" |
| 27 |
], factory ); |
| 28 |
} else { |
| 29 |
|
| 30 |
|
| 31 |
factory( jQuery ); |
| 32 |
} |
| 33 |
} )( function( $ ) { |
| 34 |
"use strict"; |
| 35 |
|
| 36 |
var dataSpace = "ui-effects-", |
| 37 |
dataSpaceStyle = "ui-effects-style", |
| 38 |
dataSpaceAnimated = "ui-effects-animated"; |
| 39 |
|
| 40 |
$.effects = { |
| 41 |
effect: {} |
| 42 |
}; |
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
( function() { |
| 48 |
|
| 49 |
var classAnimationActions = [ "add", "remove", "toggle" ], |
| 50 |
shorthandStyles = { |
| 51 |
border: 1, |
| 52 |
borderBottom: 1, |
| 53 |
borderColor: 1, |
| 54 |
borderLeft: 1, |
| 55 |
borderRight: 1, |
| 56 |
borderTop: 1, |
| 57 |
borderWidth: 1, |
| 58 |
margin: 1, |
| 59 |
padding: 1 |
| 60 |
}; |
| 61 |
|
| 62 |
$.each( |
| 63 |
[ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], |
| 64 |
function( _, prop ) { |
| 65 |
$.fx.step[ prop ] = function( fx ) { |
| 66 |
if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) { |
| 67 |
jQuery.style( fx.elem, prop, fx.end ); |
| 68 |
fx.setAttr = true; |
| 69 |
} |
| 70 |
}; |
| 71 |
} |
| 72 |
); |
| 73 |
|
| 74 |
function camelCase( string ) { |
| 75 |
return string.replace( /-([\da-z])/gi, function( all, letter ) { |
| 76 |
return letter.toUpperCase(); |
| 77 |
} ); |
| 78 |
} |
| 79 |
|
| 80 |
function getElementStyles( elem ) { |
| 81 |
var key, len, |
| 82 |
style = elem.ownerDocument.defaultView.getComputedStyle( elem ), |
| 83 |
styles = {}; |
| 84 |
|
| 85 |
len = style.length; |
| 86 |
while ( len-- ) { |
| 87 |
key = style[ len ]; |
| 88 |
if ( typeof style[ key ] === "string" ) { |
| 89 |
styles[ camelCase( key ) ] = style[ key ]; |
| 90 |
} |
| 91 |
} |
| 92 |
|
| 93 |
return styles; |
| 94 |
} |
| 95 |
|
| 96 |
function styleDifference( oldStyle, newStyle ) { |
| 97 |
var diff = {}, |
| 98 |
name, value; |
| 99 |
|
| 100 |
for ( name in newStyle ) { |
| 101 |
value = newStyle[ name ]; |
| 102 |
if ( oldStyle[ name ] !== value ) { |
| 103 |
if ( !shorthandStyles[ name ] ) { |
| 104 |
if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) { |
| 105 |
diff[ name ] = value; |
| 106 |
} |
| 107 |
} |
| 108 |
} |
| 109 |
} |
| 110 |
|
| 111 |
return diff; |
| 112 |
} |
| 113 |
|
| 114 |
$.effects.animateClass = function( value, duration, easing, callback ) { |
| 115 |
var o = $.speed( duration, easing, callback ); |
| 116 |
|
| 117 |
return this.queue( function() { |
| 118 |
var animated = $( this ), |
| 119 |
baseClass = animated.attr( "class" ) || "", |
| 120 |
applyClassChange, |
| 121 |
allAnimations = o.children ? animated.find( "*" ).addBack() : animated; |
| 122 |
|
| 123 |
|
| 124 |
allAnimations = allAnimations.map( function() { |
| 125 |
var el = $( this ); |
| 126 |
return { |
| 127 |
el: el, |
| 128 |
start: getElementStyles( this ) |
| 129 |
}; |
| 130 |
} ); |
| 131 |
|
| 132 |
|
| 133 |
applyClassChange = function() { |
| 134 |
$.each( classAnimationActions, function( i, action ) { |
| 135 |
if ( value[ action ] ) { |
| 136 |
animated[ action + "Class" ]( value[ action ] ); |
| 137 |
} |
| 138 |
} ); |
| 139 |
}; |
| 140 |
applyClassChange(); |
| 141 |
|
| 142 |
|
| 143 |
allAnimations = allAnimations.map( function() { |
| 144 |
this.end = getElementStyles( this.el[ 0 ] ); |
| 145 |
this.diff = styleDifference( this.start, this.end ); |
| 146 |
return this; |
| 147 |
} ); |
| 148 |
|
| 149 |
|
| 150 |
animated.attr( "class", baseClass ); |
| 151 |
|
| 152 |
|
| 153 |
allAnimations = allAnimations.map( function() { |
| 154 |
var styleInfo = this, |
| 155 |
dfd = $.Deferred(), |
| 156 |
opts = $.extend( {}, o, { |
| 157 |
queue: false, |
| 158 |
complete: function() { |
| 159 |
dfd.resolve( styleInfo ); |
| 160 |
} |
| 161 |
} ); |
| 162 |
|
| 163 |
this.el.animate( this.diff, opts ); |
| 164 |
return dfd.promise(); |
| 165 |
} ); |
| 166 |
|
| 167 |
|
| 168 |
$.when.apply( $, allAnimations.get() ).done( function() { |
| 169 |
|
| 170 |
|
| 171 |
applyClassChange(); |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
$.each( arguments, function() { |
| 176 |
var el = this.el; |
| 177 |
$.each( this.diff, function( key ) { |
| 178 |
el.css( key, "" ); |
| 179 |
} ); |
| 180 |
} ); |
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
o.complete.call( animated[ 0 ] ); |
| 185 |
} ); |
| 186 |
} ); |
| 187 |
}; |
| 188 |
|
| 189 |
$.fn.extend( { |
| 190 |
addClass: ( function( orig ) { |
| 191 |
return function( classNames, speed, easing, callback ) { |
| 192 |
return speed ? |
| 193 |
$.effects.animateClass.call( this, |
| 194 |
{ add: classNames }, speed, easing, callback ) : |
| 195 |
orig.apply( this, arguments ); |
| 196 |
}; |
| 197 |
} )( $.fn.addClass ), |
| 198 |
|
| 199 |
removeClass: ( function( orig ) { |
| 200 |
return function( classNames, speed, easing, callback ) { |
| 201 |
return arguments.length > 1 ? |
| 202 |
$.effects.animateClass.call( this, |
| 203 |
{ remove: classNames }, speed, easing, callback ) : |
| 204 |
orig.apply( this, arguments ); |
| 205 |
}; |
| 206 |
} )( $.fn.removeClass ), |
| 207 |
|
| 208 |
toggleClass: ( function( orig ) { |
| 209 |
return function( classNames, force, speed, easing, callback ) { |
| 210 |
if ( typeof force === "boolean" || force === undefined ) { |
| 211 |
if ( !speed ) { |
| 212 |
|
| 213 |
|
| 214 |
return orig.apply( this, arguments ); |
| 215 |
} else { |
| 216 |
return $.effects.animateClass.call( this, |
| 217 |
( force ? { add: classNames } : { remove: classNames } ), |
| 218 |
speed, easing, callback ); |
| 219 |
} |
| 220 |
} else { |
| 221 |
|
| 222 |
|
| 223 |
return $.effects.animateClass.call( this, |
| 224 |
{ toggle: classNames }, force, speed, easing ); |
| 225 |
} |
| 226 |
}; |
| 227 |
} )( $.fn.toggleClass ), |
| 228 |
|
| 229 |
switchClass: function( remove, add, speed, easing, callback ) { |
| 230 |
return $.effects.animateClass.call( this, { |
| 231 |
add: add, |
| 232 |
remove: remove |
| 233 |
}, speed, easing, callback ); |
| 234 |
} |
| 235 |
} ); |
| 236 |
|
| 237 |
} )(); |
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
( function() { |
| 244 |
|
| 245 |
if ( $.expr && $.expr.pseudos && $.expr.pseudos.animated ) { |
| 246 |
$.expr.pseudos.animated = ( function( orig ) { |
| 247 |
return function( elem ) { |
| 248 |
return !!$( elem ).data( dataSpaceAnimated ) || orig( elem ); |
| 249 |
}; |
| 250 |
} )( $.expr.pseudos.animated ); |
| 251 |
} |
| 252 |
|
| 253 |
if ( $.uiBackCompat === true ) { |
| 254 |
$.extend( $.effects, { |
| 255 |
|
| 256 |
|
| 257 |
save: function( element, set ) { |
| 258 |
var i = 0, length = set.length; |
| 259 |
for ( ; i < length; i++ ) { |
| 260 |
if ( set[ i ] !== null ) { |
| 261 |
element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] ); |
| 262 |
} |
| 263 |
} |
| 264 |
}, |
| 265 |
|
| 266 |
|
| 267 |
restore: function( element, set ) { |
| 268 |
var val, i = 0, length = set.length; |
| 269 |
for ( ; i < length; i++ ) { |
| 270 |
if ( set[ i ] !== null ) { |
| 271 |
val = element.data( dataSpace + set[ i ] ); |
| 272 |
element.css( set[ i ], val ); |
| 273 |
} |
| 274 |
} |
| 275 |
}, |
| 276 |
|
| 277 |
setMode: function( el, mode ) { |
| 278 |
if ( mode === "toggle" ) { |
| 279 |
mode = el.is( ":hidden" ) ? "show" : "hide"; |
| 280 |
} |
| 281 |
return mode; |
| 282 |
}, |
| 283 |
|
| 284 |
|
| 285 |
createWrapper: function( element ) { |
| 286 |
|
| 287 |
|
| 288 |
if ( element.parent().is( ".ui-effects-wrapper" ) ) { |
| 289 |
return element.parent(); |
| 290 |
} |
| 291 |
|
| 292 |
|
| 293 |
var props = { |
| 294 |
width: element.outerWidth( true ), |
| 295 |
height: element.outerHeight( true ), |
| 296 |
"float": element.css( "float" ) |
| 297 |
}, |
| 298 |
wrapper = $( "<div></div>" ) |
| 299 |
.addClass( "ui-effects-wrapper" ) |
| 300 |
.css( { |
| 301 |
fontSize: "100%", |
| 302 |
background: "transparent", |
| 303 |
border: "none", |
| 304 |
margin: 0, |
| 305 |
padding: 0 |
| 306 |
} ), |
| 307 |
|
| 308 |
|
| 309 |
size = { |
| 310 |
width: element.width(), |
| 311 |
height: element.height() |
| 312 |
}, |
| 313 |
active = document.activeElement; |
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
try { |
| 319 |
|
| 320 |
active.id; |
| 321 |
} catch ( _e ) { |
| 322 |
active = document.body; |
| 323 |
} |
| 324 |
|
| 325 |
element.wrap( wrapper ); |
| 326 |
|
| 327 |
|
| 328 |
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { |
| 329 |
$( active ).trigger( "focus" ); |
| 330 |
} |
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
wrapper = element.parent(); |
| 335 |
|
| 336 |
|
| 337 |
if ( element.css( "position" ) === "static" ) { |
| 338 |
wrapper.css( { position: "relative" } ); |
| 339 |
element.css( { position: "relative" } ); |
| 340 |
} else { |
| 341 |
$.extend( props, { |
| 342 |
position: element.css( "position" ), |
| 343 |
zIndex: element.css( "z-index" ) |
| 344 |
} ); |
| 345 |
$.each( [ "top", "left", "bottom", "right" ], function( i, pos ) { |
| 346 |
props[ pos ] = element.css( pos ); |
| 347 |
if ( isNaN( parseInt( props[ pos ], 10 ) ) ) { |
| 348 |
props[ pos ] = "auto"; |
| 349 |
} |
| 350 |
} ); |
| 351 |
element.css( { |
| 352 |
position: "relative", |
| 353 |
top: 0, |
| 354 |
left: 0, |
| 355 |
right: "auto", |
| 356 |
bottom: "auto" |
| 357 |
} ); |
| 358 |
} |
| 359 |
element.css( size ); |
| 360 |
|
| 361 |
return wrapper.css( props ).show(); |
| 362 |
}, |
| 363 |
|
| 364 |
removeWrapper: function( element ) { |
| 365 |
var active = document.activeElement; |
| 366 |
|
| 367 |
if ( element.parent().is( ".ui-effects-wrapper" ) ) { |
| 368 |
element.parent().replaceWith( element ); |
| 369 |
|
| 370 |
|
| 371 |
if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) { |
| 372 |
$( active ).trigger( "focus" ); |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
return element; |
| 377 |
} |
| 378 |
} ); |
| 379 |
} |
| 380 |
|
| 381 |
$.extend( $.effects, { |
| 382 |
version: "1.14.2", |
| 383 |
|
| 384 |
define: function( name, mode, effect ) { |
| 385 |
if ( !effect ) { |
| 386 |
effect = mode; |
| 387 |
mode = "effect"; |
| 388 |
} |
| 389 |
|
| 390 |
$.effects.effect[ name ] = effect; |
| 391 |
$.effects.effect[ name ].mode = mode; |
| 392 |
|
| 393 |
return effect; |
| 394 |
}, |
| 395 |
|
| 396 |
scaledDimensions: function( element, percent, direction ) { |
| 397 |
if ( percent === 0 ) { |
| 398 |
return { |
| 399 |
height: 0, |
| 400 |
width: 0, |
| 401 |
outerHeight: 0, |
| 402 |
outerWidth: 0 |
| 403 |
}; |
| 404 |
} |
| 405 |
|
| 406 |
var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1, |
| 407 |
y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1; |
| 408 |
|
| 409 |
return { |
| 410 |
height: element.height() * y, |
| 411 |
width: element.width() * x, |
| 412 |
outerHeight: element.outerHeight() * y, |
| 413 |
outerWidth: element.outerWidth() * x |
| 414 |
}; |
| 415 |
|
| 416 |
}, |
| 417 |
|
| 418 |
clipToBox: function( animation ) { |
| 419 |
return { |
| 420 |
width: animation.clip.right - animation.clip.left, |
| 421 |
height: animation.clip.bottom - animation.clip.top, |
| 422 |
left: animation.clip.left, |
| 423 |
top: animation.clip.top |
| 424 |
}; |
| 425 |
}, |
| 426 |
|
| 427 |
|
| 428 |
unshift: function( element, queueLength, count ) { |
| 429 |
var queue = element.queue(); |
| 430 |
|
| 431 |
if ( queueLength > 1 ) { |
| 432 |
queue.splice.apply( queue, |
| 433 |
[ 1, 0 ].concat( queue.splice( queueLength, count ) ) ); |
| 434 |
} |
| 435 |
element.dequeue(); |
| 436 |
}, |
| 437 |
|
| 438 |
saveStyle: function( element ) { |
| 439 |
element.data( dataSpaceStyle, element[ 0 ].style.cssText ); |
| 440 |
}, |
| 441 |
|
| 442 |
restoreStyle: function( element ) { |
| 443 |
element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || ""; |
| 444 |
element.removeData( dataSpaceStyle ); |
| 445 |
}, |
| 446 |
|
| 447 |
mode: function( element, mode ) { |
| 448 |
var hidden = element.is( ":hidden" ); |
| 449 |
|
| 450 |
if ( mode === "toggle" ) { |
| 451 |
mode = hidden ? "show" : "hide"; |
| 452 |
} |
| 453 |
if ( hidden ? mode === "hide" : mode === "show" ) { |
| 454 |
mode = "none"; |
| 455 |
} |
| 456 |
return mode; |
| 457 |
}, |
| 458 |
|
| 459 |
|
| 460 |
getBaseline: function( origin, original ) { |
| 461 |
var y, x; |
| 462 |
|
| 463 |
switch ( origin[ 0 ] ) { |
| 464 |
case "top": |
| 465 |
y = 0; |
| 466 |
break; |
| 467 |
case "middle": |
| 468 |
y = 0.5; |
| 469 |
break; |
| 470 |
case "bottom": |
| 471 |
y = 1; |
| 472 |
break; |
| 473 |
default: |
| 474 |
y = origin[ 0 ] / original.height; |
| 475 |
} |
| 476 |
|
| 477 |
switch ( origin[ 1 ] ) { |
| 478 |
case "left": |
| 479 |
x = 0; |
| 480 |
break; |
| 481 |
case "center": |
| 482 |
x = 0.5; |
| 483 |
break; |
| 484 |
case "right": |
| 485 |
x = 1; |
| 486 |
break; |
| 487 |
default: |
| 488 |
x = origin[ 1 ] / original.width; |
| 489 |
} |
| 490 |
|
| 491 |
return { |
| 492 |
x: x, |
| 493 |
y: y |
| 494 |
}; |
| 495 |
}, |
| 496 |
|
| 497 |
|
| 498 |
createPlaceholder: function( element ) { |
| 499 |
var placeholder, |
| 500 |
cssPosition = element.css( "position" ), |
| 501 |
position = element.position(); |
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
element.css( { |
| 508 |
marginTop: element.css( "marginTop" ), |
| 509 |
marginBottom: element.css( "marginBottom" ), |
| 510 |
marginLeft: element.css( "marginLeft" ), |
| 511 |
marginRight: element.css( "marginRight" ) |
| 512 |
} ) |
| 513 |
.outerWidth( element.outerWidth() ) |
| 514 |
.outerHeight( element.outerHeight() ); |
| 515 |
|
| 516 |
if ( /^(static|relative)/.test( cssPosition ) ) { |
| 517 |
cssPosition = "absolute"; |
| 518 |
|
| 519 |
placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( { |
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
display: /^(inline|ruby)/.test( element.css( "display" ) ) ? |
| 524 |
"inline-block" : |
| 525 |
"block", |
| 526 |
visibility: "hidden", |
| 527 |
|
| 528 |
|
| 529 |
marginTop: element.css( "marginTop" ), |
| 530 |
marginBottom: element.css( "marginBottom" ), |
| 531 |
marginLeft: element.css( "marginLeft" ), |
| 532 |
marginRight: element.css( "marginRight" ), |
| 533 |
"float": element.css( "float" ) |
| 534 |
} ) |
| 535 |
.outerWidth( element.outerWidth() ) |
| 536 |
.outerHeight( element.outerHeight() ) |
| 537 |
.addClass( "ui-effects-placeholder" ); |
| 538 |
|
| 539 |
element.data( dataSpace + "placeholder", placeholder ); |
| 540 |
} |
| 541 |
|
| 542 |
element.css( { |
| 543 |
position: cssPosition, |
| 544 |
left: position.left, |
| 545 |
top: position.top |
| 546 |
} ); |
| 547 |
|
| 548 |
return placeholder; |
| 549 |
}, |
| 550 |
|
| 551 |
removePlaceholder: function( element ) { |
| 552 |
var dataKey = dataSpace + "placeholder", |
| 553 |
placeholder = element.data( dataKey ); |
| 554 |
|
| 555 |
if ( placeholder ) { |
| 556 |
placeholder.remove(); |
| 557 |
element.removeData( dataKey ); |
| 558 |
} |
| 559 |
}, |
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
cleanUp: function( element ) { |
| 564 |
$.effects.restoreStyle( element ); |
| 565 |
$.effects.removePlaceholder( element ); |
| 566 |
}, |
| 567 |
|
| 568 |
setTransition: function( element, list, factor, value ) { |
| 569 |
value = value || {}; |
| 570 |
$.each( list, function( i, x ) { |
| 571 |
var unit = element.cssUnit( x ); |
| 572 |
if ( unit[ 0 ] > 0 ) { |
| 573 |
value[ x ] = unit[ 0 ] * factor + unit[ 1 ]; |
| 574 |
} |
| 575 |
} ); |
| 576 |
return value; |
| 577 |
} |
| 578 |
} ); |
| 579 |
|
| 580 |
|
| 581 |
function _normalizeArguments( effect, options, speed, callback ) { |
| 582 |
|
| 583 |
|
| 584 |
if ( $.isPlainObject( effect ) ) { |
| 585 |
options = effect; |
| 586 |
effect = effect.effect; |
| 587 |
} |
| 588 |
|
| 589 |
|
| 590 |
effect = { effect: effect }; |
| 591 |
|
| 592 |
|
| 593 |
if ( options == null ) { |
| 594 |
options = {}; |
| 595 |
} |
| 596 |
|
| 597 |
|
| 598 |
if ( typeof options === "function" ) { |
| 599 |
callback = options; |
| 600 |
speed = null; |
| 601 |
options = {}; |
| 602 |
} |
| 603 |
|
| 604 |
|
| 605 |
if ( typeof options === "number" || $.fx.speeds[ options ] ) { |
| 606 |
callback = speed; |
| 607 |
speed = options; |
| 608 |
options = {}; |
| 609 |
} |
| 610 |
|
| 611 |
|
| 612 |
if ( typeof speed === "function" ) { |
| 613 |
callback = speed; |
| 614 |
speed = null; |
| 615 |
} |
| 616 |
|
| 617 |
|
| 618 |
if ( options ) { |
| 619 |
$.extend( effect, options ); |
| 620 |
} |
| 621 |
|
| 622 |
speed = speed || options.duration; |
| 623 |
effect.duration = $.fx.off ? 0 : |
| 624 |
typeof speed === "number" ? speed : |
| 625 |
speed in $.fx.speeds ? $.fx.speeds[ speed ] : |
| 626 |
$.fx.speeds._default; |
| 627 |
|
| 628 |
effect.complete = callback || options.complete; |
| 629 |
|
| 630 |
return effect; |
| 631 |
} |
| 632 |
|
| 633 |
function standardAnimationOption( option ) { |
| 634 |
|
| 635 |
|
| 636 |
if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) { |
| 637 |
return true; |
| 638 |
} |
| 639 |
|
| 640 |
|
| 641 |
if ( typeof option === "string" && !$.effects.effect[ option ] ) { |
| 642 |
return true; |
| 643 |
} |
| 644 |
|
| 645 |
|
| 646 |
if ( typeof option === "function" ) { |
| 647 |
return true; |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
if ( typeof option === "object" && !option.effect ) { |
| 652 |
return true; |
| 653 |
} |
| 654 |
|
| 655 |
|
| 656 |
return false; |
| 657 |
} |
| 658 |
|
| 659 |
$.fn.extend( { |
| 660 |
effect: function( ) { |
| 661 |
var args = _normalizeArguments.apply( this, arguments ), |
| 662 |
effectMethod = $.effects.effect[ args.effect ], |
| 663 |
defaultMode = effectMethod.mode, |
| 664 |
queue = args.queue, |
| 665 |
queueName = queue || "fx", |
| 666 |
complete = args.complete, |
| 667 |
mode = args.mode, |
| 668 |
modes = [], |
| 669 |
prefilter = function( next ) { |
| 670 |
var el = $( this ), |
| 671 |
normalizedMode = $.effects.mode( el, mode ) || defaultMode; |
| 672 |
|
| 673 |
|
| 674 |
el.data( dataSpaceAnimated, true ); |
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
modes.push( normalizedMode ); |
| 680 |
|
| 681 |
|
| 682 |
if ( defaultMode && ( normalizedMode === "show" || |
| 683 |
( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) { |
| 684 |
el.show(); |
| 685 |
} |
| 686 |
|
| 687 |
if ( !defaultMode || normalizedMode !== "none" ) { |
| 688 |
$.effects.saveStyle( el ); |
| 689 |
} |
| 690 |
|
| 691 |
if ( typeof next === "function" ) { |
| 692 |
next(); |
| 693 |
} |
| 694 |
}; |
| 695 |
|
| 696 |
if ( $.fx.off || !effectMethod ) { |
| 697 |
|
| 698 |
|
| 699 |
if ( mode ) { |
| 700 |
return this[ mode ]( args.duration, complete ); |
| 701 |
} else { |
| 702 |
return this.each( function() { |
| 703 |
if ( complete ) { |
| 704 |
complete.call( this ); |
| 705 |
} |
| 706 |
} ); |
| 707 |
} |
| 708 |
} |
| 709 |
|
| 710 |
function run( next ) { |
| 711 |
var elem = $( this ); |
| 712 |
|
| 713 |
function cleanup() { |
| 714 |
elem.removeData( dataSpaceAnimated ); |
| 715 |
|
| 716 |
$.effects.cleanUp( elem ); |
| 717 |
|
| 718 |
if ( args.mode === "hide" ) { |
| 719 |
elem.hide(); |
| 720 |
} |
| 721 |
|
| 722 |
done(); |
| 723 |
} |
| 724 |
|
| 725 |
function done() { |
| 726 |
if ( typeof complete === "function" ) { |
| 727 |
complete.call( elem[ 0 ] ); |
| 728 |
} |
| 729 |
|
| 730 |
if ( typeof next === "function" ) { |
| 731 |
next(); |
| 732 |
} |
| 733 |
} |
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
args.mode = modes.shift(); |
| 738 |
|
| 739 |
if ( $.uiBackCompat === true && !defaultMode ) { |
| 740 |
if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) { |
| 741 |
|
| 742 |
|
| 743 |
elem[ mode ](); |
| 744 |
done(); |
| 745 |
} else { |
| 746 |
effectMethod.call( elem[ 0 ], args, done ); |
| 747 |
} |
| 748 |
} else { |
| 749 |
if ( args.mode === "none" ) { |
| 750 |
|
| 751 |
|
| 752 |
elem[ mode ](); |
| 753 |
done(); |
| 754 |
} else { |
| 755 |
effectMethod.call( elem[ 0 ], args, cleanup ); |
| 756 |
} |
| 757 |
} |
| 758 |
} |
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
return queue === false ? |
| 764 |
this.each( prefilter ).each( run ) : |
| 765 |
this.queue( queueName, prefilter ).queue( queueName, run ); |
| 766 |
}, |
| 767 |
|
| 768 |
show: ( function( orig ) { |
| 769 |
return function( option ) { |
| 770 |
if ( standardAnimationOption( option ) ) { |
| 771 |
return orig.apply( this, arguments ); |
| 772 |
} else { |
| 773 |
var args = _normalizeArguments.apply( this, arguments ); |
| 774 |
args.mode = "show"; |
| 775 |
return this.effect.call( this, args ); |
| 776 |
} |
| 777 |
}; |
| 778 |
} )( $.fn.show ), |
| 779 |
|
| 780 |
hide: ( function( orig ) { |
| 781 |
return function( option ) { |
| 782 |
if ( standardAnimationOption( option ) ) { |
| 783 |
return orig.apply( this, arguments ); |
| 784 |
} else { |
| 785 |
var args = _normalizeArguments.apply( this, arguments ); |
| 786 |
args.mode = "hide"; |
| 787 |
return this.effect.call( this, args ); |
| 788 |
} |
| 789 |
}; |
| 790 |
} )( $.fn.hide ), |
| 791 |
|
| 792 |
toggle: ( function( orig ) { |
| 793 |
return function( option ) { |
| 794 |
if ( standardAnimationOption( option ) || typeof option === "boolean" ) { |
| 795 |
return orig.apply( this, arguments ); |
| 796 |
} else { |
| 797 |
var args = _normalizeArguments.apply( this, arguments ); |
| 798 |
args.mode = "toggle"; |
| 799 |
return this.effect.call( this, args ); |
| 800 |
} |
| 801 |
}; |
| 802 |
} )( $.fn.toggle ), |
| 803 |
|
| 804 |
cssUnit: function( key ) { |
| 805 |
var style = this.css( key ), |
| 806 |
val = []; |
| 807 |
|
| 808 |
$.each( [ "em", "px", "%", "pt" ], function( i, unit ) { |
| 809 |
if ( style.indexOf( unit ) > 0 ) { |
| 810 |
val = [ parseFloat( style ), unit ]; |
| 811 |
} |
| 812 |
} ); |
| 813 |
return val; |
| 814 |
}, |
| 815 |
|
| 816 |
cssClip: function( clipObj ) { |
| 817 |
if ( clipObj ) { |
| 818 |
return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " + |
| 819 |
clipObj.bottom + "px " + clipObj.left + "px)" ); |
| 820 |
} |
| 821 |
return parseClip( this.css( "clip" ), this ); |
| 822 |
}, |
| 823 |
|
| 824 |
transfer: function( options, done ) { |
| 825 |
var element = $( this ), |
| 826 |
target = $( options.to ), |
| 827 |
targetFixed = target.css( "position" ) === "fixed", |
| 828 |
body = $( "body" ), |
| 829 |
fixTop = targetFixed ? body.scrollTop() : 0, |
| 830 |
fixLeft = targetFixed ? body.scrollLeft() : 0, |
| 831 |
endPosition = target.offset(), |
| 832 |
animation = { |
| 833 |
top: endPosition.top - fixTop, |
| 834 |
left: endPosition.left - fixLeft, |
| 835 |
height: target.innerHeight(), |
| 836 |
width: target.innerWidth() |
| 837 |
}, |
| 838 |
startPosition = element.offset(), |
| 839 |
transfer = $( "<div class='ui-effects-transfer'></div>" ); |
| 840 |
|
| 841 |
transfer |
| 842 |
.appendTo( "body" ) |
| 843 |
.addClass( options.className ) |
| 844 |
.css( { |
| 845 |
top: startPosition.top - fixTop, |
| 846 |
left: startPosition.left - fixLeft, |
| 847 |
height: element.innerHeight(), |
| 848 |
width: element.innerWidth(), |
| 849 |
position: targetFixed ? "fixed" : "absolute" |
| 850 |
} ) |
| 851 |
.animate( animation, options.duration, options.easing, function() { |
| 852 |
transfer.remove(); |
| 853 |
if ( typeof done === "function" ) { |
| 854 |
done(); |
| 855 |
} |
| 856 |
} ); |
| 857 |
} |
| 858 |
} ); |
| 859 |
|
| 860 |
function parseClip( str, element ) { |
| 861 |
var outerWidth = element.outerWidth(), |
| 862 |
outerHeight = element.outerHeight(), |
| 863 |
clipRegex = /^rect\((-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto),?\s*(-?\d*\.?\d*px|-?\d+%|auto)\)$/, |
| 864 |
values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ]; |
| 865 |
|
| 866 |
return { |
| 867 |
top: parseFloat( values[ 1 ] ) || 0, |
| 868 |
right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ), |
| 869 |
bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ), |
| 870 |
left: parseFloat( values[ 4 ] ) || 0 |
| 871 |
}; |
| 872 |
} |
| 873 |
|
| 874 |
$.fx.step.clip = function( fx ) { |
| 875 |
if ( !fx.clipInit ) { |
| 876 |
fx.start = $( fx.elem ).cssClip(); |
| 877 |
if ( typeof fx.end === "string" ) { |
| 878 |
fx.end = parseClip( fx.end, fx.elem ); |
| 879 |
} |
| 880 |
fx.clipInit = true; |
| 881 |
} |
| 882 |
|
| 883 |
$( fx.elem ).cssClip( { |
| 884 |
top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top, |
| 885 |
right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right, |
| 886 |
bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom, |
| 887 |
left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left |
| 888 |
} ); |
| 889 |
}; |
| 890 |
|
| 891 |
} )(); |
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
( function() { |
| 898 |
|
| 899 |
|
| 900 |
|
| 901 |
var baseEasings = {}; |
| 902 |
|
| 903 |
$.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) { |
| 904 |
baseEasings[ name ] = function( p ) { |
| 905 |
return Math.pow( p, i + 2 ); |
| 906 |
}; |
| 907 |
} ); |
| 908 |
|
| 909 |
$.extend( baseEasings, { |
| 910 |
Sine: function( p ) { |
| 911 |
return 1 - Math.cos( p * Math.PI / 2 ); |
| 912 |
}, |
| 913 |
Circ: function( p ) { |
| 914 |
return 1 - Math.sqrt( 1 - p * p ); |
| 915 |
}, |
| 916 |
Elastic: function( p ) { |
| 917 |
return p === 0 || p === 1 ? p : |
| 918 |
-Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 ); |
| 919 |
}, |
| 920 |
Back: function( p ) { |
| 921 |
return p * p * ( 3 * p - 2 ); |
| 922 |
}, |
| 923 |
Bounce: function( p ) { |
| 924 |
var pow2, |
| 925 |
bounce = 4; |
| 926 |
|
| 927 |
while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {} |
| 928 |
return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 ); |
| 929 |
} |
| 930 |
} ); |
| 931 |
|
| 932 |
$.each( baseEasings, function( name, easeIn ) { |
| 933 |
$.easing[ "easeIn" + name ] = easeIn; |
| 934 |
$.easing[ "easeOut" + name ] = function( p ) { |
| 935 |
return 1 - easeIn( 1 - p ); |
| 936 |
}; |
| 937 |
$.easing[ "easeInOut" + name ] = function( p ) { |
| 938 |
return p < 0.5 ? |
| 939 |
easeIn( p * 2 ) / 2 : |
| 940 |
1 - easeIn( p * -2 + 2 ) / 2; |
| 941 |
}; |
| 942 |
} ); |
| 943 |
|
| 944 |
} )(); |
| 945 |
|
| 946 |
return $.effects; |
| 947 |
|
| 948 |
} ); |