Fixes bug when reopening cronjob log error message
authorMatthias Schmidt <gravatronics@live.com>
Sun, 28 Apr 2013 09:05:55 +0000 (11:05 +0200)
committerMatthias Schmidt <gravatronics@live.com>
Sun, 28 Apr 2013 09:05:55 +0000 (11:05 +0200)
They could only be opened once and when reopening them, nothing happened since the DOM element had been removed.

wcfsetup/install/files/acp/js/WCF.ACP.js
wcfsetup/install/files/acp/templates/cronjobLogList.tpl

index fd247a574ed6e249fadd3c8b2e8084f04536e6b5..a53d5d9cf355cb2b4314b531e934b2979ccde776 100644 (file)
@@ -2,7 +2,7 @@
  * Class and function collection for WCF ACP
  * 
  * @author     Alexander Ebert, Matthias Schmidt
- * @copyright  2001-2012 WoltLab GmbH
+ * @copyright  2001-2013 WoltLab GmbH
  * @license    GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
  */
 
@@ -77,6 +77,68 @@ WCF.ACP.Application.SetAsPrimary = Class.extend({
        }
 });
 
+/**
+ * Namespace for ACP cronjob management.
+ */
+WCF.ACP.Cronjob = { };
+
+/**
+ * Handles the cronjob log list.
+ */
+WCF.ACP.Cronjob.LogList = Class.extend({
+       /**
+        * error message dialog
+        * @var jQuery
+        */
+       _dialog: null,
+       
+       /**
+        * Initializes WCF.ACP.Cronjob.LogList object.
+        */
+       init: function() {
+               // bind event listener to delete cronjob log button
+               $('.jsCronjobLogDelete').click(function() {
+                       WCF.System.Confirmation.show(WCF.Language.get('wcf.acp.cronjob.log.clear.confirm'), function(action) {
+                               if (action == 'confirm') {
+                                       new WCF.Action.Proxy({
+                                               autoSend: true,
+                                               data: {
+                                                       actionName: 'clearAll',
+                                                       className: 'wcf\\data\\cronjob\\log\\CronjobLogAction'
+                                               },
+                                               success: function() {
+                                                       window.location.reload();
+                                               }
+                                       });
+                               }
+                       });
+               });
+               
+               // bind event listeners to error badges
+               $('.jsCronjobError').click($.proxy(this._showError, this));
+       },
+       
+       /**
+        * Shows certain error message
+        * 
+        * @param       object          event
+        */
+       _showError: function(event) {
+               var $errorBadge = $(event.currentTarget);
+               
+               if (this._dialog === null) {
+                       this._dialog = $('<div>' + $errorBadge.next().html() + '</div>').hide().appendTo(document.body);
+                       this._dialog.wcfDialog({
+                               title: WCF.Language.get('wcf.acp.cronjob.log.error.details')
+                       });
+               }
+               else {
+                       this._dialog.html($errorBadge.next().html());
+                       this._dialog.wcfDialog('open');
+               }
+       }
+});
+
 /**
  * Handles ACPMenu.
  * 
index 7e36aae7367fefc4c26d413e54c5b73ce6116650..69133c9aa08a93bad3b9e3fdb4779f4794094946 100644 (file)
@@ -3,28 +3,12 @@
 <script type="text/javascript">
        //<![CDATA[
        $(function() {
-               $('.jsCronjobLogDelete').click(function() {
-                       WCF.System.Confirmation.show('{lang}wcf.acp.cronjob.log.clear.confirm{/lang}', function(action) {
-                               if (action == 'confirm') {
-                                       new WCF.Action.Proxy({
-                                               autoSend: true,
-                                               data: {
-                                                       actionName: 'clearAll',
-                                                       className: 'wcf\\data\\cronjob\\log\\CronjobLogAction'
-                                               },
-                                               success: function() {
-                                                       window.location.reload();
-                                               }
-                                       });
-                               }
-                       });
+               WCF.Language.addObject({
+                       'wcf.acp.cronjob.log.clear.confirm': '{lang}wcf.acp.cronjob.log.clear.confirm{/lang}',
+                       'wcf.acp.cronjob.log.error.details': '{lang}wcf.acp.cronjob.log.error.details{/lang}'
                });
                
-               $('.jsCronjobError').click(function(event) {
-                       $(event.currentTarget).next().wcfDialog({
-                               title: '{lang}wcf.acp.cronjob.log.error.details{/lang}'
-                       });
-               });
+               new WCF.ACP.Cronjob.LogList();
        });
        //]]>
 </script>
@@ -82,7 +66,7 @@
                                                        <td class="columnText columnSuccess">
                                                                {if $cronjobLog->success}
                                                                        <span class="badge green">{lang}wcf.acp.cronjob.log.success{/lang}</span>
-                                                               {elseif $cronjobLog->error}     
+                                                               {elseif $cronjobLog->error}
                                                                        <a class="badge red jsTooltip jsCronjobError" title="{lang}wcf.acp.cronjob.log.error.showDetails{/lang}">{lang}wcf.acp.cronjob.log.error{/lang}</a>
                                                                        <span style="display: none">{@$cronjobLog->error}</span>
                                                                {/if}