You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1013 lines
32 KiB

9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
9 years ago
10 years ago
10 years ago
10 years ago
  1. /*!
  2. * # Semantic UI 2.0.0 - Transition
  3. * http://github.com/semantic-org/semantic-ui/
  4. *
  5. *
  6. * Copyright 2015 Contributors
  7. * Released under the MIT license
  8. * http://opensource.org/licenses/MIT
  9. *
  10. */
  11. ;(function ( $, window, document, undefined ) {
  12. "use strict";
  13. $.fn.transition = function() {
  14. var
  15. $allModules = $(this),
  16. moduleSelector = $allModules.selector || '',
  17. time = new Date().getTime(),
  18. performance = [],
  19. moduleArguments = arguments,
  20. query = moduleArguments[0],
  21. queryArguments = [].slice.call(arguments, 1),
  22. methodInvoked = (typeof query === 'string'),
  23. requestAnimationFrame = window.requestAnimationFrame
  24. || window.mozRequestAnimationFrame
  25. || window.webkitRequestAnimationFrame
  26. || window.msRequestAnimationFrame
  27. || function(callback) { setTimeout(callback, 0); },
  28. returnedValue
  29. ;
  30. $allModules
  31. .each(function(index) {
  32. var
  33. $module = $(this),
  34. element = this,
  35. // set at run time
  36. settings,
  37. instance,
  38. error,
  39. className,
  40. metadata,
  41. animationEnd,
  42. animationName,
  43. namespace,
  44. moduleNamespace,
  45. eventNamespace,
  46. module
  47. ;
  48. module = {
  49. initialize: function() {
  50. // get full settings
  51. settings = module.get.settings.apply(element, moduleArguments);
  52. // shorthand
  53. className = settings.className;
  54. error = settings.error;
  55. metadata = settings.metadata;
  56. // define namespace
  57. eventNamespace = '.' + settings.namespace;
  58. moduleNamespace = 'module-' + settings.namespace;
  59. instance = $module.data(moduleNamespace) || module;
  60. // get vendor specific events
  61. animationEnd = module.get.animationEndEvent();
  62. if(methodInvoked) {
  63. methodInvoked = module.invoke(query);
  64. }
  65. // method not invoked, lets run an animation
  66. if(methodInvoked === false) {
  67. module.verbose('Converted arguments into settings object', settings);
  68. if(settings.interval) {
  69. module.delay(settings.animate);
  70. }
  71. else {
  72. module.animate();
  73. }
  74. module.instantiate();
  75. }
  76. },
  77. instantiate: function() {
  78. module.verbose('Storing instance of module', module);
  79. instance = module;
  80. $module
  81. .data(moduleNamespace, instance)
  82. ;
  83. },
  84. destroy: function() {
  85. module.verbose('Destroying previous module for', element);
  86. $module
  87. .removeData(moduleNamespace)
  88. ;
  89. },
  90. refresh: function() {
  91. module.verbose('Refreshing display type on next animation');
  92. delete module.displayType;
  93. },
  94. forceRepaint: function() {
  95. module.verbose('Forcing element repaint');
  96. var
  97. $parentElement = $module.parent(),
  98. $nextElement = $module.next()
  99. ;
  100. if($nextElement.length === 0) {
  101. $module.detach().appendTo($parentElement);
  102. }
  103. else {
  104. $module.detach().insertBefore($nextElement);
  105. }
  106. },
  107. repaint: function() {
  108. module.verbose('Repainting element');
  109. var
  110. fakeAssignment = element.offsetWidth
  111. ;
  112. },
  113. delay: function(interval) {
  114. var
  115. isReverse = (settings.reverse === true),
  116. shouldReverse = (settings.reverse == 'auto' && module.get.direction() == className.outward),
  117. delay
  118. ;
  119. interval = (typeof interval !== undefined)
  120. ? interval
  121. : settings.interval
  122. ;
  123. delay = (isReverse || shouldReverse)
  124. ? ($allModules.length - index) * settings.interval
  125. : index * settings.interval
  126. ;
  127. module.debug('Delaying animation by', delay);
  128. setTimeout(module.animate, delay);
  129. },
  130. animate: function(overrideSettings) {
  131. settings = overrideSettings || settings;
  132. if(!module.is.supported()) {
  133. module.error(error.support);
  134. return false;
  135. }
  136. module.debug('Preparing animation', settings.animation);
  137. if(module.is.animating()) {
  138. if(settings.queue) {
  139. if(!settings.allowRepeats && module.has.direction() && module.is.occurring() && module.queuing !== true) {
  140. module.debug('Animation is currently occurring, preventing queueing same animation', settings.animation);
  141. }
  142. else {
  143. module.queue(settings.animation);
  144. }
  145. return false;
  146. }
  147. else if(!settings.allowRepeats && module.is.occurring()) {
  148. module.debug('Animation is already occurring, will not execute repeated animation', settings.animation);
  149. return false;
  150. }
  151. else {
  152. module.debug('New animation started, completing previous early', settings.animation);
  153. module.complete();
  154. }
  155. }
  156. if( module.can.animate() ) {
  157. module.set.animating(settings.animation);
  158. }
  159. else {
  160. module.error(error.noAnimation, settings.animation, element);
  161. }
  162. },
  163. reset: function() {
  164. module.debug('Resetting animation to beginning conditions');
  165. module.remove.animationCallbacks();
  166. module.restore.conditions();
  167. module.remove.animating();
  168. },
  169. queue: function(animation) {
  170. module.debug('Queueing animation of', animation);
  171. module.queuing = true;
  172. $module
  173. .one(animationEnd + '.queue' + eventNamespace, function() {
  174. module.queuing = false;
  175. module.repaint();
  176. module.animate.apply(this, settings);
  177. })
  178. ;
  179. },
  180. complete: function (event) {
  181. module.debug('Animation complete', settings.animation);
  182. module.remove.completeCallback();
  183. module.remove.failSafe();
  184. if(!module.is.looping()) {
  185. if( module.is.outward() ) {
  186. module.verbose('Animation is outward, hiding element');
  187. module.restore.conditions();
  188. module.hide();
  189. settings.onHide.call(this);
  190. }
  191. else if( module.is.inward() ) {
  192. module.verbose('Animation is outward, showing element');
  193. module.restore.conditions();
  194. module.show();
  195. settings.onShow.call(this);
  196. }
  197. else {
  198. module.restore.conditions();
  199. }
  200. module.remove.animation();
  201. module.remove.animating();
  202. }
  203. settings.onComplete.call(this);
  204. },
  205. has: {
  206. direction: function(animation) {
  207. var
  208. hasDirection = false
  209. ;
  210. animation = animation || settings.animation;
  211. if(typeof animation === 'string') {
  212. animation = animation.split(' ');
  213. $.each(animation, function(index, word){
  214. if(word === className.inward || word === className.outward) {
  215. hasDirection = true;
  216. }
  217. });
  218. }
  219. return hasDirection;
  220. },
  221. inlineDisplay: function() {
  222. var
  223. style = $module.attr('style') || ''
  224. ;
  225. return $.isArray(style.match(/display.*?;/, ''));
  226. }
  227. },
  228. set: {
  229. animating: function(animation) {
  230. animation = animation || settings.animation;
  231. if(!module.is.animating()) {
  232. module.save.conditions();
  233. }
  234. module.remove.direction();
  235. module.remove.completeCallback();
  236. if(module.can.transition() && !module.has.direction()) {
  237. module.set.direction();
  238. }
  239. module.remove.hidden();
  240. module.set.display();
  241. $module
  242. .addClass(className.animating + ' ' + className.transition + ' ' + animation)
  243. .one(animationEnd + '.complete' + eventNamespace, module.complete)
  244. ;
  245. if(settings.useFailSafe) {
  246. module.add.failSafe();
  247. }
  248. module.set.duration(settings.duration);
  249. settings.onStart.call(this);
  250. module.debug('Starting tween', animation, $module.attr('class'));
  251. },
  252. duration: function(animationName, duration) {
  253. duration = duration || settings.duration;
  254. duration = (typeof duration == 'number')
  255. ? duration + 'ms'
  256. : duration
  257. ;
  258. if(duration || duration === 0) {
  259. module.verbose('Setting animation duration', duration);
  260. $module
  261. .css({
  262. 'animation-duration': duration
  263. })
  264. ;
  265. }
  266. },
  267. display: function() {
  268. var
  269. style = module.get.style(),
  270. displayType = module.get.displayType(),
  271. overrideStyle = style + 'display: ' + displayType + ' !important;'
  272. ;
  273. $module.css('display', '');
  274. module.refresh();
  275. if( $module.css('display') !== displayType ) {
  276. module.verbose('Setting inline visibility to', displayType);
  277. $module
  278. .attr('style', overrideStyle)
  279. ;
  280. }
  281. },
  282. direction: function() {
  283. if($module.is(':visible') && !module.is.hidden()) {
  284. module.debug('Automatically determining the direction of animation', 'Outward');
  285. $module
  286. .removeClass(className.inward)
  287. .addClass(className.outward)
  288. ;
  289. }
  290. else {
  291. module.debug('Automatically determining the direction of animation', 'Inward');
  292. $module
  293. .removeClass(className.outward)
  294. .addClass(className.inward)
  295. ;
  296. }
  297. },
  298. looping: function() {
  299. module.debug('Transition set to loop');
  300. $module
  301. .addClass(className.looping)
  302. ;
  303. },
  304. hidden: function() {
  305. if(!module.is.hidden()) {
  306. $module
  307. .addClass(className.transition)
  308. .addClass(className.hidden)
  309. ;
  310. }
  311. if($module.css('display') !== 'none') {
  312. module.verbose('Overriding default display to hide element');
  313. $module
  314. .css('display', 'none')
  315. ;
  316. }
  317. },
  318. visible: function() {
  319. $module
  320. .addClass(className.transition)
  321. .addClass(className.visible)
  322. ;
  323. }
  324. },
  325. save: {
  326. displayType: function(displayType) {
  327. if(displayType !== 'none') {
  328. $module.data(metadata.displayType, displayType);
  329. }
  330. },
  331. transitionExists: function(animation, exists) {
  332. $.fn.transition.exists[animation] = exists;
  333. module.verbose('Saving existence of transition', animation, exists);
  334. },
  335. conditions: function() {
  336. $module.removeClass(settings.animation);
  337. module.remove.direction();
  338. module.cache = {
  339. className : $module.attr('class'),
  340. style : module.get.style()
  341. };
  342. module.verbose('Saving original attributes', module.cache);
  343. }
  344. },
  345. restore: {
  346. conditions: function() {
  347. if(module.cache === undefined) {
  348. return false;
  349. }
  350. if(module.cache.className) {
  351. $module.attr('class', module.cache.className);
  352. }
  353. else {
  354. $module.removeAttr('class');
  355. }
  356. if(module.cache.style) {
  357. module.verbose('Restoring original style attribute', module.cache.style);
  358. $module.attr('style', module.cache.style);
  359. }
  360. else {
  361. module.verbose('Clearing style attribute');
  362. $module.removeAttr('style');
  363. }
  364. module.verbose('Restoring original attributes', module.cache);
  365. }
  366. },
  367. add: {
  368. failSafe: function() {
  369. var
  370. duration = module.get.duration()
  371. ;
  372. module.timer = setTimeout(function() {
  373. $module.trigger(animationEnd);
  374. }, duration + settings.failSafeDelay);
  375. module.verbose('Adding fail safe timer', module.timer);
  376. }
  377. },
  378. remove: {
  379. animating: function() {
  380. $module.removeClass(className.animating);
  381. },
  382. animation: function() {
  383. $module
  384. .css({
  385. '-webkit-animation' : '',
  386. '-moz-animation' : '',
  387. '-ms-animation' : '',
  388. '-o-animation' : '',
  389. 'animation' : ''
  390. })
  391. ;
  392. },
  393. animationCallbacks: function() {
  394. module.remove.queueCallback();
  395. module.remove.completeCallback();
  396. },
  397. queueCallback: function() {
  398. $module.off('.queue' + eventNamespace);
  399. },
  400. completeCallback: function() {
  401. $module.off('.complete' + eventNamespace);
  402. },
  403. display: function() {
  404. $module.css('display', '');
  405. },
  406. direction: function() {
  407. $module
  408. .removeClass(className.inward)
  409. .removeClass(className.outward)
  410. ;
  411. },
  412. failSafe: function() {
  413. module.verbose('Removing fail safe timer', module.timer);
  414. if(module.timer) {
  415. clearTimeout(module.timer);
  416. }
  417. },
  418. hidden: function() {
  419. $module.removeClass(className.hidden);
  420. },
  421. visible: function() {
  422. $module.removeClass(className.visible);
  423. },
  424. looping: function() {
  425. module.debug('Transitions are no longer looping');
  426. if( module.is.looping() ) {
  427. module.reset();
  428. $module
  429. .removeClass(className.looping)
  430. ;
  431. }
  432. },
  433. transition: function() {
  434. $module
  435. .removeClass(className.visible)
  436. .removeClass(className.hidden)
  437. ;
  438. }
  439. },
  440. get: {
  441. settings: function(animation, duration, onComplete) {
  442. // single settings object
  443. if(typeof animation == 'object') {
  444. return $.extend(true, {}, $.fn.transition.settings, animation);
  445. }
  446. // all arguments provided
  447. else if(typeof onComplete == 'function') {
  448. return $.extend({}, $.fn.transition.settings, {
  449. animation : animation,
  450. onComplete : onComplete,
  451. duration : duration
  452. });
  453. }
  454. // only duration provided
  455. else if(typeof duration == 'string' || typeof duration == 'number') {
  456. return $.extend({}, $.fn.transition.settings, {
  457. animation : animation,
  458. duration : duration
  459. });
  460. }
  461. // duration is actually settings object
  462. else if(typeof duration == 'object') {
  463. return $.extend({}, $.fn.transition.settings, duration, {
  464. animation : animation
  465. });
  466. }
  467. // duration is actually callback
  468. else if(typeof duration == 'function') {
  469. return $.extend({}, $.fn.transition.settings, {
  470. animation : animation,
  471. onComplete : duration
  472. });
  473. }
  474. // only animation provided
  475. else {
  476. return $.extend({}, $.fn.transition.settings, {
  477. animation : animation
  478. });
  479. }
  480. return $.fn.transition.settings;
  481. },
  482. direction: function(animation) {
  483. // quickest manually specified direction
  484. animation = animation || settings.animation;
  485. if(typeof animation === 'string') {
  486. animation = animation.split(' ');
  487. $.each(animation, function(index, word){
  488. if(word === className.inward) {
  489. return className.inward;
  490. }
  491. else if(word === className.outward) {
  492. return className.outward;
  493. }
  494. });
  495. }
  496. // slower backup
  497. if( !module.can.transition() ) {
  498. return 'static';
  499. }
  500. if($module.is(':visible') && !module.is.hidden()) {
  501. return className.outward;
  502. }
  503. else {
  504. return className.inward;
  505. }
  506. },
  507. duration: function(duration) {
  508. duration = duration || settings.duration;
  509. if(duration === false) {
  510. duration = $module.css('animation-duration') || 0;
  511. }
  512. return (typeof duration === 'string')
  513. ? (duration.indexOf('ms') > -1)
  514. ? parseFloat(duration)
  515. : parseFloat(duration) * 1000
  516. : duration
  517. ;
  518. },
  519. displayType: function() {
  520. if(settings.displayType) {
  521. return settings.displayType;
  522. }
  523. if($module.data(metadata.displayType) === undefined) {
  524. // create fake element to determine display state
  525. module.can.transition(true);
  526. }
  527. return $module.data(metadata.displayType);
  528. },
  529. style: function() {
  530. var
  531. style = $module.attr('style') || ''
  532. ;
  533. return style.replace(/display.*?;/, '');
  534. },
  535. transitionExists: function(animation) {
  536. return $.fn.transition.exists[animation];
  537. },
  538. animationStartEvent: function() {
  539. var
  540. element = document.createElement('div'),
  541. animations = {
  542. 'animation' :'animationstart',
  543. 'OAnimation' :'oAnimationStart',
  544. 'MozAnimation' :'mozAnimationStart',
  545. 'WebkitAnimation' :'webkitAnimationStart'
  546. },
  547. animation
  548. ;
  549. for(animation in animations){
  550. if( element.style[animation] !== undefined ){
  551. return animations[animation];
  552. }
  553. }
  554. return false;
  555. },
  556. animationEndEvent: function() {
  557. var
  558. element = document.createElement('div'),
  559. animations = {
  560. 'animation' :'animationend',
  561. 'OAnimation' :'oAnimationEnd',
  562. 'MozAnimation' :'mozAnimationEnd',
  563. 'WebkitAnimation' :'webkitAnimationEnd'
  564. },
  565. animation
  566. ;
  567. for(animation in animations){
  568. if( element.style[animation] !== undefined ){
  569. return animations[animation];
  570. }
  571. }
  572. return false;
  573. }
  574. },
  575. can: {
  576. transition: function(forced) {
  577. var
  578. animation = settings.animation,
  579. transitionExists = module.get.transitionExists(animation),
  580. elementClass,
  581. tagName,
  582. $clone,
  583. currentAnimation,
  584. inAnimation,
  585. directionExists,
  586. displayType
  587. ;
  588. if( transitionExists === undefined || forced) {
  589. module.verbose('Determining whether animation exists');
  590. elementClass = $module.attr('class');
  591. tagName = $module.prop('tagName');
  592. $clone = $('<' + tagName + ' />').addClass( elementClass ).insertAfter($module);
  593. currentAnimation = $clone
  594. .addClass(animation)
  595. .removeClass(className.inward)
  596. .removeClass(className.outward)
  597. .addClass(className.animating)
  598. .addClass(className.transition)
  599. .css('animationName')
  600. ;
  601. inAnimation = $clone
  602. .addClass(className.inward)
  603. .css('animationName')
  604. ;
  605. displayType = $clone
  606. .attr('class', elementClass)
  607. .removeAttr('style')
  608. .removeClass(className.hidden)
  609. .removeClass(className.visible)
  610. .show()
  611. .css('display')
  612. ;
  613. module.verbose('Determining final display state', displayType);
  614. module.save.displayType(displayType);
  615. $clone.remove();
  616. if(currentAnimation != inAnimation) {
  617. module.debug('Direction exists for animation', animation);
  618. directionExists = true;
  619. }
  620. else if(currentAnimation == 'none' || !currentAnimation) {
  621. module.debug('No animation defined in css', animation);
  622. return;
  623. }
  624. else {
  625. module.debug('Static animation found', animation, displayType);
  626. directionExists = false;
  627. }
  628. module.save.transitionExists(animation, directionExists);
  629. }
  630. return (transitionExists !== undefined)
  631. ? transitionExists
  632. : directionExists
  633. ;
  634. },
  635. animate: function() {
  636. // can transition does not return a value if animation does not exist
  637. return (module.can.transition() !== undefined);
  638. }
  639. },
  640. is: {
  641. animating: function() {
  642. return $module.hasClass(className.animating);
  643. },
  644. inward: function() {
  645. return $module.hasClass(className.inward);
  646. },
  647. outward: function() {
  648. return $module.hasClass(className.outward);
  649. },
  650. looping: function() {
  651. return $module.hasClass(className.looping);
  652. },
  653. occurring: function(animation) {
  654. animation = animation || settings.animation;
  655. animation = '.' + animation.replace(' ', '.');
  656. return ( $module.filter(animation).length > 0 );
  657. },
  658. visible: function() {
  659. return $module.is(':visible');
  660. },
  661. hidden: function() {
  662. return $module.css('visibility') === 'hidden';
  663. },
  664. supported: function() {
  665. return(animationEnd !== false);
  666. }
  667. },
  668. hide: function() {
  669. module.verbose('Hiding element');
  670. if( module.is.animating() ) {
  671. module.reset();
  672. }
  673. module.remove.display();
  674. module.remove.visible();
  675. module.set.hidden();
  676. module.repaint();
  677. },
  678. show: function(display) {
  679. module.verbose('Showing element', display);
  680. module.remove.hidden();
  681. module.set.visible();
  682. module.set.display();
  683. module.repaint();
  684. },
  685. toggle: function() {
  686. if( module.is.visible() ) {
  687. module.hide();
  688. }
  689. else {
  690. module.show();
  691. }
  692. },
  693. stop: function() {
  694. module.debug('Stopping current animation');
  695. $module.trigger(animationEnd);
  696. },
  697. stopAll: function() {
  698. module.debug('Stopping all animation');
  699. module.remove.queueCallback();
  700. $module.trigger(animationEnd);
  701. },
  702. clear: {
  703. queue: function() {
  704. module.debug('Clearing animation queue');
  705. module.remove.queueCallback();
  706. }
  707. },
  708. enable: function() {
  709. module.verbose('Starting animation');
  710. $module.removeClass(className.disabled);
  711. },
  712. disable: function() {
  713. module.debug('Stopping animation');
  714. $module.addClass(className.disabled);
  715. },
  716. setting: function(name, value) {
  717. module.debug('Changing setting', name, value);
  718. if( $.isPlainObject(name) ) {
  719. $.extend(true, settings, name);
  720. }
  721. else if(value !== undefined) {
  722. settings[name] = value;
  723. }
  724. else {
  725. return settings[name];
  726. }
  727. },
  728. internal: function(name, value) {
  729. if( $.isPlainObject(name) ) {
  730. $.extend(true, module, name);
  731. }
  732. else if(value !== undefined) {
  733. module[name] = value;
  734. }
  735. else {
  736. return module[name];
  737. }
  738. },
  739. debug: function() {
  740. if(settings.debug) {
  741. if(settings.performance) {
  742. module.performance.log(arguments);
  743. }
  744. else {
  745. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  746. module.debug.apply(console, arguments);
  747. }
  748. }
  749. },
  750. verbose: function() {
  751. if(settings.verbose && settings.debug) {
  752. if(settings.performance) {
  753. module.performance.log(arguments);
  754. }
  755. else {
  756. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  757. module.verbose.apply(console, arguments);
  758. }
  759. }
  760. },
  761. error: function() {
  762. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  763. module.error.apply(console, arguments);
  764. },
  765. performance: {
  766. log: function(message) {
  767. var
  768. currentTime,
  769. executionTime,
  770. previousTime
  771. ;
  772. if(settings.performance) {
  773. currentTime = new Date().getTime();
  774. previousTime = time || currentTime;
  775. executionTime = currentTime - previousTime;
  776. time = currentTime;
  777. performance.push({
  778. 'Name' : message[0],
  779. 'Arguments' : [].slice.call(message, 1) || '',
  780. 'Element' : element,
  781. 'Execution Time' : executionTime
  782. });
  783. }
  784. clearTimeout(module.performance.timer);
  785. module.performance.timer = setTimeout(module.performance.display, 500);
  786. },
  787. display: function() {
  788. var
  789. title = settings.name + ':',
  790. totalTime = 0
  791. ;
  792. time = false;
  793. clearTimeout(module.performance.timer);
  794. $.each(performance, function(index, data) {
  795. totalTime += data['Execution Time'];
  796. });
  797. title += ' ' + totalTime + 'ms';
  798. if(moduleSelector) {
  799. title += ' \'' + moduleSelector + '\'';
  800. }
  801. if($allModules.length > 1) {
  802. title += ' ' + '(' + $allModules.length + ')';
  803. }
  804. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  805. console.groupCollapsed(title);
  806. if(console.table) {
  807. console.table(performance);
  808. }
  809. else {
  810. $.each(performance, function(index, data) {
  811. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  812. });
  813. }
  814. console.groupEnd();
  815. }
  816. performance = [];
  817. }
  818. },
  819. // modified for transition to return invoke success
  820. invoke: function(query, passedArguments, context) {
  821. var
  822. object = instance,
  823. maxDepth,
  824. found,
  825. response
  826. ;
  827. passedArguments = passedArguments || queryArguments;
  828. context = element || context;
  829. if(typeof query == 'string' && object !== undefined) {
  830. query = query.split(/[\. ]/);
  831. maxDepth = query.length - 1;
  832. $.each(query, function(depth, value) {
  833. var camelCaseValue = (depth != maxDepth)
  834. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  835. : query
  836. ;
  837. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  838. object = object[camelCaseValue];
  839. }
  840. else if( object[camelCaseValue] !== undefined ) {
  841. found = object[camelCaseValue];
  842. return false;
  843. }
  844. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  845. object = object[value];
  846. }
  847. else if( object[value] !== undefined ) {
  848. found = object[value];
  849. return false;
  850. }
  851. else {
  852. return false;
  853. }
  854. });
  855. }
  856. if ( $.isFunction( found ) ) {
  857. response = found.apply(context, passedArguments);
  858. }
  859. else if(found !== undefined) {
  860. response = found;
  861. }
  862. if($.isArray(returnedValue)) {
  863. returnedValue.push(response);
  864. }
  865. else if(returnedValue !== undefined) {
  866. returnedValue = [returnedValue, response];
  867. }
  868. else if(response !== undefined) {
  869. returnedValue = response;
  870. }
  871. return (found !== undefined)
  872. ? found
  873. : false
  874. ;
  875. }
  876. };
  877. module.initialize();
  878. })
  879. ;
  880. return (returnedValue !== undefined)
  881. ? returnedValue
  882. : this
  883. ;
  884. };
  885. // Records if CSS transition is available
  886. $.fn.transition.exists = {};
  887. $.fn.transition.settings = {
  888. // module info
  889. name : 'Transition',
  890. // debug content outputted to console
  891. debug : false,
  892. // verbose debug output
  893. verbose : false,
  894. // performance data output
  895. performance : true,
  896. // event namespace
  897. namespace : 'transition',
  898. // delay between animations in group
  899. interval : 0,
  900. // whether group animations should be reversed
  901. reverse : 'auto',
  902. // animation callback event
  903. onStart : function() {},
  904. onComplete : function() {},
  905. onShow : function() {},
  906. onHide : function() {},
  907. // whether timeout should be used to ensure callback fires in cases animationend does not
  908. useFailSafe : true,
  909. // delay in ms for fail safe
  910. failSafeDelay : 100,
  911. // whether EXACT animation can occur twice in a row
  912. allowRepeats : false,
  913. // Override final display type on visible
  914. displayType : false,
  915. // animation duration
  916. animation : 'fade',
  917. duration : false,
  918. // new animations will occur after previous ones
  919. queue : true,
  920. metadata : {
  921. displayType: 'display'
  922. },
  923. className : {
  924. animating : 'animating',
  925. disabled : 'disabled',
  926. hidden : 'hidden',
  927. inward : 'in',
  928. loading : 'loading',
  929. looping : 'looping',
  930. outward : 'out',
  931. transition : 'transition',
  932. visible : 'visible'
  933. },
  934. // possible errors
  935. error: {
  936. noAnimation : 'There is no css animation matching the one you specified.',
  937. repeated : 'That animation is already occurring, cancelling repeated animation',
  938. method : 'The method you called is not defined',
  939. support : 'This browser does not support CSS animations'
  940. }
  941. };
  942. })( jQuery, window , document );