PageRenderTime 205ms CodeModel.GetById 39ms RepoModel.GetById 2ms app.codeStats 6ms

/app/lib/angular-1.0.1.js

https://bitbucket.org/deshartman/containerdirective
JavaScript | 14327 lines | 7833 code | 1073 blank | 5421 comment | 1082 complexity | 5e5b7510dafb031f7893cf091bc20559 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. /**
  2. * @license AngularJS v1.0.1
  3. * (c) 2010-2012 Google, Inc. http://angularjs.org
  4. * License: MIT
  5. */
  6. (function(window, document, undefined) {
  7. 'use strict';
  8. ////////////////////////////////////
  9. /**
  10. * @ngdoc function
  11. * @name angular.lowercase
  12. * @function
  13. *
  14. * @description Converts the specified string to lowercase.
  15. * @param {string} string String to be converted to lowercase.
  16. * @returns {string} Lowercased string.
  17. */
  18. var lowercase = function(string){return isString(string) ? string.toLowerCase() : string;};
  19. /**
  20. * @ngdoc function
  21. * @name angular.uppercase
  22. * @function
  23. *
  24. * @description Converts the specified string to uppercase.
  25. * @param {string} string String to be converted to uppercase.
  26. * @returns {string} Uppercased string.
  27. */
  28. var uppercase = function(string){return isString(string) ? string.toUpperCase() : string;};
  29. var manualLowercase = function(s) {
  30. return isString(s)
  31. ? s.replace(/[A-Z]/g, function(ch) {return fromCharCode(ch.charCodeAt(0) | 32);})
  32. : s;
  33. };
  34. var manualUppercase = function(s) {
  35. return isString(s)
  36. ? s.replace(/[a-z]/g, function(ch) {return fromCharCode(ch.charCodeAt(0) & ~32);})
  37. : s;
  38. };
  39. // String#toLowerCase and String#toUpperCase don't produce correct results in browsers with Turkish
  40. // locale, for this reason we need to detect this case and redefine lowercase/uppercase methods
  41. // with correct but slower alternatives.
  42. if ('i' !== 'I'.toLowerCase()) {
  43. lowercase = manualLowercase;
  44. uppercase = manualUppercase;
  45. }
  46. function fromCharCode(code) {return String.fromCharCode(code);}
  47. var Error = window.Error,
  48. /** holds major version number for IE or NaN for real browsers */
  49. msie = int((/msie (\d+)/.exec(lowercase(navigator.userAgent)) || [])[1]),
  50. jqLite, // delay binding since jQuery could be loaded after us.
  51. jQuery, // delay binding
  52. slice = [].slice,
  53. push = [].push,
  54. toString = Object.prototype.toString,
  55. /** @name angular */
  56. angular = window.angular || (window.angular = {}),
  57. angularModule,
  58. nodeName_,
  59. uid = ['0', '0', '0'];
  60. /**
  61. * @ngdoc function
  62. * @name angular.forEach
  63. * @function
  64. *
  65. * @description
  66. * Invokes the `iterator` function once for each item in `obj` collection, which can be either an
  67. * object or an array. The `iterator` function is invoked with `iterator(value, key)`, where `value`
  68. * is the value of an object property or an array element and `key` is the object property key or
  69. * array element index. Specifying a `context` for the function is optional.
  70. *
  71. * Note: this function was previously known as `angular.foreach`.
  72. *
  73. <pre>
  74. var values = {name: 'misko', gender: 'male'};
  75. var log = [];
  76. angular.forEach(values, function(value, key){
  77. this.push(key + ': ' + value);
  78. }, log);
  79. expect(log).toEqual(['name: misko', 'gender:male']);
  80. </pre>
  81. *
  82. * @param {Object|Array} obj Object to iterate over.
  83. * @param {Function} iterator Iterator function.
  84. * @param {Object=} context Object to become context (`this`) for the iterator function.
  85. * @returns {Object|Array} Reference to `obj`.
  86. */
  87. function forEach(obj, iterator, context) {
  88. var key;
  89. if (obj) {
  90. if (isFunction(obj)){
  91. for (key in obj) {
  92. if (key != 'prototype' && key != 'length' && key != 'name' && obj.hasOwnProperty(key)) {
  93. iterator.call(context, obj[key], key);
  94. }
  95. }
  96. } else if (obj.forEach && obj.forEach !== forEach) {
  97. obj.forEach(iterator, context);
  98. } else if (isObject(obj) && isNumber(obj.length)) {
  99. for (key = 0; key < obj.length; key++)
  100. iterator.call(context, obj[key], key);
  101. } else {
  102. for (key in obj) {
  103. if (obj.hasOwnProperty(key)) {
  104. iterator.call(context, obj[key], key);
  105. }
  106. }
  107. }
  108. }
  109. return obj;
  110. }
  111. function sortedKeys(obj) {
  112. var keys = [];
  113. for (var key in obj) {
  114. if (obj.hasOwnProperty(key)) {
  115. keys.push(key);
  116. }
  117. }
  118. return keys.sort();
  119. }
  120. function forEachSorted(obj, iterator, context) {
  121. var keys = sortedKeys(obj);
  122. for ( var i = 0; i < keys.length; i++) {
  123. iterator.call(context, obj[keys[i]], keys[i]);
  124. }
  125. return keys;
  126. }
  127. /**
  128. * when using forEach the params are value, key, but it is often useful to have key, value.
  129. * @param {function(string, *)} iteratorFn
  130. * @returns {function(*, string)}
  131. */
  132. function reverseParams(iteratorFn) {
  133. return function(value, key) { iteratorFn(key, value) };
  134. }
  135. /**
  136. * A consistent way of creating unique IDs in angular. The ID is a sequence of alpha numeric
  137. * characters such as '012ABC'. The reason why we are not using simply a number counter is that
  138. * the number string gets longer over time, and it can also overflow, where as the the nextId
  139. * will grow much slower, it is a string, and it will never overflow.
  140. *
  141. * @returns an unique alpha-numeric string
  142. */
  143. function nextUid() {
  144. var index = uid.length;
  145. var digit;
  146. while(index) {
  147. index--;
  148. digit = uid[index].charCodeAt(0);
  149. if (digit == 57 /*'9'*/) {
  150. uid[index] = 'A';
  151. return uid.join('');
  152. }
  153. if (digit == 90 /*'Z'*/) {
  154. uid[index] = '0';
  155. } else {
  156. uid[index] = String.fromCharCode(digit + 1);
  157. return uid.join('');
  158. }
  159. }
  160. uid.unshift('0');
  161. return uid.join('');
  162. }
  163. /**
  164. * @ngdoc function
  165. * @name angular.extend
  166. * @function
  167. *
  168. * @description
  169. * Extends the destination object `dst` by copying all of the properties from the `src` object(s)
  170. * to `dst`. You can specify multiple `src` objects.
  171. *
  172. * @param {Object} dst Destination object.
  173. * @param {...Object} src Source object(s).
  174. */
  175. function extend(dst) {
  176. forEach(arguments, function(obj){
  177. if (obj !== dst) {
  178. forEach(obj, function(value, key){
  179. dst[key] = value;
  180. });
  181. }
  182. });
  183. return dst;
  184. }
  185. function int(str) {
  186. return parseInt(str, 10);
  187. }
  188. function inherit(parent, extra) {
  189. return extend(new (extend(function() {}, {prototype:parent}))(), extra);
  190. }
  191. /**
  192. * @ngdoc function
  193. * @name angular.noop
  194. * @function
  195. *
  196. * @description
  197. * A function that performs no operations. This function can be useful when writing code in the
  198. * functional style.
  199. <pre>
  200. function foo(callback) {
  201. var result = calculateResult();
  202. (callback || angular.noop)(result);
  203. }
  204. </pre>
  205. */
  206. function noop() {}
  207. noop.$inject = [];
  208. /**
  209. * @ngdoc function
  210. * @name angular.identity
  211. * @function
  212. *
  213. * @description
  214. * A function that returns its first argument. This function is useful when writing code in the
  215. * functional style.
  216. *
  217. <pre>
  218. function transformer(transformationFn, value) {
  219. return (transformationFn || identity)(value);
  220. };
  221. </pre>
  222. */
  223. function identity($) {return $;}
  224. identity.$inject = [];
  225. function valueFn(value) {return function() {return value;};}
  226. /**
  227. * @ngdoc function
  228. * @name angular.isUndefined
  229. * @function
  230. *
  231. * @description
  232. * Determines if a reference is undefined.
  233. *
  234. * @param {*} value Reference to check.
  235. * @returns {boolean} True if `value` is undefined.
  236. */
  237. function isUndefined(value){return typeof value == 'undefined';}
  238. /**
  239. * @ngdoc function
  240. * @name angular.isDefined
  241. * @function
  242. *
  243. * @description
  244. * Determines if a reference is defined.
  245. *
  246. * @param {*} value Reference to check.
  247. * @returns {boolean} True if `value` is defined.
  248. */
  249. function isDefined(value){return typeof value != 'undefined';}
  250. /**
  251. * @ngdoc function
  252. * @name angular.isObject
  253. * @function
  254. *
  255. * @description
  256. * Determines if a reference is an `Object`. Unlike `typeof` in JavaScript, `null`s are not
  257. * considered to be objects.
  258. *
  259. * @param {*} value Reference to check.
  260. * @returns {boolean} True if `value` is an `Object` but not `null`.
  261. */
  262. function isObject(value){return value != null && typeof value == 'object';}
  263. /**
  264. * @ngdoc function
  265. * @name angular.isString
  266. * @function
  267. *
  268. * @description
  269. * Determines if a reference is a `String`.
  270. *
  271. * @param {*} value Reference to check.
  272. * @returns {boolean} True if `value` is a `String`.
  273. */
  274. function isString(value){return typeof value == 'string';}
  275. /**
  276. * @ngdoc function
  277. * @name angular.isNumber
  278. * @function
  279. *
  280. * @description
  281. * Determines if a reference is a `Number`.
  282. *
  283. * @param {*} value Reference to check.
  284. * @returns {boolean} True if `value` is a `Number`.
  285. */
  286. function isNumber(value){return typeof value == 'number';}
  287. /**
  288. * @ngdoc function
  289. * @name angular.isDate
  290. * @function
  291. *
  292. * @description
  293. * Determines if a value is a date.
  294. *
  295. * @param {*} value Reference to check.
  296. * @returns {boolean} True if `value` is a `Date`.
  297. */
  298. function isDate(value){
  299. return toString.apply(value) == '[object Date]';
  300. }
  301. /**
  302. * @ngdoc function
  303. * @name angular.isArray
  304. * @function
  305. *
  306. * @description
  307. * Determines if a reference is an `Array`.
  308. *
  309. * @param {*} value Reference to check.
  310. * @returns {boolean} True if `value` is an `Array`.
  311. */
  312. function isArray(value) {
  313. return toString.apply(value) == '[object Array]';
  314. }
  315. /**
  316. * @ngdoc function
  317. * @name angular.isFunction
  318. * @function
  319. *
  320. * @description
  321. * Determines if a reference is a `Function`.
  322. *
  323. * @param {*} value Reference to check.
  324. * @returns {boolean} True if `value` is a `Function`.
  325. */
  326. function isFunction(value){return typeof value == 'function';}
  327. /**
  328. * Checks if `obj` is a window object.
  329. *
  330. * @private
  331. * @param {*} obj Object to check
  332. * @returns {boolean} True if `obj` is a window obj.
  333. */
  334. function isWindow(obj) {
  335. return obj && obj.document && obj.location && obj.alert && obj.setInterval;
  336. }
  337. function isScope(obj) {
  338. return obj && obj.$evalAsync && obj.$watch;
  339. }
  340. function isFile(obj) {
  341. return toString.apply(obj) === '[object File]';
  342. }
  343. function isBoolean(value) {
  344. return typeof value == 'boolean';
  345. }
  346. function trim(value) {
  347. return isString(value) ? value.replace(/^\s*/, '').replace(/\s*$/, '') : value;
  348. }
  349. /**
  350. * @ngdoc function
  351. * @name angular.isElement
  352. * @function
  353. *
  354. * @description
  355. * Determines if a reference is a DOM element (or wrapped jQuery element).
  356. *
  357. * @param {*} value Reference to check.
  358. * @returns {boolean} True if `value` is a DOM element (or wrapped jQuery element).
  359. */
  360. function isElement(node) {
  361. return node &&
  362. (node.nodeName // we are a direct element
  363. || (node.bind && node.find)); // we have a bind and find method part of jQuery API
  364. }
  365. /**
  366. * @param str 'key1,key2,...'
  367. * @returns {object} in the form of {key1:true, key2:true, ...}
  368. */
  369. function makeMap(str){
  370. var obj = {}, items = str.split(","), i;
  371. for ( i = 0; i < items.length; i++ )
  372. obj[ items[i] ] = true;
  373. return obj;
  374. }
  375. if (msie < 9) {
  376. nodeName_ = function(element) {
  377. element = element.nodeName ? element : element[0];
  378. return (element.scopeName && element.scopeName != 'HTML')
  379. ? uppercase(element.scopeName + ':' + element.nodeName) : element.nodeName;
  380. };
  381. } else {
  382. nodeName_ = function(element) {
  383. return element.nodeName ? element.nodeName : element[0].nodeName;
  384. };
  385. }
  386. function map(obj, iterator, context) {
  387. var results = [];
  388. forEach(obj, function(value, index, list) {
  389. results.push(iterator.call(context, value, index, list));
  390. });
  391. return results;
  392. }
  393. /**
  394. * @description
  395. * Determines the number of elements in an array, the number of properties an object has, or
  396. * the length of a string.
  397. *
  398. * Note: This function is used to augment the Object type in Angular expressions. See
  399. * {@link angular.Object} for more information about Angular arrays.
  400. *
  401. * @param {Object|Array|string} obj Object, array, or string to inspect.
  402. * @param {boolean} [ownPropsOnly=false] Count only "own" properties in an object
  403. * @returns {number} The size of `obj` or `0` if `obj` is neither an object nor an array.
  404. */
  405. function size(obj, ownPropsOnly) {
  406. var size = 0, key;
  407. if (isArray(obj) || isString(obj)) {
  408. return obj.length;
  409. } else if (isObject(obj)){
  410. for (key in obj)
  411. if (!ownPropsOnly || obj.hasOwnProperty(key))
  412. size++;
  413. }
  414. return size;
  415. }
  416. function includes(array, obj) {
  417. return indexOf(array, obj) != -1;
  418. }
  419. function indexOf(array, obj) {
  420. if (array.indexOf) return array.indexOf(obj);
  421. for ( var i = 0; i < array.length; i++) {
  422. if (obj === array[i]) return i;
  423. }
  424. return -1;
  425. }
  426. function arrayRemove(array, value) {
  427. var index = indexOf(array, value);
  428. if (index >=0)
  429. array.splice(index, 1);
  430. return value;
  431. }
  432. function isLeafNode (node) {
  433. if (node) {
  434. switch (node.nodeName) {
  435. case "OPTION":
  436. case "PRE":
  437. case "TITLE":
  438. return true;
  439. }
  440. }
  441. return false;
  442. }
  443. /**
  444. * @ngdoc function
  445. * @name angular.copy
  446. * @function
  447. *
  448. * @description
  449. * Creates a deep copy of `source`, which should be an object or an array.
  450. *
  451. * * If no destination is supplied, a copy of the object or array is created.
  452. * * If a destination is provided, all of its elements (for array) or properties (for objects)
  453. * are deleted and then all elements/properties from the source are copied to it.
  454. * * If `source` is not an object or array, `source` is returned.
  455. *
  456. * Note: this function is used to augment the Object type in Angular expressions. See
  457. * {@link ng.$filter} for more information about Angular arrays.
  458. *
  459. * @param {*} source The source that will be used to make a copy.
  460. * Can be any type, including primitives, `null`, and `undefined`.
  461. * @param {(Object|Array)=} destination Destination into which the source is copied. If
  462. * provided, must be of the same type as `source`.
  463. * @returns {*} The copy or updated `destination`, if `destination` was specified.
  464. */
  465. function copy(source, destination){
  466. if (isWindow(source) || isScope(source)) throw Error("Can't copy Window or Scope");
  467. if (!destination) {
  468. destination = source;
  469. if (source) {
  470. if (isArray(source)) {
  471. destination = copy(source, []);
  472. } else if (isDate(source)) {
  473. destination = new Date(source.getTime());
  474. } else if (isObject(source)) {
  475. destination = copy(source, {});
  476. }
  477. }
  478. } else {
  479. if (source === destination) throw Error("Can't copy equivalent objects or arrays");
  480. if (isArray(source)) {
  481. while(destination.length) {
  482. destination.pop();
  483. }
  484. for ( var i = 0; i < source.length; i++) {
  485. destination.push(copy(source[i]));
  486. }
  487. } else {
  488. forEach(destination, function(value, key){
  489. delete destination[key];
  490. });
  491. for ( var key in source) {
  492. destination[key] = copy(source[key]);
  493. }
  494. }
  495. }
  496. return destination;
  497. }
  498. /**
  499. * Create a shallow copy of an object
  500. */
  501. function shallowCopy(src, dst) {
  502. dst = dst || {};
  503. for(var key in src) {
  504. if (src.hasOwnProperty(key) && key.substr(0, 2) !== '$$') {
  505. dst[key] = src[key];
  506. }
  507. }
  508. return dst;
  509. }
  510. /**
  511. * @ngdoc function
  512. * @name angular.equals
  513. * @function
  514. *
  515. * @description
  516. * Determines if two objects or two values are equivalent. Supports value types, arrays and
  517. * objects.
  518. *
  519. * Two objects or values are considered equivalent if at least one of the following is true:
  520. *
  521. * * Both objects or values pass `===` comparison.
  522. * * Both objects or values are of the same type and all of their properties pass `===` comparison.
  523. * * Both values are NaN. (In JavasScript, NaN == NaN => false. But we consider two NaN as equal)
  524. *
  525. * During a property comparision, properties of `function` type and properties with names
  526. * that begin with `$` are ignored.
  527. *
  528. * Scope and DOMWindow objects are being compared only be identify (`===`).
  529. *
  530. * @param {*} o1 Object or value to compare.
  531. * @param {*} o2 Object or value to compare.
  532. * @returns {boolean} True if arguments are equal.
  533. */
  534. function equals(o1, o2) {
  535. if (o1 === o2) return true;
  536. if (o1 === null || o2 === null) return false;
  537. if (o1 !== o1 && o2 !== o2) return true; // NaN === NaN
  538. var t1 = typeof o1, t2 = typeof o2, length, key, keySet;
  539. if (t1 == t2) {
  540. if (t1 == 'object') {
  541. if (isArray(o1)) {
  542. if ((length = o1.length) == o2.length) {
  543. for(key=0; key<length; key++) {
  544. if (!equals(o1[key], o2[key])) return false;
  545. }
  546. return true;
  547. }
  548. } else if (isDate(o1)) {
  549. return isDate(o2) && o1.getTime() == o2.getTime();
  550. } else {
  551. if (isScope(o1) || isScope(o2) || isWindow(o1) || isWindow(o2)) return false;
  552. keySet = {};
  553. for(key in o1) {
  554. if (key.charAt(0) !== '$' && !isFunction(o1[key]) && !equals(o1[key], o2[key])) {
  555. return false;
  556. }
  557. keySet[key] = true;
  558. }
  559. for(key in o2) {
  560. if (!keySet[key] && key.charAt(0) !== '$' && !isFunction(o2[key])) return false;
  561. }
  562. return true;
  563. }
  564. }
  565. }
  566. return false;
  567. }
  568. function concat(array1, array2, index) {
  569. return array1.concat(slice.call(array2, index));
  570. }
  571. function sliceArgs(args, startIndex) {
  572. return slice.call(args, startIndex || 0);
  573. }
  574. /**
  575. * @ngdoc function
  576. * @name angular.bind
  577. * @function
  578. *
  579. * @description
  580. * Returns a function which calls function `fn` bound to `self` (`self` becomes the `this` for
  581. * `fn`). You can supply optional `args` that are are prebound to the function. This feature is also
  582. * known as [function currying](http://en.wikipedia.org/wiki/Currying).
  583. *
  584. * @param {Object} self Context which `fn` should be evaluated in.
  585. * @param {function()} fn Function to be bound.
  586. * @param {...*} args Optional arguments to be prebound to the `fn` function call.
  587. * @returns {function()} Function that wraps the `fn` with all the specified bindings.
  588. */
  589. function bind(self, fn) {
  590. var curryArgs = arguments.length > 2 ? sliceArgs(arguments, 2) : [];
  591. if (isFunction(fn) && !(fn instanceof RegExp)) {
  592. return curryArgs.length
  593. ? function() {
  594. return arguments.length
  595. ? fn.apply(self, curryArgs.concat(slice.call(arguments, 0)))
  596. : fn.apply(self, curryArgs);
  597. }
  598. : function() {
  599. return arguments.length
  600. ? fn.apply(self, arguments)
  601. : fn.call(self);
  602. };
  603. } else {
  604. // in IE, native methods are not functions so they cannot be bound (note: they don't need to be)
  605. return fn;
  606. }
  607. }
  608. function toJsonReplacer(key, value) {
  609. var val = value;
  610. if (/^\$+/.test(key)) {
  611. val = undefined;
  612. } else if (isWindow(value)) {
  613. val = '$WINDOW';
  614. } else if (value && document === value) {
  615. val = '$DOCUMENT';
  616. } else if (isScope(value)) {
  617. val = '$SCOPE';
  618. }
  619. return val;
  620. }
  621. /**
  622. * @ngdoc function
  623. * @name angular.toJson
  624. * @function
  625. *
  626. * @description
  627. * Serializes input into a JSON-formatted string.
  628. *
  629. * @param {Object|Array|Date|string|number} obj Input to be serialized into JSON.
  630. * @param {boolean=} pretty If set to true, the JSON output will contain newlines and whitespace.
  631. * @returns {string} Jsonified string representing `obj`.
  632. */
  633. function toJson(obj, pretty) {
  634. return JSON.stringify(obj, toJsonReplacer, pretty ? ' ' : null);
  635. }
  636. /**
  637. * @ngdoc function
  638. * @name angular.fromJson
  639. * @function
  640. *
  641. * @description
  642. * Deserializes a JSON string.
  643. *
  644. * @param {string} json JSON string to deserialize.
  645. * @returns {Object|Array|Date|string|number} Deserialized thingy.
  646. */
  647. function fromJson(json) {
  648. return isString(json)
  649. ? JSON.parse(json)
  650. : json;
  651. }
  652. function toBoolean(value) {
  653. if (value && value.length !== 0) {
  654. var v = lowercase("" + value);
  655. value = !(v == 'f' || v == '0' || v == 'false' || v == 'no' || v == 'n' || v == '[]');
  656. } else {
  657. value = false;
  658. }
  659. return value;
  660. }
  661. /**
  662. * @returns {string} Returns the string representation of the element.
  663. */
  664. function startingTag(element) {
  665. element = jqLite(element).clone();
  666. try {
  667. // turns out IE does not let you set .html() on elements which
  668. // are not allowed to have children. So we just ignore it.
  669. element.html('');
  670. } catch(e) {}
  671. return jqLite('<div>').append(element).html().
  672. match(/^(<[^>]+>)/)[1].
  673. replace(/^<([\w\-]+)/, function(match, nodeName) { return '<' + lowercase(nodeName); });
  674. }
  675. /////////////////////////////////////////////////
  676. /**
  677. * Parses an escaped url query string into key-value pairs.
  678. * @returns Object.<(string|boolean)>
  679. */
  680. function parseKeyValue(/**string*/keyValue) {
  681. var obj = {}, key_value, key;
  682. forEach((keyValue || "").split('&'), function(keyValue){
  683. if (keyValue) {
  684. key_value = keyValue.split('=');
  685. key = decodeURIComponent(key_value[0]);
  686. obj[key] = isDefined(key_value[1]) ? decodeURIComponent(key_value[1]) : true;
  687. }
  688. });
  689. return obj;
  690. }
  691. function toKeyValue(obj) {
  692. var parts = [];
  693. forEach(obj, function(value, key) {
  694. parts.push(encodeUriQuery(key, true) + (value === true ? '' : '=' + encodeUriQuery(value, true)));
  695. });
  696. return parts.length ? parts.join('&') : '';
  697. }
  698. /**
  699. * We need our custom mehtod because encodeURIComponent is too agressive and doesn't follow
  700. * http://www.ietf.org/rfc/rfc3986.txt with regards to the character set (pchar) allowed in path
  701. * segments:
  702. * segment = *pchar
  703. * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
  704. * pct-encoded = "%" HEXDIG HEXDIG
  705. * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
  706. * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
  707. * / "*" / "+" / "," / ";" / "="
  708. */
  709. function encodeUriSegment(val) {
  710. return encodeUriQuery(val, true).
  711. replace(/%26/gi, '&').
  712. replace(/%3D/gi, '=').
  713. replace(/%2B/gi, '+');
  714. }
  715. /**
  716. * This method is intended for encoding *key* or *value* parts of query component. We need a custom
  717. * method becuase encodeURIComponent is too agressive and encodes stuff that doesn't have to be
  718. * encoded per http://tools.ietf.org/html/rfc3986:
  719. * query = *( pchar / "/" / "?" )
  720. * pchar = unreserved / pct-encoded / sub-delims / ":" / "@"
  721. * unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
  722. * pct-encoded = "%" HEXDIG HEXDIG
  723. * sub-delims = "!" / "$" / "&" / "'" / "(" / ")"
  724. * / "*" / "+" / "," / ";" / "="
  725. */
  726. function encodeUriQuery(val, pctEncodeSpaces) {
  727. return encodeURIComponent(val).
  728. replace(/%40/gi, '@').
  729. replace(/%3A/gi, ':').
  730. replace(/%24/g, '$').
  731. replace(/%2C/gi, ',').
  732. replace((pctEncodeSpaces ? null : /%20/g), '+');
  733. }
  734. /**
  735. * @ngdoc directive
  736. * @name ng.directive:ngApp
  737. *
  738. * @element ANY
  739. * @param {angular.Module} ngApp on optional application
  740. * {@link angular.module module} name to load.
  741. *
  742. * @description
  743. *
  744. * Use this directive to auto-bootstrap on application. Only
  745. * one directive can be used per HTML document. The directive
  746. * designates the root of the application and is typically placed
  747. * ot the root of the page.
  748. *
  749. * In the example below if the `ngApp` directive would not be placed
  750. * on the `html` element then the document would not be compiled
  751. * and the `{{ 1+2 }}` would not be resolved to `3`.
  752. *
  753. * `ngApp` is the easiest way to bootstrap an application.
  754. *
  755. <doc:example>
  756. <doc:source>
  757. I can add: 1 + 2 = {{ 1+2 }}
  758. </doc:source>
  759. </doc:example>
  760. *
  761. */
  762. function angularInit(element, bootstrap) {
  763. var elements = [element],
  764. appElement,
  765. module,
  766. names = ['ng:app', 'ng-app', 'x-ng-app', 'data-ng-app'],
  767. NG_APP_CLASS_REGEXP = /\sng[:\-]app(:\s*([\w\d_]+);?)?\s/;
  768. function append(element) {
  769. element && elements.push(element);
  770. }
  771. forEach(names, function(name) {
  772. names[name] = true;
  773. append(document.getElementById(name));
  774. name = name.replace(':', '\\:');
  775. if (element.querySelectorAll) {
  776. forEach(element.querySelectorAll('.' + name), append);
  777. forEach(element.querySelectorAll('.' + name + '\\:'), append);
  778. forEach(element.querySelectorAll('[' + name + ']'), append);
  779. }
  780. });
  781. forEach(elements, function(element) {
  782. if (!appElement) {
  783. var className = ' ' + element.className + ' ';
  784. var match = NG_APP_CLASS_REGEXP.exec(className);
  785. if (match) {
  786. appElement = element;
  787. module = (match[2] || '').replace(/\s+/g, ',');
  788. } else {
  789. forEach(element.attributes, function(attr) {
  790. if (!appElement && names[attr.name]) {
  791. appElement = element;
  792. module = attr.value;
  793. }
  794. });
  795. }
  796. }
  797. });
  798. if (appElement) {
  799. bootstrap(appElement, module ? [module] : []);
  800. }
  801. }
  802. /**
  803. * @ngdoc function
  804. * @name angular.bootstrap
  805. * @description
  806. * Use this function to manually start up angular application.
  807. *
  808. * See: {@link guide/bootstrap Bootstrap}
  809. *
  810. * @param {Element} element DOM element which is the root of angular application.
  811. * @param {Array<String|Function>=} modules an array of module declarations. See: {@link angular.module modules}
  812. * @returns {AUTO.$injector} Returns the newly created injector for this app.
  813. */
  814. function bootstrap(element, modules) {
  815. element = jqLite(element);
  816. modules = modules || [];
  817. modules.unshift(['$provide', function($provide) {
  818. $provide.value('$rootElement', element);
  819. }]);
  820. modules.unshift('ng');
  821. var injector = createInjector(modules);
  822. injector.invoke(
  823. ['$rootScope', '$rootElement', '$compile', '$injector', function(scope, element, compile, injector){
  824. scope.$apply(function() {
  825. element.data('$injector', injector);
  826. compile(element)(scope);
  827. });
  828. }]
  829. );
  830. return injector;
  831. }
  832. var SNAKE_CASE_REGEXP = /[A-Z]/g;
  833. function snake_case(name, separator){
  834. separator = separator || '_';
  835. return name.replace(SNAKE_CASE_REGEXP, function(letter, pos) {
  836. return (pos ? separator : '') + letter.toLowerCase();
  837. });
  838. }
  839. function bindJQuery() {
  840. // bind to jQuery if present;
  841. jQuery = window.jQuery;
  842. // reset to jQuery or default to us.
  843. if (jQuery) {
  844. jqLite = jQuery;
  845. extend(jQuery.fn, {
  846. scope: JQLitePrototype.scope,
  847. controller: JQLitePrototype.controller,
  848. injector: JQLitePrototype.injector,
  849. inheritedData: JQLitePrototype.inheritedData
  850. });
  851. JQLitePatchJQueryRemove('remove', true);
  852. JQLitePatchJQueryRemove('empty');
  853. JQLitePatchJQueryRemove('html');
  854. } else {
  855. jqLite = JQLite;
  856. }
  857. angular.element = jqLite;
  858. }
  859. /**
  860. * throw error of the argument is falsy.
  861. */
  862. function assertArg(arg, name, reason) {
  863. if (!arg) {
  864. throw new Error("Argument '" + (name || '?') + "' is " + (reason || "required"));
  865. }
  866. return arg;
  867. }
  868. function assertArgFn(arg, name, acceptArrayAnnotation) {
  869. if (acceptArrayAnnotation && isArray(arg)) {
  870. arg = arg[arg.length - 1];
  871. }
  872. assertArg(isFunction(arg), name, 'not a function, got ' +
  873. (arg && typeof arg == 'object' ? arg.constructor.name || 'Object' : typeof arg));
  874. return arg;
  875. }
  876. /**
  877. * @ngdoc interface
  878. * @name angular.Module
  879. * @description
  880. *
  881. * Interface for configuring angular {@link angular.module modules}.
  882. */
  883. function setupModuleLoader(window) {
  884. function ensure(obj, name, factory) {
  885. return obj[name] || (obj[name] = factory());
  886. }
  887. return ensure(ensure(window, 'angular', Object), 'module', function() {
  888. /** @type {Object.<string, angular.Module>} */
  889. var modules = {};
  890. /**
  891. * @ngdoc function
  892. * @name angular.module
  893. * @description
  894. *
  895. * The `angular.module` is a global place for creating and registering Angular modules. All
  896. * modules (angular core or 3rd party) that should be available to an application must be
  897. * registered using this mechanism.
  898. *
  899. *
  900. * # Module
  901. *
  902. * A module is a collocation of services, directives, filters, and configure information. Module
  903. * is used to configure the {@link AUTO.$injector $injector}.
  904. *
  905. * <pre>
  906. * // Create a new module
  907. * var myModule = angular.module('myModule', []);
  908. *
  909. * // register a new service
  910. * myModule.value('appName', 'MyCoolApp');
  911. *
  912. * // configure existing services inside initialization blocks.
  913. * myModule.config(function($locationProvider) {
  914. * // Configure existing providers
  915. * $locationProvider.hashPrefix('!');
  916. * });
  917. * </pre>
  918. *
  919. * Then you can create an injector and load your modules like this:
  920. *
  921. * <pre>
  922. * var injector = angular.injector(['ng', 'MyModule'])
  923. * </pre>
  924. *
  925. * However it's more likely that you'll just use
  926. * {@link ng.directive:ngApp ngApp} or
  927. * {@link angular.bootstrap} to simplify this process for you.
  928. *
  929. * @param {!string} name The name of the module to create or retrieve.
  930. * @param {Array.<string>=} requires If specified then new module is being created. If unspecified then the
  931. * the module is being retrieved for further configuration.
  932. * @param {Function} configFn Option configuration function for the module. Same as
  933. * {@link angular.Module#config Module#config()}.
  934. * @returns {module} new module with the {@link angular.Module} api.
  935. */
  936. return function module(name, requires, configFn) {
  937. if (requires && modules.hasOwnProperty(name)) {
  938. modules[name] = null;
  939. }
  940. return ensure(modules, name, function() {
  941. if (!requires) {
  942. throw Error('No module: ' + name);
  943. }
  944. /** @type {!Array.<Array.<*>>} */
  945. var invokeQueue = [];
  946. /** @type {!Array.<Function>} */
  947. var runBlocks = [];
  948. var config = invokeLater('$injector', 'invoke');
  949. /** @type {angular.Module} */
  950. var moduleInstance = {
  951. // Private state
  952. _invokeQueue: invokeQueue,
  953. _runBlocks: runBlocks,
  954. /**
  955. * @ngdoc property
  956. * @name angular.Module#requires
  957. * @propertyOf angular.Module
  958. * @returns {Array.<string>} List of module names which must be loaded before this module.
  959. * @description
  960. * Holds the list of modules which the injector will load before the current module is loaded.
  961. */
  962. requires: requires,
  963. /**
  964. * @ngdoc property
  965. * @name angular.Module#name
  966. * @propertyOf angular.Module
  967. * @returns {string} Name of the module.
  968. * @description
  969. */
  970. name: name,
  971. /**
  972. * @ngdoc method
  973. * @name angular.Module#provider
  974. * @methodOf angular.Module
  975. * @param {string} name service name
  976. * @param {Function} providerType Construction function for creating new instance of the service.
  977. * @description
  978. * See {@link AUTO.$provide#provider $provide.provider()}.
  979. */
  980. provider: invokeLater('$provide', 'provider'),
  981. /**
  982. * @ngdoc method
  983. * @name angular.Module#factory
  984. * @methodOf angular.Module
  985. * @param {string} name service name
  986. * @param {Function} providerFunction Function for creating new instance of the service.
  987. * @description
  988. * See {@link AUTO.$provide#factory $provide.factory()}.
  989. */
  990. factory: invokeLater('$provide', 'factory'),
  991. /**
  992. * @ngdoc method
  993. * @name angular.Module#service
  994. * @methodOf angular.Module
  995. * @param {string} name service name
  996. * @param {Function} constructor A constructor function that will be instantiated.
  997. * @description
  998. * See {@link AUTO.$provide#service $provide.service()}.
  999. */
  1000. service: invokeLater('$provide', 'service'),
  1001. /**
  1002. * @ngdoc method
  1003. * @name angular.Module#value
  1004. * @methodOf angular.Module
  1005. * @param {string} name service name
  1006. * @param {*} object Service instance object.
  1007. * @description
  1008. * See {@link AUTO.$provide#value $provide.value()}.
  1009. */
  1010. value: invokeLater('$provide', 'value'),
  1011. /**
  1012. * @ngdoc method
  1013. * @name angular.Module#constant
  1014. * @methodOf angular.Module
  1015. * @param {string} name constant name
  1016. * @param {*} object Constant value.
  1017. * @description
  1018. * Because the constant are fixed, they get applied before other provide methods.
  1019. * See {@link AUTO.$provide#constant $provide.constant()}.
  1020. */
  1021. constant: invokeLater('$provide', 'constant', 'unshift'),
  1022. /**
  1023. * @ngdoc method
  1024. * @name angular.Module#filter
  1025. * @methodOf angular.Module
  1026. * @param {string} name Filter name.
  1027. * @param {Function} filterFactory Factory function for creating new instance of filter.
  1028. * @description
  1029. * See {@link ng.$filterProvider#register $filterProvider.register()}.
  1030. */
  1031. filter: invokeLater('$filterProvider', 'register'),
  1032. /**
  1033. * @ngdoc method
  1034. * @name angular.Module#controller
  1035. * @methodOf angular.Module
  1036. * @param {string} name Controller name.
  1037. * @param {Function} constructor Controller constructor function.
  1038. * @description
  1039. * See {@link ng.$controllerProvider#register $controllerProvider.register()}.
  1040. */
  1041. controller: invokeLater('$controllerProvider', 'register'),
  1042. /**
  1043. * @ngdoc method
  1044. * @name angular.Module#directive
  1045. * @methodOf angular.Module
  1046. * @param {string} name directive name
  1047. * @param {Function} directiveFactory Factory function for creating new instance of
  1048. * directives.
  1049. * @description
  1050. * See {@link ng.$compileProvider.directive $compileProvider.directive()}.
  1051. */
  1052. directive: invokeLater('$compileProvider', 'directive'),
  1053. /**
  1054. * @ngdoc method
  1055. * @name angular.Module#config
  1056. * @methodOf angular.Module
  1057. * @param {Function} configFn Execute this function on module load. Useful for service
  1058. * configuration.
  1059. * @description
  1060. * Use this method to register work which needs to be performed on module loading.
  1061. */
  1062. config: config,
  1063. /**
  1064. * @ngdoc method
  1065. * @name angular.Module#run
  1066. * @methodOf angular.Module
  1067. * @param {Function} initializationFn Execute this function after injector creation.
  1068. * Useful for application initialization.
  1069. * @description
  1070. * Use this method to register work which needs to be performed when the injector with
  1071. * with the current module is finished loading.
  1072. */
  1073. run: function(block) {
  1074. runBlocks.push(block);
  1075. return this;
  1076. }
  1077. };
  1078. if (configFn) {
  1079. config(configFn);
  1080. }
  1081. return moduleInstance;
  1082. /**
  1083. * @param {string} provider
  1084. * @param {string} method
  1085. * @param {String=} insertMethod
  1086. * @returns {angular.Module}
  1087. */
  1088. function invokeLater(provider, method, insertMethod) {
  1089. return function() {
  1090. invokeQueue[insertMethod || 'push']([provider, method, arguments]);
  1091. return moduleInstance;
  1092. }
  1093. }
  1094. });
  1095. };
  1096. });
  1097. }
  1098. /**
  1099. * @ngdoc property
  1100. * @name angular.version
  1101. * @description
  1102. * An object that contains information about the current AngularJS version. This object has the
  1103. * following properties:
  1104. *
  1105. * - `full` – `{string}` – Full version string, such as "0.9.18".
  1106. * - `major` – `{number}` – Major version number, such as "0".
  1107. * - `minor` – `{number}` – Minor version number, such as "9".
  1108. * - `dot` – `{number}` – Dot version number, such as "18".
  1109. * - `codeName` – `{string}` – Code name of the release, such as "jiggling-armfat".
  1110. */
  1111. var version = {
  1112. full: '1.0.1', // all of these placeholder strings will be replaced by rake's
  1113. major: 1, // compile task
  1114. minor: 0,
  1115. dot: 1,
  1116. codeName: 'thorium-shielding'
  1117. };
  1118. function publishExternalAPI(angular){
  1119. extend(angular, {
  1120. 'bootstrap': bootstrap,
  1121. 'copy': copy,
  1122. 'extend': extend,
  1123. 'equals': equals,
  1124. 'element': jqLite,
  1125. 'forEach': forEach,
  1126. 'injector': createInjector,
  1127. 'noop':noop,
  1128. 'bind':bind,
  1129. 'toJson': toJson,
  1130. 'fromJson': fromJson,
  1131. 'identity':identity,
  1132. 'isUndefined': isUndefined,
  1133. 'isDefined': isDefined,
  1134. 'isString': isString,
  1135. 'isFunction': isFunction,
  1136. 'isObject': isObject,
  1137. 'isNumber': isNumber,
  1138. 'isElement': isElement,
  1139. 'isArray': isArray,
  1140. 'version': version,
  1141. 'isDate': isDate,
  1142. 'lowercase': lowercase,
  1143. 'uppercase': uppercase,
  1144. 'callbacks': {counter: 0}
  1145. });
  1146. angularModule = setupModuleLoader(window);
  1147. try {
  1148. angularModule('ngLocale');
  1149. } catch (e) {
  1150. angularModule('ngLocale', []).provider('$locale', $LocaleProvider);
  1151. }
  1152. angularModule('ng', ['ngLocale'], ['$provide',
  1153. function ngModule($provide) {
  1154. $provide.provider('$compile', $CompileProvider).
  1155. directive({
  1156. a: htmlAnchorDirective,
  1157. input: inputDirective,
  1158. textarea: inputDirective,
  1159. form: formDirective,
  1160. script: scriptDirective,
  1161. select: selectDirective,
  1162. style: styleDirective,
  1163. option: optionDirective,
  1164. ngBind: ngBindDirective,
  1165. ngBindHtmlUnsafe: ngBindHtmlUnsafeDirective,
  1166. ngBindTemplate: ngBindTemplateDirective,
  1167. ngClass: ngClassDirective,
  1168. ngClassEven: ngClassEvenDirective,
  1169. ngClassOdd: ngClassOddDirective,
  1170. ngCsp: ngCspDirective,
  1171. ngCloak: ngCloakDirective,
  1172. ngController: ngControllerDirective,
  1173. ngForm: ngFormDirective,
  1174. ngHide: ngHideDirective,
  1175. ngInclude: ngIncludeDirective,
  1176. ngInit: ngInitDirective,
  1177. ngNonBindable: ngNonBindableDirective,
  1178. ngPluralize: ngPluralizeDirective,
  1179. ngRepeat: ngRepeatDirective,
  1180. ngShow: ngShowDirective,
  1181. ngSubmit: ngSubmitDirective,
  1182. ngStyle: ngStyleDirective,
  1183. ngSwitch: ngSwitchDirective,
  1184. ngSwitchWhen: ngSwitchWhenDirective,
  1185. ngSwitchDefault: ngSwitchDefaultDirective,
  1186. ngOptions: ngOptionsDirective,
  1187. ngView: ngViewDirective,
  1188. ngTransclude: ngTranscludeDirective,
  1189. ngModel: ngModelDirective,
  1190. ngList: ngListDirective,
  1191. ngChange: ngChangeDirective,
  1192. required: requiredDirective,
  1193. ngRequired: requiredDirective,
  1194. ngValue: ngValueDirective
  1195. }).
  1196. directive(ngAttributeAliasDirectives).
  1197. directive(ngEventDirectives);
  1198. $provide.provider({
  1199. $anchorScroll: $AnchorScrollProvider,
  1200. $browser: $BrowserProvider,
  1201. $cacheFactory: $CacheFactoryProvider,
  1202. $controller: $ControllerProvider,
  1203. $document: $DocumentProvider,
  1204. $exceptionHandler: $ExceptionHandlerProvider,
  1205. $filter: $FilterProvider,
  1206. $interpolate: $InterpolateProvider,
  1207. $http: $HttpProvider,
  1208. $httpBackend: $HttpBackendProvider,
  1209. $location: $LocationProvider,
  1210. $log: $LogProvider,
  1211. $parse: $ParseProvider,
  1212. $route: $RouteProvider,
  1213. $routeParams: $RouteParamsProvider,
  1214. $rootScope: $RootScopeProvider,
  1215. $q: $QProvider,
  1216. $sniffer: $SnifferProvider,
  1217. $templateCache: $TemplateCacheProvider,
  1218. $timeout: $TimeoutProvider,
  1219. $window: $WindowProvider
  1220. });
  1221. }
  1222. ]);
  1223. }
  1224. //////////////////////////////////
  1225. //JQLite
  1226. //////////////////////////////////
  1227. /**
  1228. * @ngdoc function
  1229. * @name angular.element
  1230. * @function
  1231. *
  1232. * @description
  1233. * Wraps a raw DOM element or HTML string as a [jQuery](http://jquery.com) element.
  1234. * `angular.element` can be either an alias for [jQuery](http://api.jquery.com/jQuery/) function, if
  1235. * jQuery is available, or a function that wraps the element or string in Angular's jQuery lite
  1236. * implementation (commonly referred to as jqLite).
  1237. *
  1238. * Real jQuery always takes precedence over jqLite, provided it was loaded before `DOMContentLoaded`
  1239. * event fired.
  1240. *
  1241. * jqLite is a tiny, API-compatible subset of jQuery that allows
  1242. * Angular to manipulate the DOM. jqLite implements only the most commonly needed functionality
  1243. * within a very small footprint, so only a subset of the jQuery API - methods, arguments and
  1244. * invocation styles - are supported.
  1245. *
  1246. * Note: All element references in Angular are always wrapped with jQuery or jqLite; they are never
  1247. * raw DOM references.
  1248. *
  1249. * ## Angular's jQuery lite provides the following methods:
  1250. *
  1251. * - [addClass()](http://api.jquery.com/addClass/)
  1252. * - [after()](http://api.jquery.com/after/)
  1253. * - [append()](http://api.jquery.com/append/)
  1254. * - [attr()](http://api.jquery.com/attr/)
  1255. * - [bind()](http://api.jquery.com/bind/)
  1256. * - [children()](http://api.jquery.com/children/)
  1257. * - [clone()](http://api.jquery.com/clone/)
  1258. * - [contents()](http://api.jquery.com/contents/)
  1259. * - [css()](http://api.jquery.com/css/)
  1260. * - [data()](http://api.jquery.com/data/)
  1261. * - [eq()](http://api.jquery.com/eq/)
  1262. * - [find()](http://api.jquery.com/find/) - Limited to lookups by tag name.
  1263. * - [hasClass()](http://api.jquery.com/hasClass/)
  1264. * - [html()](http://api.jquery.com/html/)
  1265. * - [next()](http://api.jquery.com/next/)
  1266. * - [parent()](http://api.jquery.com/parent/)
  1267. * - [prepend()](http://api.jquery.com/prepend/)
  1268. * - [prop()](http://api.jquery.com/prop/)
  1269. * - [ready()](http://api.jquery.com/ready/)
  1270. * - [remove()](http://api.jquery.com/remove/)
  1271. * - [removeAttr()](http://api.jquery.com/removeAttr/)
  1272. * - [removeClass()](http://api.jquery.com/removeClass/)
  1273. * - [removeData()](http://api.jquery.com/removeData/)
  1274. * - [replaceWith()](http://api.jquery.com/replaceWith/)
  1275. * - [text()](http://api.jquery.com/text/)
  1276. * - [toggleClass()](http://api.jquery.com/toggleClass/)
  1277. * - [unbind()](http://api.jquery.com/unbind/)
  1278. * - [val()](http://api.jquery.com/val/)
  1279. * - [wrap()](http://api.jquery.com/wrap/)
  1280. *
  1281. * ## In addtion to the above, Angular privides an additional method to both jQuery and jQuery lite:
  1282. *
  1283. * - `controller(name)` - retrieves the controller of the current element or its parent. By default
  1284. * retrieves controller associated with the `ngController` directive. If `name` is provided as
  1285. * camelCase directive name, then the controller for this directive will be retrieved (e.g.
  1286. * `'ngModel'`).
  1287. * - `injector()` - retrieves the injector of the current element or its parent.
  1288. * - `scope()` - retrieves the {@link api/ng.$rootScope.Scope scope} of the current
  1289. * element or its parent.
  1290. * - `inheritedData()` - same as `data()`, but walks up the DOM until a value is found or the top
  1291. * parent element is reached.
  1292. *
  1293. * @param {string|DOMElement} element HTML string or DOMElement to be wrapped into jQuery.
  1294. * @returns {Object} jQuery object.
  1295. */
  1296. var jqCache = JQLite.cache = {},
  1297. jqName = JQLite.expando = 'ng-' + new Date().getTime(),
  1298. jqId = 1,
  1299. addEventListenerFn = (window.document.addEventListener
  1300. ? function(element, type, fn) {element.addEventListener(type, fn, false);}
  1301. : function(element, type, fn) {element.attachEvent('on' + type, fn);}),
  1302. removeEventListenerFn = (window.document.removeEventListener
  1303. ? function(element, type, fn) {element.removeEventListener(type, fn, false); }
  1304. : function(element, type, fn) {element.detachEvent('on' + type, fn); });
  1305. function jqNextId() { return ++jqId; }
  1306. var SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
  1307. var MOZ_HACK_REGEXP = /^moz([A-Z])/;
  1308. /**
  1309. * Converts snake_case to camelCase.
  1310. * Also there is special case for Moz prefix starting with upper case letter.
  1311. * @param name Name to normalize
  1312. */
  1313. function camelCase(name) {
  1314. return name.
  1315. replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
  1316. return offset ? letter.toUpperCase() : letter;
  1317. }).
  1318. replace(MOZ_HACK_REGEXP, 'Moz$1');
  1319. }
  1320. /////////////////////////////////////////////
  1321. // jQuery mutation patch
  1322. //
  1323. // In conjunction with bindJQuery intercepts all jQuery's DOM destruction apis and fires a
  1324. // $destroy event on all DOM nodes being removed.
  1325. //
  1326. /////////////////////////////////////////////
  1327. function JQLitePatchJQueryRemove(name, dispatchThis) {
  1328. var originalJqFn = jQuery.fn[name];
  1329. originalJqFn = originalJqFn.$original || originalJqFn;
  1330. removePatch.$original = originalJqFn;
  1331. jQuery.fn[name] = removePatch;
  1332. function removePatch() {
  1333. var list = [this],
  1334. fireEvent = dispatchThis,
  1335. set, setIndex, setLength,
  1336. element, childIndex, childLength, children,
  1337. fns, events;
  1338. while(list.length) {
  1339. set = list.shift();
  1340. for(setIndex = 0, setLength = set.length; setIndex < setLength; setIndex++) {
  1341. element = jqLite(set[setIndex]);
  1342. if (fireEvent) {
  1343. events = element.data('events');
  1344. if ( (fns = events && events.$destroy) ) {
  1345. forEach(fns, function(fn){
  1346. fn.handler();
  1347. });
  1348. }
  1349. } else {
  1350. fireEvent = !fireEvent;
  1351. }
  1352. for(childIndex = 0, childLength = (children = element.children()).length;
  1353. childIndex < childLength;
  1354. childIndex++) {
  1355. list.push(jQuery(children[childIndex]));
  1356. }
  1357. }
  1358. }
  1359. return originalJqFn.apply(this, arguments);
  1360. }
  1361. }
  1362. /////////////////////////////////////////////
  1363. function JQLite(element) {
  1364. if (element instanceof JQLite) {
  1365. return element;
  1366. }
  1367. if (!(this instanceof JQLite)) {
  1368. if (isString(element) && element.charAt(0) != '<') {
  1369. throw Error('selectors not implemented');
  1370. }
  1371. return new JQLite(element);
  1372. }
  1373. if (isString(element)) {
  1374. var div = document.createElement('div');
  1375. // Read about the NoScope elements here:
  1376. // http://msdn.microsoft.com/en-us/library/ms533897(VS.85).aspx
  1377. div.innerHTML = '<div>&nbsp;</div>' + element; // IE insanity to make NoScope elements work!
  1378. div.removeChild(div.firstChild); // remove the superfluous div
  1379. JQLiteAddNodes(this, div.childNodes);
  1380. this.remove(); // detach the elements from the temporary DOM div.
  1381. } else {
  1382. JQLiteAddNodes(this, element);
  1383. }
  1384. }
  1385. function JQLiteClone(element) {
  1386. return element.cloneNode(true);
  1387. }
  1388. function JQLiteDealoc(element){
  1389. JQLiteRemoveData(element);
  1390. for ( var i = 0, children = element.childNodes || []; i < children.length; i++) {
  1391. JQLiteDealoc(children[i]);
  1392. }
  1393. }
  1394. function JQLiteUnbind(element, type, fn) {
  1395. var events = JQLiteExpandoStore(element, 'events'),
  1396. handle = JQLiteExpandoStore(element, 'handle');
  1397. if (!handle) return; //no listeners registered
  1398. if (isUndefined(type)) {
  1399. forEach(events, function(eventHandler, type) {
  1400. removeEventListenerFn(element, type, eventHandler);
  1401. delete events[type];
  1402. });
  1403. } else {
  1404. if (isUndefined(fn)) {
  1405. removeEventListenerFn(element, type, events[type]);
  1406. delete events[type];
  1407. } else {
  1408. arrayRemove(events[type], fn);
  1409. }
  1410. }
  1411. }
  1412. function JQLiteRemoveData(element) {
  1413. var expandoId = element[jqName],
  1414. expandoStore = jqCache[expandoId];
  1415. if (expandoStore) {
  1416. if (expandoStore.handle) {
  1417. expandoStore.events.$destroy && expandoStore.handle({}, '$destroy');
  1418. JQLiteUnbind(element);
  1419. }
  1420. delete jqCache[expandoId];
  1421. element[jqName] = undefined; // ie does not allow deletion of attributes on elements.
  1422. }
  1423. }
  1424. function JQLiteExpandoStore(element, key, value) {
  1425. var expandoId = element[jqName],
  1426. expandoStore = jqCache[expandoId || -1];
  1427. if (isDefined(value)) {
  1428. if (!expandoStore) {
  1429. element[jqName] = expandoId = jqNextId();
  1430. expandoStore = jqCache[expandoId] = {};
  1431. }
  1432. expandoStore[key] = value;
  1433. } else {
  1434. return expandoStore && expandoStore[key];
  1435. }
  1436. }
  1437. function JQLiteData(element, key, value) {
  1438. var data = JQLiteExpandoStore(element, 'data'),
  1439. isSetter = isDefined(value),
  1440. keyDefined = !isSetter && isDefined(key),
  1441. isSimpleGetter = keyDefined && !isObject(key);
  1442. if (!data && !isSimpleGetter) {
  1443. JQLiteExpandoStore(element, 'data', data = {});
  1444. }
  1445. if (isSetter) {
  1446. data[key] = value;
  1447. } else {
  1448. if (keyDefined) {
  1449. if (isSimpleGetter) {
  1450. // don't create data in this case.
  1451. return data && data[key];
  1452. } else {
  1453. extend(data, key);
  1454. }
  1455. } else {
  1456. return data;
  1457. }
  1458. }
  1459. }
  1460. function JQLiteHasClass(element, selector) {
  1461. return ((" " + element.className + " ").replace(/[\n\t]/g, " ").
  1462. indexOf( " " + selector + " " ) > -1);
  1463. }
  1464. function JQLiteRemoveClass(element, selector) {
  1465. if (selector) {
  1466. forEach(selector.split(' '), function(cssClass) {
  1467. element.className = trim(
  1468. (" " + element.className + " ")
  1469. .replace(/[\n\t]/g, " ")
  1470. .replace(" " + trim(cssClass) + " ", " ")
  1471. );
  1472. });
  1473. }
  1474. }
  1475. function JQLiteAddClass(element, selector) {
  1476. if (selector) {
  1477. forEach(selector.split(' '), function(cssClass) {
  1478. if (!JQLiteHasClass(element, cssClass)) {
  1479. element.className = trim(element.className + ' ' + trim(cssClass));
  1480. }
  1481. });
  1482. }
  1483. }
  1484. function JQLiteAddNodes(root, elements) {
  1485. if (elements) {
  1486. elements = (!elements.nodeName && isDefined(elements.length) && !isWindow(elements))
  1487. ? elements
  1488. : [ elements ];
  1489. for(var i=0; i < elements.length; i++) {
  1490. root.push(elements[i]);
  1491. }
  1492. }
  1493. }
  1494. function JQLiteController(element, name) {
  1495. return JQLiteInheritedData(element, '$' + (name || 'ngController' ) + 'Controller');
  1496. }
  1497. function JQLiteInheritedData(element, name, value) {
  1498. element = jqLite(element);
  1499. // if element is the document object work with the html element instead
  1500. // this makes $(document).scope() possible
  1501. if(element[0].nodeType == 9) {
  1502. element = element.find('html');
  1503. }
  1504. while (element.length) {
  1505. if (value = element.data(name)) return value;
  1506. element = element.parent();
  1507. }
  1508. }
  1509. ////////////////////////…

Large files files are truncated, but you can click here to view the full file