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.

1036 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
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
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
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
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
  1. /*!
  2. * # Semantic UI 2.0.0 - 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. if(displayType !== 'none') {
  336. $module.data(metadata.displayType, displayType);
  337. }
  338. },
  339. transitionExists: function(animation, exists) {
  340. $.fn.transition.exists[animation] = exists;
  341. module.verbose('Saving existence of transition', animation, exists);
  342. },
  343. conditions: function() {
  344. $module.removeClass(settings.animation);
  345. module.remove.direction();
  346. module.cache = {
  347. className : $module.attr('class'),
  348. style : module.get.style()
  349. };
  350. module.verbose('Saving original attributes', module.cache);
  351. }
  352. },
  353. restore: {
  354. conditions: function() {
  355. if(module.cache === undefined) {
  356. return false;
  357. }
  358. if(module.cache.className) {
  359. $module.attr('class', module.cache.className);
  360. }
  361. else {
  362. $module.removeAttr('class');
  363. }
  364. if(module.cache.style) {
  365. module.verbose('Restoring original style attribute', module.cache.style);
  366. $module.attr('style', module.cache.style);
  367. }
  368. else {
  369. module.verbose('Clearing style attribute');
  370. $module.removeAttr('style');
  371. }
  372. module.verbose('Restoring original attributes', module.cache);
  373. }
  374. },
  375. add: {
  376. failSafe: function() {
  377. var
  378. duration = module.get.duration()
  379. ;
  380. module.timer = setTimeout(function() {
  381. $module.trigger(animationEnd);
  382. }, duration + settings.failSafeDelay);
  383. module.verbose('Adding fail safe timer', module.timer);
  384. }
  385. },
  386. remove: {
  387. animating: function() {
  388. $module.removeClass(className.animating);
  389. },
  390. animation: function() {
  391. $module
  392. .css({
  393. '-webkit-animation' : '',
  394. '-moz-animation' : '',
  395. '-ms-animation' : '',
  396. '-o-animation' : '',
  397. 'animation' : ''
  398. })
  399. ;
  400. },
  401. animationCallbacks: function() {
  402. module.remove.queueCallback();
  403. module.remove.completeCallback();
  404. },
  405. queueCallback: function() {
  406. $module.off('.queue' + eventNamespace)
  407. },
  408. completeCallback: function() {
  409. $module.off('.complete' + eventNamespace);
  410. },
  411. display: function() {
  412. $module.css('display', '');
  413. },
  414. direction: function() {
  415. $module
  416. .removeClass(className.inward)
  417. .removeClass(className.outward)
  418. ;
  419. },
  420. failSafe: function() {
  421. module.verbose('Removing fail safe timer', module.timer);
  422. if(module.timer) {
  423. clearTimeout(module.timer);
  424. }
  425. },
  426. hidden: function() {
  427. $module.removeClass(className.hidden);
  428. },
  429. visible: function() {
  430. $module.removeClass(className.visible);
  431. },
  432. looping: function() {
  433. module.debug('Transitions are no longer looping');
  434. if( module.is.looping() ) {
  435. module.reset();
  436. $module
  437. .removeClass(className.looping)
  438. ;
  439. }
  440. },
  441. transition: function() {
  442. $module
  443. .removeClass(className.visible)
  444. .removeClass(className.hidden)
  445. ;
  446. }
  447. },
  448. get: {
  449. settings: function(animation, duration, onComplete) {
  450. // single settings object
  451. if(typeof animation == 'object') {
  452. return $.extend(true, {}, $.fn.transition.settings, animation);
  453. }
  454. // all arguments provided
  455. else if(typeof onComplete == 'function') {
  456. return $.extend({}, $.fn.transition.settings, {
  457. animation : animation,
  458. onComplete : onComplete,
  459. duration : duration
  460. });
  461. }
  462. // only duration provided
  463. else if(typeof duration == 'string' || typeof duration == 'number') {
  464. return $.extend({}, $.fn.transition.settings, {
  465. animation : animation,
  466. duration : duration
  467. });
  468. }
  469. // duration is actually settings object
  470. else if(typeof duration == 'object') {
  471. return $.extend({}, $.fn.transition.settings, duration, {
  472. animation : animation
  473. });
  474. }
  475. // duration is actually callback
  476. else if(typeof duration == 'function') {
  477. return $.extend({}, $.fn.transition.settings, {
  478. animation : animation,
  479. onComplete : duration
  480. });
  481. }
  482. // only animation provided
  483. else {
  484. return $.extend({}, $.fn.transition.settings, {
  485. animation : animation
  486. });
  487. }
  488. return $.fn.transition.settings;
  489. },
  490. direction: function(animation) {
  491. // quickest manually specified direction
  492. animation = animation || settings.animation;
  493. if(typeof animation === 'string') {
  494. animation = animation.split(' ');
  495. $.each(animation, function(index, word){
  496. if(word === className.inward) {
  497. return className.inward;
  498. }
  499. else if(word === className.outward) {
  500. return className.outward;
  501. }
  502. });
  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. animationName: function() {
  547. var
  548. element = document.createElement('div'),
  549. animations = {
  550. 'animation' :'animationName',
  551. 'OAnimation' :'oAnimationName',
  552. 'MozAnimation' :'mozAnimationName',
  553. 'WebkitAnimation' :'webkitAnimationName'
  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. animationStartEvent: function() {
  565. var
  566. element = document.createElement('div'),
  567. animations = {
  568. 'animation' :'animationstart',
  569. 'OAnimation' :'oAnimationStart',
  570. 'MozAnimation' :'mozAnimationStart',
  571. 'WebkitAnimation' :'webkitAnimationStart'
  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. animationEndEvent: function() {
  583. var
  584. element = document.createElement('div'),
  585. animations = {
  586. 'animation' :'animationend',
  587. 'OAnimation' :'oAnimationEnd',
  588. 'MozAnimation' :'mozAnimationEnd',
  589. 'WebkitAnimation' :'webkitAnimationEnd'
  590. },
  591. animation
  592. ;
  593. for(animation in animations){
  594. if( element.style[animation] !== undefined ){
  595. return animations[animation];
  596. }
  597. }
  598. return false;
  599. }
  600. },
  601. can: {
  602. transition: function(forced) {
  603. var
  604. elementClass = $module.attr('class'),
  605. tagName = $module.prop('tagName'),
  606. animation = settings.animation,
  607. transitionExists = module.get.transitionExists(animation),
  608. $clone,
  609. currentAnimation,
  610. inAnimation,
  611. directionExists,
  612. displayType
  613. ;
  614. if( transitionExists === undefined || forced) {
  615. module.verbose('Determining whether animation exists');
  616. $clone = $('<' + tagName + ' />').addClass( elementClass ).insertAfter($module);
  617. currentAnimation = $clone
  618. .addClass(animation)
  619. .removeClass(className.inward)
  620. .removeClass(className.outward)
  621. .addClass(className.animating)
  622. .addClass(className.transition)
  623. .css(animationName)
  624. ;
  625. inAnimation = $clone
  626. .addClass(className.inward)
  627. .css(animationName)
  628. ;
  629. displayType = $clone
  630. .attr('class', elementClass)
  631. .removeAttr('style')
  632. .removeClass(className.hidden)
  633. .removeClass(className.visible)
  634. .show()
  635. .css('display')
  636. ;
  637. module.verbose('Determining final display state', displayType);
  638. module.save.displayType(displayType);
  639. $clone.remove();
  640. if(currentAnimation != inAnimation) {
  641. module.debug('Direction exists for animation', animation);
  642. directionExists = true;
  643. }
  644. else if(currentAnimation == 'none' || !currentAnimation) {
  645. module.debug('No animation defined in css', animation);
  646. return;
  647. }
  648. else {
  649. module.debug('Static animation found', animation, displayType);
  650. directionExists = false;
  651. }
  652. module.save.transitionExists(animation, directionExists);
  653. }
  654. return (transitionExists !== undefined)
  655. ? transitionExists
  656. : directionExists
  657. ;
  658. },
  659. animate: function() {
  660. // can transition does not return a value if animation does not exist
  661. return (module.can.transition() !== undefined);
  662. }
  663. },
  664. is: {
  665. animating: function() {
  666. return $module.hasClass(className.animating);
  667. },
  668. inward: function() {
  669. return $module.hasClass(className.inward);
  670. },
  671. outward: function() {
  672. return $module.hasClass(className.outward);
  673. },
  674. looping: function() {
  675. return $module.hasClass(className.looping);
  676. },
  677. occurring: function(animation) {
  678. animation = animation || settings.animation;
  679. animation = '.' + animation.replace(' ', '.');
  680. return ( $module.filter(animation).length > 0 );
  681. },
  682. visible: function() {
  683. return $module.is(':visible');
  684. },
  685. hidden: function() {
  686. return $module.css('visibility') === 'hidden';
  687. },
  688. supported: function() {
  689. return(animationName !== false && animationEnd !== false);
  690. }
  691. },
  692. hide: function() {
  693. module.verbose('Hiding element');
  694. if( module.is.animating() ) {
  695. module.reset();
  696. }
  697. module.remove.display();
  698. module.remove.visible();
  699. module.set.hidden();
  700. module.repaint();
  701. },
  702. show: function(display) {
  703. module.verbose('Showing element', display);
  704. module.remove.hidden();
  705. module.set.visible();
  706. module.set.display();
  707. module.repaint();
  708. },
  709. toggle: function() {
  710. if( module.is.visible() ) {
  711. module.hide();
  712. }
  713. else {
  714. module.show();
  715. }
  716. },
  717. stop: function() {
  718. module.debug('Stopping current animation');
  719. $module.trigger(animationEnd);
  720. },
  721. stopAll: function() {
  722. module.debug('Stopping all animation');
  723. module.remove.queueCallback();
  724. $module.trigger(animationEnd);
  725. },
  726. clear: {
  727. queue: function() {
  728. module.debug('Clearing animation queue')
  729. module.remove.queueCallback();
  730. }
  731. },
  732. enable: function() {
  733. module.verbose('Starting animation');
  734. $module.removeClass(className.disabled);
  735. },
  736. disable: function() {
  737. module.debug('Stopping animation');
  738. $module.addClass(className.disabled);
  739. },
  740. setting: function(name, value) {
  741. module.debug('Changing setting', name, value);
  742. if( $.isPlainObject(name) ) {
  743. $.extend(true, settings, name);
  744. }
  745. else if(value !== undefined) {
  746. settings[name] = value;
  747. }
  748. else {
  749. return settings[name];
  750. }
  751. },
  752. internal: function(name, value) {
  753. if( $.isPlainObject(name) ) {
  754. $.extend(true, module, name);
  755. }
  756. else if(value !== undefined) {
  757. module[name] = value;
  758. }
  759. else {
  760. return module[name];
  761. }
  762. },
  763. debug: function() {
  764. if(settings.debug) {
  765. if(settings.performance) {
  766. module.performance.log(arguments);
  767. }
  768. else {
  769. module.debug = Function.prototype.bind.call(console.info, console, settings.name + ':');
  770. module.debug.apply(console, arguments);
  771. }
  772. }
  773. },
  774. verbose: function() {
  775. if(settings.verbose && settings.debug) {
  776. if(settings.performance) {
  777. module.performance.log(arguments);
  778. }
  779. else {
  780. module.verbose = Function.prototype.bind.call(console.info, console, settings.name + ':');
  781. module.verbose.apply(console, arguments);
  782. }
  783. }
  784. },
  785. error: function() {
  786. module.error = Function.prototype.bind.call(console.error, console, settings.name + ':');
  787. module.error.apply(console, arguments);
  788. },
  789. performance: {
  790. log: function(message) {
  791. var
  792. currentTime,
  793. executionTime,
  794. previousTime
  795. ;
  796. if(settings.performance) {
  797. currentTime = new Date().getTime();
  798. previousTime = time || currentTime;
  799. executionTime = currentTime - previousTime;
  800. time = currentTime;
  801. performance.push({
  802. 'Name' : message[0],
  803. 'Arguments' : [].slice.call(message, 1) || '',
  804. 'Element' : element,
  805. 'Execution Time' : executionTime
  806. });
  807. }
  808. clearTimeout(module.performance.timer);
  809. module.performance.timer = setTimeout(module.performance.display, 500);
  810. },
  811. display: function() {
  812. var
  813. title = settings.name + ':',
  814. totalTime = 0
  815. ;
  816. time = false;
  817. clearTimeout(module.performance.timer);
  818. $.each(performance, function(index, data) {
  819. totalTime += data['Execution Time'];
  820. });
  821. title += ' ' + totalTime + 'ms';
  822. if(moduleSelector) {
  823. title += ' \'' + moduleSelector + '\'';
  824. }
  825. if($allModules.length > 1) {
  826. title += ' ' + '(' + $allModules.length + ')';
  827. }
  828. if( (console.group !== undefined || console.table !== undefined) && performance.length > 0) {
  829. console.groupCollapsed(title);
  830. if(console.table) {
  831. console.table(performance);
  832. }
  833. else {
  834. $.each(performance, function(index, data) {
  835. console.log(data['Name'] + ': ' + data['Execution Time']+'ms');
  836. });
  837. }
  838. console.groupEnd();
  839. }
  840. performance = [];
  841. }
  842. },
  843. // modified for transition to return invoke success
  844. invoke: function(query, passedArguments, context) {
  845. var
  846. object = instance,
  847. maxDepth,
  848. found,
  849. response
  850. ;
  851. passedArguments = passedArguments || queryArguments;
  852. context = element || context;
  853. if(typeof query == 'string' && object !== undefined) {
  854. query = query.split(/[\. ]/);
  855. maxDepth = query.length - 1;
  856. $.each(query, function(depth, value) {
  857. var camelCaseValue = (depth != maxDepth)
  858. ? value + query[depth + 1].charAt(0).toUpperCase() + query[depth + 1].slice(1)
  859. : query
  860. ;
  861. if( $.isPlainObject( object[camelCaseValue] ) && (depth != maxDepth) ) {
  862. object = object[camelCaseValue];
  863. }
  864. else if( object[camelCaseValue] !== undefined ) {
  865. found = object[camelCaseValue];
  866. return false;
  867. }
  868. else if( $.isPlainObject( object[value] ) && (depth != maxDepth) ) {
  869. object = object[value];
  870. }
  871. else if( object[value] !== undefined ) {
  872. found = object[value];
  873. return false;
  874. }
  875. else {
  876. return false;
  877. }
  878. });
  879. }
  880. if ( $.isFunction( found ) ) {
  881. response = found.apply(context, passedArguments);
  882. }
  883. else if(found !== undefined) {
  884. response = found;
  885. }
  886. if($.isArray(returnedValue)) {
  887. returnedValue.push(response);
  888. }
  889. else if(returnedValue !== undefined) {
  890. returnedValue = [returnedValue, response];
  891. }
  892. else if(response !== undefined) {
  893. returnedValue = response;
  894. }
  895. return (found !== undefined)
  896. ? found
  897. : false
  898. ;
  899. }
  900. };
  901. module.initialize();
  902. })
  903. ;
  904. return (returnedValue !== undefined)
  905. ? returnedValue
  906. : this
  907. ;
  908. };
  909. // Records if CSS transition is available
  910. $.fn.transition.exists = {};
  911. $.fn.transition.settings = {
  912. // module info
  913. name : 'Transition',
  914. // debug content outputted to console
  915. debug : false,
  916. // verbose debug output
  917. verbose : false,
  918. // performance data output
  919. performance : true,
  920. // event namespace
  921. namespace : 'transition',
  922. // delay between animations in group
  923. interval : 0,
  924. // whether group animations should be reversed
  925. reverse : 'auto',
  926. // animation callback event
  927. onStart : function() {},
  928. onComplete : function() {},
  929. onShow : function() {},
  930. onHide : function() {},
  931. // whether timeout should be used to ensure callback fires in cases animationend does not
  932. useFailSafe : true,
  933. // delay in ms for fail safe
  934. failSafeDelay : 100,
  935. // whether EXACT animation can occur twice in a row
  936. allowRepeats : false,
  937. // Override final display type on visible
  938. displayType : false,
  939. // animation duration
  940. animation : 'fade',
  941. duration : false,
  942. // new animations will occur after previous ones
  943. queue : true,
  944. metadata : {
  945. displayType: 'display'
  946. },
  947. className : {
  948. animating : 'animating',
  949. disabled : 'disabled',
  950. hidden : 'hidden',
  951. inward : 'in',
  952. loading : 'loading',
  953. looping : 'looping',
  954. outward : 'out',
  955. transition : 'transition',
  956. visible : 'visible'
  957. },
  958. // possible errors
  959. error: {
  960. noAnimation : 'There is no css animation matching the one you specified.',
  961. repeated : 'That animation is already occurring, cancelling repeated animation',
  962. method : 'The method you called is not defined',
  963. support : 'This browser does not support CSS animations'
  964. }
  965. };
  966. })( jQuery, window , document );