Path: blob/master/webroot/rsrc/externals/javelin/lib/Mask.js
12242 views
/**1* @requires javelin-install2* javelin-dom3* @provides javelin-mask4* @javelin5*/67/**8* Show a "mask" over the page for lightboxes or dialogs. This is used by9* Workflow to draw visual attention to modal dialogs.10*11* JX.Mask.show();12* // Show a dialog, lightbox, or other modal UI.13* JX.Mask.hide();14*15* Masks are stackable, if modal UIs need to spawn other modal UIs.16*17* The mask has class `jx-mask`, which you should apply styles to. For example:18*19* .jx-mask {20* opacity: 0.8;21* background: #000000;22* position: fixed;23* top: 0;24* bottom: 0;25* left: 0;26* right: 0;27* z-index: 2;28* }29*30* You can create multiple mask styles and select them with the `mask_type`31* parameter to `show()` (for instance, a light mask for dialogs and a dark32* mask for lightboxing):33*34* JX.Mask.show('jx-light-mask');35* // ...36* JX.Mask.hide();37*38* This will be applied as a class name to the mask element, which you can39* customize in CSS:40*41* .jx-light-mask {42* background: #ffffff;43* }44*45* The mask has sigil `jx-mask`, which can be used to intercept events46* targeting it, like clicks on the mask.47*/48JX.install('Mask', {49statics : {50_stack : [],51_mask : null,52_currentType : null,535455/**56* Show a mask over the document. Multiple calls push masks onto a stack.57*58* @param string Optional class name to apply to the mask, if you have59* multiple masks (e.g., one dark and one light).60* @return void61*/62show : function(mask_type) {63var self = JX.Mask;64mask_type = mask_type || null;6566if (!self._stack.length) {67self._mask = JX.$N('div', {className: 'jx-mask', sigil: 'jx-mask'});68document.body.appendChild(self._mask);69}7071self._adjustType(mask_type);72JX.Mask._stack.push(mask_type);73},7475/**76* Hide the current mask. The mask stack is popped, which may reveal another77* mask below the current mask.78*79* @return void80*/81hide : function() {82var self = JX.Mask;83var mask_type = self._stack.pop();8485self._adjustType(mask_type);8687if (!self._stack.length) {88JX.DOM.remove(JX.Mask._mask);89JX.Mask._mask = null;90}91},929394_adjustType : function(new_type) {95var self = JX.Mask;96if (self._currentType) {97JX.DOM.alterClass(self._mask, self._currentType, false);98self._currentType = null;99}100if (new_type) {101JX.DOM.alterClass(self._mask, new_type, true);102self._currentType = new_type;103}104}105}106});107108109