Search code examples
javascriptmootoolsblockui

Mootools jquery's blockUI equivalent


I am searching for jquery's plugin blockUI functionality for mootools. Do You know some plugin or simple way to block browser for a given time by mootools ?


Solution

  • Here's some code to get you started. http://jsfiddle.net/5BCPS/

    taken it out of my plugin here: https://github.com/DimitarChristoff/Modal/blob/master/Source/js/Modal.js

    (function() {
    
    this.Modal = {};
    
    Element.implement({
        diffuse: function(position){
            return this.setStyles({
                position: position || 'absolute',
                top: 0,
                bottom: 0,
                left: 0,
                right: 0,
                height: '100%',
                width: '100%'
            });
        }
    });
    
    Modal.Overlay = new Class({
    
        Implements: [Events, Options],
    
        options: {
            zIndex: 900000,
            opacity: .3,
            backgroundColor: '#555',
            fx: {
                duration: 300
            }
        },
    
        initialize: function(container, options){
            this.setOptions(options);
            this.container = document.id(container);
            var self = this;
            this.element = new Element('div', {
                'class': 'overlay',
                styles: {
                    display: 'none',
                    opacity: 0,
                    zIndex: this.options.zIndex,
                    backgroundColor: this.options.backgroundColor
                },
                events: {
                    click: function() {
                        self.fireEvent("overlayClick");
                    }
                },
                tween: this.options.fx
            }).diffuse('fixed').inject(this.container);
            return this;
        },
    
        show: function(){
            this.element.setStyle("display", "block").fade(this.options.opacity);
            return this.fireEvent("show");
        },
    
        hide: function(){
            this.element.fade(this.options.opacity).get("tween").chain(function() {
                this.element.setStyle("display", "none");
            });
            return this.fireEvent("hide");
        }
    
    });
    
    })();
    
    var modal = new Modal.Overlay(document.body, {
        hideAfter: 5,
        onHide: function() {
            // do something.
        }
    }).show();
    
    
    modal.hide.delay(3000, modal);
    

    all you need is what you display on top / counter. thats just plain js.