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.

1021 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
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 years ago
9 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. var
  486. direction
  487. ;
  488. animation = animation || settings.animation;
  489. if(typeof animation === 'string') {
  490. animation = animation.split(' ');
  491. $.each(animation, function(index, word){
  492. if(word === className.inward) {
  493. direction = className.inward;
  494. }
  495. else if(word === className.outward) {
  496. direction = className.outward;
  497. }
  498. });
  499. }
  500. // return found direction
  501. if(direction) {
  502. return direction;
  503. }
  504. // slower backup
  505. if( !module.can.transition() ) {
  506. return 'static';
  507. }
  508. if($module.is(':visible') && !module.is.hidden()) {
  509. return className.outward;
  510. }
  511. else {
  512. return className.inward;
  513. }
  514. },
  515. duration: function(duration) {
  516. duration = duration || settings.duration;
  517. if(duration === false) {
  518. duration = $module.css('animation-duration') || 0;
  519. }
  520. return (typeof duration === 'string')
  521. ? (duration.indexOf('ms') > -1)
  522. ? parseFloat(duration)
  523. : parseFloat(duration) * 1000
  524. : duration
  525. ;
  526. },
  527. displayType: function() {
  528. if(settings.displayType) {
  529. return settings.displayType;
  530. }
  531. if($module.data(metadata.displayType) === undefined) {
  532. // create fake element to determine display state
  533. module.can.transition(true);
  534. }
  535. return $module.data(metadata.displayType);
  536. },
  537. style: function() {
  538. var
  539. style = $module.attr('style') || ''
  540. ;
  541. return style.replace(/display.*?;/, '');
  542. },
  543. transitionExists: function(animation) {
  544. return $.fn.transition.exists[animation];
  545. },
  546. animationStartEvent: function() {
  547. var
  548. element = document.createElement('div'),
  549. animations = {
  550. 'animation' :'animationstart',
  551. 'OAnimation' :'oAnimationStart',
  552. 'MozAnimation' :'mozAnimationStart',
  553. 'WebkitAnimation' :'webkitAnimationStart'
  554. },
  555. animation
  556. ;
  557. for(animation in animations){
  558. if( element.style[animation] !== undefined ){
  559. return animations[animation];
  560. }
  561. }
  562. return false;
  563. },
  564. animationEndEvent: function() {
  565. var
  566. element = document.createElement('div'),
  567. animations = {
  568. 'animation' :'animationend',
  569. 'OAnimation' :'oAnimationEnd',
  570. 'MozAnimation' :'mozAnimationEnd',
  571. 'WebkitAnimation' :'webkitAnimationEnd'
  572. },
  573. animation
  574. ;
  575. for(animation in animations){
  576. if( element.style[animation] !== undefined ){
  577. return animations[animation];
  578. }
  579. }
  580. return false;
  581. }
  582. },
  583. can: {
  584. transition: function(forced) {
  585. var
  586. animation = settings.animation,
  587. transitionExists = module.get.transitionExists(animation),
  588. elementClass,
  589. tagName,
  590. $clone,
  591. currentAnimation,
  592. inAnimation,
  593. directionExists,
  594. displayType
  595. ;
  596. if( transitionExists === undefined || forced) {
  597. module.verbose('Determining whether animation exists');
  598. elementClass = $module.attr('class');
  599. tagName = $module.prop('tagName');
  600. $clone = $('<' + tagName + ' />').addClass( elementClass ).insertAfter($module);
  601. currentAnimation = $clone
  602. .addClass(animation)
  603. .removeClass(className.inward)
  604. .removeClass(className.outward)
  605. .addClass(className.animating)
  606. .addClass(className.transition)
  607. .css('animationName')
  608. ;
  609. inAnimation = $clone
  610. .addClass(className.inward)
  611. .css('animationName')
  612. ;
  613. displayType = $clone
  614. .attr('class', elementClass)
  615. .removeAttr('style')
  616. .removeClass(className.hidden)
  617. .removeClass(className.visible)
  618. .show()
  619. .css('display')
  620. ;
  621. module.verbose('Determining final display state', displayType);
  622. module.save.displayType(displayType);
  623. $clone.remove();
  624. if(currentAnimation != inAnimation) {
  625. module.debug('Direction exists for animation', animation);
  626. directionExists = true;
  627. }
  628. else if(currentAnimation == 'none' || !currentAnimation) {
  629. module.debug('No animation defined in css', animation);
  630. return;
  631. }
  632. else {
  633. module.debug('Static animation found', animation, displayType);
  634. directionExists = false;
  635. }
  636. module.save.transitionExists(animation, directionExists);
  637. }
  638. return (transitionExists !== undefined)
  639. ? transitionExists
  640. : directionExists
  641. ;
  642. },
  643. animate: function() {
  644. // can transition does not return a value if animation does not exist
  645. return (module.can.transition() !== undefined);
  646. }
  647. },
  648. is: {
  649. animating: function() {
  650. return $module.hasClass(className.animating);
  651. },
  652. inward: function() {
  653. return $module.hasClass(className.inward);
  654. },
  655. outward: function() {
  656. return $module.hasClass(className.outward);
  657. },
  658. looping: function() {
  659. return $module.hasClass(className.looping);
  660. },
  661. occurring: function(animation) {
  662. animation = animation || settings.animation;
  663. animation = '.' + animation.replace(' ', '.');
  664. return ( $module.filter(animation).length > 0 );
  665. },
  666. visible: function() {
  667. return $module.is(':visible');
  668. },
  669. hidden: function() {
  670. return $module.css('visibility') === 'hidden';
  671. },
  672. supported: function() {
  673. return(animationEnd !== false);
  674. }
  675. },
  676. hide: function() {
  677. module.verbose('Hiding element');
  678. if( module.is.animating() ) {
  679. module.reset();
  680. }
  681. module.remove.display();
  682. module.remove.visible();
  683. module.set.hidden();
  684. module.repaint();
  685. },
  686. show: function(display) {
  687. module.verbose('Showing element', display);
  688. module.remove.hidden();
  689. module.set.visible();
  690. module.set.display();
  691. module.repaint();
  692. },
  693. toggle: function() {
  694. if( module.is.visible() ) {
  695. module.hide();
  696. }
  697. else {
  698. module.show();
  699. }
  700. },
  701. stop: function() {
  702. module.debug('Stopping current animation');
  703. $module.triggerHandler(animationEnd);
  704. },
  705. stopAll: function() {
  706. module.debug('Stopping all animation');
  707. module.remove.queueCallback();
  708. $module.triggerHandler(animationEnd);
  709. },
  710. clear: {
  711. queue: function() {
  712. module.debug('Clearing animation queue');
  713. module.remove.queueCallback();
  714. }
  715. },
  716. enable: function() {
  717. module.verbose('Starting animation');
  718. $module.removeClass(className.disabled);
  719. },
  720. disable: function() {
  721. module.debug('Stopping animation');
  722. $module.addClass(className.disabled);
  723. },
  724. setting: function(name, value) {
  725. module.debug('Changing setting', name, value);
  726. if( $.isPlainObject(name) ) {
  727. $.extend(true, settings, name);
  728. }
  729. else if(value !== undefined) {
  730. settings[name] = value;
  731. }
  732. else {
  733. return settings[name];
  734. }
  735. },
  736. internal: function(name, value) {
  737. if( $.isPlainObject(name) ) {
  738. $.extend(true, module, name);
  739. }
  740. else if(value !== undefined) {
  741. module[name] = value;
  742. }
  743. else {
  744. return module[name];
  745. }
  746. },
  747. debug: function() {
  748. if(settings.debug) {
  749. if(settings.performance) {
  750. module.performance.log(arguments);
  751. }
  752. else {
  753. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  754. module.debug.apply(console, arguments);
  755. }
  756. }
  757. },
  758. verbose: function() {
  759. if(settings.verbose && settings.debug) {
  760. if(settings.performance) {
  761. module.performance.log(arguments);
  762. }
  763. else {
  764. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  765. module.verbose.apply(console, arguments);
  766. }
  767. }
  768. },
  769. error: function() {
  770. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  771. module.error.apply(console, arguments);
  772. },
  773. performance: {
  774. log: function(message) {
  775. var
  776. currentTime,
  777. executionTime,
  778. previousTime
  779. ;
  780. if(settings.performance) {
  781. currentTime = new Date().getTime();
  782. previousTime = time || currentTime;
  783. executionTime = currentTime - previousTime;
  784. time = currentTime;
  785. performance.push({
  786. 'Name' : message[0],
  787. 'Arguments' : [].slice.call(message, 1) || '',
  788. 'Element' : element,
  789. 'Execution Time' : executionTime
  790. });
  791. }
  792. clearTimeout(module.performance.timer);
  793. module.performance.timer = setTimeout(module.performance.display, 500);
  794. },
  795. display: function() {
  796. var
  797. title = settings.name + ':',
  798. totalTime = 0
  799. ;
  800. time = false;
  801. clearTimeout(module.performance.timer);
  802. $.each(performance, function(index, data) {
  803. totalTime += data['Execution Time'];
  804. });
  805. title += ' ' + totalTime + 'ms';
  806. if(moduleSelector) {
  807. title += ' \'' + moduleSelector + '\'';
  808. }
  809. if($allModules.length > 1) {
  810. title += ' ' + '(' + $allModules.length + ')';
  811. }
  812. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  813. console.groupCollapsed(title);
  814. if(console.table) {
  815. console.table(performance);
  816. }
  817. else {
  818. $.each(performance, function(index, data) {
  819. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  820. });
  821. }
  822. console.groupEnd();
  823. }
  824. performance = [];
  825. }
  826. },
  827. // modified for transition to return invoke success
  828. invoke: function(query, passedArguments, context) {
  829. var
  830. object = instance,
  831. maxDepth,
  832. found,
  833. response
  834. ;
  835. passedArguments = passedArguments || queryArguments;
  836. context = element || context;
  837. if(typeof query == 'string' && object !== undefined) {
  838. query = query.split(/[\. ]/);
  839. maxDepth = query.length - 1;
  840. $.each(query, function(depth, value) {
  841. var camelCaseValue = (depth != maxDepth)
  842. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  843. : query
  844. ;
  845. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  846. object = object[camelCaseValue];
  847. }
  848. else if( object[camelCaseValue] !== undefined ) {
  849. found = object[camelCaseValue];
  850. return false;
  851. }
  852. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  853. object = object[value];
  854. }
  855. else if( object[value] !== undefined ) {
  856. found = object[value];
  857. return false;
  858. }
  859. else {
  860. return false;
  861. }
  862. });
  863. }
  864. if ( $.isFunction( found ) ) {
  865. response = found.apply(context, passedArguments);
  866. }
  867. else if(found !== undefined) {
  868. response = found;
  869. }
  870. if($.isArray(returnedValue)) {
  871. returnedValue.push(response);
  872. }
  873. else if(returnedValue !== undefined) {
  874. returnedValue = [returnedValue, response];
  875. }
  876. else if(response !== undefined) {
  877. returnedValue = response;
  878. }
  879. return (found !== undefined)
  880. ? found
  881. : false
  882. ;
  883. }
  884. };
  885. module.initialize();
  886. })
  887. ;
  888. return (returnedValue !== undefined)
  889. ? returnedValue
  890. : this
  891. ;
  892. };
  893. // Records if CSS transition is available
  894. $.fn.transition.exists = {};
  895. $.fn.transition.settings = {
  896. // module info
  897. name : 'Transition',
  898. // debug content outputted to console
  899. debug : false,
  900. // verbose debug output
  901. verbose : false,
  902. // performance data output
  903. performance : true,
  904. // event namespace
  905. namespace : 'transition',
  906. // delay between animations in group
  907. interval : 0,
  908. // whether group animations should be reversed
  909. reverse : 'auto',
  910. // animation callback event
  911. onStart : function() {},
  912. onComplete : function() {},
  913. onShow : function() {},
  914. onHide : function() {},
  915. // whether timeout should be used to ensure callback fires in cases animationend does not
  916. useFailSafe : true,
  917. // delay in ms for fail safe
  918. failSafeDelay : 100,
  919. // whether EXACT animation can occur twice in a row
  920. allowRepeats : false,
  921. // Override final display type on visible
  922. displayType : false,
  923. // animation duration
  924. animation : 'fade',
  925. duration : false,
  926. // new animations will occur after previous ones
  927. queue : true,
  928. metadata : {
  929. displayType: 'display'
  930. },
  931. className : {
  932. animating : 'animating',
  933. disabled : 'disabled',
  934. hidden : 'hidden',
  935. inward : 'in',
  936. loading : 'loading',
  937. looping : 'looping',
  938. outward : 'out',
  939. transition : 'transition',
  940. visible : 'visible'
  941. },
  942. // possible errors
  943. error: {
  944. 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.',
  945. repeated : 'That animation is already occurring, cancelling repeated animation',
  946. method : 'The method you called is not defined',
  947. support : 'This browser does not support CSS animations'
  948. }
  949. };
  950. })( jQuery, window , document );