inputmask.dependencyLib.js 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. Input Mask plugin dependencyLib
  3. http://github.com/RobinHerbots/jquery.inputmask
  4. Copyright (c) Robin Herbots
  5. Licensed under the MIT license
  6. */
  7. import window from "../global/window";
  8. import data from "./data";
  9. import { on, off, trigger, Event } from "./events";
  10. import extend from "./extend";
  11. const document = window.document;
  12. function DependencyLib(elem) {
  13. if (elem instanceof DependencyLib) {
  14. return elem;
  15. }
  16. if (!(this instanceof DependencyLib)) {
  17. return new DependencyLib(elem);
  18. }
  19. if (elem !== undefined && elem !== null && elem !== window) {
  20. this[0] = elem.nodeName
  21. ? elem
  22. : elem[0] !== undefined && elem[0].nodeName
  23. ? elem[0]
  24. : document.querySelector(elem);
  25. if (this[0] !== undefined && this[0] !== null) {
  26. this[0].eventRegistry = this[0].eventRegistry || {};
  27. }
  28. }
  29. }
  30. DependencyLib.prototype = {
  31. on,
  32. off,
  33. trigger
  34. };
  35. // static
  36. DependencyLib.extend = extend;
  37. DependencyLib.data = data;
  38. DependencyLib.Event = Event;
  39. export default DependencyLib;