__page_controler.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*
  2. * Core js fw functions
  3. * Do not edit this file
  4. */
  5. /*
  6. * Js page controler
  7. */
  8. function mgVuePageControler(controlerId) {
  9. this.baseLoaderUrl = mgUrlParser.getCurrentUrl();
  10. //main app container id
  11. this.vueLoaderId = controlerId;
  12. //main app instance
  13. this.vueLoader = false,
  14. //main app instance init
  15. this.vinit = function () {
  16. var self = this;
  17. self.vueLoader = new Vue(self.getVueAppInits());
  18. },
  19. //prepare main app config object
  20. this.getVueAppInits = function () {
  21. var vAppId = this.vueLoaderId;
  22. var newVueAppConfig = mgDefauleVueObject;
  23. newVueAppConfig.el = '#' + vAppId;
  24. newVueAppConfig.data.targetId = vAppId;
  25. newVueAppConfig.data.targetUrl = mgUrlParser.getCurrentUrl();
  26. return newVueAppConfig;
  27. },
  28. //modal data
  29. this.modalData = {};
  30. //modal instance
  31. this.modalInstance = null;
  32. //modal app container id
  33. this.modalAppContainerId = controlerId + '_modal';
  34. //load modal
  35. this.initModal = function (id, namespace, index, event, dataLoaded) {
  36. var self = this;
  37. self.modalData.id = id;
  38. self.modalData.namespace = namespace;
  39. self.modalData.index = index;
  40. self.modalData.event = event;
  41. self.modalData.dataLoaded = dataLoaded.htmlData;
  42. jQuery('#' + self.modalAppContainerId).html(dataLoaded.htmlData);
  43. if (typeof dataLoaded.registrations !== 'undefined') {
  44. $('#loadedTemplates').html(dataLoaded.template);
  45. for (var key in dataLoaded.registrations) {
  46. if (!dataLoaded.registrations.hasOwnProperty(key)) {
  47. continue;
  48. }
  49. mgJsComponentHandler.registerNowByDefaultTemplate(key.toLowerCase(), dataLoaded.registrations[key]);
  50. }
  51. }
  52. self.modalInstance = new Vue(self.getVueModalAppInits());
  53. mgEventHandler.runCallback('ModalLoaded', self.modalData.id, {containerId: self.modalAppContainerId, modalInstance: self.modalInstance});
  54. },
  55. this.destructModal = function () {
  56. var self = this;
  57. //destruct vue modal app
  58. self.modalInstance.$destroy();
  59. self.modalInstance = null;
  60. //unset modal data
  61. self.modalData.id = null;
  62. self.modalData.namespace = null;
  63. self.modalData.index = null;
  64. self.modalData.event = null;
  65. self.modalData.dataLoaded = null;
  66. //remove old modal content
  67. jQuery('#' + self.modalAppContainerId).html('');
  68. }
  69. this.reloadVueModal = function () {
  70. $('#mgModalContainer').append('<div class="lu-preloader-container lu-preloader-container--full-screen lu-preloader-container--overlay" v-show="1"><div class="lu-preloader lu-preloader--sm"></div></div>');
  71. var self = this;
  72. var tempData = self.modalData;
  73. self.modalInstance.$destroy();
  74. self.vueLoader.reloadModalContent(tempData.event, tempData.id, tempData.namespace, tempData.index, null);
  75. };
  76. this.getVueModalAppInits = function () {
  77. var self = this;
  78. var vmAppId = self.modalAppContainerId;
  79. var newVuemAppConfig = mgDefauleVueModalObject;
  80. newVuemAppConfig.el = '#' + vmAppId;
  81. newVuemAppConfig.data.targetId = self.modalData.id;
  82. newVuemAppConfig.data.targetUrl = mgUrlParser.getCurrentUrl();
  83. return newVuemAppConfig;
  84. };
  85. this.initModalAdditions = function () {
  86. initModalSelects();
  87. initModalTooltips();
  88. };
  89. }