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.

1069 lines
33 KiB

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