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.

1002 lines
32 KiB

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