inputmask.dependencyLib.jqlite.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*
  2. Input Mask plugin dependencyLib
  3. http://github.com/RobinHerbots/jquery.inputmask
  4. Copyright (c) 2010 - Robin Herbots
  5. Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. */
  7. (function(factory) {
  8. if (typeof define === "function" && define.amd) {
  9. define(["jqlite"], factory);
  10. } else if (typeof exports === "object") {
  11. module.exports = factory(require("jqlite"));
  12. } else {
  13. factory(jQuery);
  14. }
  15. }
  16. (function($) {
  17. var class2type = {},
  18. classTypes = "Boolean Number String Function Array Date RegExp Object Error".split(" ");
  19. for (var nameNdx = 0; nameNdx < classTypes.length; nameNdx++) {
  20. class2type["[object " + classTypes[nameNdx] + "]"] = classTypes[nameNdx].toLowerCase();
  21. }
  22. function type(obj) {
  23. if (obj == null) {
  24. return obj + "";
  25. }
  26. // Support: Android<4.0, iOS<6 (functionish RegExp)
  27. return typeof obj === "object" || typeof obj === "function" ?
  28. class2type[class2type.toString.call(obj)] || "object" :
  29. typeof obj;
  30. }
  31. $.isFunction = function(obj) {
  32. return type(obj) === "function";
  33. };
  34. $.isArray = Array.isArray;
  35. $.isWindow = function(obj) {
  36. return obj != null && obj === obj.window;
  37. };
  38. $.isPlainObject = function(obj) {
  39. // Not plain objects:
  40. // - Any object or value whose internal [[Class]] property is not "[object Object]"
  41. // - DOM nodes
  42. // - window
  43. if (type(obj) !== "object" || obj.nodeType || $.isWindow(obj)) {
  44. return false;
  45. }
  46. if (obj.constructor && !class2type.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
  47. return false;
  48. }
  49. // If the function hasn't returned already, we're confident that
  50. // |obj| is a plain object, created by {} or constructed with new Object
  51. return true;
  52. };
  53. $.extend = function() {
  54. var options, name, src, copy, copyIsArray, clone,
  55. target = arguments[0] || {},
  56. i = 1,
  57. length = arguments.length,
  58. deep = false;
  59. // Handle a deep copy situation
  60. if (typeof target === "boolean") {
  61. deep = target;
  62. // Skip the boolean and the target
  63. target = arguments[i] || {};
  64. i++;
  65. }
  66. // Handle case when target is a string or something (possible in deep copy)
  67. if (typeof target !== "object" && !$.isFunction(target)) {
  68. target = {};
  69. }
  70. // Extend jQuery itself if only one argument is passed
  71. if (i === length) {
  72. target = this;
  73. i--;
  74. }
  75. for (; i < length; i++) {
  76. // Only deal with non-null/undefined values
  77. if ((options = arguments[i]) != null) {
  78. // Extend the base object
  79. for (name in options) {
  80. src = target[name];
  81. copy = options[name];
  82. // Prevent never-ending loop
  83. if (target === copy) {
  84. continue;
  85. }
  86. // Recurse if we're merging plain objects or arrays
  87. if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) {
  88. if (copyIsArray) {
  89. copyIsArray = false;
  90. clone = src && $.isArray(src) ? src : [];
  91. } else {
  92. clone = src && $.isPlainObject(src) ? src : {};
  93. }
  94. // Never move original objects, clone them
  95. target[name] = $.extend(deep, clone, copy);
  96. // Don't bring in undefined values
  97. } else if (copy !== undefined) {
  98. target[name] = copy;
  99. }
  100. }
  101. }
  102. }
  103. // Return the modified object
  104. return target;
  105. };
  106. $.each = function(obj, callback) {
  107. var value, i = 0;
  108. if (isArraylike(obj)) {
  109. for (var length = obj.length; i < length; i++) {
  110. value = callback.call(obj[i], i, obj[i]);
  111. if (value === false) {
  112. break;
  113. }
  114. }
  115. } else {
  116. for (i in obj) {
  117. value = callback.call(obj[i], i, obj[i]);
  118. if (value === false) {
  119. break;
  120. }
  121. }
  122. }
  123. return obj;
  124. };
  125. $.map = function(elems, callback) {
  126. var value,
  127. i = 0,
  128. length = elems.length,
  129. isArray = isArraylike(elems),
  130. ret = [];
  131. // Go through the array, translating each of the items to their new values
  132. if (isArray) {
  133. for (; i < length; i++) {
  134. value = callback(elems[i], i);
  135. if (value != null) {
  136. ret.push(value);
  137. }
  138. }
  139. // Go through every key on the object,
  140. } else {
  141. for (i in elems) {
  142. value = callback(elems[i], i);
  143. if (value != null) {
  144. ret.push(value);
  145. }
  146. }
  147. }
  148. // Flatten any nested arrays
  149. return [].concat(ret);
  150. };
  151. $.data = function(elem, name, data) {
  152. return $(elem).data(name, data);
  153. };
  154. window.dependencyLib = $;
  155. return $;
  156. }));