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.

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