component_registrator.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /**
  2. * DevExtreme (integration/jquery/component_registrator.js)
  3. * Version: 19.1.16
  4. * Build date: Tue Oct 18 2022
  5. *
  6. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  7. * Read about DevExtreme licensing here: https://js.devexpress.com/Licensing/
  8. */
  9. "use strict";
  10. var jQuery = require("jquery");
  11. var componentRegistratorCallbacks = require("../../core/component_registrator_callbacks");
  12. var errors = require("../../core/errors");
  13. if (jQuery) {
  14. var registerJQueryComponent = function(name, componentClass) {
  15. jQuery.fn[name] = function(options) {
  16. var isMemberInvoke = "string" === typeof options;
  17. var result;
  18. if (isMemberInvoke) {
  19. var memberName = options;
  20. var memberArgs = [].slice.call(arguments).slice(1);
  21. this.each(function() {
  22. var instance = componentClass.getInstance(this);
  23. if (!instance) {
  24. throw errors.Error("E0009", name)
  25. }
  26. var member = instance[memberName];
  27. var memberValue = member.apply(instance, memberArgs);
  28. if (void 0 === result) {
  29. result = memberValue
  30. }
  31. })
  32. } else {
  33. this.each(function() {
  34. var instance = componentClass.getInstance(this);
  35. if (instance) {
  36. instance.option(options)
  37. } else {
  38. new componentClass(this, options)
  39. }
  40. });
  41. result = this
  42. }
  43. return result
  44. }
  45. };
  46. componentRegistratorCallbacks.add(registerJQueryComponent)
  47. }