Explorar el Código

Stag popup: support for specifying "hook" via [update-parent]

Vijayakrishnan hace 3 años
padre
commit
dc6834e039
Se han modificado 1 ficheros con 21 adiciones y 6 borrados
  1. 21 6
      js-dev/stag-popup.js

+ 21 - 6
js-dev/stag-popup.js

@@ -47,12 +47,18 @@ function closeStagPopup(_noEvent = false) {
     }
     else {
         if(popup.is('[update-parent]') && !_noEvent) {
-            if(stagPopupsQueue.length) {
-                refreshDynamicStagPopup();
+            let hook = popup.attr('update-parent');
+            if(!!$.trim(hook) && hasMCHook(hook)) {
+                runMCHook(hook)
             }
             else {
-                fastReload(popup.is('[update-target]') ? popup.attr('update-target') : '');
-                return;
+                if(stagPopupsQueue.length) {
+                    refreshDynamicStagPopup();
+                }
+                else {
+                    fastReload(popup.is('[update-target]') ? popup.attr('update-target') : '');
+                    return;
+                }
             }
         }
     }
@@ -129,7 +135,7 @@ function openDynamicStagPopup(_url, initer, title, updateParent, style = '', rep
 
         if(!replace) {
             if(updateParent) {
-                popup.attr('update-parent', 1);
+                popup.attr('update-parent', updateParent);
             }
             else {
                 popup.removeAttr('update-parent');
@@ -245,11 +251,20 @@ function hasResponseError(_data) {
             .off('click.open-in-stag-popup', '[open-in-stag-popup]')
             .on('click.open-in-stag-popup', '[open-in-stag-popup]', function() {
                 let trig = $(this);
+                let updateParent = trig.is('[update-parent]');
+                if(updateParent) {
+                    if(!!$.trim(trig.attr('update-parent'))) {
+                        updateParent = trig.attr('update-parent');
+                    }
+                    else {
+                        updateParent = true;
+                    }
+                }
                 openDynamicStagPopup(
                     trig.attr('href'),
                     trig.attr('mc-initer'),
                     trig.attr('title'),
-                    trig.is('[update-parent]'),
+                    updateParent,
                     trig.attr('popup-style'),
                     false,
                     trig.is('[update-target]') ? trig.attr('update-target') : null