]> git.argeo.org Git - gpl/argeo-slc.git/blobdiff - org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js
"Confirm" mode in Modal
[gpl/argeo-slc.git] / org.argeo.slc.webapp / src / main / webapp / argeo-ria-src / class / org / argeo / ria / components / Modal.js
index b69c1580f36b749be49051da2d3defbf32d3ee0a..f39cca36f73e99dc8c57417a1824ade437ec4bfa 100644 (file)
@@ -7,6 +7,9 @@ qx.Class.define("org.argeo.ria.components.Modal",
 {\r
        extend : qx.ui.window.Window,\r
   \r
+       events : {\r
+               "ok" : "qx.event.type.Event"\r
+       },\r
        /**\r
         * \r
         * @param caption {String} Title of the window\r
@@ -35,9 +38,19 @@ qx.Class.define("org.argeo.ria.components.Modal",
                 * @param text {String} A string content for the popup\r
                 */\r
                addLabel:function(text){\r
-                       this.add(new qx.ui.basic.Label(text), {edge:'center', width:'100%'});           \r
+                       var label = new qx.ui.basic.Label(text);\r
+                       label.setRich(true);\r
+                       label.setTextAlign("center");\r
+                       this.add(label, {edge:'center', width:'100%'});\r
                        this.addCloseButton();\r
                },\r
+               addConfirm : function(text){\r
+                       var label = new qx.ui.basic.Label(text);\r
+                       label.setRich(true);\r
+                       label.setTextAlign("center");\r
+                       this.add(label, {edge:'center', width:'100%'});\r
+                       this.addOkCancel();\r
+               },\r
                /**\r
                 * Display a component (panel) in the center of the popup\r
                 * @param panel {qx.ui.core.Widget} A gui component (will be set at width 100%).\r
@@ -53,21 +66,38 @@ qx.Class.define("org.argeo.ria.components.Modal",
                        org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this);                     \r
                        this.show();\r
                },\r
+               /**\r
+                * Adds a close button bottom-center aligned to the popup\r
+                */\r
                addCloseButton : function(){\r
                        this.closeButton = new qx.ui.form.Button("Close");\r
                        this.closeButton.addListener("execute", this._closeAndDestroy, this);\r
                        this.add(this.closeButton, {edge:'south'});                     \r
                },\r
+               /**\r
+                * Adds two buttons bottom-center aligned (Ok and Cancel). \r
+                * Ok button has no listener by default, Cancel will close and destroy the popup.\r
+                */\r
                addOkCancel : function(){\r
                        var buttonPane = new qx.ui.container.Composite(new qx.ui.layout.HBox(5, 'right'));\r
                        buttonPane.setAlignX("center");\r
                        this.add(buttonPane, {edge:"south"});\r
                        this.okButton = new qx.ui.form.Button("Ok");\r
+                       this.okButton.addListener("execute", function(e){\r
+                               this.fireEvent("ok");\r
+                               this._closeAndDestroy();\r
+                       }, this);\r
                        this.cancelButton = new qx.ui.form.Button("Cancel");\r
                        this.cancelButton.addListener("execute", this._closeAndDestroy, this);\r
-                       buttonPane.add(this.cancelButton);\r
                        buttonPane.add(this.okButton);\r
+                       buttonPane.add(this.cancelButton);\r
                },\r
+               /**\r
+                * Adds a prompt form to the popup : a question, followed by a text input.\r
+                * @param questionString {String} The question to ask to the user \r
+                * @param validationCallback {Function} Callback to apply : takes the text input value as unique argument.\r
+                * @param callbackContext {Object} Context for the callback, optional.\r
+                */\r
                makePromptForm:function(questionString, validationCallback, callbackContext){\r
                        this.add(new qx.ui.basic.Label(questionString), {edge:'north'});\r
                        var textField = new qx.ui.form.TextField();\r
@@ -82,6 +112,9 @@ qx.Class.define("org.argeo.ria.components.Modal",
                                if(valid) this._closeAndDestroy();\r
                        }, this);\r
                },\r
+               /**\r
+                * Close this modal window and destroy it.\r
+                */\r
                _closeAndDestroy : function(){\r
                        this.hide();\r
                        this.destroy();                 \r