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.

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