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.

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