inputmask.dependencyLib.jqlite.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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", "../global/window"], factory);
  10. } else if (typeof exports === "object") {
  11. module.exports = factory(require("jqlite"), require("../global/window"));
  12. } else {
  13. window.dependencyLib = factory(jqlite, window);
  14. }
  15. }
  16. (function ($, window) {
  17. var document = window.document;
  18. // Use a stripped-down indexOf as it's faster than native
  19. // http://jsperf.com/thor-indexof-vs-for/5
  20. function indexOf(list, elem) {
  21. var i = 0,
  22. len = list.length;
  23. for (; i < len; i++) {
  24. if (list[i] === elem) {
  25. return i;
  26. }
  27. }
  28. return -1;
  29. }
  30. function isWindow(obj) {
  31. return obj != null && obj === obj.window;
  32. }
  33. function isArraylike(obj) {
  34. // Support: iOS 8.2 (not reproducible in simulator)
  35. // `in` check used to prevent JIT error (gh-2145)
  36. // hasOwn isn't used here due to false negatives
  37. // regarding Nodelist length in IE
  38. var length = "length" in obj && obj.length,
  39. ltype = typeof obj;
  40. if (ltype === "function" || isWindow(obj)) {
  41. return false;
  42. }
  43. if (obj.nodeType === 1 && length) {
  44. return true;
  45. }
  46. return ltype === "array" || length === 0 ||
  47. typeof length === "number" && length > 0 && (length - 1) in obj;
  48. }
  49. $.inArray = function (elem, arr, i) {
  50. return arr == null ? -1 : indexOf(arr, elem, i);
  51. };
  52. $.isFunction = function (obj) {
  53. return typeof obj === "function";
  54. };
  55. $.isArray = Array.isArray;
  56. $.isPlainObject = function (obj) {
  57. // Not plain objects:
  58. // - Any object or value whose internal [[Class]] property is not "[object Object]"
  59. // - DOM nodes
  60. // - window
  61. if (typeof obj !== "object" || obj.nodeType || isWindow(obj)) {
  62. return false;
  63. }
  64. if (obj.constructor && !Object.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
  65. return false;
  66. }
  67. // If the function hasn't returned already, we're confident that
  68. // |obj| is a plain object, created by {} or constructed with new Object
  69. return true;
  70. };
  71. $.extend = function () {
  72. var options, name, src, copy, copyIsArray, clone,
  73. target = arguments[0] || {},
  74. i = 1,
  75. length = arguments.length,
  76. deep = false;
  77. // Handle a deep copy situation
  78. if (typeof target === "boolean") {
  79. deep = target;
  80. // Skip the boolean and the target
  81. target = arguments[i] || {};
  82. i++;
  83. }
  84. // Handle case when target is a string or something (possible in deep copy)
  85. if (typeof target !== "object" && !$.isFunction(target)) {
  86. target = {};
  87. }
  88. // Extend jQuery itself if only one argument is passed
  89. if (i === length) {
  90. target = this;
  91. i--;
  92. }
  93. for (; i < length; i++) {
  94. // Only deal with non-null/undefined values
  95. if ((options = arguments[i]) != null) {
  96. // Extend the base object
  97. for (name in options) {
  98. src = target[name];
  99. copy = options[name];
  100. // Prevent never-ending loop
  101. if (target === copy) {
  102. continue;
  103. }
  104. // Recurse if we're merging plain objects or arrays
  105. if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) {
  106. if (copyIsArray) {
  107. copyIsArray = false;
  108. clone = src && $.isArray(src) ? src : [];
  109. } else {
  110. clone = src && $.isPlainObject(src) ? src : {};
  111. }
  112. // Never move original objects, clone them
  113. target[name] = $.extend(deep, clone, copy);
  114. // Don't bring in undefined values
  115. } else if (copy !== undefined) {
  116. target[name] = copy;
  117. }
  118. }
  119. }
  120. }
  121. // Return the modified object
  122. return target;
  123. };
  124. $.each = function (obj, callback) {
  125. var value, i = 0;
  126. if (isArraylike(obj)) {
  127. for (var length = obj.length; i < length; i++) {
  128. value = callback.call(obj[i], i, obj[i]);
  129. if (value === false) {
  130. break;
  131. }
  132. }
  133. } else {
  134. for (i in obj) {
  135. value = callback.call(obj[i], i, obj[i]);
  136. if (value === false) {
  137. break;
  138. }
  139. }
  140. }
  141. return obj;
  142. };
  143. $.data = function (elem, name, data) {
  144. return $(elem).data(name, data);
  145. };
  146. $.Event = $.Event || function CustomEvent(event, params) {
  147. params = params || {
  148. bubbles: false,
  149. cancelable: false,
  150. detail: undefined
  151. };
  152. var evt = document.createEvent("CustomEvent");
  153. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  154. return evt;
  155. };
  156. $.Event.prototype = window.Event.prototype;
  157. return $;
  158. }));