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.

1068 lines
33 KiB

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