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.

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