浏览代码

Returns the dialog instances that were created and adds an optional close callback.

j8
damencho 9 年前
父节点
当前提交
d5de49b5cf
共有 1 个文件被更改,包括 16 次插入6 次删除
  1. 16
    6
      modules/UI/util/MessageHandler.js

+ 16
- 6
modules/UI/util/MessageHandler.js 查看文件

36
      * titleKey will be used to get a title via the translation API.
36
      * titleKey will be used to get a title via the translation API.
37
      * @param message the message to show. If a falsy value is provided,
37
      * @param message the message to show. If a falsy value is provided,
38
      * messageKey will be used to get a message via the translation API.
38
      * messageKey will be used to get a message via the translation API.
39
+     * @param closeFunction function to be called after
40
+     * the prompt is closed (optional)
41
+     * @return the prompt that was created, or null
39
      */
42
      */
40
-    openMessageDialog: function(titleKey, messageKey, title, message) {
43
+    openMessageDialog: function(titleKey, messageKey, title, message,
44
+                                closedFunction) {
41
         if (!popupEnabled)
45
         if (!popupEnabled)
42
-            return;
46
+            return null;
43
 
47
 
44
         if (!title) {
48
         if (!title) {
45
             title = APP.translation.generateTranslationHTML(titleKey);
49
             title = APP.translation.generateTranslationHTML(titleKey);
48
             message = APP.translation.generateTranslationHTML(messageKey);
52
             message = APP.translation.generateTranslationHTML(messageKey);
49
         }
53
         }
50
 
54
 
51
-        $.prompt(message,
52
-            {title: title, persistent: false}
53
-        );
55
+        return $.prompt(message, {
56
+            title: title,
57
+            persistent: false,
58
+            close: function () {
59
+                if(closedFunction) closedFunction();
60
+            }
61
+        });
54
     },
62
     },
55
     /**
63
     /**
56
      * Shows a message to the user with two buttons: first is given as a
64
      * Shows a message to the user with two buttons: first is given as a
69
      *        the dialog is opened
77
      *        the dialog is opened
70
      * @param defaultButton index of default button which will be activated when
78
      * @param defaultButton index of default button which will be activated when
71
      *        the user press 'enter'. Indexed from 0.
79
      *        the user press 'enter'. Indexed from 0.
80
+     * @return the prompt that was created, or null
72
      */
81
      */
73
     openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString,
82
     openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString,
74
         persistent, leftButtonKey, submitFunction, loadedFunction,
83
         persistent, leftButtonKey, submitFunction, loadedFunction,
75
         closeFunction, focus, defaultButton) {
84
         closeFunction, focus, defaultButton) {
76
 
85
 
77
         if (!popupEnabled || twoButtonDialog)
86
         if (!popupEnabled || twoButtonDialog)
78
-            return;
87
+            return null;
79
 
88
 
80
         var buttons = [];
89
         var buttons = [];
81
 
90
 
111
                     closeFunction();
120
                     closeFunction();
112
             }
121
             }
113
         });
122
         });
123
+        return twoButtonDialog;
114
     },
124
     },
115
 
125
 
116
     /**
126
     /**

正在加载...
取消
保存