Work-around for wcfAJAXDialog via AJAXProxy
authorAlexander Ebert <ebert@woltlab.com>
Mon, 14 Nov 2011 18:39:37 +0000 (19:39 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 14 Nov 2011 18:39:37 +0000 (19:39 +0100)
wcfsetup/install/files/js/WCF.js

index 8aa22c5c00a5135a1a81ce00cb90b2b55d27f382..be9614fb1366f171e3fc7f4c5771b034d84e4e66 100644 (file)
@@ -3311,9 +3311,11 @@ $.widget('ui.wcfAJAXDialog', $.ui.dialog, {
        _createDialog: function(data) {
                data.ignoreTemplate = true;
                this.element.data('responseData', data);
+
+               // work-around for AJAXProxy's different return values
                
                this.element.wcfGrow({
-                       content: data.template,
+                       content: this._getResponseValue('template'),
                        parent: this.element.parent('.ui-dialog')
                }, {
                        duration: 600,
@@ -3330,7 +3332,7 @@ $.widget('ui.wcfAJAXDialog', $.ui.dialog, {
                                this._callbackExecuted = true;
                                
                                this.element.removeClass('overlayLoading');
-                               this.element.html(this.element.data('responseData').template);
+                               this.element.html(this._getResponseValue('template'));
                                
                                if (this.options.ajax.success) {
                                        this.options.ajax.success();
@@ -3338,6 +3340,32 @@ $.widget('ui.wcfAJAXDialog', $.ui.dialog, {
                        }, this)
                });
        },
+
+       /**
+        * Returns specific AJAX response value.
+        * 
+        * @param       string          key
+        * @return      mixed
+        */
+       _getResponseValue: function(key) {
+               var $data = this.element.data('responseData');
+
+               // no response data stored
+               if (!$data) {
+                       return null;
+               }
+
+               // AJAXProxy
+               if ($data.returnValues[key]) {
+                       return $data.returnValues[key];
+               }
+               // PackageInstallation
+               else if ($data[key]) {
+                       return $data[key];
+               }
+
+               return null;
+       },
        
        /**
         * Redraws dialog, should be executed everytime content is changed.