MooConsole

コンソールウィンドウプラグイン

by Tenderfeel

JavaScript

(function($) {
    this.Console = new Class({
        Extends: Fx.Morph,

        options: {
            windowTarget: $('container'),
            buttonTarget: $('container'),
            set: [
                {
                'content': 'Hello World',
                'button': 'Console',
                'open': {
                    'bottom': 35,
                    'opacity': 1
                },
                'styles': {
                    'background': 'rgba(255,255,255,0.1)',
                    'height': 120
                }}
            ],
            show: false,
            duration: 300,
            link: 'chain'
        },
        setWindow: function(num, obj) {
            this.options.set[num] = obj;
        },
        destroy: function() {
            this.element.destroy();
            return this;
        },
        reset: function() {
            this.initialize();
            return this;
        },
        initialize: function(options) {
            var element = new Element('div', {
                'id': 'console'
            });
            this.parent(element, options);
            this.element.inject(this.options.windowTarget);
            var height = this.element.getSize().y;

            this.set({
                'bottom': -height,
                'opacity': 0
            });

            this.active = false;
            this.next = 0;
            this.reopen = false;
            this.setInner();

            if (this.options.show !== false) {
                this.open(this.options.show);
            }
        },
        onComplete: function() {
            if (this.reopen) {
                this.reopen = false;
                this.open(this.next);
                return;
            }

            if (this.active !== false) {
                this.fireEvent('open', [this.element, this.inner[this.active], this.active]);
            } else {
                this.fireEvent('close', [this.element, this.inner]);
            }
       ...