Sin descripción

effect.js 40KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640
  1. /*!
  2. * jQuery UI Effects 1.12.1
  3. * http://jqueryui.com
  4. *
  5. * Copyright jQuery Foundation and other contributors
  6. * Released under the MIT license.
  7. * http://jquery.org/license
  8. */
  9. //>>label: Effects Core
  10. //>>group: Effects
  11. // jscs:disable maximumLineLength
  12. //>>description: Extends the internal jQuery effects. Includes morphing and easing. Required by all other effects.
  13. // jscs:enable maximumLineLength
  14. //>>docs: http://api.jqueryui.com/category/effects-core/
  15. //>>demos: http://jqueryui.com/effect/
  16. ( function( factory ) {
  17. if ( typeof define === "function" && define.amd ) {
  18. // AMD. Register as an anonymous module.
  19. define( [ "jquery" ], factory );
  20. } else {
  21. // Browser globals
  22. factory( jQuery );
  23. }
  24. }( function( $ ) {
  25. // Include version.js
  26. $.ui = $.ui || {};
  27. $.ui.version = "1.12.1";
  28. var dataSpace = "ui-effects-",
  29. dataSpaceStyle = "ui-effects-style",
  30. dataSpaceAnimated = "ui-effects-animated",
  31. // Create a local jQuery because jQuery Color relies on it and the
  32. // global may not exist with AMD and a custom build (#10199)
  33. jQuery = $;
  34. $.effects = {
  35. effect: {}
  36. };
  37. /*!
  38. * jQuery Color Animations v2.1.2
  39. * https://github.com/jquery/jquery-color
  40. *
  41. * Copyright 2014 jQuery Foundation and other contributors
  42. * Released under the MIT license.
  43. * http://jquery.org/license
  44. *
  45. * Date: Wed Jan 16 08:47:09 2013 -0600
  46. */
  47. ( function( jQuery, undefined ) {
  48. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor " +
  49. "borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  50. // Plusequals test for += 100 -= 100
  51. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  52. // A set of RE's that can match strings and generate color tuples.
  53. stringParsers = [ {
  54. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  55. parse: function( execResult ) {
  56. return [
  57. execResult[ 1 ],
  58. execResult[ 2 ],
  59. execResult[ 3 ],
  60. execResult[ 4 ]
  61. ];
  62. }
  63. }, {
  64. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  65. parse: function( execResult ) {
  66. return [
  67. execResult[ 1 ] * 2.55,
  68. execResult[ 2 ] * 2.55,
  69. execResult[ 3 ] * 2.55,
  70. execResult[ 4 ]
  71. ];
  72. }
  73. }, {
  74. // This regex ignores A-F because it's compared against an already lowercased string
  75. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  76. parse: function( execResult ) {
  77. return [
  78. parseInt( execResult[ 1 ], 16 ),
  79. parseInt( execResult[ 2 ], 16 ),
  80. parseInt( execResult[ 3 ], 16 )
  81. ];
  82. }
  83. }, {
  84. // This regex ignores A-F because it's compared against an already lowercased string
  85. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  86. parse: function( execResult ) {
  87. return [
  88. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  89. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  90. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  91. ];
  92. }
  93. }, {
  94. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  95. space: "hsla",
  96. parse: function( execResult ) {
  97. return [
  98. execResult[ 1 ],
  99. execResult[ 2 ] / 100,
  100. execResult[ 3 ] / 100,
  101. execResult[ 4 ]
  102. ];
  103. }
  104. } ],
  105. // JQuery.Color( )
  106. color = jQuery.Color = function( color, green, blue, alpha ) {
  107. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  108. },
  109. spaces = {
  110. rgba: {
  111. props: {
  112. red: {
  113. idx: 0,
  114. type: "byte"
  115. },
  116. green: {
  117. idx: 1,
  118. type: "byte"
  119. },
  120. blue: {
  121. idx: 2,
  122. type: "byte"
  123. }
  124. }
  125. },
  126. hsla: {
  127. props: {
  128. hue: {
  129. idx: 0,
  130. type: "degrees"
  131. },
  132. saturation: {
  133. idx: 1,
  134. type: "percent"
  135. },
  136. lightness: {
  137. idx: 2,
  138. type: "percent"
  139. }
  140. }
  141. }
  142. },
  143. propTypes = {
  144. "byte": {
  145. floor: true,
  146. max: 255
  147. },
  148. "percent": {
  149. max: 1
  150. },
  151. "degrees": {
  152. mod: 360,
  153. floor: true
  154. }
  155. },
  156. support = color.support = {},
  157. // Element for support tests
  158. supportElem = jQuery( "<p>" )[ 0 ],
  159. // Colors = jQuery.Color.names
  160. colors,
  161. // Local aliases of functions called often
  162. each = jQuery.each;
  163. // Determine rgba support immediately
  164. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  165. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  166. // Define cache name and alpha properties
  167. // for rgba and hsla spaces
  168. each( spaces, function( spaceName, space ) {
  169. space.cache = "_" + spaceName;
  170. space.props.alpha = {
  171. idx: 3,
  172. type: "percent",
  173. def: 1
  174. };
  175. } );
  176. function clamp( value, prop, allowEmpty ) {
  177. var type = propTypes[ prop.type ] || {};
  178. if ( value == null ) {
  179. return ( allowEmpty || !prop.def ) ? null : prop.def;
  180. }
  181. // ~~ is an short way of doing floor for positive numbers
  182. value = type.floor ? ~~value : parseFloat( value );
  183. // IE will pass in empty strings as value for alpha,
  184. // which will hit this case
  185. if ( isNaN( value ) ) {
  186. return prop.def;
  187. }
  188. if ( type.mod ) {
  189. // We add mod before modding to make sure that negatives values
  190. // get converted properly: -10 -> 350
  191. return ( value + type.mod ) % type.mod;
  192. }
  193. // For now all property types without mod have min and max
  194. return 0 > value ? 0 : type.max < value ? type.max : value;
  195. }
  196. function stringParse( string ) {
  197. var inst = color(),
  198. rgba = inst._rgba = [];
  199. string = string.toLowerCase();
  200. each( stringParsers, function( i, parser ) {
  201. var parsed,
  202. match = parser.re.exec( string ),
  203. values = match && parser.parse( match ),
  204. spaceName = parser.space || "rgba";
  205. if ( values ) {
  206. parsed = inst[ spaceName ]( values );
  207. // If this was an rgba parse the assignment might happen twice
  208. // oh well....
  209. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  210. rgba = inst._rgba = parsed._rgba;
  211. // Exit each( stringParsers ) here because we matched
  212. return false;
  213. }
  214. } );
  215. // Found a stringParser that handled it
  216. if ( rgba.length ) {
  217. // If this came from a parsed string, force "transparent" when alpha is 0
  218. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  219. if ( rgba.join() === "0,0,0,0" ) {
  220. jQuery.extend( rgba, colors.transparent );
  221. }
  222. return inst;
  223. }
  224. // Named colors
  225. return colors[ string ];
  226. }
  227. color.fn = jQuery.extend( color.prototype, {
  228. parse: function( red, green, blue, alpha ) {
  229. if ( red === undefined ) {
  230. this._rgba = [ null, null, null, null ];
  231. return this;
  232. }
  233. if ( red.jquery || red.nodeType ) {
  234. red = jQuery( red ).css( green );
  235. green = undefined;
  236. }
  237. var inst = this,
  238. type = jQuery.type( red ),
  239. rgba = this._rgba = [];
  240. // More than 1 argument specified - assume ( red, green, blue, alpha )
  241. if ( green !== undefined ) {
  242. red = [ red, green, blue, alpha ];
  243. type = "array";
  244. }
  245. if ( type === "string" ) {
  246. return this.parse( stringParse( red ) || colors._default );
  247. }
  248. if ( type === "array" ) {
  249. each( spaces.rgba.props, function( key, prop ) {
  250. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  251. } );
  252. return this;
  253. }
  254. if ( type === "object" ) {
  255. if ( red instanceof color ) {
  256. each( spaces, function( spaceName, space ) {
  257. if ( red[ space.cache ] ) {
  258. inst[ space.cache ] = red[ space.cache ].slice();
  259. }
  260. } );
  261. } else {
  262. each( spaces, function( spaceName, space ) {
  263. var cache = space.cache;
  264. each( space.props, function( key, prop ) {
  265. // If the cache doesn't exist, and we know how to convert
  266. if ( !inst[ cache ] && space.to ) {
  267. // If the value was null, we don't need to copy it
  268. // if the key was alpha, we don't need to copy it either
  269. if ( key === "alpha" || red[ key ] == null ) {
  270. return;
  271. }
  272. inst[ cache ] = space.to( inst._rgba );
  273. }
  274. // This is the only case where we allow nulls for ALL properties.
  275. // call clamp with alwaysAllowEmpty
  276. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  277. } );
  278. // Everything defined but alpha?
  279. if ( inst[ cache ] &&
  280. jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  281. // Use the default of 1
  282. inst[ cache ][ 3 ] = 1;
  283. if ( space.from ) {
  284. inst._rgba = space.from( inst[ cache ] );
  285. }
  286. }
  287. } );
  288. }
  289. return this;
  290. }
  291. },
  292. is: function( compare ) {
  293. var is = color( compare ),
  294. same = true,
  295. inst = this;
  296. each( spaces, function( _, space ) {
  297. var localCache,
  298. isCache = is[ space.cache ];
  299. if ( isCache ) {
  300. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  301. each( space.props, function( _, prop ) {
  302. if ( isCache[ prop.idx ] != null ) {
  303. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  304. return same;
  305. }
  306. } );
  307. }
  308. return same;
  309. } );
  310. return same;
  311. },
  312. _space: function() {
  313. var used = [],
  314. inst = this;
  315. each( spaces, function( spaceName, space ) {
  316. if ( inst[ space.cache ] ) {
  317. used.push( spaceName );
  318. }
  319. } );
  320. return used.pop();
  321. },
  322. transition: function( other, distance ) {
  323. var end = color( other ),
  324. spaceName = end._space(),
  325. space = spaces[ spaceName ],
  326. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  327. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  328. result = start.slice();
  329. end = end[ space.cache ];
  330. each( space.props, function( key, prop ) {
  331. var index = prop.idx,
  332. startValue = start[ index ],
  333. endValue = end[ index ],
  334. type = propTypes[ prop.type ] || {};
  335. // If null, don't override start value
  336. if ( endValue === null ) {
  337. return;
  338. }
  339. // If null - use end
  340. if ( startValue === null ) {
  341. result[ index ] = endValue;
  342. } else {
  343. if ( type.mod ) {
  344. if ( endValue - startValue > type.mod / 2 ) {
  345. startValue += type.mod;
  346. } else if ( startValue - endValue > type.mod / 2 ) {
  347. startValue -= type.mod;
  348. }
  349. }
  350. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  351. }
  352. } );
  353. return this[ spaceName ]( result );
  354. },
  355. blend: function( opaque ) {
  356. // If we are already opaque - return ourself
  357. if ( this._rgba[ 3 ] === 1 ) {
  358. return this;
  359. }
  360. var rgb = this._rgba.slice(),
  361. a = rgb.pop(),
  362. blend = color( opaque )._rgba;
  363. return color( jQuery.map( rgb, function( v, i ) {
  364. return ( 1 - a ) * blend[ i ] + a * v;
  365. } ) );
  366. },
  367. toRgbaString: function() {
  368. var prefix = "rgba(",
  369. rgba = jQuery.map( this._rgba, function( v, i ) {
  370. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  371. } );
  372. if ( rgba[ 3 ] === 1 ) {
  373. rgba.pop();
  374. prefix = "rgb(";
  375. }
  376. return prefix + rgba.join() + ")";
  377. },
  378. toHslaString: function() {
  379. var prefix = "hsla(",
  380. hsla = jQuery.map( this.hsla(), function( v, i ) {
  381. if ( v == null ) {
  382. v = i > 2 ? 1 : 0;
  383. }
  384. // Catch 1 and 2
  385. if ( i && i < 3 ) {
  386. v = Math.round( v * 100 ) + "%";
  387. }
  388. return v;
  389. } );
  390. if ( hsla[ 3 ] === 1 ) {
  391. hsla.pop();
  392. prefix = "hsl(";
  393. }
  394. return prefix + hsla.join() + ")";
  395. },
  396. toHexString: function( includeAlpha ) {
  397. var rgba = this._rgba.slice(),
  398. alpha = rgba.pop();
  399. if ( includeAlpha ) {
  400. rgba.push( ~~( alpha * 255 ) );
  401. }
  402. return "#" + jQuery.map( rgba, function( v ) {
  403. // Default to 0 when nulls exist
  404. v = ( v || 0 ).toString( 16 );
  405. return v.length === 1 ? "0" + v : v;
  406. } ).join( "" );
  407. },
  408. toString: function() {
  409. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  410. }
  411. } );
  412. color.fn.parse.prototype = color.fn;
  413. // Hsla conversions adapted from:
  414. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  415. function hue2rgb( p, q, h ) {
  416. h = ( h + 1 ) % 1;
  417. if ( h * 6 < 1 ) {
  418. return p + ( q - p ) * h * 6;
  419. }
  420. if ( h * 2 < 1 ) {
  421. return q;
  422. }
  423. if ( h * 3 < 2 ) {
  424. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  425. }
  426. return p;
  427. }
  428. spaces.hsla.to = function( rgba ) {
  429. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  430. return [ null, null, null, rgba[ 3 ] ];
  431. }
  432. var r = rgba[ 0 ] / 255,
  433. g = rgba[ 1 ] / 255,
  434. b = rgba[ 2 ] / 255,
  435. a = rgba[ 3 ],
  436. max = Math.max( r, g, b ),
  437. min = Math.min( r, g, b ),
  438. diff = max - min,
  439. add = max + min,
  440. l = add * 0.5,
  441. h, s;
  442. if ( min === max ) {
  443. h = 0;
  444. } else if ( r === max ) {
  445. h = ( 60 * ( g - b ) / diff ) + 360;
  446. } else if ( g === max ) {
  447. h = ( 60 * ( b - r ) / diff ) + 120;
  448. } else {
  449. h = ( 60 * ( r - g ) / diff ) + 240;
  450. }
  451. // Chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  452. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  453. if ( diff === 0 ) {
  454. s = 0;
  455. } else if ( l <= 0.5 ) {
  456. s = diff / add;
  457. } else {
  458. s = diff / ( 2 - add );
  459. }
  460. return [ Math.round( h ) % 360, s, l, a == null ? 1 : a ];
  461. };
  462. spaces.hsla.from = function( hsla ) {
  463. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  464. return [ null, null, null, hsla[ 3 ] ];
  465. }
  466. var h = hsla[ 0 ] / 360,
  467. s = hsla[ 1 ],
  468. l = hsla[ 2 ],
  469. a = hsla[ 3 ],
  470. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  471. p = 2 * l - q;
  472. return [
  473. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  474. Math.round( hue2rgb( p, q, h ) * 255 ),
  475. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  476. a
  477. ];
  478. };
  479. each( spaces, function( spaceName, space ) {
  480. var props = space.props,
  481. cache = space.cache,
  482. to = space.to,
  483. from = space.from;
  484. // Makes rgba() and hsla()
  485. color.fn[ spaceName ] = function( value ) {
  486. // Generate a cache for this space if it doesn't exist
  487. if ( to && !this[ cache ] ) {
  488. this[ cache ] = to( this._rgba );
  489. }
  490. if ( value === undefined ) {
  491. return this[ cache ].slice();
  492. }
  493. var ret,
  494. type = jQuery.type( value ),
  495. arr = ( type === "array" || type === "object" ) ? value : arguments,
  496. local = this[ cache ].slice();
  497. each( props, function( key, prop ) {
  498. var val = arr[ type === "object" ? key : prop.idx ];
  499. if ( val == null ) {
  500. val = local[ prop.idx ];
  501. }
  502. local[ prop.idx ] = clamp( val, prop );
  503. } );
  504. if ( from ) {
  505. ret = color( from( local ) );
  506. ret[ cache ] = local;
  507. return ret;
  508. } else {
  509. return color( local );
  510. }
  511. };
  512. // Makes red() green() blue() alpha() hue() saturation() lightness()
  513. each( props, function( key, prop ) {
  514. // Alpha is included in more than one space
  515. if ( color.fn[ key ] ) {
  516. return;
  517. }
  518. color.fn[ key ] = function( value ) {
  519. var vtype = jQuery.type( value ),
  520. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  521. local = this[ fn ](),
  522. cur = local[ prop.idx ],
  523. match;
  524. if ( vtype === "undefined" ) {
  525. return cur;
  526. }
  527. if ( vtype === "function" ) {
  528. value = value.call( this, cur );
  529. vtype = jQuery.type( value );
  530. }
  531. if ( value == null && prop.empty ) {
  532. return this;
  533. }
  534. if ( vtype === "string" ) {
  535. match = rplusequals.exec( value );
  536. if ( match ) {
  537. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  538. }
  539. }
  540. local[ prop.idx ] = value;
  541. return this[ fn ]( local );
  542. };
  543. } );
  544. } );
  545. // Add cssHook and .fx.step function for each named hook.
  546. // accept a space separated string of properties
  547. color.hook = function( hook ) {
  548. var hooks = hook.split( " " );
  549. each( hooks, function( i, hook ) {
  550. jQuery.cssHooks[ hook ] = {
  551. set: function( elem, value ) {
  552. var parsed, curElem,
  553. backgroundColor = "";
  554. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" ||
  555. ( parsed = stringParse( value ) ) ) ) {
  556. value = color( parsed || value );
  557. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  558. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  559. while (
  560. ( backgroundColor === "" || backgroundColor === "transparent" ) &&
  561. curElem && curElem.style
  562. ) {
  563. try {
  564. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  565. curElem = curElem.parentNode;
  566. } catch ( e ) {
  567. }
  568. }
  569. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  570. backgroundColor :
  571. "_default" );
  572. }
  573. value = value.toRgbaString();
  574. }
  575. try {
  576. elem.style[ hook ] = value;
  577. } catch ( e ) {
  578. // Wrapped to prevent IE from throwing errors on "invalid" values like
  579. // 'auto' or 'inherit'
  580. }
  581. }
  582. };
  583. jQuery.fx.step[ hook ] = function( fx ) {
  584. if ( !fx.colorInit ) {
  585. fx.start = color( fx.elem, hook );
  586. fx.end = color( fx.end );
  587. fx.colorInit = true;
  588. }
  589. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  590. };
  591. } );
  592. };
  593. color.hook( stepHooks );
  594. jQuery.cssHooks.borderColor = {
  595. expand: function( value ) {
  596. var expanded = {};
  597. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  598. expanded[ "border" + part + "Color" ] = value;
  599. } );
  600. return expanded;
  601. }
  602. };
  603. // Basic color names only.
  604. // Usage of any of the other color names requires adding yourself or including
  605. // jquery.color.svg-names.js.
  606. colors = jQuery.Color.names = {
  607. // 4.1. Basic color keywords
  608. aqua: "#00ffff",
  609. black: "#000000",
  610. blue: "#0000ff",
  611. fuchsia: "#ff00ff",
  612. gray: "#808080",
  613. green: "#008000",
  614. lime: "#00ff00",
  615. maroon: "#800000",
  616. navy: "#000080",
  617. olive: "#808000",
  618. purple: "#800080",
  619. red: "#ff0000",
  620. silver: "#c0c0c0",
  621. teal: "#008080",
  622. white: "#ffffff",
  623. yellow: "#ffff00",
  624. // 4.2.3. "transparent" color keyword
  625. transparent: [ null, null, null, 0 ],
  626. _default: "#ffffff"
  627. };
  628. } )( jQuery );
  629. /******************************************************************************/
  630. /****************************** CLASS ANIMATIONS ******************************/
  631. /******************************************************************************/
  632. ( function() {
  633. var classAnimationActions = [ "add", "remove", "toggle" ],
  634. shorthandStyles = {
  635. border: 1,
  636. borderBottom: 1,
  637. borderColor: 1,
  638. borderLeft: 1,
  639. borderRight: 1,
  640. borderTop: 1,
  641. borderWidth: 1,
  642. margin: 1,
  643. padding: 1
  644. };
  645. $.each(
  646. [ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ],
  647. function( _, prop ) {
  648. $.fx.step[ prop ] = function( fx ) {
  649. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  650. jQuery.style( fx.elem, prop, fx.end );
  651. fx.setAttr = true;
  652. }
  653. };
  654. }
  655. );
  656. function getElementStyles( elem ) {
  657. var key, len,
  658. style = elem.ownerDocument.defaultView ?
  659. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  660. elem.currentStyle,
  661. styles = {};
  662. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  663. len = style.length;
  664. while ( len-- ) {
  665. key = style[ len ];
  666. if ( typeof style[ key ] === "string" ) {
  667. styles[ $.camelCase( key ) ] = style[ key ];
  668. }
  669. }
  670. // Support: Opera, IE <9
  671. } else {
  672. for ( key in style ) {
  673. if ( typeof style[ key ] === "string" ) {
  674. styles[ key ] = style[ key ];
  675. }
  676. }
  677. }
  678. return styles;
  679. }
  680. function styleDifference( oldStyle, newStyle ) {
  681. var diff = {},
  682. name, value;
  683. for ( name in newStyle ) {
  684. value = newStyle[ name ];
  685. if ( oldStyle[ name ] !== value ) {
  686. if ( !shorthandStyles[ name ] ) {
  687. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  688. diff[ name ] = value;
  689. }
  690. }
  691. }
  692. }
  693. return diff;
  694. }
  695. // Support: jQuery <1.8
  696. if ( !$.fn.addBack ) {
  697. $.fn.addBack = function( selector ) {
  698. return this.add( selector == null ?
  699. this.prevObject : this.prevObject.filter( selector )
  700. );
  701. };
  702. }
  703. $.effects.animateClass = function( value, duration, easing, callback ) {
  704. var o = $.speed( duration, easing, callback );
  705. return this.queue( function() {
  706. var animated = $( this ),
  707. baseClass = animated.attr( "class" ) || "",
  708. applyClassChange,
  709. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  710. // Map the animated objects to store the original styles.
  711. allAnimations = allAnimations.map( function() {
  712. var el = $( this );
  713. return {
  714. el: el,
  715. start: getElementStyles( this )
  716. };
  717. } );
  718. // Apply class change
  719. applyClassChange = function() {
  720. $.each( classAnimationActions, function( i, action ) {
  721. if ( value[ action ] ) {
  722. animated[ action + "Class" ]( value[ action ] );
  723. }
  724. } );
  725. };
  726. applyClassChange();
  727. // Map all animated objects again - calculate new styles and diff
  728. allAnimations = allAnimations.map( function() {
  729. this.end = getElementStyles( this.el[ 0 ] );
  730. this.diff = styleDifference( this.start, this.end );
  731. return this;
  732. } );
  733. // Apply original class
  734. animated.attr( "class", baseClass );
  735. // Map all animated objects again - this time collecting a promise
  736. allAnimations = allAnimations.map( function() {
  737. var styleInfo = this,
  738. dfd = $.Deferred(),
  739. opts = $.extend( {}, o, {
  740. queue: false,
  741. complete: function() {
  742. dfd.resolve( styleInfo );
  743. }
  744. } );
  745. this.el.animate( this.diff, opts );
  746. return dfd.promise();
  747. } );
  748. // Once all animations have completed:
  749. $.when.apply( $, allAnimations.get() ).done( function() {
  750. // Set the final class
  751. applyClassChange();
  752. // For each animated element,
  753. // clear all css properties that were animated
  754. $.each( arguments, function() {
  755. var el = this.el;
  756. $.each( this.diff, function( key ) {
  757. el.css( key, "" );
  758. } );
  759. } );
  760. // This is guarnteed to be there if you use jQuery.speed()
  761. // it also handles dequeuing the next anim...
  762. o.complete.call( animated[ 0 ] );
  763. } );
  764. } );
  765. };
  766. $.fn.extend( {
  767. addClass: ( function( orig ) {
  768. return function( classNames, speed, easing, callback ) {
  769. return speed ?
  770. $.effects.animateClass.call( this,
  771. { add: classNames }, speed, easing, callback ) :
  772. orig.apply( this, arguments );
  773. };
  774. } )( $.fn.addClass ),
  775. removeClass: ( function( orig ) {
  776. return function( classNames, speed, easing, callback ) {
  777. return arguments.length > 1 ?
  778. $.effects.animateClass.call( this,
  779. { remove: classNames }, speed, easing, callback ) :
  780. orig.apply( this, arguments );
  781. };
  782. } )( $.fn.removeClass ),
  783. toggleClass: ( function( orig ) {
  784. return function( classNames, force, speed, easing, callback ) {
  785. if ( typeof force === "boolean" || force === undefined ) {
  786. if ( !speed ) {
  787. // Without speed parameter
  788. return orig.apply( this, arguments );
  789. } else {
  790. return $.effects.animateClass.call( this,
  791. ( force ? { add: classNames } : { remove: classNames } ),
  792. speed, easing, callback );
  793. }
  794. } else {
  795. // Without force parameter
  796. return $.effects.animateClass.call( this,
  797. { toggle: classNames }, force, speed, easing );
  798. }
  799. };
  800. } )( $.fn.toggleClass ),
  801. switchClass: function( remove, add, speed, easing, callback ) {
  802. return $.effects.animateClass.call( this, {
  803. add: add,
  804. remove: remove
  805. }, speed, easing, callback );
  806. }
  807. } );
  808. } )();
  809. /******************************************************************************/
  810. /*********************************** EFFECTS **********************************/
  811. /******************************************************************************/
  812. ( function() {
  813. if ( $.expr && $.expr.filters && $.expr.filters.animated ) {
  814. $.expr.filters.animated = ( function( orig ) {
  815. return function( elem ) {
  816. return !!$( elem ).data( dataSpaceAnimated ) || orig( elem );
  817. };
  818. } )( $.expr.filters.animated );
  819. }
  820. if ( $.uiBackCompat !== false ) {
  821. $.extend( $.effects, {
  822. // Saves a set of properties in a data storage
  823. save: function( element, set ) {
  824. var i = 0, length = set.length;
  825. for ( ; i < length; i++ ) {
  826. if ( set[ i ] !== null ) {
  827. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  828. }
  829. }
  830. },
  831. // Restores a set of previously saved properties from a data storage
  832. restore: function( element, set ) {
  833. var val, i = 0, length = set.length;
  834. for ( ; i < length; i++ ) {
  835. if ( set[ i ] !== null ) {
  836. val = element.data( dataSpace + set[ i ] );
  837. element.css( set[ i ], val );
  838. }
  839. }
  840. },
  841. setMode: function( el, mode ) {
  842. if ( mode === "toggle" ) {
  843. mode = el.is( ":hidden" ) ? "show" : "hide";
  844. }
  845. return mode;
  846. },
  847. // Wraps the element around a wrapper that copies position properties
  848. createWrapper: function( element ) {
  849. // If the element is already wrapped, return it
  850. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  851. return element.parent();
  852. }
  853. // Wrap the element
  854. var props = {
  855. width: element.outerWidth( true ),
  856. height: element.outerHeight( true ),
  857. "float": element.css( "float" )
  858. },
  859. wrapper = $( "<div></div>" )
  860. .addClass( "ui-effects-wrapper" )
  861. .css( {
  862. fontSize: "100%",
  863. background: "transparent",
  864. border: "none",
  865. margin: 0,
  866. padding: 0
  867. } ),
  868. // Store the size in case width/height are defined in % - Fixes #5245
  869. size = {
  870. width: element.width(),
  871. height: element.height()
  872. },
  873. active = document.activeElement;
  874. // Support: Firefox
  875. // Firefox incorrectly exposes anonymous content
  876. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  877. try {
  878. active.id;
  879. } catch ( e ) {
  880. active = document.body;
  881. }
  882. element.wrap( wrapper );
  883. // Fixes #7595 - Elements lose focus when wrapped.
  884. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  885. $( active ).trigger( "focus" );
  886. }
  887. // Hotfix for jQuery 1.4 since some change in wrap() seems to actually
  888. // lose the reference to the wrapped element
  889. wrapper = element.parent();
  890. // Transfer positioning properties to the wrapper
  891. if ( element.css( "position" ) === "static" ) {
  892. wrapper.css( { position: "relative" } );
  893. element.css( { position: "relative" } );
  894. } else {
  895. $.extend( props, {
  896. position: element.css( "position" ),
  897. zIndex: element.css( "z-index" )
  898. } );
  899. $.each( [ "top", "left", "bottom", "right" ], function( i, pos ) {
  900. props[ pos ] = element.css( pos );
  901. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  902. props[ pos ] = "auto";
  903. }
  904. } );
  905. element.css( {
  906. position: "relative",
  907. top: 0,
  908. left: 0,
  909. right: "auto",
  910. bottom: "auto"
  911. } );
  912. }
  913. element.css( size );
  914. return wrapper.css( props ).show();
  915. },
  916. removeWrapper: function( element ) {
  917. var active = document.activeElement;
  918. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  919. element.parent().replaceWith( element );
  920. // Fixes #7595 - Elements lose focus when wrapped.
  921. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  922. $( active ).trigger( "focus" );
  923. }
  924. }
  925. return element;
  926. }
  927. } );
  928. }
  929. $.extend( $.effects, {
  930. version: "1.12.1",
  931. define: function( name, mode, effect ) {
  932. if ( !effect ) {
  933. effect = mode;
  934. mode = "effect";
  935. }
  936. $.effects.effect[ name ] = effect;
  937. $.effects.effect[ name ].mode = mode;
  938. return effect;
  939. },
  940. scaledDimensions: function( element, percent, direction ) {
  941. if ( percent === 0 ) {
  942. return {
  943. height: 0,
  944. width: 0,
  945. outerHeight: 0,
  946. outerWidth: 0
  947. };
  948. }
  949. var x = direction !== "horizontal" ? ( ( percent || 100 ) / 100 ) : 1,
  950. y = direction !== "vertical" ? ( ( percent || 100 ) / 100 ) : 1;
  951. return {
  952. height: element.height() * y,
  953. width: element.width() * x,
  954. outerHeight: element.outerHeight() * y,
  955. outerWidth: element.outerWidth() * x
  956. };
  957. },
  958. clipToBox: function( animation ) {
  959. return {
  960. width: animation.clip.right - animation.clip.left,
  961. height: animation.clip.bottom - animation.clip.top,
  962. left: animation.clip.left,
  963. top: animation.clip.top
  964. };
  965. },
  966. // Injects recently queued functions to be first in line (after "inprogress")
  967. unshift: function( element, queueLength, count ) {
  968. var queue = element.queue();
  969. if ( queueLength > 1 ) {
  970. queue.splice.apply( queue,
  971. [ 1, 0 ].concat( queue.splice( queueLength, count ) ) );
  972. }
  973. element.dequeue();
  974. },
  975. saveStyle: function( element ) {
  976. element.data( dataSpaceStyle, element[ 0 ].style.cssText );
  977. },
  978. restoreStyle: function( element ) {
  979. element[ 0 ].style.cssText = element.data( dataSpaceStyle ) || "";
  980. element.removeData( dataSpaceStyle );
  981. },
  982. mode: function( element, mode ) {
  983. var hidden = element.is( ":hidden" );
  984. if ( mode === "toggle" ) {
  985. mode = hidden ? "show" : "hide";
  986. }
  987. if ( hidden ? mode === "hide" : mode === "show" ) {
  988. mode = "none";
  989. }
  990. return mode;
  991. },
  992. // Translates a [top,left] array into a baseline value
  993. getBaseline: function( origin, original ) {
  994. var y, x;
  995. switch ( origin[ 0 ] ) {
  996. case "top":
  997. y = 0;
  998. break;
  999. case "middle":
  1000. y = 0.5;
  1001. break;
  1002. case "bottom":
  1003. y = 1;
  1004. break;
  1005. default:
  1006. y = origin[ 0 ] / original.height;
  1007. }
  1008. switch ( origin[ 1 ] ) {
  1009. case "left":
  1010. x = 0;
  1011. break;
  1012. case "center":
  1013. x = 0.5;
  1014. break;
  1015. case "right":
  1016. x = 1;
  1017. break;
  1018. default:
  1019. x = origin[ 1 ] / original.width;
  1020. }
  1021. return {
  1022. x: x,
  1023. y: y
  1024. };
  1025. },
  1026. // Creates a placeholder element so that the original element can be made absolute
  1027. createPlaceholder: function( element ) {
  1028. var placeholder,
  1029. cssPosition = element.css( "position" ),
  1030. position = element.position();
  1031. // Lock in margins first to account for form elements, which
  1032. // will change margin if you explicitly set height
  1033. // see: http://jsfiddle.net/JZSMt/3/ https://bugs.webkit.org/show_bug.cgi?id=107380
  1034. // Support: Safari
  1035. element.css( {
  1036. marginTop: element.css( "marginTop" ),
  1037. marginBottom: element.css( "marginBottom" ),
  1038. marginLeft: element.css( "marginLeft" ),
  1039. marginRight: element.css( "marginRight" )
  1040. } )
  1041. .outerWidth( element.outerWidth() )
  1042. .outerHeight( element.outerHeight() );
  1043. if ( /^(static|relative)/.test( cssPosition ) ) {
  1044. cssPosition = "absolute";
  1045. placeholder = $( "<" + element[ 0 ].nodeName + ">" ).insertAfter( element ).css( {
  1046. // Convert inline to inline block to account for inline elements
  1047. // that turn to inline block based on content (like img)
  1048. display: /^(inline|ruby)/.test( element.css( "display" ) ) ?
  1049. "inline-block" :
  1050. "block",
  1051. visibility: "hidden",
  1052. // Margins need to be set to account for margin collapse
  1053. marginTop: element.css( "marginTop" ),
  1054. marginBottom: element.css( "marginBottom" ),
  1055. marginLeft: element.css( "marginLeft" ),
  1056. marginRight: element.css( "marginRight" ),
  1057. "float": element.css( "float" )
  1058. } )
  1059. .outerWidth( element.outerWidth() )
  1060. .outerHeight( element.outerHeight() )
  1061. .addClass( "ui-effects-placeholder" );
  1062. element.data( dataSpace + "placeholder", placeholder );
  1063. }
  1064. element.css( {
  1065. position: cssPosition,
  1066. left: position.left,
  1067. top: position.top
  1068. } );
  1069. return placeholder;
  1070. },
  1071. removePlaceholder: function( element ) {
  1072. var dataKey = dataSpace + "placeholder",
  1073. placeholder = element.data( dataKey );
  1074. if ( placeholder ) {
  1075. placeholder.remove();
  1076. element.removeData( dataKey );
  1077. }
  1078. },
  1079. // Removes a placeholder if it exists and restores
  1080. // properties that were modified during placeholder creation
  1081. cleanUp: function( element ) {
  1082. $.effects.restoreStyle( element );
  1083. $.effects.removePlaceholder( element );
  1084. },
  1085. setTransition: function( element, list, factor, value ) {
  1086. value = value || {};
  1087. $.each( list, function( i, x ) {
  1088. var unit = element.cssUnit( x );
  1089. if ( unit[ 0 ] > 0 ) {
  1090. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  1091. }
  1092. } );
  1093. return value;
  1094. }
  1095. } );
  1096. // Return an effect options object for the given parameters:
  1097. function _normalizeArguments( effect, options, speed, callback ) {
  1098. // Allow passing all options as the first parameter
  1099. if ( $.isPlainObject( effect ) ) {
  1100. options = effect;
  1101. effect = effect.effect;
  1102. }
  1103. // Convert to an object
  1104. effect = { effect: effect };
  1105. // Catch (effect, null, ...)
  1106. if ( options == null ) {
  1107. options = {};
  1108. }
  1109. // Catch (effect, callback)
  1110. if ( $.isFunction( options ) ) {
  1111. callback = options;
  1112. speed = null;
  1113. options = {};
  1114. }
  1115. // Catch (effect, speed, ?)
  1116. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  1117. callback = speed;
  1118. speed = options;
  1119. options = {};
  1120. }
  1121. // Catch (effect, options, callback)
  1122. if ( $.isFunction( speed ) ) {
  1123. callback = speed;
  1124. speed = null;
  1125. }
  1126. // Add options to effect
  1127. if ( options ) {
  1128. $.extend( effect, options );
  1129. }
  1130. speed = speed || options.duration;
  1131. effect.duration = $.fx.off ? 0 :
  1132. typeof speed === "number" ? speed :
  1133. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  1134. $.fx.speeds._default;
  1135. effect.complete = callback || options.complete;
  1136. return effect;
  1137. }
  1138. function standardAnimationOption( option ) {
  1139. // Valid standard speeds (nothing, number, named speed)
  1140. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  1141. return true;
  1142. }
  1143. // Invalid strings - treat as "normal" speed
  1144. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  1145. return true;
  1146. }
  1147. // Complete callback
  1148. if ( $.isFunction( option ) ) {
  1149. return true;
  1150. }
  1151. // Options hash (but not naming an effect)
  1152. if ( typeof option === "object" && !option.effect ) {
  1153. return true;
  1154. }
  1155. // Didn't match any standard API
  1156. return false;
  1157. }
  1158. $.fn.extend( {
  1159. effect: function( /* effect, options, speed, callback */ ) {
  1160. var args = _normalizeArguments.apply( this, arguments ),
  1161. effectMethod = $.effects.effect[ args.effect ],
  1162. defaultMode = effectMethod.mode,
  1163. queue = args.queue,
  1164. queueName = queue || "fx",
  1165. complete = args.complete,
  1166. mode = args.mode,
  1167. modes = [],
  1168. prefilter = function( next ) {
  1169. var el = $( this ),
  1170. normalizedMode = $.effects.mode( el, mode ) || defaultMode;
  1171. // Sentinel for duck-punching the :animated psuedo-selector
  1172. el.data( dataSpaceAnimated, true );
  1173. // Save effect mode for later use,
  1174. // we can't just call $.effects.mode again later,
  1175. // as the .show() below destroys the initial state
  1176. modes.push( normalizedMode );
  1177. // See $.uiBackCompat inside of run() for removal of defaultMode in 1.13
  1178. if ( defaultMode && ( normalizedMode === "show" ||
  1179. ( normalizedMode === defaultMode && normalizedMode === "hide" ) ) ) {
  1180. el.show();
  1181. }
  1182. if ( !defaultMode || normalizedMode !== "none" ) {
  1183. $.effects.saveStyle( el );
  1184. }
  1185. if ( $.isFunction( next ) ) {
  1186. next();
  1187. }
  1188. };
  1189. if ( $.fx.off || !effectMethod ) {
  1190. // Delegate to the original method (e.g., .show()) if possible
  1191. if ( mode ) {
  1192. return this[ mode ]( args.duration, complete );
  1193. } else {
  1194. return this.each( function() {
  1195. if ( complete ) {
  1196. complete.call( this );
  1197. }
  1198. } );
  1199. }
  1200. }
  1201. function run( next ) {
  1202. var elem = $( this );
  1203. function cleanup() {
  1204. elem.removeData( dataSpaceAnimated );
  1205. $.effects.cleanUp( elem );
  1206. if ( args.mode === "hide" ) {
  1207. elem.hide();
  1208. }
  1209. done();
  1210. }
  1211. function done() {
  1212. if ( $.isFunction( complete ) ) {
  1213. complete.call( elem[ 0 ] );
  1214. }
  1215. if ( $.isFunction( next ) ) {
  1216. next();
  1217. }
  1218. }
  1219. // Override mode option on a per element basis,
  1220. // as toggle can be either show or hide depending on element state
  1221. args.mode = modes.shift();
  1222. if ( $.uiBackCompat !== false && !defaultMode ) {
  1223. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  1224. // Call the core method to track "olddisplay" properly
  1225. elem[ mode ]();
  1226. done();
  1227. } else {
  1228. effectMethod.call( elem[ 0 ], args, done );
  1229. }
  1230. } else {
  1231. if ( args.mode === "none" ) {
  1232. // Call the core method to track "olddisplay" properly
  1233. elem[ mode ]();
  1234. done();
  1235. } else {
  1236. effectMethod.call( elem[ 0 ], args, cleanup );
  1237. }
  1238. }
  1239. }
  1240. // Run prefilter on all elements first to ensure that
  1241. // any showing or hiding happens before placeholder creation,
  1242. // which ensures that any layout changes are correctly captured.
  1243. return queue === false ?
  1244. this.each( prefilter ).each( run ) :
  1245. this.queue( queueName, prefilter ).queue( queueName, run );
  1246. },
  1247. show: ( function( orig ) {
  1248. return function( option ) {
  1249. if ( standardAnimationOption( option ) ) {
  1250. return orig.apply( this, arguments );
  1251. } else {
  1252. var args = _normalizeArguments.apply( this, arguments );
  1253. args.mode = "show";
  1254. return this.effect.call( this, args );
  1255. }
  1256. };
  1257. } )( $.fn.show ),
  1258. hide: ( function( orig ) {
  1259. return function( option ) {
  1260. if ( standardAnimationOption( option ) ) {
  1261. return orig.apply( this, arguments );
  1262. } else {
  1263. var args = _normalizeArguments.apply( this, arguments );
  1264. args.mode = "hide";
  1265. return this.effect.call( this, args );
  1266. }
  1267. };
  1268. } )( $.fn.hide ),
  1269. toggle: ( function( orig ) {
  1270. return function( option ) {
  1271. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  1272. return orig.apply( this, arguments );
  1273. } else {
  1274. var args = _normalizeArguments.apply( this, arguments );
  1275. args.mode = "toggle";
  1276. return this.effect.call( this, args );
  1277. }
  1278. };
  1279. } )( $.fn.toggle ),
  1280. cssUnit: function( key ) {
  1281. var style = this.css( key ),
  1282. val = [];
  1283. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  1284. if ( style.indexOf( unit ) > 0 ) {
  1285. val = [ parseFloat( style ), unit ];
  1286. }
  1287. } );
  1288. return val;
  1289. },
  1290. cssClip: function( clipObj ) {
  1291. if ( clipObj ) {
  1292. return this.css( "clip", "rect(" + clipObj.top + "px " + clipObj.right + "px " +
  1293. clipObj.bottom + "px " + clipObj.left + "px)" );
  1294. }
  1295. return parseClip( this.css( "clip" ), this );
  1296. },
  1297. transfer: function( options, done ) {
  1298. var element = $( this ),
  1299. target = $( options.to ),
  1300. targetFixed = target.css( "position" ) === "fixed",
  1301. body = $( "body" ),
  1302. fixTop = targetFixed ? body.scrollTop() : 0,
  1303. fixLeft = targetFixed ? body.scrollLeft() : 0,
  1304. endPosition = target.offset(),
  1305. animation = {
  1306. top: endPosition.top - fixTop,
  1307. left: endPosition.left - fixLeft,
  1308. height: target.innerHeight(),
  1309. width: target.innerWidth()
  1310. },
  1311. startPosition = element.offset(),
  1312. transfer = $( "<div class='ui-effects-transfer'></div>" )
  1313. .appendTo( "body" )
  1314. .addClass( options.className )
  1315. .css( {
  1316. top: startPosition.top - fixTop,
  1317. left: startPosition.left - fixLeft,
  1318. height: element.innerHeight(),
  1319. width: element.innerWidth(),
  1320. position: targetFixed ? "fixed" : "absolute"
  1321. } )
  1322. .animate( animation, options.duration, options.easing, function() {
  1323. transfer.remove();
  1324. if ( $.isFunction( done ) ) {
  1325. done();
  1326. }
  1327. } );
  1328. }
  1329. } );
  1330. function parseClip( str, element ) {
  1331. var outerWidth = element.outerWidth(),
  1332. outerHeight = element.outerHeight(),
  1333. 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)\)$/,
  1334. values = clipRegex.exec( str ) || [ "", 0, outerWidth, outerHeight, 0 ];
  1335. return {
  1336. top: parseFloat( values[ 1 ] ) || 0,
  1337. right: values[ 2 ] === "auto" ? outerWidth : parseFloat( values[ 2 ] ),
  1338. bottom: values[ 3 ] === "auto" ? outerHeight : parseFloat( values[ 3 ] ),
  1339. left: parseFloat( values[ 4 ] ) || 0
  1340. };
  1341. }
  1342. $.fx.step.clip = function( fx ) {
  1343. if ( !fx.clipInit ) {
  1344. fx.start = $( fx.elem ).cssClip();
  1345. if ( typeof fx.end === "string" ) {
  1346. fx.end = parseClip( fx.end, fx.elem );
  1347. }
  1348. fx.clipInit = true;
  1349. }
  1350. $( fx.elem ).cssClip( {
  1351. top: fx.pos * ( fx.end.top - fx.start.top ) + fx.start.top,
  1352. right: fx.pos * ( fx.end.right - fx.start.right ) + fx.start.right,
  1353. bottom: fx.pos * ( fx.end.bottom - fx.start.bottom ) + fx.start.bottom,
  1354. left: fx.pos * ( fx.end.left - fx.start.left ) + fx.start.left
  1355. } );
  1356. };
  1357. } )();
  1358. /******************************************************************************/
  1359. /*********************************** EASING ***********************************/
  1360. /******************************************************************************/
  1361. ( function() {
  1362. // Based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  1363. var baseEasings = {};
  1364. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  1365. baseEasings[ name ] = function( p ) {
  1366. return Math.pow( p, i + 2 );
  1367. };
  1368. } );
  1369. $.extend( baseEasings, {
  1370. Sine: function( p ) {
  1371. return 1 - Math.cos( p * Math.PI / 2 );
  1372. },
  1373. Circ: function( p ) {
  1374. return 1 - Math.sqrt( 1 - p * p );
  1375. },
  1376. Elastic: function( p ) {
  1377. return p === 0 || p === 1 ? p :
  1378. -Math.pow( 2, 8 * ( p - 1 ) ) * Math.sin( ( ( p - 1 ) * 80 - 7.5 ) * Math.PI / 15 );
  1379. },
  1380. Back: function( p ) {
  1381. return p * p * ( 3 * p - 2 );
  1382. },
  1383. Bounce: function( p ) {
  1384. var pow2,
  1385. bounce = 4;
  1386. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  1387. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  1388. }
  1389. } );
  1390. $.each( baseEasings, function( name, easeIn ) {
  1391. $.easing[ "easeIn" + name ] = easeIn;
  1392. $.easing[ "easeOut" + name ] = function( p ) {
  1393. return 1 - easeIn( 1 - p );
  1394. };
  1395. $.easing[ "easeInOut" + name ] = function( p ) {
  1396. return p < 0.5 ?
  1397. easeIn( p * 2 ) / 2 :
  1398. 1 - easeIn( p * -2 + 2 ) / 2;
  1399. };
  1400. } );
  1401. } )();
  1402. return $.effects;
  1403. } ) );