1
0

effect.js 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301
  1. /*!
  2. * jQuery UI Effects 1.11.4
  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. * http://api.jqueryui.com/category/effects-core/
  10. */
  11. (function( factory ) {
  12. if ( typeof define === "function" && define.amd ) {
  13. // AMD. Register as an anonymous module.
  14. define( [ "jquery" ], factory );
  15. } else {
  16. // Browser globals
  17. factory( jQuery );
  18. }
  19. }(function( $ ) {
  20. var dataSpace = "ui-effects-",
  21. // Create a local jQuery because jQuery Color relies on it and the
  22. // global may not exist with AMD and a custom build (#10199)
  23. jQuery = $;
  24. $.effects = {
  25. effect: {}
  26. };
  27. /*!
  28. * jQuery Color Animations v2.1.2
  29. * https://github.com/jquery/jquery-color
  30. *
  31. * Copyright 2014 jQuery Foundation and other contributors
  32. * Released under the MIT license.
  33. * http://jquery.org/license
  34. *
  35. * Date: Wed Jan 16 08:47:09 2013 -0600
  36. */
  37. (function( jQuery, undefined ) {
  38. var stepHooks = "backgroundColor borderBottomColor borderLeftColor borderRightColor borderTopColor color columnRuleColor outlineColor textDecorationColor textEmphasisColor",
  39. // plusequals test for += 100 -= 100
  40. rplusequals = /^([\-+])=\s*(\d+\.?\d*)/,
  41. // a set of RE's that can match strings and generate color tuples.
  42. stringParsers = [ {
  43. re: /rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  44. parse: function( execResult ) {
  45. return [
  46. execResult[ 1 ],
  47. execResult[ 2 ],
  48. execResult[ 3 ],
  49. execResult[ 4 ]
  50. ];
  51. }
  52. }, {
  53. re: /rgba?\(\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  54. parse: function( execResult ) {
  55. return [
  56. execResult[ 1 ] * 2.55,
  57. execResult[ 2 ] * 2.55,
  58. execResult[ 3 ] * 2.55,
  59. execResult[ 4 ]
  60. ];
  61. }
  62. }, {
  63. // this regex ignores A-F because it's compared against an already lowercased string
  64. re: /#([a-f0-9]{2})([a-f0-9]{2})([a-f0-9]{2})/,
  65. parse: function( execResult ) {
  66. return [
  67. parseInt( execResult[ 1 ], 16 ),
  68. parseInt( execResult[ 2 ], 16 ),
  69. parseInt( execResult[ 3 ], 16 )
  70. ];
  71. }
  72. }, {
  73. // this regex ignores A-F because it's compared against an already lowercased string
  74. re: /#([a-f0-9])([a-f0-9])([a-f0-9])/,
  75. parse: function( execResult ) {
  76. return [
  77. parseInt( execResult[ 1 ] + execResult[ 1 ], 16 ),
  78. parseInt( execResult[ 2 ] + execResult[ 2 ], 16 ),
  79. parseInt( execResult[ 3 ] + execResult[ 3 ], 16 )
  80. ];
  81. }
  82. }, {
  83. re: /hsla?\(\s*(\d+(?:\.\d+)?)\s*,\s*(\d+(?:\.\d+)?)\%\s*,\s*(\d+(?:\.\d+)?)\%\s*(?:,\s*(\d?(?:\.\d+)?)\s*)?\)/,
  84. space: "hsla",
  85. parse: function( execResult ) {
  86. return [
  87. execResult[ 1 ],
  88. execResult[ 2 ] / 100,
  89. execResult[ 3 ] / 100,
  90. execResult[ 4 ]
  91. ];
  92. }
  93. } ],
  94. // jQuery.Color( )
  95. color = jQuery.Color = function( color, green, blue, alpha ) {
  96. return new jQuery.Color.fn.parse( color, green, blue, alpha );
  97. },
  98. spaces = {
  99. rgba: {
  100. props: {
  101. red: {
  102. idx: 0,
  103. type: "byte"
  104. },
  105. green: {
  106. idx: 1,
  107. type: "byte"
  108. },
  109. blue: {
  110. idx: 2,
  111. type: "byte"
  112. }
  113. }
  114. },
  115. hsla: {
  116. props: {
  117. hue: {
  118. idx: 0,
  119. type: "degrees"
  120. },
  121. saturation: {
  122. idx: 1,
  123. type: "percent"
  124. },
  125. lightness: {
  126. idx: 2,
  127. type: "percent"
  128. }
  129. }
  130. }
  131. },
  132. propTypes = {
  133. "byte": {
  134. floor: true,
  135. max: 255
  136. },
  137. "percent": {
  138. max: 1
  139. },
  140. "degrees": {
  141. mod: 360,
  142. floor: true
  143. }
  144. },
  145. support = color.support = {},
  146. // element for support tests
  147. supportElem = jQuery( "<p>" )[ 0 ],
  148. // colors = jQuery.Color.names
  149. colors,
  150. // local aliases of functions called often
  151. each = jQuery.each;
  152. // determine rgba support immediately
  153. supportElem.style.cssText = "background-color:rgba(1,1,1,.5)";
  154. support.rgba = supportElem.style.backgroundColor.indexOf( "rgba" ) > -1;
  155. // define cache name and alpha properties
  156. // for rgba and hsla spaces
  157. each( spaces, function( spaceName, space ) {
  158. space.cache = "_" + spaceName;
  159. space.props.alpha = {
  160. idx: 3,
  161. type: "percent",
  162. def: 1
  163. };
  164. });
  165. function clamp( value, prop, allowEmpty ) {
  166. var type = propTypes[ prop.type ] || {};
  167. if ( value == null ) {
  168. return (allowEmpty || !prop.def) ? null : prop.def;
  169. }
  170. // ~~ is an short way of doing floor for positive numbers
  171. value = type.floor ? ~~value : parseFloat( value );
  172. // IE will pass in empty strings as value for alpha,
  173. // which will hit this case
  174. if ( isNaN( value ) ) {
  175. return prop.def;
  176. }
  177. if ( type.mod ) {
  178. // we add mod before modding to make sure that negatives values
  179. // get converted properly: -10 -> 350
  180. return (value + type.mod) % type.mod;
  181. }
  182. // for now all property types without mod have min and max
  183. return 0 > value ? 0 : type.max < value ? type.max : value;
  184. }
  185. function stringParse( string ) {
  186. var inst = color(),
  187. rgba = inst._rgba = [];
  188. string = string.toLowerCase();
  189. each( stringParsers, function( i, parser ) {
  190. var parsed,
  191. match = parser.re.exec( string ),
  192. values = match && parser.parse( match ),
  193. spaceName = parser.space || "rgba";
  194. if ( values ) {
  195. parsed = inst[ spaceName ]( values );
  196. // if this was an rgba parse the assignment might happen twice
  197. // oh well....
  198. inst[ spaces[ spaceName ].cache ] = parsed[ spaces[ spaceName ].cache ];
  199. rgba = inst._rgba = parsed._rgba;
  200. // exit each( stringParsers ) here because we matched
  201. return false;
  202. }
  203. });
  204. // Found a stringParser that handled it
  205. if ( rgba.length ) {
  206. // if this came from a parsed string, force "transparent" when alpha is 0
  207. // chrome, (and maybe others) return "transparent" as rgba(0,0,0,0)
  208. if ( rgba.join() === "0,0,0,0" ) {
  209. jQuery.extend( rgba, colors.transparent );
  210. }
  211. return inst;
  212. }
  213. // named colors
  214. return colors[ string ];
  215. }
  216. color.fn = jQuery.extend( color.prototype, {
  217. parse: function( red, green, blue, alpha ) {
  218. if ( red === undefined ) {
  219. this._rgba = [ null, null, null, null ];
  220. return this;
  221. }
  222. if ( red.jquery || red.nodeType ) {
  223. red = jQuery( red ).css( green );
  224. green = undefined;
  225. }
  226. var inst = this,
  227. type = jQuery.type( red ),
  228. rgba = this._rgba = [];
  229. // more than 1 argument specified - assume ( red, green, blue, alpha )
  230. if ( green !== undefined ) {
  231. red = [ red, green, blue, alpha ];
  232. type = "array";
  233. }
  234. if ( type === "string" ) {
  235. return this.parse( stringParse( red ) || colors._default );
  236. }
  237. if ( type === "array" ) {
  238. each( spaces.rgba.props, function( key, prop ) {
  239. rgba[ prop.idx ] = clamp( red[ prop.idx ], prop );
  240. });
  241. return this;
  242. }
  243. if ( type === "object" ) {
  244. if ( red instanceof color ) {
  245. each( spaces, function( spaceName, space ) {
  246. if ( red[ space.cache ] ) {
  247. inst[ space.cache ] = red[ space.cache ].slice();
  248. }
  249. });
  250. } else {
  251. each( spaces, function( spaceName, space ) {
  252. var cache = space.cache;
  253. each( space.props, function( key, prop ) {
  254. // if the cache doesn't exist, and we know how to convert
  255. if ( !inst[ cache ] && space.to ) {
  256. // if the value was null, we don't need to copy it
  257. // if the key was alpha, we don't need to copy it either
  258. if ( key === "alpha" || red[ key ] == null ) {
  259. return;
  260. }
  261. inst[ cache ] = space.to( inst._rgba );
  262. }
  263. // this is the only case where we allow nulls for ALL properties.
  264. // call clamp with alwaysAllowEmpty
  265. inst[ cache ][ prop.idx ] = clamp( red[ key ], prop, true );
  266. });
  267. // everything defined but alpha?
  268. if ( inst[ cache ] && jQuery.inArray( null, inst[ cache ].slice( 0, 3 ) ) < 0 ) {
  269. // use the default of 1
  270. inst[ cache ][ 3 ] = 1;
  271. if ( space.from ) {
  272. inst._rgba = space.from( inst[ cache ] );
  273. }
  274. }
  275. });
  276. }
  277. return this;
  278. }
  279. },
  280. is: function( compare ) {
  281. var is = color( compare ),
  282. same = true,
  283. inst = this;
  284. each( spaces, function( _, space ) {
  285. var localCache,
  286. isCache = is[ space.cache ];
  287. if (isCache) {
  288. localCache = inst[ space.cache ] || space.to && space.to( inst._rgba ) || [];
  289. each( space.props, function( _, prop ) {
  290. if ( isCache[ prop.idx ] != null ) {
  291. same = ( isCache[ prop.idx ] === localCache[ prop.idx ] );
  292. return same;
  293. }
  294. });
  295. }
  296. return same;
  297. });
  298. return same;
  299. },
  300. _space: function() {
  301. var used = [],
  302. inst = this;
  303. each( spaces, function( spaceName, space ) {
  304. if ( inst[ space.cache ] ) {
  305. used.push( spaceName );
  306. }
  307. });
  308. return used.pop();
  309. },
  310. transition: function( other, distance ) {
  311. var end = color( other ),
  312. spaceName = end._space(),
  313. space = spaces[ spaceName ],
  314. startColor = this.alpha() === 0 ? color( "transparent" ) : this,
  315. start = startColor[ space.cache ] || space.to( startColor._rgba ),
  316. result = start.slice();
  317. end = end[ space.cache ];
  318. each( space.props, function( key, prop ) {
  319. var index = prop.idx,
  320. startValue = start[ index ],
  321. endValue = end[ index ],
  322. type = propTypes[ prop.type ] || {};
  323. // if null, don't override start value
  324. if ( endValue === null ) {
  325. return;
  326. }
  327. // if null - use end
  328. if ( startValue === null ) {
  329. result[ index ] = endValue;
  330. } else {
  331. if ( type.mod ) {
  332. if ( endValue - startValue > type.mod / 2 ) {
  333. startValue += type.mod;
  334. } else if ( startValue - endValue > type.mod / 2 ) {
  335. startValue -= type.mod;
  336. }
  337. }
  338. result[ index ] = clamp( ( endValue - startValue ) * distance + startValue, prop );
  339. }
  340. });
  341. return this[ spaceName ]( result );
  342. },
  343. blend: function( opaque ) {
  344. // if we are already opaque - return ourself
  345. if ( this._rgba[ 3 ] === 1 ) {
  346. return this;
  347. }
  348. var rgb = this._rgba.slice(),
  349. a = rgb.pop(),
  350. blend = color( opaque )._rgba;
  351. return color( jQuery.map( rgb, function( v, i ) {
  352. return ( 1 - a ) * blend[ i ] + a * v;
  353. }));
  354. },
  355. toRgbaString: function() {
  356. var prefix = "rgba(",
  357. rgba = jQuery.map( this._rgba, function( v, i ) {
  358. return v == null ? ( i > 2 ? 1 : 0 ) : v;
  359. });
  360. if ( rgba[ 3 ] === 1 ) {
  361. rgba.pop();
  362. prefix = "rgb(";
  363. }
  364. return prefix + rgba.join() + ")";
  365. },
  366. toHslaString: function() {
  367. var prefix = "hsla(",
  368. hsla = jQuery.map( this.hsla(), function( v, i ) {
  369. if ( v == null ) {
  370. v = i > 2 ? 1 : 0;
  371. }
  372. // catch 1 and 2
  373. if ( i && i < 3 ) {
  374. v = Math.round( v * 100 ) + "%";
  375. }
  376. return v;
  377. });
  378. if ( hsla[ 3 ] === 1 ) {
  379. hsla.pop();
  380. prefix = "hsl(";
  381. }
  382. return prefix + hsla.join() + ")";
  383. },
  384. toHexString: function( includeAlpha ) {
  385. var rgba = this._rgba.slice(),
  386. alpha = rgba.pop();
  387. if ( includeAlpha ) {
  388. rgba.push( ~~( alpha * 255 ) );
  389. }
  390. return "#" + jQuery.map( rgba, function( v ) {
  391. // default to 0 when nulls exist
  392. v = ( v || 0 ).toString( 16 );
  393. return v.length === 1 ? "0" + v : v;
  394. }).join("");
  395. },
  396. toString: function() {
  397. return this._rgba[ 3 ] === 0 ? "transparent" : this.toRgbaString();
  398. }
  399. });
  400. color.fn.parse.prototype = color.fn;
  401. // hsla conversions adapted from:
  402. // https://code.google.com/p/maashaack/source/browse/packages/graphics/trunk/src/graphics/colors/HUE2RGB.as?r=5021
  403. function hue2rgb( p, q, h ) {
  404. h = ( h + 1 ) % 1;
  405. if ( h * 6 < 1 ) {
  406. return p + ( q - p ) * h * 6;
  407. }
  408. if ( h * 2 < 1) {
  409. return q;
  410. }
  411. if ( h * 3 < 2 ) {
  412. return p + ( q - p ) * ( ( 2 / 3 ) - h ) * 6;
  413. }
  414. return p;
  415. }
  416. spaces.hsla.to = function( rgba ) {
  417. if ( rgba[ 0 ] == null || rgba[ 1 ] == null || rgba[ 2 ] == null ) {
  418. return [ null, null, null, rgba[ 3 ] ];
  419. }
  420. var r = rgba[ 0 ] / 255,
  421. g = rgba[ 1 ] / 255,
  422. b = rgba[ 2 ] / 255,
  423. a = rgba[ 3 ],
  424. max = Math.max( r, g, b ),
  425. min = Math.min( r, g, b ),
  426. diff = max - min,
  427. add = max + min,
  428. l = add * 0.5,
  429. h, s;
  430. if ( min === max ) {
  431. h = 0;
  432. } else if ( r === max ) {
  433. h = ( 60 * ( g - b ) / diff ) + 360;
  434. } else if ( g === max ) {
  435. h = ( 60 * ( b - r ) / diff ) + 120;
  436. } else {
  437. h = ( 60 * ( r - g ) / diff ) + 240;
  438. }
  439. // chroma (diff) == 0 means greyscale which, by definition, saturation = 0%
  440. // otherwise, saturation is based on the ratio of chroma (diff) to lightness (add)
  441. if ( diff === 0 ) {
  442. s = 0;
  443. } else if ( l <= 0.5 ) {
  444. s = diff / add;
  445. } else {
  446. s = diff / ( 2 - add );
  447. }
  448. return [ Math.round(h) % 360, s, l, a == null ? 1 : a ];
  449. };
  450. spaces.hsla.from = function( hsla ) {
  451. if ( hsla[ 0 ] == null || hsla[ 1 ] == null || hsla[ 2 ] == null ) {
  452. return [ null, null, null, hsla[ 3 ] ];
  453. }
  454. var h = hsla[ 0 ] / 360,
  455. s = hsla[ 1 ],
  456. l = hsla[ 2 ],
  457. a = hsla[ 3 ],
  458. q = l <= 0.5 ? l * ( 1 + s ) : l + s - l * s,
  459. p = 2 * l - q;
  460. return [
  461. Math.round( hue2rgb( p, q, h + ( 1 / 3 ) ) * 255 ),
  462. Math.round( hue2rgb( p, q, h ) * 255 ),
  463. Math.round( hue2rgb( p, q, h - ( 1 / 3 ) ) * 255 ),
  464. a
  465. ];
  466. };
  467. each( spaces, function( spaceName, space ) {
  468. var props = space.props,
  469. cache = space.cache,
  470. to = space.to,
  471. from = space.from;
  472. // makes rgba() and hsla()
  473. color.fn[ spaceName ] = function( value ) {
  474. // generate a cache for this space if it doesn't exist
  475. if ( to && !this[ cache ] ) {
  476. this[ cache ] = to( this._rgba );
  477. }
  478. if ( value === undefined ) {
  479. return this[ cache ].slice();
  480. }
  481. var ret,
  482. type = jQuery.type( value ),
  483. arr = ( type === "array" || type === "object" ) ? value : arguments,
  484. local = this[ cache ].slice();
  485. each( props, function( key, prop ) {
  486. var val = arr[ type === "object" ? key : prop.idx ];
  487. if ( val == null ) {
  488. val = local[ prop.idx ];
  489. }
  490. local[ prop.idx ] = clamp( val, prop );
  491. });
  492. if ( from ) {
  493. ret = color( from( local ) );
  494. ret[ cache ] = local;
  495. return ret;
  496. } else {
  497. return color( local );
  498. }
  499. };
  500. // makes red() green() blue() alpha() hue() saturation() lightness()
  501. each( props, function( key, prop ) {
  502. // alpha is included in more than one space
  503. if ( color.fn[ key ] ) {
  504. return;
  505. }
  506. color.fn[ key ] = function( value ) {
  507. var vtype = jQuery.type( value ),
  508. fn = ( key === "alpha" ? ( this._hsla ? "hsla" : "rgba" ) : spaceName ),
  509. local = this[ fn ](),
  510. cur = local[ prop.idx ],
  511. match;
  512. if ( vtype === "undefined" ) {
  513. return cur;
  514. }
  515. if ( vtype === "function" ) {
  516. value = value.call( this, cur );
  517. vtype = jQuery.type( value );
  518. }
  519. if ( value == null && prop.empty ) {
  520. return this;
  521. }
  522. if ( vtype === "string" ) {
  523. match = rplusequals.exec( value );
  524. if ( match ) {
  525. value = cur + parseFloat( match[ 2 ] ) * ( match[ 1 ] === "+" ? 1 : -1 );
  526. }
  527. }
  528. local[ prop.idx ] = value;
  529. return this[ fn ]( local );
  530. };
  531. });
  532. });
  533. // add cssHook and .fx.step function for each named hook.
  534. // accept a space separated string of properties
  535. color.hook = function( hook ) {
  536. var hooks = hook.split( " " );
  537. each( hooks, function( i, hook ) {
  538. jQuery.cssHooks[ hook ] = {
  539. set: function( elem, value ) {
  540. var parsed, curElem,
  541. backgroundColor = "";
  542. if ( value !== "transparent" && ( jQuery.type( value ) !== "string" || ( parsed = stringParse( value ) ) ) ) {
  543. value = color( parsed || value );
  544. if ( !support.rgba && value._rgba[ 3 ] !== 1 ) {
  545. curElem = hook === "backgroundColor" ? elem.parentNode : elem;
  546. while (
  547. (backgroundColor === "" || backgroundColor === "transparent") &&
  548. curElem && curElem.style
  549. ) {
  550. try {
  551. backgroundColor = jQuery.css( curElem, "backgroundColor" );
  552. curElem = curElem.parentNode;
  553. } catch ( e ) {
  554. }
  555. }
  556. value = value.blend( backgroundColor && backgroundColor !== "transparent" ?
  557. backgroundColor :
  558. "_default" );
  559. }
  560. value = value.toRgbaString();
  561. }
  562. try {
  563. elem.style[ hook ] = value;
  564. } catch ( e ) {
  565. // wrapped to prevent IE from throwing errors on "invalid" values like 'auto' or 'inherit'
  566. }
  567. }
  568. };
  569. jQuery.fx.step[ hook ] = function( fx ) {
  570. if ( !fx.colorInit ) {
  571. fx.start = color( fx.elem, hook );
  572. fx.end = color( fx.end );
  573. fx.colorInit = true;
  574. }
  575. jQuery.cssHooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) );
  576. };
  577. });
  578. };
  579. color.hook( stepHooks );
  580. jQuery.cssHooks.borderColor = {
  581. expand: function( value ) {
  582. var expanded = {};
  583. each( [ "Top", "Right", "Bottom", "Left" ], function( i, part ) {
  584. expanded[ "border" + part + "Color" ] = value;
  585. });
  586. return expanded;
  587. }
  588. };
  589. // Basic color names only.
  590. // Usage of any of the other color names requires adding yourself or including
  591. // jquery.color.svg-names.js.
  592. colors = jQuery.Color.names = {
  593. // 4.1. Basic color keywords
  594. aqua: "#00ffff",
  595. black: "#000000",
  596. blue: "#0000ff",
  597. fuchsia: "#ff00ff",
  598. gray: "#808080",
  599. green: "#008000",
  600. lime: "#00ff00",
  601. maroon: "#800000",
  602. navy: "#000080",
  603. olive: "#808000",
  604. purple: "#800080",
  605. red: "#ff0000",
  606. silver: "#c0c0c0",
  607. teal: "#008080",
  608. white: "#ffffff",
  609. yellow: "#ffff00",
  610. // 4.2.3. "transparent" color keyword
  611. transparent: [ null, null, null, 0 ],
  612. _default: "#ffffff"
  613. };
  614. })( jQuery );
  615. /******************************************************************************/
  616. /****************************** CLASS ANIMATIONS ******************************/
  617. /******************************************************************************/
  618. (function() {
  619. var classAnimationActions = [ "add", "remove", "toggle" ],
  620. shorthandStyles = {
  621. border: 1,
  622. borderBottom: 1,
  623. borderColor: 1,
  624. borderLeft: 1,
  625. borderRight: 1,
  626. borderTop: 1,
  627. borderWidth: 1,
  628. margin: 1,
  629. padding: 1
  630. };
  631. $.each([ "borderLeftStyle", "borderRightStyle", "borderBottomStyle", "borderTopStyle" ], function( _, prop ) {
  632. $.fx.step[ prop ] = function( fx ) {
  633. if ( fx.end !== "none" && !fx.setAttr || fx.pos === 1 && !fx.setAttr ) {
  634. jQuery.style( fx.elem, prop, fx.end );
  635. fx.setAttr = true;
  636. }
  637. };
  638. });
  639. function getElementStyles( elem ) {
  640. var key, len,
  641. style = elem.ownerDocument.defaultView ?
  642. elem.ownerDocument.defaultView.getComputedStyle( elem, null ) :
  643. elem.currentStyle,
  644. styles = {};
  645. if ( style && style.length && style[ 0 ] && style[ style[ 0 ] ] ) {
  646. len = style.length;
  647. while ( len-- ) {
  648. key = style[ len ];
  649. if ( typeof style[ key ] === "string" ) {
  650. styles[ $.camelCase( key ) ] = style[ key ];
  651. }
  652. }
  653. // support: Opera, IE <9
  654. } else {
  655. for ( key in style ) {
  656. if ( typeof style[ key ] === "string" ) {
  657. styles[ key ] = style[ key ];
  658. }
  659. }
  660. }
  661. return styles;
  662. }
  663. function styleDifference( oldStyle, newStyle ) {
  664. var diff = {},
  665. name, value;
  666. for ( name in newStyle ) {
  667. value = newStyle[ name ];
  668. if ( oldStyle[ name ] !== value ) {
  669. if ( !shorthandStyles[ name ] ) {
  670. if ( $.fx.step[ name ] || !isNaN( parseFloat( value ) ) ) {
  671. diff[ name ] = value;
  672. }
  673. }
  674. }
  675. }
  676. return diff;
  677. }
  678. // support: jQuery <1.8
  679. if ( !$.fn.addBack ) {
  680. $.fn.addBack = function( selector ) {
  681. return this.add( selector == null ?
  682. this.prevObject : this.prevObject.filter( selector )
  683. );
  684. };
  685. }
  686. $.effects.animateClass = function( value, duration, easing, callback ) {
  687. var o = $.speed( duration, easing, callback );
  688. return this.queue( function() {
  689. var animated = $( this ),
  690. baseClass = animated.attr( "class" ) || "",
  691. applyClassChange,
  692. allAnimations = o.children ? animated.find( "*" ).addBack() : animated;
  693. // map the animated objects to store the original styles.
  694. allAnimations = allAnimations.map(function() {
  695. var el = $( this );
  696. return {
  697. el: el,
  698. start: getElementStyles( this )
  699. };
  700. });
  701. // apply class change
  702. applyClassChange = function() {
  703. $.each( classAnimationActions, function(i, action) {
  704. if ( value[ action ] ) {
  705. animated[ action + "Class" ]( value[ action ] );
  706. }
  707. });
  708. };
  709. applyClassChange();
  710. // map all animated objects again - calculate new styles and diff
  711. allAnimations = allAnimations.map(function() {
  712. this.end = getElementStyles( this.el[ 0 ] );
  713. this.diff = styleDifference( this.start, this.end );
  714. return this;
  715. });
  716. // apply original class
  717. animated.attr( "class", baseClass );
  718. // map all animated objects again - this time collecting a promise
  719. allAnimations = allAnimations.map(function() {
  720. var styleInfo = this,
  721. dfd = $.Deferred(),
  722. opts = $.extend({}, o, {
  723. queue: false,
  724. complete: function() {
  725. dfd.resolve( styleInfo );
  726. }
  727. });
  728. this.el.animate( this.diff, opts );
  729. return dfd.promise();
  730. });
  731. // once all animations have completed:
  732. $.when.apply( $, allAnimations.get() ).done(function() {
  733. // set the final class
  734. applyClassChange();
  735. // for each animated element,
  736. // clear all css properties that were animated
  737. $.each( arguments, function() {
  738. var el = this.el;
  739. $.each( this.diff, function(key) {
  740. el.css( key, "" );
  741. });
  742. });
  743. // this is guarnteed to be there if you use jQuery.speed()
  744. // it also handles dequeuing the next anim...
  745. o.complete.call( animated[ 0 ] );
  746. });
  747. });
  748. };
  749. $.fn.extend({
  750. addClass: (function( orig ) {
  751. return function( classNames, speed, easing, callback ) {
  752. return speed ?
  753. $.effects.animateClass.call( this,
  754. { add: classNames }, speed, easing, callback ) :
  755. orig.apply( this, arguments );
  756. };
  757. })( $.fn.addClass ),
  758. removeClass: (function( orig ) {
  759. return function( classNames, speed, easing, callback ) {
  760. return arguments.length > 1 ?
  761. $.effects.animateClass.call( this,
  762. { remove: classNames }, speed, easing, callback ) :
  763. orig.apply( this, arguments );
  764. };
  765. })( $.fn.removeClass ),
  766. toggleClass: (function( orig ) {
  767. return function( classNames, force, speed, easing, callback ) {
  768. if ( typeof force === "boolean" || force === undefined ) {
  769. if ( !speed ) {
  770. // without speed parameter
  771. return orig.apply( this, arguments );
  772. } else {
  773. return $.effects.animateClass.call( this,
  774. (force ? { add: classNames } : { remove: classNames }),
  775. speed, easing, callback );
  776. }
  777. } else {
  778. // without force parameter
  779. return $.effects.animateClass.call( this,
  780. { toggle: classNames }, force, speed, easing );
  781. }
  782. };
  783. })( $.fn.toggleClass ),
  784. switchClass: function( remove, add, speed, easing, callback) {
  785. return $.effects.animateClass.call( this, {
  786. add: add,
  787. remove: remove
  788. }, speed, easing, callback );
  789. }
  790. });
  791. })();
  792. /******************************************************************************/
  793. /*********************************** EFFECTS **********************************/
  794. /******************************************************************************/
  795. (function() {
  796. $.extend( $.effects, {
  797. version: "1.11.4",
  798. // Saves a set of properties in a data storage
  799. save: function( element, set ) {
  800. for ( var i = 0; i < set.length; i++ ) {
  801. if ( set[ i ] !== null ) {
  802. element.data( dataSpace + set[ i ], element[ 0 ].style[ set[ i ] ] );
  803. }
  804. }
  805. },
  806. // Restores a set of previously saved properties from a data storage
  807. restore: function( element, set ) {
  808. var val, i;
  809. for ( i = 0; i < set.length; i++ ) {
  810. if ( set[ i ] !== null ) {
  811. val = element.data( dataSpace + set[ i ] );
  812. // support: jQuery 1.6.2
  813. // http://bugs.jquery.com/ticket/9917
  814. // jQuery 1.6.2 incorrectly returns undefined for any falsy value.
  815. // We can't differentiate between "" and 0 here, so we just assume
  816. // empty string since it's likely to be a more common value...
  817. if ( val === undefined ) {
  818. val = "";
  819. }
  820. element.css( set[ i ], val );
  821. }
  822. }
  823. },
  824. setMode: function( el, mode ) {
  825. if (mode === "toggle") {
  826. mode = el.is( ":hidden" ) ? "show" : "hide";
  827. }
  828. return mode;
  829. },
  830. // Translates a [top,left] array into a baseline value
  831. // this should be a little more flexible in the future to handle a string & hash
  832. getBaseline: function( origin, original ) {
  833. var y, x;
  834. switch ( origin[ 0 ] ) {
  835. case "top": y = 0; break;
  836. case "middle": y = 0.5; break;
  837. case "bottom": y = 1; break;
  838. default: y = origin[ 0 ] / original.height;
  839. }
  840. switch ( origin[ 1 ] ) {
  841. case "left": x = 0; break;
  842. case "center": x = 0.5; break;
  843. case "right": x = 1; break;
  844. default: x = origin[ 1 ] / original.width;
  845. }
  846. return {
  847. x: x,
  848. y: y
  849. };
  850. },
  851. // Wraps the element around a wrapper that copies position properties
  852. createWrapper: function( element ) {
  853. // if the element is already wrapped, return it
  854. if ( element.parent().is( ".ui-effects-wrapper" )) {
  855. return element.parent();
  856. }
  857. // wrap the element
  858. var props = {
  859. width: element.outerWidth(true),
  860. height: element.outerHeight(true),
  861. "float": element.css( "float" )
  862. },
  863. wrapper = $( "<div></div>" )
  864. .addClass( "ui-effects-wrapper" )
  865. .css({
  866. fontSize: "100%",
  867. background: "transparent",
  868. border: "none",
  869. margin: 0,
  870. padding: 0
  871. }),
  872. // Store the size in case width/height are defined in % - Fixes #5245
  873. size = {
  874. width: element.width(),
  875. height: element.height()
  876. },
  877. active = document.activeElement;
  878. // support: Firefox
  879. // Firefox incorrectly exposes anonymous content
  880. // https://bugzilla.mozilla.org/show_bug.cgi?id=561664
  881. try {
  882. active.id;
  883. } catch ( e ) {
  884. active = document.body;
  885. }
  886. element.wrap( wrapper );
  887. // Fixes #7595 - Elements lose focus when wrapped.
  888. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  889. $( active ).focus();
  890. }
  891. wrapper = element.parent(); //Hotfix for jQuery 1.4 since some change in wrap() seems to actually lose the reference to the wrapped element
  892. // transfer positioning properties to the wrapper
  893. if ( element.css( "position" ) === "static" ) {
  894. wrapper.css({ position: "relative" });
  895. element.css({ position: "relative" });
  896. } else {
  897. $.extend( props, {
  898. position: element.css( "position" ),
  899. zIndex: element.css( "z-index" )
  900. });
  901. $.each([ "top", "left", "bottom", "right" ], function(i, pos) {
  902. props[ pos ] = element.css( pos );
  903. if ( isNaN( parseInt( props[ pos ], 10 ) ) ) {
  904. props[ pos ] = "auto";
  905. }
  906. });
  907. element.css({
  908. position: "relative",
  909. top: 0,
  910. left: 0,
  911. right: "auto",
  912. bottom: "auto"
  913. });
  914. }
  915. element.css(size);
  916. return wrapper.css( props ).show();
  917. },
  918. removeWrapper: function( element ) {
  919. var active = document.activeElement;
  920. if ( element.parent().is( ".ui-effects-wrapper" ) ) {
  921. element.parent().replaceWith( element );
  922. // Fixes #7595 - Elements lose focus when wrapped.
  923. if ( element[ 0 ] === active || $.contains( element[ 0 ], active ) ) {
  924. $( active ).focus();
  925. }
  926. }
  927. return element;
  928. },
  929. setTransition: function( element, list, factor, value ) {
  930. value = value || {};
  931. $.each( list, function( i, x ) {
  932. var unit = element.cssUnit( x );
  933. if ( unit[ 0 ] > 0 ) {
  934. value[ x ] = unit[ 0 ] * factor + unit[ 1 ];
  935. }
  936. });
  937. return value;
  938. }
  939. });
  940. // return an effect options object for the given parameters:
  941. function _normalizeArguments( effect, options, speed, callback ) {
  942. // allow passing all options as the first parameter
  943. if ( $.isPlainObject( effect ) ) {
  944. options = effect;
  945. effect = effect.effect;
  946. }
  947. // convert to an object
  948. effect = { effect: effect };
  949. // catch (effect, null, ...)
  950. if ( options == null ) {
  951. options = {};
  952. }
  953. // catch (effect, callback)
  954. if ( $.isFunction( options ) ) {
  955. callback = options;
  956. speed = null;
  957. options = {};
  958. }
  959. // catch (effect, speed, ?)
  960. if ( typeof options === "number" || $.fx.speeds[ options ] ) {
  961. callback = speed;
  962. speed = options;
  963. options = {};
  964. }
  965. // catch (effect, options, callback)
  966. if ( $.isFunction( speed ) ) {
  967. callback = speed;
  968. speed = null;
  969. }
  970. // add options to effect
  971. if ( options ) {
  972. $.extend( effect, options );
  973. }
  974. speed = speed || options.duration;
  975. effect.duration = $.fx.off ? 0 :
  976. typeof speed === "number" ? speed :
  977. speed in $.fx.speeds ? $.fx.speeds[ speed ] :
  978. $.fx.speeds._default;
  979. effect.complete = callback || options.complete;
  980. return effect;
  981. }
  982. function standardAnimationOption( option ) {
  983. // Valid standard speeds (nothing, number, named speed)
  984. if ( !option || typeof option === "number" || $.fx.speeds[ option ] ) {
  985. return true;
  986. }
  987. // Invalid strings - treat as "normal" speed
  988. if ( typeof option === "string" && !$.effects.effect[ option ] ) {
  989. return true;
  990. }
  991. // Complete callback
  992. if ( $.isFunction( option ) ) {
  993. return true;
  994. }
  995. // Options hash (but not naming an effect)
  996. if ( typeof option === "object" && !option.effect ) {
  997. return true;
  998. }
  999. // Didn't match any standard API
  1000. return false;
  1001. }
  1002. $.fn.extend({
  1003. effect: function( /* effect, options, speed, callback */ ) {
  1004. var args = _normalizeArguments.apply( this, arguments ),
  1005. mode = args.mode,
  1006. queue = args.queue,
  1007. effectMethod = $.effects.effect[ args.effect ];
  1008. if ( $.fx.off || !effectMethod ) {
  1009. // delegate to the original method (e.g., .show()) if possible
  1010. if ( mode ) {
  1011. return this[ mode ]( args.duration, args.complete );
  1012. } else {
  1013. return this.each( function() {
  1014. if ( args.complete ) {
  1015. args.complete.call( this );
  1016. }
  1017. });
  1018. }
  1019. }
  1020. function run( next ) {
  1021. var elem = $( this ),
  1022. complete = args.complete,
  1023. mode = args.mode;
  1024. function done() {
  1025. if ( $.isFunction( complete ) ) {
  1026. complete.call( elem[0] );
  1027. }
  1028. if ( $.isFunction( next ) ) {
  1029. next();
  1030. }
  1031. }
  1032. // If the element already has the correct final state, delegate to
  1033. // the core methods so the internal tracking of "olddisplay" works.
  1034. if ( elem.is( ":hidden" ) ? mode === "hide" : mode === "show" ) {
  1035. elem[ mode ]();
  1036. done();
  1037. } else {
  1038. effectMethod.call( elem[0], args, done );
  1039. }
  1040. }
  1041. return queue === false ? this.each( run ) : this.queue( queue || "fx", run );
  1042. },
  1043. show: (function( orig ) {
  1044. return function( option ) {
  1045. if ( standardAnimationOption( option ) ) {
  1046. return orig.apply( this, arguments );
  1047. } else {
  1048. var args = _normalizeArguments.apply( this, arguments );
  1049. args.mode = "show";
  1050. return this.effect.call( this, args );
  1051. }
  1052. };
  1053. })( $.fn.show ),
  1054. hide: (function( orig ) {
  1055. return function( option ) {
  1056. if ( standardAnimationOption( option ) ) {
  1057. return orig.apply( this, arguments );
  1058. } else {
  1059. var args = _normalizeArguments.apply( this, arguments );
  1060. args.mode = "hide";
  1061. return this.effect.call( this, args );
  1062. }
  1063. };
  1064. })( $.fn.hide ),
  1065. toggle: (function( orig ) {
  1066. return function( option ) {
  1067. if ( standardAnimationOption( option ) || typeof option === "boolean" ) {
  1068. return orig.apply( this, arguments );
  1069. } else {
  1070. var args = _normalizeArguments.apply( this, arguments );
  1071. args.mode = "toggle";
  1072. return this.effect.call( this, args );
  1073. }
  1074. };
  1075. })( $.fn.toggle ),
  1076. // helper functions
  1077. cssUnit: function(key) {
  1078. var style = this.css( key ),
  1079. val = [];
  1080. $.each( [ "em", "px", "%", "pt" ], function( i, unit ) {
  1081. if ( style.indexOf( unit ) > 0 ) {
  1082. val = [ parseFloat( style ), unit ];
  1083. }
  1084. });
  1085. return val;
  1086. }
  1087. });
  1088. })();
  1089. /******************************************************************************/
  1090. /*********************************** EASING ***********************************/
  1091. /******************************************************************************/
  1092. (function() {
  1093. // based on easing equations from Robert Penner (http://www.robertpenner.com/easing)
  1094. var baseEasings = {};
  1095. $.each( [ "Quad", "Cubic", "Quart", "Quint", "Expo" ], function( i, name ) {
  1096. baseEasings[ name ] = function( p ) {
  1097. return Math.pow( p, i + 2 );
  1098. };
  1099. });
  1100. $.extend( baseEasings, {
  1101. Sine: function( p ) {
  1102. return 1 - Math.cos( p * Math.PI / 2 );
  1103. },
  1104. Circ: function( p ) {
  1105. return 1 - Math.sqrt( 1 - p * p );
  1106. },
  1107. Elastic: function( p ) {
  1108. return p === 0 || p === 1 ? p :
  1109. -Math.pow( 2, 8 * (p - 1) ) * Math.sin( ( (p - 1) * 80 - 7.5 ) * Math.PI / 15 );
  1110. },
  1111. Back: function( p ) {
  1112. return p * p * ( 3 * p - 2 );
  1113. },
  1114. Bounce: function( p ) {
  1115. var pow2,
  1116. bounce = 4;
  1117. while ( p < ( ( pow2 = Math.pow( 2, --bounce ) ) - 1 ) / 11 ) {}
  1118. return 1 / Math.pow( 4, 3 - bounce ) - 7.5625 * Math.pow( ( pow2 * 3 - 2 ) / 22 - p, 2 );
  1119. }
  1120. });
  1121. $.each( baseEasings, function( name, easeIn ) {
  1122. $.easing[ "easeIn" + name ] = easeIn;
  1123. $.easing[ "easeOut" + name ] = function( p ) {
  1124. return 1 - easeIn( 1 - p );
  1125. };
  1126. $.easing[ "easeInOut" + name ] = function( p ) {
  1127. return p < 0.5 ?
  1128. easeIn( p * 2 ) / 2 :
  1129. 1 - easeIn( p * -2 + 2 ) / 2;
  1130. };
  1131. });
  1132. })();
  1133. return $.effects;
  1134. }));