inputmask.dependencyLib.jqlite.js 4.3 KB

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