Explorar o código

Moe features: [target] and [noreload]

Vijayakrishnan %!s(int64=3) %!d(string=hai) anos
pai
achega
65ebf96e95
Modificáronse 2 ficheiros con 20 adicións e 14 borrados
  1. 0 0
      public/js/yemi.js
  2. 20 14
      yemi.js

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
public/js/yemi.js


+ 20 - 14
yemi.js

@@ -187,23 +187,13 @@ var doAjaxFormData = function (url, data, pre, post, onSuccess, onFailure, suppr
 
 var justLog = false; //THIS IS FOR TEST MODE, FORMS WILL NOT TRIGGER REFRESH/REDIR
 
-var pageReload = function () {
+var pageReload = function (_target) {
     setTimeout(function () {
         hideMoeFormMask();
-        fastReload();
+        fastReload(_target);
     }, 500);
 };
 
-var fastReload = function() {
-    var targetLocation = window.top.location.pathname + window.top.location.search;
-    if(targetLocation.indexOf('/mc') === 0) {
-        targetLocation = targetLocation.substr(3);
-    }
-    if(targetLocation === '' || targetLocation[0] !== '/') targetLocation = '/' + targetLocation;
-    fastLoad(targetLocation, false, false);
-    return false;
-}
-
 if (typeof String.prototype.startsWith != 'function') {
     // see below for better implementation!
     String.prototype.startsWith = function (str) {
@@ -329,6 +319,8 @@ var initMoes = function() {
         var form = moe.find('[url]')[0]; // REQUIRED
         var url = $(form).attr('url'); // REQUIRED
         var redir = $(form).attr('redir'); // OPTIONAL
+        var target = $(form).attr('target'); // OPTIONAL
+        var noreload = $(form).is('[noreload]'); // OPTIONAL
         var submit = moe.find('[submit]'); // REQUIRED
         var cancel = moe.find('[cancel]')[0]; // OPTIONAL
 
@@ -506,6 +498,13 @@ var initMoes = function() {
                     doAjax(url, data, null, function () {
                         moe.isProcessing = false;
                     }, function (data) {
+                        if(noreload) {
+                            $(cancel).trigger('click.moe');
+                            hideMoeFormMask();
+                            hideMask();
+                            toastr.success('Done');
+                            return;
+                        }
                         if (justLog) { // this is to test!
                             console.log('RETURNED', data);
                         } else if(isDynamicStagPopupPresent()) {
@@ -530,7 +529,7 @@ var initMoes = function() {
                                 initAutoRxAndICDComplete();
                             });
                         } else {
-                            pageReload();
+                            pageReload(target);
                         }
                     }, function (errorMessage) {
 
@@ -540,6 +539,13 @@ var initMoes = function() {
                     doAjaxFormData(url, data, null, function () {
                         moe.isProcessing = false;
                     }, function (data) {
+                        if(noreload) {
+                            $(cancel).trigger('click.moe');
+                            hideMoeFormMask();
+                            hideMask();
+                            toastr.success('Done');
+                            return;
+                        }
                         if (justLog) { // this is to test!
                             console.log('RETURNED', data);
                         } else if(isDynamicStagPopupPresent()) {
@@ -564,7 +570,7 @@ var initMoes = function() {
                                 initAutoRxAndICDComplete();
                             });
                         } else {
-                            pageReload();
+                            pageReload(target);
                         }
                     }, function (errorMessage) {
 

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio