/*** * 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); } }) }());