inputmask.dependencyLib.jqlite.js 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. (function(factory) {
  2. if (typeof define === "function" && define.amd) {
  3. define(["jqlite"], factory);
  4. } else if (typeof exports === "object") {
  5. module.exports = factory(require("jqlite"));
  6. } else {
  7. factory(jQuery);
  8. }
  9. }
  10. (function($) {
  11. var class2type = {},
  12. classTypes = "Boolean Number String Function Array Date RegExp Object Error".split(" ");
  13. for (var nameNdx = 0; nameNdx < classTypes.length; nameNdx++) {
  14. class2type["[object " + classTypes[nameNdx] + "]"] = classTypes[nameNdx].toLowerCase();
  15. }
  16. function type(obj) {
  17. if (obj == null) {
  18. return obj + "";
  19. }
  20. // Support: Android<4.0, iOS<6 (functionish RegExp)
  21. return typeof obj === "object" || typeof obj === "function" ?
  22. class2type[class2type.toString.call(obj)] || "object" :
  23. typeof obj;
  24. }
  25. $.isFunction = function(obj) {
  26. return type(obj) === "function";
  27. };
  28. $.isArray = Array.isArray;
  29. $.isWindow = function(obj) {
  30. return obj != null && obj === obj.window;
  31. };
  32. $.isPlainObject = function(obj) {
  33. // Not plain objects:
  34. // - Any object or value whose internal [[Class]] property is not "[object Object]"
  35. // - DOM nodes
  36. // - window
  37. if (type(obj) !== "object" || obj.nodeType || $.isWindow(obj)) {
  38. return false;
  39. }
  40. if (obj.constructor && !class2type.hasOwnProperty.call(obj.constructor.prototype, "isPrototypeOf")) {
  41. return false;
  42. }
  43. // If the function hasn't returned already, we're confident that
  44. // |obj| is a plain object, created by {} or constructed with new Object
  45. return true;
  46. };
  47. $.extend = function() {
  48. var options, name, src, copy, copyIsArray, clone,
  49. target = arguments[0] || {},
  50. i = 1,
  51. length = arguments.length,
  52. deep = false;
  53. // Handle a deep copy situation
  54. if (typeof target === "boolean") {
  55. deep = target;
  56. // Skip the boolean and the target
  57. target = arguments[i] || {};
  58. i++;
  59. }
  60. // Handle case when target is a string or something (possible in deep copy)
  61. if (typeof target !== "object" && !$.isFunction(target)) {
  62. target = {};
  63. }
  64. // Extend jQuery itself if only one argument is passed
  65. if (i === length) {
  66. target = this;
  67. i--;
  68. }
  69. for (; i < length; i++) {
  70. // Only deal with non-null/undefined values
  71. if ((options = arguments[i]) != null) {
  72. // Extend the base object
  73. for (name in options) {
  74. src = target[name];
  75. copy = options[name];
  76. // Prevent never-ending loop
  77. if (target === copy) {
  78. continue;
  79. }
  80. // Recurse if we're merging plain objects or arrays
  81. if (deep && copy && ($.isPlainObject(copy) || (copyIsArray = $.isArray(copy)))) {
  82. if (copyIsArray) {
  83. copyIsArray = false;
  84. clone = src && $.isArray(src) ? src : [];
  85. } else {
  86. clone = src && $.isPlainObject(src) ? src : {};
  87. }
  88. // Never move original objects, clone them
  89. target[name] = $.extend(deep, clone, copy);
  90. // Don't bring in undefined values
  91. } else if (copy !== undefined) {
  92. target[name] = copy;
  93. }
  94. }
  95. }
  96. }
  97. // Return the modified object
  98. return target;
  99. };
  100. $.data = function(elem, name, data) {
  101. return $(elem).data(name, data);
  102. };
  103. window.dependencyLib = $;
  104. return $;
  105. }));