XPages Compatible Dojo Dijit Dialog with Non-Closable option


/***
 * XPages Compatible Dojo Dijit Dialog with Non-Closable option
 *
 * Dojo dialog with option to prevent getting closed via <ESC> or Close icon
 *
 * This XSnippet is based on the original dialog from Jeremy Hodge
 * http://openntf.org/XSnippets.nsf/snippet.xsp?id=xpages-compatible-dojo-dijit-dialog
 *
 * @author Sven Hasselbach 
 *
 ***/

dojo.provide('ch.hasselba.widget.NonClosableDialog');
dojo.require('dijit.Dialog');
(function(){
    dojo.declare("ch.hasselba.widget.NonClosableDialog", dijit.Dialog, {
            disableCloseButton: false,
             _onKey: function(evt)
            {
                if(this.disableCloseButton &&
                   evt.charOrCode == dojo.keys.ESCAPE) return;
                this.inherited(arguments);
            },
            setCloseButtonDisabled: function(flag)
            {
                this.disableCloseButton = flag;
                this._updateCloseButtonState();
            },
            _updateCloseButtonState: function()
            {
                dojo.style(this.closeButtonNode,
                "display",this.disableCloseButton ? "none" : "block");
            },
            postCreate: function(){
                this.inherited(arguments);
                this._updateCloseButtonState();
                dojo.query('form', dojo.body())[0].appendChild(this.domNode);
            },
            _setup: function() {
                this.inherited(arguments);
                if (this.domNode.parentNode.nodeName.toLowerCase() == 'body')
                    dojo.query('form', dojo.body())[0].appendChild(this.domNode);                
            }                
        })
}());

All code submitted to OpenNTF XSnippets, whether submitted as a "Snippet" or in the body of a Comment, is provided under the Apache License Version 2.0. See Terms of Use for full details.
1 comment(s)Login first to comment...
jeniffer homes
(at 04:30 on 19.12.2015)
Construct this just like you would a normal dijit.Dialog by either using dojoType="com.ZetaOne.widget.Dialog" or var x = new com.ZetaOne.widget.Dialog({...});