Parcourir la source

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

j8
damencho il y a 9 ans
Parent
révision
d5de49b5cf
1 fichiers modifiés avec 16 ajouts et 6 suppressions
  1. 16
    6
      modules/UI/util/MessageHandler.js

+ 16
- 6
modules/UI/util/MessageHandler.js Voir le fichier

@@ -36,10 +36,14 @@ var messageHandler = {
36 36
      * titleKey will be used to get a title via the translation API.
37 37
      * @param message the message to show. If a falsy value is provided,
38 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 45
         if (!popupEnabled)
42
-            return;
46
+            return null;
43 47
 
44 48
         if (!title) {
45 49
             title = APP.translation.generateTranslationHTML(titleKey);
@@ -48,9 +52,13 @@ var messageHandler = {
48 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 64
      * Shows a message to the user with two buttons: first is given as a
@@ -69,13 +77,14 @@ var messageHandler = {
69 77
      *        the dialog is opened
70 78
      * @param defaultButton index of default button which will be activated when
71 79
      *        the user press 'enter'. Indexed from 0.
80
+     * @return the prompt that was created, or null
72 81
      */
73 82
     openTwoButtonDialog: function(titleKey, titleString, msgKey, msgString,
74 83
         persistent, leftButtonKey, submitFunction, loadedFunction,
75 84
         closeFunction, focus, defaultButton) {
76 85
 
77 86
         if (!popupEnabled || twoButtonDialog)
78
-            return;
87
+            return null;
79 88
 
80 89
         var buttons = [];
81 90
 
@@ -111,6 +120,7 @@ var messageHandler = {
111 120
                     closeFunction();
112 121
             }
113 122
         });
123
+        return twoButtonDialog;
114 124
     },
115 125
 
116 126
     /**

Chargement…
Annuler
Enregistrer