From 62004a2a583742fde9e3da25805311d0fe9aa63b Mon Sep 17 00:00:00 2001 From: Mathieu De Keyzer Date: Mon, 19 Feb 2024 21:07:36 +0100 Subject: [PATCH] fix: closeModalNotification and intAjaxModalLinks --- EMS/admin-ui-bundle/_to_be_ref/js/core.js | 7 --- EMS/admin-ui-bundle/_to_be_ref/js/initEms.js | 54 ------------------- .../assets/js/core/components/modal.js | 27 ++++++++++ 3 files changed, 27 insertions(+), 61 deletions(-) delete mode 100644 EMS/admin-ui-bundle/_to_be_ref/js/initEms.js diff --git a/EMS/admin-ui-bundle/_to_be_ref/js/core.js b/EMS/admin-ui-bundle/_to_be_ref/js/core.js index 553f32b9d..4f1383c75 100644 --- a/EMS/admin-ui-bundle/_to_be_ref/js/core.js +++ b/EMS/admin-ui-bundle/_to_be_ref/js/core.js @@ -1,6 +1,5 @@ window.ems_wysiwyg_type_filters = JSON.parse(document.querySelector("BODY").getAttribute('data-wysiwyg-type-filters')); -require('admin-lte/plugins/timepicker/bootstrap-timepicker'); require('chart.js'); require('fastclick'); require('flot'); @@ -11,12 +10,8 @@ require('jquery-sparkline'); require('moment'); require('pace'); require('raphael'); -require('select2/dist/js/select2.full'); require('slimscroll'); -require('bootstrap-datepicker'); -require('daterangepicker'); require('fullcalendar'); -require('jquery-match-height'); //Fix issue CK editor in bootstrap model //https://ckeditor.com/old/forums/Support/Issue-with-Twitter-Bootstrap#comment-127719 @@ -31,5 +26,3 @@ $.fn.modal.Constructor.prototype.enforceFocus = function() { }) }; -require('./initEms'); - diff --git a/EMS/admin-ui-bundle/_to_be_ref/js/initEms.js b/EMS/admin-ui-bundle/_to_be_ref/js/initEms.js deleted file mode 100644 index a5ee2fd2c..000000000 --- a/EMS/admin-ui-bundle/_to_be_ref/js/initEms.js +++ /dev/null @@ -1,54 +0,0 @@ -'use strict'; - -/* - * This function initialized the elasticms admin interface - * - */ -import EmsListeners from "./EmsListeners"; -import ajaxModal from "../../js/core/helpers/ajaxModal"; - -(function(factory) { - "use strict"; - - if ( typeof define === "function" && define.amd ) { - // AMD. Register as an anonymous module. - define([ - "jquery", - ], factory ); - } else { - // Browser globals - factory( window.jQuery ); - } - -}(function($) { - - function closeModalNotification() { - $('#modal-notification-close-button').on('click', function(){ - $('#modal-notifications .modal-body').empty(); - $('#modal-notifications').modal('hide'); - }); - } - - function intAjaxModalLinks() { - let ajaxModalLinks = document.querySelectorAll('a[data-ajax-modal-url]'); - [].forEach.call(ajaxModalLinks, function (link) { - link.onclick = (event) => { - ajaxModal.load({ - url: event.target.dataset.ajaxModalUrl, - size: event.target.dataset.ajaxModalSize - }, (json) => { - if (json.hasOwnProperty('success') && json.success === true) { - location.reload(); - } - }); - } - }); - } - - - $(document).ready(function() { - closeModalNotification(); - intAjaxModalLinks(); - }); - -})); diff --git a/EMS/admin-ui-bundle/assets/js/core/components/modal.js b/EMS/admin-ui-bundle/assets/js/core/components/modal.js index 07bcbbd9a..412953d41 100644 --- a/EMS/admin-ui-bundle/assets/js/core/components/modal.js +++ b/EMS/admin-ui-bundle/assets/js/core/components/modal.js @@ -1,9 +1,13 @@ 'use strict' +import $ from 'jquery' import queryString from '../helpers/queryString' +import ajaxModal from '../../../js/core/helpers/ajaxModal' export default class Modal { constructor () { this.autoOpenModal() + this.closeModalNotification() + this.intAjaxModalLinks() } autoOpenModal () { @@ -14,4 +18,27 @@ export default class Modal { modal.show() } } + + closeModalNotification () { + $('#modal-notification-close-button').on('click', function () { + $('#modal-notifications .modal-body').empty() + $('#modal-notifications').modal('hide') + }) + } + + intAjaxModalLinks () { + const ajaxModalLinks = document.querySelectorAll('a[data-ajax-modal-url]'); + [].forEach.call(ajaxModalLinks, function (link) { + link.onclick = (event) => { + ajaxModal.load({ + url: event.target.dataset.ajaxModalUrl, + size: event.target.dataset.ajaxModalSize + }, (json) => { + if (Object.prototype.hasOwnProperty.call(json, 'success') && json.success === true) { + location.reload() + } + }) + } + }) + } }