inputmask.dependencyLib.jqlite.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. $.data = function(elem, name, data) {
  107. return $(elem).data(name, data);
  108. };
  109. window.dependencyLib = $;
  110. return $;
  111. }));