⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 signal.js

📁 Ajax下日志框架
💻 JS
📖 第 1 页 / 共 2 页
字号:
/***MochiKit.Signal 1.3.1See <http://mochikit.com/> for documentation, downloads, license, etc.(c) 2006 Jonathan Gardner, Beau Hartshorne, Bob Ippolito.  All rights Reserved.***/if (typeof(dojo) != 'undefined') {    dojo.provide('MochiKit.Signal');    dojo.require('MochiKit.Base');    dojo.require('MochiKit.DOM');}if (typeof(JSAN) != 'undefined') {    JSAN.use('MochiKit.Base', []);    JSAN.use('MochiKit.DOM', []);}try {    if (typeof(MochiKit.Base) == 'undefined') {        throw '';    }} catch (e) {    throw 'MochiKit.Signal depends on MochiKit.Base!';}try {    if (typeof(MochiKit.DOM) == 'undefined') {        throw '';    }} catch (e) {    throw 'MochiKit.Signal depends on MochiKit.DOM!';}if (typeof(MochiKit.Signal) == 'undefined') {    MochiKit.Signal = {};}MochiKit.Signal.NAME = 'MochiKit.Signal';MochiKit.Signal.VERSION = '1.3.1';MochiKit.Signal._observers = [];MochiKit.Signal.Event = function (src, e) {    this._event = e || window.event;    this._src = src;};MochiKit.Base.update(MochiKit.Signal.Event.prototype, {    __repr__: function() {        var repr = MochiKit.Base.repr;        var str = '{event(): ' + repr(this.event()) +            ', src(): ' + repr(this.src()) +             ', type(): ' + repr(this.type()) +            ', target(): ' + repr(this.target()) +            ', modifier(): ' + '{alt: ' + repr(this.modifier().alt) +            ', ctrl: ' + repr(this.modifier().ctrl) +            ', meta: ' + repr(this.modifier().meta) +            ', shift: ' + repr(this.modifier().shift) +             ', any: ' + repr(this.modifier().any) + '}';                if (this.type() && this.type().indexOf('key') === 0) {            str += ', key(): {code: ' + repr(this.key().code) +                ', string: ' + repr(this.key().string) + '}';        }        if (this.type() && (            this.type().indexOf('mouse') === 0 ||            this.type().indexOf('click') != -1 ||            this.type() == 'contextmenu')) {            str += ', mouse(): {page: ' + repr(this.mouse().page) +                ', client: ' + repr(this.mouse().client);            if (this.type() != 'mousemove') {                str += ', button: {left: ' + repr(this.mouse().button.left) +                    ', middle: ' + repr(this.mouse().button.middle) +                    ', right: ' + repr(this.mouse().button.right) + '}}';            } else {                str += '}';            }        }        if (this.type() == 'mouseover' || this.type() == 'mouseout') {            str += ', relatedTarget(): ' + repr(this.relatedTarget());        }        str += '}';        return str;    },    toString: function () {        return this.__repr__();    },    src: function () {        return this._src;    },    event: function () {        return this._event;    },    type: function () {        return this._event.type || undefined;    },    target: function () {        return this._event.target || this._event.srcElement;    },    relatedTarget: function () {        if (this.type() == 'mouseover') {            return (this._event.relatedTarget ||                this._event.fromElement);        } else if (this.type() == 'mouseout') {            return (this._event.relatedTarget ||                this._event.toElement);        }        // throw new Error("relatedTarget only available for 'mouseover' and 'mouseout'");        return undefined;    },    modifier: function () {        var m = {};        m.alt = this._event.altKey;        m.ctrl = this._event.ctrlKey;        m.meta = this._event.metaKey || false; // IE and Opera punt here        m.shift = this._event.shiftKey;        m.any = m.alt || m.ctrl || m.shift || m.meta;        return m;    },    key: function () {        var k = {};        if (this.type() && this.type().indexOf('key') === 0) {            /*    			If you're looking for a special key, look for it in keydown or                keyup, but never keypress. If you're looking for a Unicode                chracter, look for it with keypress, but never keyup or                keydown.	    			Notes:	    			FF key event behavior:    			key     event   charCode    keyCode    			DOWN    ku,kd   0           40    			DOWN    kp      0           40    			ESC     ku,kd   0           27    			ESC     kp      0           27    			a       ku,kd   0           65    			a       kp      97          0    			shift+a ku,kd   0           65    			shift+a kp      65          0    			1       ku,kd   0           49    			1       kp      49          0    			shift+1 ku,kd   0           0    			shift+1 kp      33          0	    			IE key event behavior:    			(IE doesn't fire keypress events for special keys.)    			key     event   keyCode    			DOWN    ku,kd   40    			DOWN    kp      undefined    			ESC     ku,kd   27    			ESC     kp      27    			a       ku,kd   65    			a       kp      97    			shift+a ku,kd   65    			shift+a kp      65    			1       ku,kd   49    			1       kp      49    			shift+1 ku,kd   49    			shift+1 kp      33    			Safari key event behavior:    			(Safari sets charCode and keyCode to something crazy for    			special keys.)    			key     event   charCode    keyCode    			DOWN    ku,kd   63233       40    			DOWN    kp      63233       63233    			ESC     ku,kd   27          27    			ESC     kp      27          27    			a       ku,kd   97          65    			a       kp      97          97    			shift+a ku,kd   65          65    			shift+a kp      65          65    			1       ku,kd   49          49    			1       kp      49          49    			shift+1 ku,kd   33          49    			shift+1 kp      33          33            */            /* look for special keys here */            if (this.type() == 'keydown' || this.type() == 'keyup') {                k.code = this._event.keyCode;                k.string = (MochiKit.Signal._specialKeys[k.code] ||                    'KEY_UNKNOWN');                return k;                    /* look for characters here */            } else if (this.type() == 'keypress') {                            /*                                Special key behavior:                                    IE: does not fire keypress events for special keys                    FF: sets charCode to 0, and sets the correct keyCode                    Safari: sets keyCode and charCode to something stupid                            */                            k.code = 0;                k.string = '';                                        if (typeof(this._event.charCode) != 'undefined' &&                     this._event.charCode !== 0 &&                    !MochiKit.Signal._specialMacKeys[this._event.charCode]) {                    k.code = this._event.charCode;                    k.string = String.fromCharCode(k.code);                } else if (this._event.keyCode &&                     typeof(this._event.charCode) == 'undefined') { // IE                    k.code = this._event.keyCode;                    k.string = String.fromCharCode(k.code);                }                            return k;            }        }        // throw new Error('This is not a key event');        return undefined;    },    mouse: function () {        var m = {};        var e = this._event;                if (this.type() && (            this.type().indexOf('mouse') === 0 ||            this.type().indexOf('click') != -1 ||            this.type() == 'contextmenu')) {                        m.client = new MochiKit.DOM.Coordinates(0, 0);            if (e.clientX || e.clientY) {                m.client.x = (!e.clientX || e.clientX < 0) ? 0 : e.clientX;                m.client.y = (!e.clientY || e.clientY < 0) ? 0 : e.clientY;            }            m.page = new MochiKit.DOM.Coordinates(0, 0);            if (e.pageX || e.pageY) {                m.page.x = (!e.pageX || e.pageX < 0) ? 0 : e.pageX;                m.page.y = (!e.pageY || e.pageY < 0) ? 0 : e.pageY;            } else {                /*                				IE keeps the document offset in:        				document.documentElement.clientTop ||        				document.body.clientTop				    				and:        				document.documentElement.clientLeft ||        				document.body.clientLeft                    see:    				http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/getboundingclientrect.asp    				The offset is (2,2) in standards mode and (0,0) in quirks     				mode.				                */                            var de = MochiKit.DOM._document.documentElement;                var b = MochiKit.DOM._document.body;                            m.page.x = e.clientX +                    (de.scrollLeft || b.scrollLeft) -                     (de.clientLeft || b.clientLeft);                            m.page.y = e.clientY +                    (de.scrollTop || b.scrollTop) -                     (de.clientTop || b.clientTop);                        }            if (this.type() != 'mousemove') {                m.button = {};                m.button.left = false;                m.button.right = false;                m.button.middle = false;                /* we could check e.button, but which is more consistent */                if (e.which) {                    m.button.left = (e.which == 1);                    m.button.middle = (e.which == 2);                    m.button.right = (e.which == 3);                    /*                    					Mac browsers and right click:					    						- Safari doesn't fire any click events on a right    						  click:    						  http://bugzilla.opendarwin.org/show_bug.cgi?id=6595						      						- Firefox fires the event, and sets ctrlKey = true						      						- Opera fires the event, and sets metaKey = true					    					oncontextmenu is fired on right clicks between     					browsers and across platforms.					                    */                                } else {                    m.button.left = !!(e.button & 1);                    m.button.right = !!(e.button & 2);                    m.button.middle = !!(e.button & 4);                }            }            return m;        }        // throw new Error('This is not a mouse event');        return undefined;    },    stop: function () {        this.stopPropagation();        this.preventDefault();    },    stopPropagation: function () {        if (this._event.stopPropagation) {            this._event.stopPropagation();        } else {            this._event.cancelBubble = true;        }    },

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -