jquery.ui.custom-effects.js 54 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224
  1. /*! jQuery UI - v1.9.0 - 2012-10-22
  2. * http://jqueryui.com
  3. * Includes: jquery.ui.effect.js, jquery.ui.effect-blind.js, jquery.ui.effect-bounce.js, jquery.ui.effect-clip.js, jquery.ui.effect-drop.js, jquery.ui.effect-explode.js, jquery.ui.effect-fade.js, jquery.ui.effect-fold.js, jquery.ui.effect-highlight.js, jquery.ui.effect-pulsate.js, jquery.ui.effect-scale.js, jquery.ui.effect-shake.js, jquery.ui.effect-slide.js, jquery.ui.effect-transfer.js
  4. * Copyright (c) 2012 jQuery Foundation and other contributors Licensed MIT */
  5. ;(jQuery.effects || (function($, undefined) {
  6. var backCompat = $.uiBackCompat !== false,
  7. // prefix used for storing data on .data()
  8. dataSpace = "ui-effects-";
  9. $.effects = {
  10. effect: {}
  11. };
  12. /*!
  13. * jQuery Color Animations v2.0.0
  14. * http://jquery.com/
  15. *
  16. * Copyright 2012 jQuery Foundation and other contributors
  17. * Released under the MIT license.
  18. * http://jquery.org/license
  19. *
  20. * Date: Mon Aug 13 13:41:02 2012 -0500
  21. */
  22. (function( jQuery, undefined ) {
  23. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor".split(" "),
  24. // plusequals test for += 100 -= 100
  25. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  26. // a set of RE's that can match strings and generate color tuples.
  27. stringParsers = [{
  28. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  29. parse: function( execResult ) {
  30. return [
  31. execResult[ 1 ],
  32. execResult[ 2 ],
  33. execResult[ 3 ],
  34. execResult[ 4 ]
  35. ];
  36. }
  37. }, {
  38. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  39. parse: function( execResult ) {
  40. return [
  41. execResult[ 1 ] * 2.55,
  42. execResult[ 2 ] * 2.55,
  43. execResult[ 3 ] * 2.55,
  44. execResult[ 4 ]
  45. ];
  46. }
  47. }, {
  48. // this regex ignores A-F because it's compared against an already lowercased string
  49. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  50. parse: function( execResult ) {
  51. return [
  52. parseInt( execResult[ 1 ], 16 ),
  53. parseInt( execResult[ 2 ], 16 ),
  54. parseInt( execResult[ 3 ], 16 )
  55. ];
  56. }
  57. }, {
  58. // this regex ignores A-F because it's compared against an already lowercased string
  59. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  60. parse: function( execResult ) {
  61. return [
  62. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  63. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  64. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  65. ];
  66. }
  67. }, {
  68. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d+(?:\.\d+)?)\s*)?\)/,
  69. space: "hsla",
  70. parse: function( execResult ) {
  71. return [
  72. execResult[ 1 ],
  73. execResult[ 2 ] / 100,
  74. execResult[ 3 ] / 100,
  75. execResult[ 4 ]
  76. ];
  77. }
  78. }],
  79. // jQuery.Color( )
  80. color = jQuery.Color = function( color, green, blue, alpha ) {
  81. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  82. },
  83. spaces = {
  84. rgba: {
  85. props: {
  86. red: {
  87. idx: 0,
  88. type: "byte"
  89. },
  90. green: {
  91. idx: 1,
  92. type: "byte"
  93. },
  94. blue: {
  95. idx: 2,
  96. type: "byte"
  97. }
  98. }
  99. },
  100. hsla: {
  101. props: {
  102. hue: {
  103. idx: 0,
  104. type: "degrees"
  105. },
  106. saturation: {
  107. idx: 1,
  108. type: "percent"
  109. },
  110. lightness: {
  111. idx: 2,
  112. type: "percent"
  113. }
  114. }
  115. }
  116. },
  117. propTypes = {
  118. "byte": {
  119. floor: true,
  120. max: 255
  121. },
  122. "percent": {
  123. max: 1
  124. },
  125. "degrees": {
  126. mod: 360,
  127. floor: true
  128. }
  129. },
  130. support = color.support = {},
  131. // element for support tests
  132. supportElem = jQuery( "<p>" )[ 0 ],
  133. // colors = jQuery.Color.names
  134. colors,
  135. // local aliases of functions called often
  136. each = jQuery.each;
  137. // determine rgba support immediately
  138. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  139. support.rgba = (supportElem.style.backgroundColor || supportElem.style['background-color']).indexOf( "rgba" ) > -1;
  140. // define cache name and alpha properties
  141. // for rgba and hsla spaces
  142. each( spaces, function( spaceName, space ) {
  143. space.cache = "_" + spaceName;
  144. space.props.alpha = {
  145. idx: 3,
  146. type: "percent",
  147. def: 1
  148. };
  149. });
  150. function clamp( value, prop, allowEmpty ) {
  151. var type = propTypes[ prop.type ] || {};
  152. if ( value == null ) {
  153. return (allowEmpty || !prop.def) ? null : prop.def;
  154. }
  155. // ~~ is an short way of doing floor for positive numbers
  156. value = type.floor ? ~~value : parseFloat( value );
  157. // IE will pass in empty strings as value for alpha,
  158. // which will hit this case
  159. if ( isNaN( value ) ) {
  160. return prop.def;
  161. }
  162. if ( type.mod ) {
  163. // we add mod before modding to make sure that negatives values
  164. // get converted properly: -10 -> 350
  165. return (value + type.mod) % type.mod;
  166. }
  167. // for now all property types without mod have min and max
  168. return 0 > value ? 0 : type.max < value ? type.max : value;
  169. }
  170. function stringParse( string ) {
  171. var inst = color(),
  172. rgba = inst._rgba = [];
  173. string = string.toLowerCase();
  174. each( stringParsers, function( i, parser ) {
  175. var parsed,
  176. match = parser.re.exec( string ),
  177. values = match && parser.parse( match ),
  178. spaceName = parser.space || "rgba";
  179. if ( values ) {
  180. parsed = inst[ spaceName ]( values );
  181. // if this was an rgba parse the assignment might happen twice
  182. // oh well....
  183. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  184. rgba = inst._rgba = parsed._rgba;
  185. // exit each( stringParsers ) here because we matched
  186. return false;
  187. }
  188. });
  189. // Found a stringParser that handled it
  190. if ( rgba.length ) {
  191. // if this came from a parsed string, force "transparent" when alpha is 0
  192. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  193. if ( rgba.join() === "0,0,0,0" ) {
  194. jQuery.extend( rgba, colors.transparent );
  195. }
  196. return inst;
  197. }
  198. // named colors
  199. return colors[ string ];
  200. }
  201. color.fn = jQuery.extend( color.prototype, {
  202. parse: function( red, green, blue, alpha ) {
  203. if ( red === undefined ) {
  204. this._rgba = [ null, null, null, null ];
  205. return this;
  206. }
  207. if ( red.jquery || red.nodeType ) {
  208. red = jQuery( red ).css( green );
  209. green = undefined;
  210. }
  211. var inst = this,
  212. type = jQuery.type( red ),
  213. rgba = this._rgba = [],
  214. source;
  215. // more than 1 argument specified - assume ( red, green, blue, alpha )
  216. if ( green !== undefined ) {
  217. red = [ red, green, blue, alpha ];
  218. type = "array";
  219. }
  220. if ( type === "string" ) {
  221. return this.parse( stringParse( red ) || colors._default );
  222. }
  223. if ( type === "array" ) {
  224. each( spaces.rgba.props, function( key, prop ) {
  225. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  226. });
  227. return this;
  228. }
  229. if ( type === "object" ) {
  230. if ( red instanceof color ) {
  231. each( spaces, function( spaceName, space ) {
  232. if ( red[ space.cache ] ) {
  233. inst[ space.cache ] = red[ space.cache ].slice();
  234. }
  235. });
  236. } else {
  237. each( spaces, function( spaceName, space ) {
  238. var cache = space.cache;
  239. each( space.props, function( key, prop ) {
  240. // if the cache doesn't exist, and we know how to convert
  241. if ( !inst[ cache ] && space.to ) {
  242. // if the value was null, we don't need to copy it
  243. // if the key was alpha, we don't need to copy it either
  244. if ( key === "alpha" || red[ key ] == null ) {
  245. return;
  246. }
  247. inst[ cache ] = space.to( inst._rgba );
  248. }
  249. // this is the only case where we allow nulls for ALL properties.
  250. // call clamp with alwaysAllowEmpty
  251. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  252. });
  253. // everything defined but alpha?
  254. if ( inst[ cache ] && $.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  255. // use the default of 1
  256. inst[ cache ][ 3 ] = 1;
  257. if ( space.from ) {
  258. inst._rgba = space.from( inst[ cache ] );
  259. }
  260. }
  261. });
  262. }
  263. return this;
  264. }
  265. },
  266. is: function( compare ) {
  267. var is = color( compare ),
  268. same = true,
  269. inst = this;
  270. each( spaces, function( _, space ) {
  271. var localCache,
  272. isCache = is[ space.cache ];
  273. if (isCache) {
  274. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  275. each( space.props, function( _, prop ) {
  276. if ( isCache[ prop.idx ] != null ) {
  277. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  278. return same;
  279. }
  280. });
  281. }
  282. return same;
  283. });
  284. return same;
  285. },
  286. _space: function() {
  287. var used = [],
  288. inst = this;
  289. each( spaces, function( spaceName, space ) {
  290. if ( inst[ space.cache ] ) {
  291. used.push( spaceName );
  292. }
  293. });
  294. return used.pop();
  295. },
  296. transition: function( other, distance ) {
  297. var end = color( other ),
  298. spaceName = end._space(),
  299. space = spaces[ spaceName ],
  300. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  301. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  302. result = start.slice();
  303. end = end[ space.cache ];
  304. each( space.props, function( key, prop ) {
  305. var index = prop.idx,
  306. startValue = start[ index ],
  307. endValue = end[ index ],
  308. type = propTypes[ prop.type ] || {};
  309. // if null, don't override start value
  310. if ( endValue === null ) {
  311. return;
  312. }
  313. // if null - use end
  314. if ( startValue === null ) {
  315. result[ index ] = endValue;
  316. } else {
  317. if ( type.mod ) {
  318. if ( endValue - startValue > type.mod / 2 ) {
  319. startValue += type.mod;
  320. } else if ( startValue - endValue > type.mod / 2 ) {
  321. startValue -= type.mod;
  322. }
  323. }
  324. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  325. }
  326. });
  327. return this[ spaceName ]( result );
  328. },
  329. blend: function( opaque ) {
  330. // if we are already opaque - return ourself
  331. if ( this._rgba[ 3 ] === 1 ) {
  332. return this;
  333. }
  334. var rgb = this._rgba.slice(),
  335. a = rgb.pop(),
  336. blend = color( opaque )._rgba;
  337. return color( jQuery.map( rgb, function( v, i ) {
  338. return ( 1 - a ) * blend[ i ] + a * v;
  339. }));
  340. },
  341. toRgbaString: function() {
  342. var prefix = "rgba(",
  343. rgba = jQuery.map( this._rgba, function( v, i ) {
  344. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  345. });
  346. if ( rgba[ 3 ] === 1 ) {
  347. rgba.pop();
  348. prefix = "rgb(";
  349. }
  350. return prefix + rgba.join() + ")";
  351. },
  352. toHslaString: function() {
  353. var prefix = "hsla(",
  354. hsla = jQuery.map( this.hsla(), function( v, i ) {
  355. if ( v == null ) {
  356. v = i > 2 ? 1 : 0;
  357. }
  358. // catch 1 and 2
  359. if ( i && i < 3 ) {
  360. v = Math.round( v * 100 ) + "%";
  361. }
  362. return v;
  363. });
  364. if ( hsla[ 3 ] === 1 ) {
  365. hsla.pop();
  366. prefix = "hsl(";
  367. }
  368. return prefix + hsla.join() + ")";
  369. },
  370. toHexString: function( includeAlpha ) {
  371. var rgba = this._rgba.slice(),
  372. alpha = rgba.pop();
  373. if ( includeAlpha ) {
  374. rgba.push( ~~( alpha * 255 ) );
  375. }
  376. return "#" + jQuery.map( rgba, function( v, i ) {
  377. // default to 0 when nulls exist
  378. v = ( v || 0 ).toString( 16 );
  379. return v.length === 1 ? "0" + v : v;
  380. }).join("");
  381. },
  382. toString: function() {
  383. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  384. }
  385. });
  386. color.fn.parse.prototype = color.fn;
  387. // hsla conversions adapted from:
  388. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  389. function hue2rgb( p, q, h ) {
  390. h = ( h + 1 ) % 1;
  391. if ( h * 6 < 1 ) {
  392. return p + (q - p) * h * 6;
  393. }
  394. if ( h * 2 < 1) {
  395. return q;
  396. }
  397. if ( h * 3 < 2 ) {
  398. return p + (q - p) * ((2/3) - h) * 6;
  399. }
  400. return p;
  401. }
  402. spaces.hsla.to = function ( rgba ) {
  403. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  404. return [ null, null, null, rgba[ 3 ] ];
  405. }
  406. var r = rgba[ 0 ] / 255,
  407. g = rgba[ 1 ] / 255,
  408. b = rgba[ 2 ] / 255,
  409. a = rgba[ 3 ],
  410. max = Math.max( r, g, b ),
  411. min = Math.min( r, g, b ),
  412. diff = max - min,
  413. add = max + min,
  414. l = add * 0.5,
  415. h, s;
  416. if ( min === max ) {
  417. h = 0;
  418. } else if ( r === max ) {
  419. h = ( 60 * ( g - b ) / diff ) + 360;
  420. } else if ( g === max ) {
  421. h = ( 60 * ( b - r ) / diff ) + 120;
  422. } else {
  423. h = ( 60 * ( r - g ) / diff ) + 240;
  424. }
  425. if ( l === 0 || l === 1 ) {
  426. s = l;
  427. } else if ( l <= 0.5 ) {
  428. s = diff / add;
  429. } else {
  430. s = diff / ( 2 - add );
  431. }
  432. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  433. };
  434. spaces.hsla.from = function ( hsla ) {
  435. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  436. return [ null, null, null, hsla[ 3 ] ];
  437. }
  438. var h = hsla[ 0 ] / 360,
  439. s = hsla[ 1 ],
  440. l = hsla[ 2 ],
  441. a = hsla[ 3 ],
  442. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  443. p = 2 * l - q,
  444. r, g, b;
  445. return [
  446. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  447. Math.round( hue2rgb( p, q, h ) * 255 ),
  448. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  449. a
  450. ];
  451. };
  452. each( spaces, function( spaceName, space ) {
  453. var props = space.props,
  454. cache = space.cache,
  455. to = space.to,
  456. from = space.from;
  457. // makes rgba() and hsla()
  458. color.fn[ spaceName ] = function( value ) {
  459. // generate a cache for this space if it doesn't exist
  460. if ( to && !this[ cache ] ) {
  461. this[ cache ] = to( this._rgba );
  462. }
  463. if ( value === undefined ) {
  464. return this[ cache ].slice();
  465. }
  466. var ret,
  467. type = jQuery.type( value ),
  468. arr = ( type === "array" || type === "object" ) ? value : arguments,
  469. local = this[ cache ].slice();
  470. each( props, function( key, prop ) {
  471. var val = arr[ type === "object" ? key : prop.idx ];
  472. if ( val == null ) {
  473. val = local[ prop.idx ];
  474. }
  475. local[ prop.idx ] = clamp( val, prop );
  476. });
  477. if ( from ) {
  478. ret = color( from( local ) );
  479. ret[ cache ] = local;
  480. return ret;
  481. } else {
  482. return color( local );
  483. }
  484. };
  485. // makes red() green() blue() alpha() hue() saturation() lightness()
  486. each( props, function( key, prop ) {
  487. // alpha is included in more than one space
  488. if ( color.fn[ key ] ) {
  489. return;
  490. }
  491. color.fn[ key ] = function( value ) {
  492. var vtype = jQuery.type( value ),
  493. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  494. local = this[ fn ](),
  495. cur = local[ prop.idx ],
  496. match;
  497. if ( vtype === "undefined" ) {
  498. return cur;
  499. }
  500. if ( vtype === "function" ) {
  501. value = value.call( this, cur );
  502. vtype = jQuery.type( value );
  503. }
  504. if ( value == null && prop.empty ) {
  505. return this;
  506. }
  507. if ( vtype === "string" ) {
  508. match = rplusequals.exec( value );
  509. if ( match ) {
  510. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  511. }
  512. }
  513. local[ prop.idx ] = value;
  514. return this[ fn ]( local );
  515. };
  516. });
  517. });
  518. // add .fx.step functions
  519. each( stepHooks, function( i, hook ) {
  520. jQuery.cssHooks[ hook ] = {
  521. set: function( elem, value ) {
  522. var parsed, curElem,
  523. backgroundColor = "";
  524. if ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) {
  525. value = color( parsed || value );
  526. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  527. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  528. while (
  529. (backgroundColor === "" || backgroundColor === "transparent") &&
  530. curElem && curElem.style
  531. ) {
  532. try {
  533. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  534. curElem = curElem.parentNode;
  535. } catch ( e ) {
  536. }
  537. }
  538. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  539. backgroundColor :
  540. "_default" );
  541. }
  542. value = value.toRgbaString();
  543. }
  544. try {
  545. elem.style[ hook ] = value;
  546. } catch( value ) {
  547. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  548. }
  549. }
  550. };
  551. jQuery.fx.step[ hook ] = function( fx ) {
  552. if ( !fx.colorInit ) {
  553. fx.start = color( fx.elem, hook );
  554. fx.end = color( fx.end );
  555. fx.colorInit = true;
  556. }
  557. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  558. };
  559. });
  560. jQuery.cssHooks.borderColor = {
  561. expand: function( value ) {
  562. var expanded = {};
  563. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  564. expanded[ "border" + part + "Color" ] = value;
  565. });
  566. return expanded;
  567. }
  568. };
  569. // Basic color names only.
  570. // Usage of any of the other color names requires adding yourself or including
  571. // jquery.color.svg-names.js.
  572. colors = jQuery.Color.names = {
  573. // 4.1. Basic color keywords
  574. aqua: "#00ffff",
  575. black: "#000000",
  576. blue: "#0000ff",
  577. fuchsia: "#ff00ff",
  578. gray: "#808080",
  579. green: "#008000",
  580. lime: "#00ff00",
  581. maroon: "#800000",
  582. navy: "#000080",
  583. olive: "#808000",
  584. purple: "#800080",
  585. red: "#ff0000",
  586. silver: "#c0c0c0",
  587. teal: "#008080",
  588. white: "#ffffff",
  589. yellow: "#ffff00",
  590. // 4.2.3. "transparent" color keyword
  591. transparent: [ null, null, null, 0 ],
  592. _default: "#ffffff"
  593. };
  594. })( jQuery );
  595. /******************************************************************************/
  596. /****************************** CLASS ANIMATIONS ******************************/
  597. /******************************************************************************/
  598. (function() {
  599. var classAnimationActions = [ "add", "remove", "toggle" ],
  600. shorthandStyles = {
  601. border: 1,
  602. borderBottom: 1,
  603. borderColor: 1,
  604. borderLeft: 1,
  605. borderRight: 1,
  606. borderTop: 1,
  607. borderWidth: 1,
  608. margin: 1,
  609. padding: 1
  610. };
  611. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  612. $.fx.step[ prop ] = function( fx ) {
  613. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  614. jQuery.style( fx.elem, prop, fx.end );
  615. fx.setAttr = true;
  616. }
  617. };
  618. });
  619. function getElementStyles() {
  620. var style = this.ownerDocument.defaultView ?
  621. this.ownerDocument.defaultView.getComputedStyle( this, null ) :
  622. this.currentStyle,
  623. newStyle = {},
  624. key,
  625. camelCase,
  626. len;
  627. // webkit enumerates style porperties
  628. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  629. len = style.length;
  630. while ( len-- ) {
  631. key = style[ len ];
  632. if ( typeof style[ key ] === "string" ) {
  633. newStyle[ $.camelCase( key ) ] = style[ key ];
  634. }
  635. }
  636. } else {
  637. for ( key in style ) {
  638. if ( typeof style[ key ] === "string" ) {
  639. newStyle[ key ] = style[ key ];
  640. }
  641. }
  642. }
  643. return newStyle;
  644. }
  645. function styleDifference( oldStyle, newStyle ) {
  646. var diff = {},
  647. name, value;
  648. for ( name in newStyle ) {
  649. value = newStyle[ name ];
  650. if ( oldStyle[ name ] !== value ) {
  651. if ( !shorthandStyles[ name ] ) {
  652. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  653. diff[ name ] = value;
  654. }
  655. }
  656. }
  657. }
  658. return diff;
  659. }
  660. $.effects.animateClass = function( value, duration, easing, callback ) {
  661. var o = $.speed( duration, easing, callback );
  662. return this.queue( function() {
  663. var animated = $( this ),
  664. baseClass = animated.attr( "class" ) || "",
  665. applyClassChange,
  666. allAnimations = o.children ? animated.find( "*" ).andSelf() : animated;
  667. // map the animated objects to store the original styles.
  668. allAnimations = allAnimations.map(function() {
  669. var el = $( this );
  670. return {
  671. el: el,
  672. start: getElementStyles.call( this )
  673. };
  674. });
  675. // apply class change
  676. applyClassChange = function() {
  677. $.each( classAnimationActions, function(i, action) {
  678. if ( value[ action ] ) {
  679. animated[ action + "Class" ]( value[ action ] );
  680. }
  681. });
  682. };
  683. applyClassChange();
  684. // map all animated objects again - calculate new styles and diff
  685. allAnimations = allAnimations.map(function() {
  686. this.end = getElementStyles.call( this.el[ 0 ] );
  687. this.diff = styleDifference( this.start, this.end );
  688. return this;
  689. });
  690. // apply original class
  691. animated.attr( "class", baseClass );
  692. // map all animated objects again - this time collecting a promise
  693. allAnimations = allAnimations.map(function() {
  694. var styleInfo = this,
  695. dfd = $.Deferred(),
  696. opts = jQuery.extend({}, o, {
  697. queue: false,
  698. complete: function() {
  699. dfd.resolve( styleInfo );
  700. }
  701. });
  702. this.el.animate( this.diff, opts );
  703. return dfd.promise();
  704. });
  705. // once all animations have completed:
  706. $.when.apply( $, allAnimations.get() ).done(function() {
  707. // set the final class
  708. applyClassChange();
  709. // for each animated element,
  710. // clear all css properties that were animated
  711. $.each( arguments, function() {
  712. var el = this.el;
  713. $.each( this.diff, function(key) {
  714. el.css( key, '' );
  715. });
  716. });
  717. // this is guarnteed to be there if you use jQuery.speed()
  718. // it also handles dequeuing the next anim...
  719. o.complete.call( animated[ 0 ] );
  720. });
  721. });
  722. };
  723. $.fn.extend({
  724. _addClass: $.fn.addClass,
  725. addClass: function( classNames, speed, easing, callback ) {
  726. return speed ?
  727. $.effects.animateClass.call( this,
  728. { add: classNames }, speed, easing, callback ) :
  729. this._addClass( classNames );
  730. },
  731. _removeClass: $.fn.removeClass,
  732. removeClass: function( classNames, speed, easing, callback ) {
  733. return speed ?
  734. $.effects.animateClass.call( this,
  735. { remove: classNames }, speed, easing, callback ) :
  736. this._removeClass( classNames );
  737. },
  738. _toggleClass: $.fn.toggleClass,
  739. toggleClass: function( classNames, force, speed, easing, callback ) {
  740. if ( typeof force === "boolean" || force === undefined ) {
  741. if ( !speed ) {
  742. // without speed parameter
  743. return this._toggleClass( classNames, force );
  744. } else {
  745. return $.effects.animateClass.call( this,
  746. (force ? { add: classNames } : { remove: classNames }),
  747. speed, easing, callback );
  748. }
  749. } else {
  750. // without force parameter
  751. return $.effects.animateClass.call( this,
  752. { toggle: classNames }, force, speed, easing );
  753. }
  754. },
  755. switchClass: function( remove, add, speed, easing, callback) {
  756. return $.effects.animateClass.call( this, {
  757. add: add,
  758. remove: remove
  759. }, speed, easing, callback );
  760. }
  761. });
  762. })();
  763. /******************************************************************************/
  764. /*********************************** EFFECTS **********************************/
  765. /******************************************************************************/
  766. (function() {
  767. $.extend( $.effects, {
  768. version: "1.9.0",
  769. // Saves a set of properties in a data storage
  770. save: function( element, set ) {
  771. for( var i=0; i < set.length; i++ ) {
  772. if ( set[ i ] !== null ) {
  773. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  774. }
  775. }
  776. },
  777. // Restores a set of previously saved properties from a data storage
  778. restore: function( element, set ) {
  779. var val, i;
  780. for( i=0; i < set.length; i++ ) {
  781. if ( set[ i ] !== null ) {
  782. val = element.data( dataSpace + set[ i ] );
  783. // support: jQuery 1.6.2
  784. // http://bugs.jquery.com/ticket/9917
  785. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  786. // We can't differentiate between "" and 0 here, so we just assume
  787. // empty string since it's likely to be a more common value...
  788. if ( val === undefined ) {
  789. val = "";
  790. }
  791. element.css( set[ i ], val );
  792. }
  793. }
  794. },
  795. setMode: function( el, mode ) {
  796. if (mode === "toggle") {
  797. mode = el.is( ":hidden" ) ? "show" : "hide";
  798. }
  799. return mode;
  800. },
  801. // Translates a [top,left] array into a baseline value
  802. // this should be a little more flexible in the future to handle a string & hash
  803. getBaseline: function( origin, original ) {
  804. var y, x;
  805. switch ( origin[ 0 ] ) {
  806. case "top": y = 0; break;
  807. case "middle": y = 0.5; break;
  808. case "bottom": y = 1; break;
  809. default: y = origin[ 0 ] / original.height;
  810. }
  811. switch ( origin[ 1 ] ) {
  812. case "left": x = 0; break;
  813. case "center": x = 0.5; break;
  814. case "right": x = 1; break;
  815. default: x = origin[ 1 ] / original.width;
  816. }
  817. return {
  818. x: x,
  819. y: y
  820. };
  821. },
  822. // Wraps the element around a wrapper that copies position properties
  823. createWrapper: function( element ) {
  824. // if the element is already wrapped, return it
  825. if ( element.parent().is( ".ui-effects-wrapper" )) {
  826. return element.parent();
  827. }
  828. // wrap the element
  829. var props = {
  830. width: element.outerWidth(true),
  831. height: element.outerHeight(true),
  832. "float": element.css( "float" )
  833. },
  834. wrapper = $( "<div></div>" )
  835. .addClass( "ui-effects-wrapper" )
  836. .css({
  837. fontSize: "100%",
  838. background: "transparent",
  839. border: "none",
  840. margin: 0,
  841. padding: 0
  842. }),
  843. // Store the size in case width/height are defined in % - Fixes #5245
  844. size = {
  845. width: element.width(),
  846. height: element.height()
  847. },
  848. active = document.activeElement;
  849. // support: Firefox
  850. // Firefox incorrectly exposes anonymous content
  851. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  852. try {
  853. active.id;
  854. } catch( e ) {
  855. active = document.body;
  856. }
  857. element.wrap( wrapper );
  858. // Fixes #7595 - Elements lose focus when wrapped.
  859. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  860. $( active ).focus();
  861. }
  862. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  863. // transfer positioning properties to the wrapper
  864. if ( element.css( "position" ) === "static" ) {
  865. wrapper.css({ position: "relative" });
  866. element.css({ position: "relative" });
  867. } else {
  868. $.extend( props, {
  869. position: element.css( "position" ),
  870. zIndex: element.css( "z-index" )
  871. });
  872. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  873. props[ pos ] = element.css( pos );
  874. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  875. props[ pos ] = "auto";
  876. }
  877. });
  878. element.css({
  879. position: "relative",
  880. top: 0,
  881. left: 0,
  882. right: "auto",
  883. bottom: "auto"
  884. });
  885. }
  886. element.css(size);
  887. return wrapper.css( props ).show();
  888. },
  889. removeWrapper: function( element ) {
  890. var active = document.activeElement;
  891. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  892. element.parent().replaceWith( element );
  893. // Fixes #7595 - Elements lose focus when wrapped.
  894. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  895. $( active ).focus();
  896. }
  897. }
  898. return element;
  899. },
  900. setTransition: function( element, list, factor, value ) {
  901. value = value || {};
  902. $.each( list, function( i, x ) {
  903. var unit = element.cssUnit( x );
  904. if ( unit[ 0 ] > 0 ) {
  905. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  906. }
  907. });
  908. return value;
  909. }
  910. });
  911. // return an effect options object for the given parameters:
  912. function _normalizeArguments( effect, options, speed, callback ) {
  913. // allow passing all optinos as the first parameter
  914. if ( $.isPlainObject( effect ) ) {
  915. options = effect;
  916. effect = effect.effect;
  917. }
  918. // convert to an object
  919. effect = { effect: effect };
  920. // catch (effect)
  921. if ( options === undefined ) {
  922. options = {};
  923. }
  924. // catch (effect, callback)
  925. if ( $.isFunction( options ) ) {
  926. callback = options;
  927. speed = null;
  928. options = {};
  929. }
  930. // catch (effect, speed, ?)
  931. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  932. callback = speed;
  933. speed = options;
  934. options = {};
  935. }
  936. // catch (effect, options, callback)
  937. if ( $.isFunction( speed ) ) {
  938. callback = speed;
  939. speed = null;
  940. }
  941. // add options to effect
  942. if ( options ) {
  943. $.extend( effect, options );
  944. }
  945. speed = speed || options.duration;
  946. effect.duration = $.fx.off ? 0 :
  947. typeof speed === "number" ? speed :
  948. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  949. $.fx.speeds._default;
  950. effect.complete = callback || options.complete;
  951. return effect;
  952. }
  953. function standardSpeed( speed ) {
  954. // valid standard speeds
  955. if ( !speed || typeof speed === "number" || $.fx.speeds[ speed ] ) {
  956. return true;
  957. }
  958. // invalid strings - treat as "normal" speed
  959. if ( typeof speed === "string" && !$.effects.effect[ speed ] ) {
  960. // TODO: remove in 2.0 (#7115)
  961. if ( backCompat && $.effects[ speed ] ) {
  962. return false;
  963. }
  964. return true;
  965. }
  966. return false;
  967. }
  968. $.fn.extend({
  969. effect: function( effect, options, speed, callback ) {
  970. var args = _normalizeArguments.apply( this, arguments ),
  971. mode = args.mode,
  972. queue = args.queue,
  973. effectMethod = $.effects.effect[ args.effect ],
  974. // DEPRECATED: remove in 2.0 (#7115)
  975. oldEffectMethod = !effectMethod && backCompat && $.effects[ args.effect ];
  976. if ( $.fx.off || !( effectMethod || oldEffectMethod ) ) {
  977. // delegate to the original method (e.g., .show()) if possible
  978. if ( mode ) {
  979. return this[ mode ]( args.duration, args.complete );
  980. } else {
  981. return this.each( function() {
  982. if ( args.complete ) {
  983. args.complete.call( this );
  984. }
  985. });
  986. }
  987. }
  988. function run( next ) {
  989. var elem = $( this ),
  990. complete = args.complete,
  991. mode = args.mode;
  992. function done() {
  993. if ( $.isFunction( complete ) ) {
  994. complete.call( elem[0] );
  995. }
  996. if ( $.isFunction( next ) ) {
  997. next();
  998. }
  999. }
  1000. // if the element is hiddden and mode is hide,
  1001. // or element is visible and mode is show
  1002. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  1003. done();
  1004. } else {
  1005. effectMethod.call( elem[0], args, done );
  1006. }
  1007. }
  1008. // TODO: remove this check in 2.0, effectMethod will always be true
  1009. if ( effectMethod ) {
  1010. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  1011. } else {
  1012. // DEPRECATED: remove in 2.0 (#7115)
  1013. return oldEffectMethod.call(this, {
  1014. options: args,
  1015. duration: args.duration,
  1016. callback: args.complete,
  1017. mode: args.mode
  1018. });
  1019. }
  1020. },
  1021. _show: $.fn.show,
  1022. show: function( speed ) {
  1023. if ( standardSpeed( speed ) ) {
  1024. return this._show.apply( this, arguments );
  1025. } else {
  1026. var args = _normalizeArguments.apply( this, arguments );
  1027. args.mode = "show";
  1028. return this.effect.call( this, args );
  1029. }
  1030. },
  1031. _hide: $.fn.hide,
  1032. hide: function( speed ) {
  1033. if ( standardSpeed( speed ) ) {
  1034. return this._hide.apply( this, arguments );
  1035. } else {
  1036. var args = _normalizeArguments.apply( this, arguments );
  1037. args.mode = "hide";
  1038. return this.effect.call( this, args );
  1039. }
  1040. },
  1041. // jQuery core overloads toggle and creates _toggle
  1042. __toggle: $.fn.toggle,
  1043. toggle: function( speed ) {
  1044. if ( standardSpeed( speed ) || typeof speed === "boolean" || $.isFunction( speed ) ) {
  1045. return this.__toggle.apply( this, arguments );
  1046. } else {
  1047. var args = _normalizeArguments.apply( this, arguments );
  1048. args.mode = "toggle";
  1049. return this.effect.call( this, args );
  1050. }
  1051. },
  1052. // helper functions
  1053. cssUnit: function(key) {
  1054. var style = this.css( key ),
  1055. val = [];
  1056. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  1057. if ( style.indexOf( unit ) > 0 ) {
  1058. val = [ parseFloat( style ), unit ];
  1059. }
  1060. });
  1061. return val;
  1062. }
  1063. });
  1064. })();
  1065. /******************************************************************************/
  1066. /*********************************** EASING ***********************************/
  1067. /******************************************************************************/
  1068. (function() {
  1069. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  1070. var baseEasings = {};
  1071. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  1072. baseEasings[ name ] = function( p ) {
  1073. return Math.pow( p, i + 2 );
  1074. };
  1075. });
  1076. $.extend( baseEasings, {
  1077. Sine: function ( p ) {
  1078. return 1 - Math.cos( p * Math.PI / 2 );
  1079. },
  1080. Circ: function ( p ) {
  1081. return 1 - Math.sqrt( 1 - p * p );
  1082. },
  1083. Elastic: function( p ) {
  1084. return p === 0 || p === 1 ? p :
  1085. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  1086. },
  1087. Back: function( p ) {
  1088. return p * p * ( 3 * p - 2 );
  1089. },
  1090. Bounce: function ( p ) {
  1091. var pow2,
  1092. bounce = 4;
  1093. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  1094. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  1095. }
  1096. });
  1097. $.each( baseEasings, function( name, easeIn ) {
  1098. $.easing[ "easeIn" + name ] = easeIn;
  1099. $.easing[ "easeOut" + name ] = function( p ) {
  1100. return 1 - easeIn( 1 - p );
  1101. };
  1102. $.easing[ "easeInOut" + name ] = function( p ) {
  1103. return p < 0.5 ?
  1104. easeIn( p * 2 ) / 2 :
  1105. 1 - easeIn( p * -2 + 2 ) / 2;
  1106. };
  1107. });
  1108. })();
  1109. })(jQuery));
  1110. (function( $, undefined ) {
  1111. var rvertical = /up|down|vertical/,
  1112. rpositivemotion = /up|left|vertical|horizontal/;
  1113. $.effects.effect.blind = function( o, done ) {
  1114. // Create element
  1115. var el = $( this ),
  1116. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  1117. mode = $.effects.setMode( el, o.mode || "hide" ),
  1118. direction = o.direction || "up",
  1119. vertical = rvertical.test( direction ),
  1120. ref = vertical ? "height" : "width",
  1121. ref2 = vertical ? "top" : "left",
  1122. motion = rpositivemotion.test( direction ),
  1123. animation = {},
  1124. show = mode === "show",
  1125. wrapper, distance, margin;
  1126. // if already wrapped, the wrapper's properties are my property. #6245
  1127. if ( el.parent().is( ".ui-effects-wrapper" ) ) {
  1128. $.effects.save( el.parent(), props );
  1129. } else {
  1130. $.effects.save( el, props );
  1131. }
  1132. el.show();
  1133. wrapper = $.effects.createWrapper( el ).css({
  1134. overflow: "hidden"
  1135. });
  1136. distance = wrapper[ ref ]();
  1137. margin = parseFloat( wrapper.css( ref2 ) ) || 0;
  1138. animation[ ref ] = show ? distance : 0;
  1139. if ( !motion ) {
  1140. el
  1141. .css( vertical ? "bottom" : "right", 0 )
  1142. .css( vertical ? "top" : "left", "auto" )
  1143. .css({ position: "absolute" });
  1144. animation[ ref2 ] = show ? margin : distance + margin;
  1145. }
  1146. // start at 0 if we are showing
  1147. if ( show ) {
  1148. wrapper.css( ref, 0 );
  1149. if ( ! motion ) {
  1150. wrapper.css( ref2, margin + distance );
  1151. }
  1152. }
  1153. // Animate
  1154. wrapper.animate( animation, {
  1155. duration: o.duration,
  1156. easing: o.easing,
  1157. queue: false,
  1158. complete: function() {
  1159. if ( mode === "hide" ) {
  1160. el.hide();
  1161. }
  1162. $.effects.restore( el, props );
  1163. $.effects.removeWrapper( el );
  1164. done();
  1165. }
  1166. });
  1167. };
  1168. })(jQuery);
  1169. (function( $, undefined ) {
  1170. $.effects.effect.bounce = function( o, done ) {
  1171. var el = $( this ),
  1172. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  1173. // defaults:
  1174. mode = $.effects.setMode( el, o.mode || "effect" ),
  1175. hide = mode === "hide",
  1176. show = mode === "show",
  1177. direction = o.direction || "up",
  1178. distance = o.distance,
  1179. times = o.times || 5,
  1180. // number of internal animations
  1181. anims = times * 2 + ( show || hide ? 1 : 0 ),
  1182. speed = o.duration / anims,
  1183. easing = o.easing,
  1184. // utility:
  1185. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  1186. motion = ( direction === "up" || direction === "left" ),
  1187. i,
  1188. upAnim,
  1189. downAnim,
  1190. // we will need to re-assemble the queue to stack our animations in place
  1191. queue = el.queue(),
  1192. queuelen = queue.length;
  1193. // Avoid touching opacity to prevent clearType and PNG issues in IE
  1194. if ( show || hide ) {
  1195. props.push( "opacity" );
  1196. }
  1197. $.effects.save( el, props );
  1198. el.show();
  1199. $.effects.createWrapper( el ); // Create Wrapper
  1200. // default distance for the BIGGEST bounce is the outer Distance / 3
  1201. if ( !distance ) {
  1202. distance = el[ ref === "top" ? "outerHeight" : "outerWidth" ]() / 3;
  1203. }
  1204. if ( show ) {
  1205. downAnim = { opacity: 1 };
  1206. downAnim[ ref ] = 0;
  1207. // if we are showing, force opacity 0 and set the initial position
  1208. // then do the "first" animation
  1209. el.css( "opacity", 0 )
  1210. .css( ref, motion ? -distance * 2 : distance * 2 )
  1211. .animate( downAnim, speed, easing );
  1212. }
  1213. // start at the smallest distance if we are hiding
  1214. if ( hide ) {
  1215. distance = distance / Math.pow( 2, times - 1 );
  1216. }
  1217. downAnim = {};
  1218. downAnim[ ref ] = 0;
  1219. // Bounces up/down/left/right then back to 0 -- times * 2 animations happen here
  1220. for ( i = 0; i < times; i++ ) {
  1221. upAnim = {};
  1222. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  1223. el.animate( upAnim, speed, easing )
  1224. .animate( downAnim, speed, easing );
  1225. distance = hide ? distance * 2 : distance / 2;
  1226. }
  1227. // Last Bounce when Hiding
  1228. if ( hide ) {
  1229. upAnim = { opacity: 0 };
  1230. upAnim[ ref ] = ( motion ? "-=" : "+=" ) + distance;
  1231. el.animate( upAnim, speed, easing );
  1232. }
  1233. el.queue(function() {
  1234. if ( hide ) {
  1235. el.hide();
  1236. }
  1237. $.effects.restore( el, props );
  1238. $.effects.removeWrapper( el );
  1239. done();
  1240. });
  1241. // inject all the animations we just queued to be first in line (after "inprogress")
  1242. if ( queuelen > 1) {
  1243. queue.splice.apply( queue,
  1244. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  1245. }
  1246. el.dequeue();
  1247. };
  1248. })(jQuery);
  1249. (function( $, undefined ) {
  1250. $.effects.effect.clip = function( o, done ) {
  1251. // Create element
  1252. var el = $( this ),
  1253. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  1254. mode = $.effects.setMode( el, o.mode || "hide" ),
  1255. show = mode === "show",
  1256. direction = o.direction || "vertical",
  1257. vert = direction === "vertical",
  1258. size = vert ? "height" : "width",
  1259. position = vert ? "top" : "left",
  1260. animation = {},
  1261. wrapper, animate, distance;
  1262. // Save & Show
  1263. $.effects.save( el, props );
  1264. el.show();
  1265. // Create Wrapper
  1266. wrapper = $.effects.createWrapper( el ).css({
  1267. overflow: "hidden"
  1268. });
  1269. animate = ( el[0].tagName === "IMG" ) ? wrapper : el;
  1270. distance = animate[ size ]();
  1271. // Shift
  1272. if ( show ) {
  1273. animate.css( size, 0 );
  1274. animate.css( position, distance / 2 );
  1275. }
  1276. // Create Animation Object:
  1277. animation[ size ] = show ? distance : 0;
  1278. animation[ position ] = show ? 0 : distance / 2;
  1279. // Animate
  1280. animate.animate( animation, {
  1281. queue: false,
  1282. duration: o.duration,
  1283. easing: o.easing,
  1284. complete: function() {
  1285. if ( !show ) {
  1286. el.hide();
  1287. }
  1288. $.effects.restore( el, props );
  1289. $.effects.removeWrapper( el );
  1290. done();
  1291. }
  1292. });
  1293. };
  1294. })(jQuery);
  1295. (function( $, undefined ) {
  1296. $.effects.effect.drop = function( o, done ) {
  1297. var el = $( this ),
  1298. props = [ "position", "top", "bottom", "left", "right", "opacity", "height", "width" ],
  1299. mode = $.effects.setMode( el, o.mode || "hide" ),
  1300. show = mode === "show",
  1301. direction = o.direction || "left",
  1302. ref = ( direction === "up" || direction === "down" ) ? "top" : "left",
  1303. motion = ( direction === "up" || direction === "left" ) ? "pos" : "neg",
  1304. animation = {
  1305. opacity: show ? 1 : 0
  1306. },
  1307. distance;
  1308. // Adjust
  1309. $.effects.save( el, props );
  1310. el.show();
  1311. $.effects.createWrapper( el );
  1312. distance = o.distance || el[ ref === "top" ? "outerHeight": "outerWidth" ]( true ) / 2;
  1313. if ( show ) {
  1314. el
  1315. .css( "opacity", 0 )
  1316. .css( ref, motion === "pos" ? -distance : distance );
  1317. }
  1318. // Animation
  1319. animation[ ref ] = ( show ?
  1320. ( motion === "pos" ? "+=" : "-=" ) :
  1321. ( motion === "pos" ? "-=" : "+=" ) ) +
  1322. distance;
  1323. // Animate
  1324. el.animate( animation, {
  1325. queue: false,
  1326. duration: o.duration,
  1327. easing: o.easing,
  1328. complete: function() {
  1329. if ( mode === "hide" ) {
  1330. el.hide();
  1331. }
  1332. $.effects.restore( el, props );
  1333. $.effects.removeWrapper( el );
  1334. done();
  1335. }
  1336. });
  1337. };
  1338. })(jQuery);
  1339. (function( $, undefined ) {
  1340. $.effects.effect.explode = function( o, done ) {
  1341. var rows = o.pieces ? Math.round( Math.sqrt( o.pieces ) ) : 3,
  1342. cells = rows,
  1343. el = $( this ),
  1344. mode = $.effects.setMode( el, o.mode || "hide" ),
  1345. show = mode === "show",
  1346. // show and then visibility:hidden the element before calculating offset
  1347. offset = el.show().css( "visibility", "hidden" ).offset(),
  1348. // width and height of a piece
  1349. width = Math.ceil( el.outerWidth() / cells ),
  1350. height = Math.ceil( el.outerHeight() / rows ),
  1351. pieces = [],
  1352. // loop
  1353. i, j, left, top, mx, my;
  1354. // children animate complete:
  1355. function childComplete() {
  1356. pieces.push( this );
  1357. if ( pieces.length === rows * cells ) {
  1358. animComplete();
  1359. }
  1360. }
  1361. // clone the element for each row and cell.
  1362. for( i = 0; i < rows ; i++ ) { // ===>
  1363. top = offset.top + i * height;
  1364. my = i - ( rows - 1 ) / 2 ;
  1365. for( j = 0; j < cells ; j++ ) { // |||
  1366. left = offset.left + j * width;
  1367. mx = j - ( cells - 1 ) / 2 ;
  1368. // Create a clone of the now hidden main element that will be absolute positioned
  1369. // within a wrapper div off the -left and -top equal to size of our pieces
  1370. el
  1371. .clone()
  1372. .appendTo( "body" )
  1373. .wrap( "<div></div>" )
  1374. .css({
  1375. position: "absolute",
  1376. visibility: "visible",
  1377. left: -j * width,
  1378. top: -i * height
  1379. })
  1380. // select the wrapper - make it overflow: hidden and absolute positioned based on
  1381. // where the original was located +left and +top equal to the size of pieces
  1382. .parent()
  1383. .addClass( "ui-effects-explode" )
  1384. .css({
  1385. position: "absolute",
  1386. overflow: "hidden",
  1387. width: width,
  1388. height: height,
  1389. left: left + ( show ? mx * width : 0 ),
  1390. top: top + ( show ? my * height : 0 ),
  1391. opacity: show ? 0 : 1
  1392. }).animate({
  1393. left: left + ( show ? 0 : mx * width ),
  1394. top: top + ( show ? 0 : my * height ),
  1395. opacity: show ? 1 : 0
  1396. }, o.duration || 500, o.easing, childComplete );
  1397. }
  1398. }
  1399. function animComplete() {
  1400. el.css({
  1401. visibility: "visible"
  1402. });
  1403. $( pieces ).remove();
  1404. if ( !show ) {
  1405. el.hide();
  1406. }
  1407. done();
  1408. }
  1409. };
  1410. })(jQuery);
  1411. (function( $, undefined ) {
  1412. $.effects.effect.fade = function( o, done ) {
  1413. var el = $( this ),
  1414. mode = $.effects.setMode( el, o.mode || "toggle" );
  1415. el.animate({
  1416. opacity: mode
  1417. }, {
  1418. queue: false,
  1419. duration: o.duration,
  1420. easing: o.easing,
  1421. complete: done
  1422. });
  1423. };
  1424. })( jQuery );
  1425. (function( $, undefined ) {
  1426. $.effects.effect.fold = function( o, done ) {
  1427. // Create element
  1428. var el = $( this ),
  1429. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  1430. mode = $.effects.setMode( el, o.mode || "hide" ),
  1431. show = mode === "show",
  1432. hide = mode === "hide",
  1433. size = o.size || 15,
  1434. percent = /([0-9]+)%/.exec( size ),
  1435. horizFirst = !!o.horizFirst,
  1436. widthFirst = show !== horizFirst,
  1437. ref = widthFirst ? [ "width", "height" ] : [ "height", "width" ],
  1438. duration = o.duration / 2,
  1439. wrapper, distance,
  1440. animation1 = {},
  1441. animation2 = {};
  1442. $.effects.save( el, props );
  1443. el.show();
  1444. // Create Wrapper
  1445. wrapper = $.effects.createWrapper( el ).css({
  1446. overflow: "hidden"
  1447. });
  1448. distance = widthFirst ?
  1449. [ wrapper.width(), wrapper.height() ] :
  1450. [ wrapper.height(), wrapper.width() ];
  1451. if ( percent ) {
  1452. size = parseInt( percent[ 1 ], 10 ) / 100 * distance[ hide ? 0 : 1 ];
  1453. }
  1454. if ( show ) {
  1455. wrapper.css( horizFirst ? {
  1456. height: 0,
  1457. width: size
  1458. } : {
  1459. height: size,
  1460. width: 0
  1461. });
  1462. }
  1463. // Animation
  1464. animation1[ ref[ 0 ] ] = show ? distance[ 0 ] : size;
  1465. animation2[ ref[ 1 ] ] = show ? distance[ 1 ] : 0;
  1466. // Animate
  1467. wrapper
  1468. .animate( animation1, duration, o.easing )
  1469. .animate( animation2, duration, o.easing, function() {
  1470. if ( hide ) {
  1471. el.hide();
  1472. }
  1473. $.effects.restore( el, props );
  1474. $.effects.removeWrapper( el );
  1475. done();
  1476. });
  1477. };
  1478. })(jQuery);
  1479. (function( $, undefined ) {
  1480. $.effects.effect.highlight = function( o, done ) {
  1481. var elem = $( this ),
  1482. props = [ "backgroundImage", "backgroundColor", "opacity" ],
  1483. mode = $.effects.setMode( elem, o.mode || "show" ),
  1484. animation = {
  1485. backgroundColor: elem.css( "backgroundColor" )
  1486. };
  1487. if (mode === "hide") {
  1488. animation.opacity = 0;
  1489. }
  1490. $.effects.save( elem, props );
  1491. elem
  1492. .show()
  1493. .css({
  1494. backgroundImage: "none",
  1495. backgroundColor: o.color || "#ffff99"
  1496. })
  1497. .animate( animation, {
  1498. queue: false,
  1499. duration: o.duration,
  1500. easing: o.easing,
  1501. complete: function() {
  1502. if ( mode === "hide" ) {
  1503. elem.hide();
  1504. }
  1505. $.effects.restore( elem, props );
  1506. done();
  1507. }
  1508. });
  1509. };
  1510. })(jQuery);
  1511. (function( $, undefined ) {
  1512. $.effects.effect.pulsate = function( o, done ) {
  1513. var elem = $( this ),
  1514. mode = $.effects.setMode( elem, o.mode || "show" ),
  1515. show = mode === "show",
  1516. hide = mode === "hide",
  1517. showhide = ( show || mode === "hide" ),
  1518. // showing or hiding leaves of the "last" animation
  1519. anims = ( ( o.times || 5 ) * 2 ) + ( showhide ? 1 : 0 ),
  1520. duration = o.duration / anims,
  1521. animateTo = 0,
  1522. queue = elem.queue(),
  1523. queuelen = queue.length,
  1524. i;
  1525. if ( show || !elem.is(":visible")) {
  1526. elem.css( "opacity", 0 ).show();
  1527. animateTo = 1;
  1528. }
  1529. // anims - 1 opacity "toggles"
  1530. for ( i = 1; i < anims; i++ ) {
  1531. elem.animate({
  1532. opacity: animateTo
  1533. }, duration, o.easing );
  1534. animateTo = 1 - animateTo;
  1535. }
  1536. elem.animate({
  1537. opacity: animateTo
  1538. }, duration, o.easing);
  1539. elem.queue(function() {
  1540. if ( hide ) {
  1541. elem.hide();
  1542. }
  1543. done();
  1544. });
  1545. // We just queued up "anims" animations, we need to put them next in the queue
  1546. if ( queuelen > 1 ) {
  1547. queue.splice.apply( queue,
  1548. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  1549. }
  1550. elem.dequeue();
  1551. };
  1552. })(jQuery);
  1553. (function( $, undefined ) {
  1554. $.effects.effect.puff = function( o, done ) {
  1555. var elem = $( this ),
  1556. mode = $.effects.setMode( elem, o.mode || "hide" ),
  1557. hide = mode === "hide",
  1558. percent = parseInt( o.percent, 10 ) || 150,
  1559. factor = percent / 100,
  1560. original = {
  1561. height: elem.height(),
  1562. width: elem.width()
  1563. };
  1564. $.extend( o, {
  1565. effect: "scale",
  1566. queue: false,
  1567. fade: true,
  1568. mode: mode,
  1569. complete: done,
  1570. percent: hide ? percent : 100,
  1571. from: hide ?
  1572. original :
  1573. {
  1574. height: original.height * factor,
  1575. width: original.width * factor
  1576. }
  1577. });
  1578. elem.effect( o );
  1579. };
  1580. $.effects.effect.scale = function( o, done ) {
  1581. // Create element
  1582. var el = $( this ),
  1583. options = $.extend( true, {}, o ),
  1584. mode = $.effects.setMode( el, o.mode || "effect" ),
  1585. percent = parseInt( o.percent, 10 ) ||
  1586. ( parseInt( o.percent, 10 ) === 0 ? 0 : ( mode === "hide" ? 0 : 100 ) ),
  1587. direction = o.direction || "both",
  1588. origin = o.origin,
  1589. original = {
  1590. height: el.height(),
  1591. width: el.width(),
  1592. outerHeight: el.outerHeight(),
  1593. outerWidth: el.outerWidth()
  1594. },
  1595. factor = {
  1596. y: direction !== "horizontal" ? (percent / 100) : 1,
  1597. x: direction !== "vertical" ? (percent / 100) : 1
  1598. };
  1599. // We are going to pass this effect to the size effect:
  1600. options.effect = "size";
  1601. options.queue = false;
  1602. options.complete = done;
  1603. // Set default origin and restore for show/hide
  1604. if ( mode !== "effect" ) {
  1605. options.origin = origin || ["middle","center"];
  1606. options.restore = true;
  1607. }
  1608. options.from = o.from || ( mode === "show" ? { height: 0, width: 0 } : original );
  1609. options.to = {
  1610. height: original.height * factor.y,
  1611. width: original.width * factor.x,
  1612. outerHeight: original.outerHeight * factor.y,
  1613. outerWidth: original.outerWidth * factor.x
  1614. };
  1615. // Fade option to support puff
  1616. if ( options.fade ) {
  1617. if ( mode === "show" ) {
  1618. options.from.opacity = 0;
  1619. options.to.opacity = 1;
  1620. }
  1621. if ( mode === "hide" ) {
  1622. options.from.opacity = 1;
  1623. options.to.opacity = 0;
  1624. }
  1625. }
  1626. // Animate
  1627. el.effect( options );
  1628. };
  1629. $.effects.effect.size = function( o, done ) {
  1630. // Create element
  1631. var el = $( this ),
  1632. props = [ "position", "top", "bottom", "left", "right", "width", "height", "overflow", "opacity" ],
  1633. // Always restore
  1634. props1 = [ "position", "top", "bottom", "left", "right", "overflow", "opacity" ],
  1635. // Copy for children
  1636. props2 = [ "width", "height", "overflow" ],
  1637. cProps = [ "fontSize" ],
  1638. vProps = [ "borderTopWidth", "borderBottomWidth", "paddingTop", "paddingBottom" ],
  1639. hProps = [ "borderLeftWidth", "borderRightWidth", "paddingLeft", "paddingRight" ],
  1640. // Set options
  1641. mode = $.effects.setMode( el, o.mode || "effect" ),
  1642. restore = o.restore || mode !== "effect",
  1643. scale = o.scale || "both",
  1644. origin = o.origin || [ "middle", "center" ],
  1645. original, baseline, factor,
  1646. position = el.css( "position" );
  1647. if ( mode === "show" ) {
  1648. el.show();
  1649. }
  1650. original = {
  1651. height: el.height(),
  1652. width: el.width(),
  1653. outerHeight: el.outerHeight(),
  1654. outerWidth: el.outerWidth()
  1655. };
  1656. el.from = o.from || original;
  1657. el.to = o.to || original;
  1658. // Set scaling factor
  1659. factor = {
  1660. from: {
  1661. y: el.from.height / original.height,
  1662. x: el.from.width / original.width
  1663. },
  1664. to: {
  1665. y: el.to.height / original.height,
  1666. x: el.to.width / original.width
  1667. }
  1668. };
  1669. // Scale the css box
  1670. if ( scale === "box" || scale === "both" ) {
  1671. // Vertical props scaling
  1672. if ( factor.from.y !== factor.to.y ) {
  1673. props = props.concat( vProps );
  1674. el.from = $.effects.setTransition( el, vProps, factor.from.y, el.from );
  1675. el.to = $.effects.setTransition( el, vProps, factor.to.y, el.to );
  1676. }
  1677. // Horizontal props scaling
  1678. if ( factor.from.x !== factor.to.x ) {
  1679. props = props.concat( hProps );
  1680. el.from = $.effects.setTransition( el, hProps, factor.from.x, el.from );
  1681. el.to = $.effects.setTransition( el, hProps, factor.to.x, el.to );
  1682. }
  1683. }
  1684. // Scale the content
  1685. if ( scale === "content" || scale === "both" ) {
  1686. // Vertical props scaling
  1687. if ( factor.from.y !== factor.to.y ) {
  1688. props = props.concat( cProps );
  1689. el.from = $.effects.setTransition( el, cProps, factor.from.y, el.from );
  1690. el.to = $.effects.setTransition( el, cProps, factor.to.y, el.to );
  1691. }
  1692. }
  1693. $.effects.save( el, restore ? props : props1 );
  1694. el.show();
  1695. $.effects.createWrapper( el );
  1696. el.css( "overflow", "hidden" ).css( el.from );
  1697. // Adjust
  1698. if (origin) { // Calculate baseline shifts
  1699. baseline = $.effects.getBaseline( origin, original );
  1700. el.from.top = ( original.outerHeight - el.outerHeight() ) * baseline.y;
  1701. el.from.left = ( original.outerWidth - el.outerWidth() ) * baseline.x;
  1702. el.to.top = ( original.outerHeight - el.to.outerHeight ) * baseline.y;
  1703. el.to.left = ( original.outerWidth - el.to.outerWidth ) * baseline.x;
  1704. }
  1705. el.css( el.from ); // set top & left
  1706. // Animate
  1707. if ( scale === "content" || scale === "both" ) { // Scale the children
  1708. // Add margins/font-size
  1709. vProps = vProps.concat([ "marginTop", "marginBottom" ]).concat(cProps);
  1710. hProps = hProps.concat([ "marginLeft", "marginRight" ]);
  1711. props2 = props.concat(vProps).concat(hProps);
  1712. el.find( "*[width]" ).each( function(){
  1713. var child = $( this ),
  1714. c_original = {
  1715. height: child.height(),
  1716. width: child.width()
  1717. };
  1718. if (restore) {
  1719. $.effects.save(child, props2);
  1720. }
  1721. child.from = {
  1722. height: c_original.height * factor.from.y,
  1723. width: c_original.width * factor.from.x
  1724. };
  1725. child.to = {
  1726. height: c_original.height * factor.to.y,
  1727. width: c_original.width * factor.to.x
  1728. };
  1729. // Vertical props scaling
  1730. if ( factor.from.y !== factor.to.y ) {
  1731. child.from = $.effects.setTransition( child, vProps, factor.from.y, child.from );
  1732. child.to = $.effects.setTransition( child, vProps, factor.to.y, child.to );
  1733. }
  1734. // Horizontal props scaling
  1735. if ( factor.from.x !== factor.to.x ) {
  1736. child.from = $.effects.setTransition( child, hProps, factor.from.x, child.from );
  1737. child.to = $.effects.setTransition( child, hProps, factor.to.x, child.to );
  1738. }
  1739. // Animate children
  1740. child.css( child.from );
  1741. child.animate( child.to, o.duration, o.easing, function() {
  1742. // Restore children
  1743. if ( restore ) {
  1744. $.effects.restore( child, props2 );
  1745. }
  1746. });
  1747. });
  1748. }
  1749. // Animate
  1750. el.animate( el.to, {
  1751. queue: false,
  1752. duration: o.duration,
  1753. easing: o.easing,
  1754. complete: function() {
  1755. if ( el.to.opacity === 0 ) {
  1756. el.css( "opacity", el.from.opacity );
  1757. }
  1758. if( mode === "hide" ) {
  1759. el.hide();
  1760. }
  1761. $.effects.restore( el, restore ? props : props1 );
  1762. if ( !restore ) {
  1763. // we need to calculate our new positioning based on the scaling
  1764. if ( position === "static" ) {
  1765. el.css({
  1766. position: "relative",
  1767. top: el.to.top,
  1768. left: el.to.left
  1769. });
  1770. } else {
  1771. $.each([ "top", "left" ], function( idx, pos ) {
  1772. el.css( pos, function( _, str ) {
  1773. var val = parseInt( str, 10 ),
  1774. toRef = idx ? el.to.left : el.to.top;
  1775. // if original was "auto", recalculate the new value from wrapper
  1776. if ( str === "auto" ) {
  1777. return toRef + "px";
  1778. }
  1779. return val + toRef + "px";
  1780. });
  1781. });
  1782. }
  1783. }
  1784. $.effects.removeWrapper( el );
  1785. done();
  1786. }
  1787. });
  1788. };
  1789. })(jQuery);
  1790. (function( $, undefined ) {
  1791. $.effects.effect.shake = function( o, done ) {
  1792. var el = $( this ),
  1793. props = [ "position", "top", "bottom", "left", "right", "height", "width" ],
  1794. mode = $.effects.setMode( el, o.mode || "effect" ),
  1795. direction = o.direction || "left",
  1796. distance = o.distance || 20,
  1797. times = o.times || 3,
  1798. anims = times * 2 + 1,
  1799. speed = Math.round(o.duration/anims),
  1800. ref = (direction === "up" || direction === "down") ? "top" : "left",
  1801. positiveMotion = (direction === "up" || direction === "left"),
  1802. animation = {},
  1803. animation1 = {},
  1804. animation2 = {},
  1805. i,
  1806. // we will need to re-assemble the queue to stack our animations in place
  1807. queue = el.queue(),
  1808. queuelen = queue.length;
  1809. $.effects.save( el, props );
  1810. el.show();
  1811. $.effects.createWrapper( el );
  1812. // Animation
  1813. animation[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance;
  1814. animation1[ ref ] = ( positiveMotion ? "+=" : "-=" ) + distance * 2;
  1815. animation2[ ref ] = ( positiveMotion ? "-=" : "+=" ) + distance * 2;
  1816. // Animate
  1817. el.animate( animation, speed, o.easing );
  1818. // Shakes
  1819. for ( i = 1; i < times; i++ ) {
  1820. el.animate( animation1, speed, o.easing ).animate( animation2, speed, o.easing );
  1821. }
  1822. el
  1823. .animate( animation1, speed, o.easing )
  1824. .animate( animation, speed / 2, o.easing )
  1825. .queue(function() {
  1826. if ( mode === "hide" ) {
  1827. el.hide();
  1828. }
  1829. $.effects.restore( el, props );
  1830. $.effects.removeWrapper( el );
  1831. done();
  1832. });
  1833. // inject all the animations we just queued to be first in line (after "inprogress")
  1834. if ( queuelen > 1) {
  1835. queue.splice.apply( queue,
  1836. [ 1, 0 ].concat( queue.splice( queuelen, anims + 1 ) ) );
  1837. }
  1838. el.dequeue();
  1839. };
  1840. })(jQuery);
  1841. (function( $, undefined ) {
  1842. $.effects.effect.slide = function( o, done ) {
  1843. // Create element
  1844. var el = $( this ),
  1845. props = [ "position", "top", "bottom", "left", "right", "width", "height" ],
  1846. mode = $.effects.setMode( el, o.mode || "show" ),
  1847. show = mode === "show",
  1848. direction = o.direction || "left",
  1849. ref = (direction === "up" || direction === "down") ? "top" : "left",
  1850. positiveMotion = (direction === "up" || direction === "left"),
  1851. distance,
  1852. animation = {};
  1853. // Adjust
  1854. $.effects.save( el, props );
  1855. el.show();
  1856. distance = o.distance || el[ ref === "top" ? "outerHeight" : "outerWidth" ]( true );
  1857. $.effects.createWrapper( el ).css({
  1858. overflow: "hidden"
  1859. });
  1860. if ( show ) {
  1861. el.css( ref, positiveMotion ? (isNaN(distance) ? "-" + distance : -distance) : distance );
  1862. }
  1863. // Animation
  1864. animation[ ref ] = ( show ?
  1865. ( positiveMotion ? "+=" : "-=") :
  1866. ( positiveMotion ? "-=" : "+=")) +
  1867. distance;
  1868. // Animate
  1869. el.animate( animation, {
  1870. queue: false,
  1871. duration: o.duration,
  1872. easing: o.easing,
  1873. complete: function() {
  1874. if ( mode === "hide" ) {
  1875. el.hide();
  1876. }
  1877. $.effects.restore( el, props );
  1878. $.effects.removeWrapper( el );
  1879. done();
  1880. }
  1881. });
  1882. };
  1883. })(jQuery);
  1884. (function( $, undefined ) {
  1885. $.effects.effect.transfer = function( o, done ) {
  1886. var elem = $( this ),
  1887. target = $( o.to ),
  1888. targetFixed = target.css( "position" ) === "fixed",
  1889. body = $("body"),
  1890. fixTop = targetFixed ? body.scrollTop() : 0,
  1891. fixLeft = targetFixed ? body.scrollLeft() : 0,
  1892. endPosition = target.offset(),
  1893. animation = {
  1894. top: endPosition.top - fixTop ,
  1895. left: endPosition.left - fixLeft ,
  1896. height: target.innerHeight(),
  1897. width: target.innerWidth()
  1898. },
  1899. startPosition = elem.offset(),
  1900. transfer = $( '<div class="ui-effects-transfer"></div>' )
  1901. .appendTo( document.body )
  1902. .addClass( o.className )
  1903. .css({
  1904. top: startPosition.top - fixTop ,
  1905. left: startPosition.left - fixLeft ,
  1906. height: elem.innerHeight(),
  1907. width: elem.innerWidth(),
  1908. position: targetFixed ? "fixed" : "absolute"
  1909. })
  1910. .animate( animation, o.duration, o.easing, function() {
  1911. transfer.remove();
  1912. done();
  1913. });
  1914. };
  1915. })(jQuery);