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.

1017 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 2014 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. '-webkit-animation-duration': duration,
  263. '-moz-animation-duration': duration,
  264. '-ms-animation-duration': duration,
  265. '-o-animation-duration': duration,
  266. 'animation-duration': duration
  267. })
  268. ;
  269. }
  270. },
  271. display: function() {
  272. var
  273. style = module.get.style(),
  274. displayType = module.get.displayType(),
  275. overrideStyle = style + 'display: ' + displayType + ' !important;'
  276. ;
  277. $module.css('display', '');
  278. module.refresh();
  279. if( $module.css('display') !== displayType ) {
  280. module.verbose('Setting inline visibility to', displayType);
  281. $module
  282. .attr('style', overrideStyle)
  283. ;
  284. }
  285. },
  286. direction: function() {
  287. if($module.is(':visible') && !module.is.hidden()) {
  288. module.debug('Automatically determining the direction of animation', 'Outward');
  289. $module
  290. .removeClass(className.inward)
  291. .addClass(className.outward)
  292. ;
  293. }
  294. else {
  295. module.debug('Automatically determining the direction of animation', 'Inward');
  296. $module
  297. .removeClass(className.outward)
  298. .addClass(className.inward)
  299. ;
  300. }
  301. },
  302. looping: function() {
  303. module.debug('Transition set to loop');
  304. $module
  305. .addClass(className.looping)
  306. ;
  307. },
  308. hidden: function() {
  309. if(!module.is.hidden()) {
  310. $module
  311. .addClass(className.transition)
  312. .addClass(className.hidden)
  313. ;
  314. }
  315. if($module.css('display') !== 'none') {
  316. module.verbose('Overriding default display to hide element');
  317. $module
  318. .css('display', 'none')
  319. ;
  320. }
  321. },
  322. visible: function() {
  323. $module
  324. .addClass(className.transition)
  325. .addClass(className.visible)
  326. ;
  327. }
  328. },
  329. save: {
  330. displayType: function(displayType) {
  331. if(displayType !== 'none') {
  332. $module.data(metadata.displayType, displayType);
  333. }
  334. },
  335. transitionExists: function(animation, exists) {
  336. $.fn.transition.exists[animation] = exists;
  337. module.verbose('Saving existence of transition', animation, exists);
  338. },
  339. conditions: function() {
  340. $module.removeClass(settings.animation);
  341. module.remove.direction();
  342. module.cache = {
  343. className : $module.attr('class'),
  344. style : module.get.style()
  345. };
  346. module.verbose('Saving original attributes', module.cache);
  347. }
  348. },
  349. restore: {
  350. conditions: function() {
  351. if(module.cache === undefined) {
  352. return false;
  353. }
  354. if(module.cache.className) {
  355. $module.attr('class', module.cache.className);
  356. }
  357. else {
  358. $module.removeAttr('class');
  359. }
  360. if(module.cache.style) {
  361. module.verbose('Restoring original style attribute', module.cache.style);
  362. $module.attr('style', module.cache.style);
  363. }
  364. else {
  365. module.verbose('Clearing style attribute');
  366. $module.removeAttr('style');
  367. }
  368. module.verbose('Restoring original attributes', module.cache);
  369. }
  370. },
  371. add: {
  372. failSafe: function() {
  373. var
  374. duration = module.get.duration()
  375. ;
  376. module.timer = setTimeout(function() {
  377. $module.trigger(animationEnd);
  378. }, duration + settings.failSafeDelay);
  379. module.verbose('Adding fail safe timer', module.timer);
  380. }
  381. },
  382. remove: {
  383. animating: function() {
  384. $module.removeClass(className.animating);
  385. },
  386. animation: function() {
  387. $module
  388. .css({
  389. '-webkit-animation' : '',
  390. '-moz-animation' : '',
  391. '-ms-animation' : '',
  392. '-o-animation' : '',
  393. 'animation' : ''
  394. })
  395. ;
  396. },
  397. animationCallbacks: function() {
  398. module.remove.queueCallback();
  399. module.remove.completeCallback();
  400. },
  401. queueCallback: function() {
  402. $module.off('.queue' + eventNamespace);
  403. },
  404. completeCallback: function() {
  405. $module.off('.complete' + eventNamespace);
  406. },
  407. display: function() {
  408. $module.css('display', '');
  409. },
  410. direction: function() {
  411. $module
  412. .removeClass(className.inward)
  413. .removeClass(className.outward)
  414. ;
  415. },
  416. failSafe: function() {
  417. module.verbose('Removing fail safe timer', module.timer);
  418. if(module.timer) {
  419. clearTimeout(module.timer);
  420. }
  421. },
  422. hidden: function() {
  423. $module.removeClass(className.hidden);
  424. },
  425. visible: function() {
  426. $module.removeClass(className.visible);
  427. },
  428. looping: function() {
  429. module.debug('Transitions are no longer looping');
  430. if( module.is.looping() ) {
  431. module.reset();
  432. $module
  433. .removeClass(className.looping)
  434. ;
  435. }
  436. },
  437. transition: function() {
  438. $module
  439. .removeClass(className.visible)
  440. .removeClass(className.hidden)
  441. ;
  442. }
  443. },
  444. get: {
  445. settings: function(animation, duration, onComplete) {
  446. // single settings object
  447. if(typeof animation == 'object') {
  448. return $.extend(true, {}, $.fn.transition.settings, animation);
  449. }
  450. // all arguments provided
  451. else if(typeof onComplete == 'function') {
  452. return $.extend({}, $.fn.transition.settings, {
  453. animation : animation,
  454. onComplete : onComplete,
  455. duration : duration
  456. });
  457. }
  458. // only duration provided
  459. else if(typeof duration == 'string' || typeof duration == 'number') {
  460. return $.extend({}, $.fn.transition.settings, {
  461. animation : animation,
  462. duration : duration
  463. });
  464. }
  465. // duration is actually settings object
  466. else if(typeof duration == 'object') {
  467. return $.extend({}, $.fn.transition.settings, duration, {
  468. animation : animation
  469. });
  470. }
  471. // duration is actually callback
  472. else if(typeof duration == 'function') {
  473. return $.extend({}, $.fn.transition.settings, {
  474. animation : animation,
  475. onComplete : duration
  476. });
  477. }
  478. // only animation provided
  479. else {
  480. return $.extend({}, $.fn.transition.settings, {
  481. animation : animation
  482. });
  483. }
  484. return $.fn.transition.settings;
  485. },
  486. direction: function(animation) {
  487. // quickest manually specified direction
  488. animation = animation || settings.animation;
  489. if(typeof animation === 'string') {
  490. animation = animation.split(' ');
  491. $.each(animation, function(index, word){
  492. if(word === className.inward) {
  493. return className.inward;
  494. }
  495. else if(word === className.outward) {
  496. return className.outward;
  497. }
  498. });
  499. }
  500. // slower backup
  501. if( !module.can.transition() ) {
  502. return 'static';
  503. }
  504. if($module.is(':visible') && !module.is.hidden()) {
  505. return className.outward;
  506. }
  507. else {
  508. return className.inward;
  509. }
  510. },
  511. duration: function(duration) {
  512. duration = duration || settings.duration;
  513. if(duration === false) {
  514. duration = $module.css('animation-duration') || 0;
  515. }
  516. return (typeof duration === 'string')
  517. ? (duration.indexOf('ms') > -1)
  518. ? parseFloat(duration)
  519. : parseFloat(duration) * 1000
  520. : duration
  521. ;
  522. },
  523. displayType: function() {
  524. if(settings.displayType) {
  525. return settings.displayType;
  526. }
  527. if($module.data(metadata.displayType) === undefined) {
  528. // create fake element to determine display state
  529. module.can.transition(true);
  530. }
  531. return $module.data(metadata.displayType);
  532. },
  533. style: function() {
  534. var
  535. style = $module.attr('style') || ''
  536. ;
  537. return style.replace(/display.*?;/, '');
  538. },
  539. transitionExists: function(animation) {
  540. return $.fn.transition.exists[animation];
  541. },
  542. animationStartEvent: function() {
  543. var
  544. element = document.createElement('div'),
  545. animations = {
  546. 'animation' :'animationstart',
  547. 'OAnimation' :'oAnimationStart',
  548. 'MozAnimation' :'mozAnimationStart',
  549. 'WebkitAnimation' :'webkitAnimationStart'
  550. },
  551. animation
  552. ;
  553. for(animation in animations){
  554. if( element.style[animation] !== undefined ){
  555. return animations[animation];
  556. }
  557. }
  558. return false;
  559. },
  560. animationEndEvent: function() {
  561. var
  562. element = document.createElement('div'),
  563. animations = {
  564. 'animation' :'animationend',
  565. 'OAnimation' :'oAnimationEnd',
  566. 'MozAnimation' :'mozAnimationEnd',
  567. 'WebkitAnimation' :'webkitAnimationEnd'
  568. },
  569. animation
  570. ;
  571. for(animation in animations){
  572. if( element.style[animation] !== undefined ){
  573. return animations[animation];
  574. }
  575. }
  576. return false;
  577. }
  578. },
  579. can: {
  580. transition: function(forced) {
  581. var
  582. animation = settings.animation,
  583. transitionExists = module.get.transitionExists(animation),
  584. elementClass,
  585. tagName,
  586. $clone,
  587. currentAnimation,
  588. inAnimation,
  589. directionExists,
  590. displayType
  591. ;
  592. if( transitionExists === undefined || forced) {
  593. module.verbose('Determining whether animation exists');
  594. elementClass = $module.attr('class');
  595. tagName = $module.prop('tagName');
  596. $clone = $('<' + tagName + ' />').addClass( elementClass ).insertAfter($module);
  597. currentAnimation = $clone
  598. .addClass(animation)
  599. .removeClass(className.inward)
  600. .removeClass(className.outward)
  601. .addClass(className.animating)
  602. .addClass(className.transition)
  603. .css('animationName')
  604. ;
  605. inAnimation = $clone
  606. .addClass(className.inward)
  607. .css('animationName')
  608. ;
  609. displayType = $clone
  610. .attr('class', elementClass)
  611. .removeAttr('style')
  612. .removeClass(className.hidden)
  613. .removeClass(className.visible)
  614. .show()
  615. .css('display')
  616. ;
  617. module.verbose('Determining final display state', displayType);
  618. module.save.displayType(displayType);
  619. $clone.remove();
  620. if(currentAnimation != inAnimation) {
  621. module.debug('Direction exists for animation', animation);
  622. directionExists = true;
  623. }
  624. else if(currentAnimation == 'none' || !currentAnimation) {
  625. module.debug('No animation defined in css', animation);
  626. return;
  627. }
  628. else {
  629. module.debug('Static animation found', animation, displayType);
  630. directionExists = false;
  631. }
  632. module.save.transitionExists(animation, directionExists);
  633. }
  634. return (transitionExists !== undefined)
  635. ? transitionExists
  636. : directionExists
  637. ;
  638. },
  639. animate: function() {
  640. // can transition does not return a value if animation does not exist
  641. return (module.can.transition() !== undefined);
  642. }
  643. },
  644. is: {
  645. animating: function() {
  646. return $module.hasClass(className.animating);
  647. },
  648. inward: function() {
  649. return $module.hasClass(className.inward);
  650. },
  651. outward: function() {
  652. return $module.hasClass(className.outward);
  653. },
  654. looping: function() {
  655. return $module.hasClass(className.looping);
  656. },
  657. occurring: function(animation) {
  658. animation = animation || settings.animation;
  659. animation = '.' + animation.replace(' ', '.');
  660. return ( $module.filter(animation).length > 0 );
  661. },
  662. visible: function() {
  663. return $module.is(':visible');
  664. },
  665. hidden: function() {
  666. return $module.css('visibility') === 'hidden';
  667. },
  668. supported: function() {
  669. return(animationEnd !== false);
  670. }
  671. },
  672. hide: function() {
  673. module.verbose('Hiding element');
  674. if( module.is.animating() ) {
  675. module.reset();
  676. }
  677. module.remove.display();
  678. module.remove.visible();
  679. module.set.hidden();
  680. module.repaint();
  681. },
  682. show: function(display) {
  683. module.verbose('Showing element', display);
  684. module.remove.hidden();
  685. module.set.visible();
  686. module.set.display();
  687. module.repaint();
  688. },
  689. toggle: function() {
  690. if( module.is.visible() ) {
  691. module.hide();
  692. }
  693. else {
  694. module.show();
  695. }
  696. },
  697. stop: function() {
  698. module.debug('Stopping current animation');
  699. $module.trigger(animationEnd);
  700. },
  701. stopAll: function() {
  702. module.debug('Stopping all animation');
  703. module.remove.queueCallback();
  704. $module.trigger(animationEnd);
  705. },
  706. clear: {
  707. queue: function() {
  708. module.debug('Clearing animation queue');
  709. module.remove.queueCallback();
  710. }
  711. },
  712. enable: function() {
  713. module.verbose('Starting animation');
  714. $module.removeClass(className.disabled);
  715. },
  716. disable: function() {
  717. module.debug('Stopping animation');
  718. $module.addClass(className.disabled);
  719. },
  720. setting: function(name, value) {
  721. module.debug('Changing setting', name, value);
  722. if( $.isPlainObject(name) ) {
  723. $.extend(true, settings, name);
  724. }
  725. else if(value !== undefined) {
  726. settings[name] = value;
  727. }
  728. else {
  729. return settings[name];
  730. }
  731. },
  732. internal: function(name, value) {
  733. if( $.isPlainObject(name) ) {
  734. $.extend(true, module, name);
  735. }
  736. else if(value !== undefined) {
  737. module[name] = value;
  738. }
  739. else {
  740. return module[name];
  741. }
  742. },
  743. debug: function() {
  744. if(settings.debug) {
  745. if(settings.performance) {
  746. module.performance.log(arguments);
  747. }
  748. else {
  749. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  750. module.debug.apply(console, arguments);
  751. }
  752. }
  753. },
  754. verbose: function() {
  755. if(settings.verbose && settings.debug) {
  756. if(settings.performance) {
  757. module.performance.log(arguments);
  758. }
  759. else {
  760. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  761. module.verbose.apply(console, arguments);
  762. }
  763. }
  764. },
  765. error: function() {
  766. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  767. module.error.apply(console, arguments);
  768. },
  769. performance: {
  770. log: function(message) {
  771. var
  772. currentTime,
  773. executionTime,
  774. previousTime
  775. ;
  776. if(settings.performance) {
  777. currentTime = new Date().getTime();
  778. previousTime = time || currentTime;
  779. executionTime = currentTime - previousTime;
  780. time = currentTime;
  781. performance.push({
  782. 'Name' : message[0],
  783. 'Arguments' : [].slice.call(message, 1) || '',
  784. 'Element' : element,
  785. 'Execution Time' : executionTime
  786. });
  787. }
  788. clearTimeout(module.performance.timer);
  789. module.performance.timer = setTimeout(module.performance.display, 500);
  790. },
  791. display: function() {
  792. var
  793. title = settings.name + ':',
  794. totalTime = 0
  795. ;
  796. time = false;
  797. clearTimeout(module.performance.timer);
  798. $.each(performance, function(index, data) {
  799. totalTime += data['Execution Time'];
  800. });
  801. title += ' ' + totalTime + 'ms';
  802. if(moduleSelector) {
  803. title += ' \'' + moduleSelector + '\'';
  804. }
  805. if($allModules.length > 1) {
  806. title += ' ' + '(' + $allModules.length + ')';
  807. }
  808. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  809. console.groupCollapsed(title);
  810. if(console.table) {
  811. console.table(performance);
  812. }
  813. else {
  814. $.each(performance, function(index, data) {
  815. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  816. });
  817. }
  818. console.groupEnd();
  819. }
  820. performance = [];
  821. }
  822. },
  823. // modified for transition to return invoke success
  824. invoke: function(query, passedArguments, context) {
  825. var
  826. object = instance,
  827. maxDepth,
  828. found,
  829. response
  830. ;
  831. passedArguments = passedArguments || queryArguments;
  832. context = element || context;
  833. if(typeof query == 'string' && object !== undefined) {
  834. query = query.split(/[\. ]/);
  835. maxDepth = query.length - 1;
  836. $.each(query, function(depth, value) {
  837. var camelCaseValue = (depth != maxDepth)
  838. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  839. : query
  840. ;
  841. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  842. object = object[camelCaseValue];
  843. }
  844. else if( object[camelCaseValue] !== undefined ) {
  845. found = object[camelCaseValue];
  846. return false;
  847. }
  848. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  849. object = object[value];
  850. }
  851. else if( object[value] !== undefined ) {
  852. found = object[value];
  853. return false;
  854. }
  855. else {
  856. return false;
  857. }
  858. });
  859. }
  860. if ( $.isFunction( found ) ) {
  861. response = found.apply(context, passedArguments);
  862. }
  863. else if(found !== undefined) {
  864. response = found;
  865. }
  866. if($.isArray(returnedValue)) {
  867. returnedValue.push(response);
  868. }
  869. else if(returnedValue !== undefined) {
  870. returnedValue = [returnedValue, response];
  871. }
  872. else if(response !== undefined) {
  873. returnedValue = response;
  874. }
  875. return (found !== undefined)
  876. ? found
  877. : false
  878. ;
  879. }
  880. };
  881. module.initialize();
  882. })
  883. ;
  884. return (returnedValue !== undefined)
  885. ? returnedValue
  886. : this
  887. ;
  888. };
  889. // Records if CSS transition is available
  890. $.fn.transition.exists = {};
  891. $.fn.transition.settings = {
  892. // module info
  893. name : 'Transition',
  894. // debug content outputted to console
  895. debug : false,
  896. // verbose debug output
  897. verbose : false,
  898. // performance data output
  899. performance : true,
  900. // event namespace
  901. namespace : 'transition',
  902. // delay between animations in group
  903. interval : 0,
  904. // whether group animations should be reversed
  905. reverse : 'auto',
  906. // animation callback event
  907. onStart : function() {},
  908. onComplete : function() {},
  909. onShow : function() {},
  910. onHide : function() {},
  911. // whether timeout should be used to ensure callback fires in cases animationend does not
  912. useFailSafe : true,
  913. // delay in ms for fail safe
  914. failSafeDelay : 100,
  915. // whether EXACT animation can occur twice in a row
  916. allowRepeats : false,
  917. // Override final display type on visible
  918. displayType : false,
  919. // animation duration
  920. animation : 'fade',
  921. duration : false,
  922. // new animations will occur after previous ones
  923. queue : true,
  924. metadata : {
  925. displayType: 'display'
  926. },
  927. className : {
  928. animating : 'animating',
  929. disabled : 'disabled',
  930. hidden : 'hidden',
  931. inward : 'in',
  932. loading : 'loading',
  933. looping : 'looping',
  934. outward : 'out',
  935. transition : 'transition',
  936. visible : 'visible'
  937. },
  938. // possible errors
  939. error: {
  940. noAnimation : 'There is no css animation matching the one you specified.',
  941. repeated : 'That animation is already occurring, cancelling repeated animation',
  942. method : 'The method you called is not defined',
  943. support : 'This browser does not support CSS animations'
  944. }
  945. };
  946. })( jQuery, window , document );