transitionize.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. ;(function(){
  2. /**
  3. * Require the given path.
  4. *
  5. * @param {String} path
  6. * @return {Object} exports
  7. * @api public
  8. */
  9. function require(path, parent, orig) {
  10. var resolved = require.resolve(path);
  11. // lookup failed
  12. if (null == resolved) {
  13. orig = orig || path;
  14. parent = parent || 'root';
  15. var err = new Error('Failed to require "' + orig + '" from "' + parent + '"');
  16. err.path = orig;
  17. err.parent = parent;
  18. err.require = true;
  19. throw err;
  20. }
  21. var module = require.modules[resolved];
  22. // perform real require()
  23. // by invoking the module's
  24. // registered function
  25. if (!module._resolving && !module.exports) {
  26. var mod = {};
  27. mod.exports = {};
  28. mod.client = mod.component = true;
  29. module._resolving = true;
  30. module.call(this, mod.exports, require.relative(resolved), mod);
  31. delete module._resolving;
  32. module.exports = mod.exports;
  33. }
  34. return module.exports;
  35. }
  36. /**
  37. * Registered modules.
  38. */
  39. require.modules = {};
  40. /**
  41. * Registered aliases.
  42. */
  43. require.aliases = {};
  44. /**
  45. * Resolve `path`.
  46. *
  47. * Lookup:
  48. *
  49. * - PATH/index.js
  50. * - PATH.js
  51. * - PATH
  52. *
  53. * @param {String} path
  54. * @return {String} path or null
  55. * @api private
  56. */
  57. require.resolve = function(path) {
  58. if (path.charAt(0) === '/') path = path.slice(1);
  59. var paths = [
  60. path,
  61. path + '.js',
  62. path + '.json',
  63. path + '/index.js',
  64. path + '/index.json'
  65. ];
  66. for (var i = 0; i < paths.length; i++) {
  67. var path = paths[i];
  68. if (require.modules.hasOwnProperty(path)) return path;
  69. if (require.aliases.hasOwnProperty(path)) return require.aliases[path];
  70. }
  71. };
  72. /**
  73. * Normalize `path` relative to the current path.
  74. *
  75. * @param {String} curr
  76. * @param {String} path
  77. * @return {String}
  78. * @api private
  79. */
  80. require.normalize = function(curr, path) {
  81. var segs = [];
  82. if ('.' != path.charAt(0)) return path;
  83. curr = curr.split('/');
  84. path = path.split('/');
  85. for (var i = 0; i < path.length; ++i) {
  86. if ('..' == path[i]) {
  87. curr.pop();
  88. } else if ('.' != path[i] && '' != path[i]) {
  89. segs.push(path[i]);
  90. }
  91. }
  92. return curr.concat(segs).join('/');
  93. };
  94. /**
  95. * Register module at `path` with callback `definition`.
  96. *
  97. * @param {String} path
  98. * @param {Function} definition
  99. * @api private
  100. */
  101. require.register = function(path, definition) {
  102. require.modules[path] = definition;
  103. };
  104. /**
  105. * Alias a module definition.
  106. *
  107. * @param {String} from
  108. * @param {String} to
  109. * @api private
  110. */
  111. require.alias = function(from, to) {
  112. if (!require.modules.hasOwnProperty(from)) {
  113. throw new Error('Failed to alias "' + from + '", it does not exist');
  114. }
  115. require.aliases[to] = from;
  116. };
  117. /**
  118. * Return a require function relative to the `parent` path.
  119. *
  120. * @param {String} parent
  121. * @return {Function}
  122. * @api private
  123. */
  124. require.relative = function(parent) {
  125. var p = require.normalize(parent, '..');
  126. /**
  127. * lastIndexOf helper.
  128. */
  129. function lastIndexOf(arr, obj) {
  130. var i = arr.length;
  131. while (i--) {
  132. if (arr[i] === obj) return i;
  133. }
  134. return -1;
  135. }
  136. /**
  137. * The relative require() itself.
  138. */
  139. function localRequire(path) {
  140. var resolved = localRequire.resolve(path);
  141. return require(resolved, parent, path);
  142. }
  143. /**
  144. * Resolve relative to the parent.
  145. */
  146. localRequire.resolve = function(path) {
  147. var c = path.charAt(0);
  148. if ('/' == c) return path.slice(1);
  149. if ('.' == c) return require.normalize(p, path);
  150. // resolve deps by returning
  151. // the dep in the nearest "deps"
  152. // directory
  153. var segs = parent.split('/');
  154. var i = lastIndexOf(segs, 'deps') + 1;
  155. if (!i) i = 0;
  156. path = segs.slice(0, i + 1).join('/') + '/deps/' + path;
  157. return path;
  158. };
  159. /**
  160. * Check if module is defined at `path`.
  161. */
  162. localRequire.exists = function(path) {
  163. return require.modules.hasOwnProperty(localRequire.resolve(path));
  164. };
  165. return localRequire;
  166. };
  167. require.register("transitionize/transitionize.js", function(exports, require, module){
  168. /**
  169. * Transitionize 0.0.3
  170. * https://github.com/abpetkov/transitionize
  171. *
  172. * Authored by Alexander Petkov
  173. * https://github.com/abpetkov
  174. *
  175. * Copyright 2013, Alexander Petkov
  176. * License: The MIT License (MIT)
  177. * http://opensource.org/licenses/MIT
  178. *
  179. */
  180. /**
  181. * Expose `Transitionize`.
  182. */
  183. module.exports = Transitionize;
  184. /**
  185. * Initialize new Transitionize.
  186. *
  187. * @param {Object} element
  188. * @param {Object} props
  189. * @api public
  190. */
  191. function Transitionize(element, props) {
  192. if (!(this instanceof Transitionize)) return new Transitionize(element, props);
  193. this.element = element;
  194. this.props = props || {};
  195. this.init();
  196. }
  197. /**
  198. * Detect if Safari.
  199. *
  200. * @returns {Boolean}
  201. * @api private
  202. */
  203. Transitionize.prototype.isSafari = function() {
  204. return (/Safari/).test(navigator.userAgent) && (/Apple Computer/).test(navigator.vendor);
  205. };
  206. /**
  207. * Loop though the object and push the keys and values in an array.
  208. * Apply the CSS3 transition to the element and prefix with -webkit- for Safari.
  209. *
  210. * @api private
  211. */
  212. Transitionize.prototype.init = function() {
  213. var transitions = [];
  214. for (var key in this.props) {
  215. transitions.push(key + ' ' + this.props[key]);
  216. }
  217. this.element.style.transition = transitions.join(', ');
  218. if (this.isSafari()) this.element.style.webkitTransition = transitions.join(', ');
  219. };
  220. });
  221. require.alias("transitionize/transitionize.js", "transitionize/index.js");if (typeof exports == "object") {
  222. module.exports = require("transitionize");
  223. } else if (typeof define == "function" && define.amd) {
  224. define(function(){ return require("transitionize"); });
  225. } else {
  226. this["Transitionize"] = require("transitionize");
  227. }})();