X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=org.argeo.slc.webapp%2Fsrc%2Fmain%2Fwebapp%2Fargeo-ria-src%2Fclass%2Forg%2Fargeo%2Fria%2Fcomponents%2FModal.js;h=3d2c2c81bb12c9925d84fe7dfb795d82fa2c49e2;hb=614cd339a65450805c1684af40bba14db6a8333f;hp=58d3a6642febc78ad20a1291999d8ff0ba609220;hpb=2709fc569678445f379f36fbdde1072e745b3736;p=gpl%2Fargeo-slc.git diff --git a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js index 58d3a6642..3d2c2c81b 100644 --- a/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js +++ b/org.argeo.slc.webapp/src/main/webapp/argeo-ria-src/class/org/argeo/ria/components/Modal.js @@ -7,7 +7,17 @@ qx.Class.define("org.argeo.ria.components.Modal", { extend : qx.ui.window.Window, + properties : { + persistent : { + check : "Boolean", + init : false + } + }, + events : { + /** + * Triggered when the user clicks the "ok" button. + */ "ok" : "qx.event.type.Event" }, /** @@ -33,6 +43,19 @@ qx.Class.define("org.argeo.ria.components.Modal", }, members : { + + addCenter : function(component){ + if(!this.getPersistent()){ + this.add(component, {edge : 'center', width:'100%'}); + }else{ + if(!this.centerScroller){ + this.centerScroller = new qx.ui.container.Composite(new qx.ui.layout.VBox(1)); + this.add(new qx.ui.container.Scroll(this.centerScroller), {edge : 'center', width:'100%', height:'100%'}); + } + this.centerScroller.add(component); + } + }, + /** * Display text inside the popup * @param text {String} A string content for the popup @@ -41,14 +64,18 @@ qx.Class.define("org.argeo.ria.components.Modal", var label = new qx.ui.basic.Label(text); label.setRich(true); label.setTextAlign("center"); - this.add(label, {edge:'center', width:'100%'}); + this.addCenter(label); this.addCloseButton(); }, + /** + * Add a question and ok / cancel buttons + * @param text {String} The question to ask to the user + */ addConfirm : function(text){ var label = new qx.ui.basic.Label(text); label.setRich(true); label.setTextAlign("center"); - this.add(label, {edge:'center', width:'100%'}); + this.addCenter(label); this.addOkCancel(); }, /** @@ -56,14 +83,17 @@ qx.Class.define("org.argeo.ria.components.Modal", * @param panel {qx.ui.core.Widget} A gui component (will be set at width 100%). */ addContent: function(panel){ - this.add(panel, {edge:'center', width:'100%'}); + this.addCenter(panel); this.addCloseButton(); }, /** * Automatically attach to the application root, then show. */ attachAndShow:function(){ - org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this); + if(!this.attached){ + org.argeo.ria.components.ViewsManager.getInstance().getApplicationRoot().add(this); + this.attached = true; + } this.show(); }, /** @@ -121,7 +151,11 @@ qx.Class.define("org.argeo.ria.components.Modal", */ _closeAndDestroy : function(){ this.hide(); - this.destroy(); + if(!this.getPersistent()){ + this.destroy(); + }else{ + if(this.centerScroller) this.centerScroller.removeAll(); + } } } }); \ No newline at end of file