Kaynağa Gözat

Moe 'target' support for moes that are inside stag-popups

Vijayakrishnan 3 yıl önce
ebeveyn
işleme
f2373762a2
3 değiştirilmiş dosya ile 50 ekleme ve 26 silme
  1. 26 2
      public/js/stag-popup.js
  2. 0 0
      public/js/yemi.js
  3. 24 24
      yemi.js

+ 26 - 2
public/js/stag-popup.js

@@ -157,7 +157,7 @@ function isDynamicStagPopupPresent() {
     if(popup.is('.dynamic-popup')) return true;
     return false;
 }
-function refreshDynamicStagPopup(_url = false) {
+function refreshDynamicStagPopup(_url = false, _target = null) {
     if(!stagPopupsQueue.length) return false;
     let popup = stagPopupsQueue[stagPopupsQueue.length - 1];
     if(popup.is('.dynamic-popup')) {
@@ -169,7 +169,31 @@ function refreshDynamicStagPopup(_url = false) {
         let url = popup.attr('stag-popup-key'),
             initer = popup.attr('mc-initer');
         $.get(url, (_data) => {
-            popup.find('.stag-popup-content-inner').html(_data);
+            if(_target) {
+                _data = '<div>' + _data + '</div>';
+                _target = _target.split(',').map(_x => $.trim(_x));
+                for (let i = 0; i < _target.length; i++) {
+                    let t = _target[i];
+                    let targetElement = $(t).first();
+                    if(targetElement.length) {
+                        let sourceElement = $(_data).find(t).first();
+                        if (sourceElement && sourceElement.length) {
+                            targetElement.html(sourceElement.html());
+                            initFastLoad(targetElement);
+                            console.log('Replaced ' + t);
+                        }
+                        else {
+                            console.warn(t + ' not found in returned content');
+                        }
+                    }
+                    else {
+                        console.warn(t + ' not found in existing content');
+                    }
+                }
+            }
+            else {
+                popup.find('.stag-popup-content-inner').html(_data);
+            }
             convertContentLinksForInPopupNavigation(popup);
             if(initer) runMCInitializer(initer);
             runMCInitializer('pro-suggest');

Dosya farkı çok büyük olduğundan ihmal edildi
+ 0 - 0
public/js/yemi.js


+ 24 - 24
yemi.js

@@ -76,17 +76,17 @@ var doAjax = function (url, data, pre, post, onSuccess, onFailure, suppressError
         showMask();
     }
     jQuery.ajax(url, {
-            dataType: 'json',
-            data: data,
-            type: 'POST',
-            beforeSend: function () {
-                if (pre) {
-                    pre();
-                }
+        dataType: 'json',
+        data: data,
+        type: 'POST',
+        beforeSend: function () {
+            if (pre) {
+                pre();
             }
-        })
+        }
+    })
         .done(function (response, b) {
-			console.log(response);
+            console.log(response);
             var success = response.success;
             if (success) {
                 if (onSuccess) {
@@ -242,14 +242,14 @@ $(function () {
                         width: 500,
                         modal: true,
                         buttons: [{
-                                text: 'Use suggestion',
-                                click: function () {
-                                    for (var prop in a) {
-                                        $(a[prop]).val(suggestion[prop]);
-                                    }
-                                    $(this).dialog('close');
+                            text: 'Use suggestion',
+                            click: function () {
+                                for (var prop in a) {
+                                    $(a[prop]).val(suggestion[prop]);
                                 }
-                            },
+                                $(this).dialog('close');
+                            }
+                        },
                             {
                                 text: 'Keep original',
                                 click: function () {
@@ -267,14 +267,14 @@ $(function () {
                         width: 500,
                         modal: true,
                         buttons: [{
-                                text: 'Erase address fields',
-                                click: function () {
-                                    for (var prop in a) {
-                                        $(a[prop]).val('');
-                                    }
-                                    $(this).dialog('close');
+                            text: 'Erase address fields',
+                            click: function () {
+                                for (var prop in a) {
+                                    $(a[prop]).val('');
                                 }
-                            },
+                                $(this).dialog('close');
+                            }
+                        },
                             {
                                 text: 'Keep original',
                                 click: function () {
@@ -520,7 +520,7 @@ var initMoes = function() {
                                     targetUrl = redir.replace('[data]', data);
                                 }
                             }
-                            refreshDynamicStagPopup(targetUrl);
+                            refreshDynamicStagPopup(targetUrl, target);
                         } else if (redir) {
                             if (redir == "back") {
                                 window.top.history.back();

Bu fark içinde çok fazla dosya değişikliği olduğu için bazı dosyalar gösterilmiyor