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.

1074 lines
34 KiB

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