inputmask.dependencyLib.jqlite.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*!
  2. * dependencyLibs/inputmask.dependencyLib.jqlite.js
  3. * https://github.com/RobinHerbots/Inputmask
  4. * Copyright (c) 2010 - 2019 Robin Herbots
  5. * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
  6. * Version: 4.0.9
  7. */
  8. (function(factory) {
  9. if (typeof define === "function" && define.amd) {
  10. define([ "jqlite", "../global/window" ], factory);
  11. } else if (typeof exports === "object") {
  12. module.exports = factory(require("jqlite"), require("../global/window"));
  13. } else {
  14. window.dependencyLib = factory(jqlite, window);
  15. }
  16. })(function($, window) {
  17. var document = window.document;
  18. function indexOf(list, elem) {
  19. var i = 0, len = list.length;
  20. for (;i < len; i++) {
  21. if (list[i] === elem) {
  22. return i;
  23. }
  24. }
  25. return -1;
  26. }
  27. function isWindow(obj) {
  28. return obj != null && obj === obj.window;
  29. }
  30. function isArraylike(obj) {
  31. var length = "length" in obj && obj.length, ltype = typeof obj;
  32. if (ltype === "function" || isWindow(obj)) {
  33. return false;
  34. }
  35. if (obj.nodeType === 1 && length) {
  36. return true;
  37. }
  38. return ltype === "array" || length === 0 || typeof length === "number" && length > 0 && length - 1 in obj;
  39. }
  40. $.inArray = function(elem, arr, i) {
  41. return arr == null ? -1 : indexOf(arr, elem, i);
  42. };
  43. $.isFunction = function(obj) {
  44. return typeof obj === "function";
  45. };
  46. $.isArray = Array.isArray;
  47. $.isPlainObject = function(obj) {
  48. if (typeof obj !== "object" || obj.nodeType || isWindow(obj)) {
  49. return false;
  50. }
  51. if (obj.constructor && !Object.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
  52. return false;
  53. }
  54. return true;
  55. };
  56. $.extend = function() {
  57. var options, name, src, copy, copyIsArray, clone, target = arguments[0] || {}, i = 1, length = arguments.length, deep = false;
  58. if (typeof target === "boolean") {
  59. deep = target;
  60. target = arguments[i] || {};
  61. i++;
  62. }
  63. if (typeof target !== "object" && !$.isFunction(target)) {
  64. target = {};
  65. }
  66. if (i === length) {
  67. target = this;
  68. i--;
  69. }
  70. for (;i < length; i++) {
  71. if ((options = arguments[i]) != null) {
  72. for (name in options) {
  73. src = target[name];
  74. copy = options[name];
  75. if (target === copy) {
  76. continue;
  77. }
  78. if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) {
  79. if (copyIsArray) {
  80. copyIsArray = false;
  81. clone = src && $.isArray(src) ? src : [];
  82. } else {
  83. clone = src && $.isPlainObject(src) ? src : {};
  84. }
  85. target[name] = $.extend(deep, clone, copy);
  86. } else if (copy !== undefined) {
  87. target[name] = copy;
  88. }
  89. }
  90. }
  91. }
  92. return target;
  93. };
  94. $.each = function(obj, callback) {
  95. var value, i = 0;
  96. if (isArraylike(obj)) {
  97. for (var length = obj.length; i < length; i++) {
  98. value = callback.call(obj[i], i, obj[i]);
  99. if (value === false) {
  100. break;
  101. }
  102. }
  103. } else {
  104. for (i in obj) {
  105. value = callback.call(obj[i], i, obj[i]);
  106. if (value === false) {
  107. break;
  108. }
  109. }
  110. }
  111. return obj;
  112. };
  113. $.data = function(elem, name, data) {
  114. return $(elem).data(name, data);
  115. };
  116. $.Event = $.Event || function CustomEvent(event, params) {
  117. params = params || {
  118. bubbles: false,
  119. cancelable: false,
  120. detail: undefined
  121. };
  122. var evt = document.createEvent("CustomEvent");
  123. evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
  124. return evt;
  125. };
  126. $.Event.prototype = window.Event.prototype;
  127. return $;
  128. });