dist/js/zui.js
function(element, options) {
        var that = this;
        that.name = NAME;
        that.$ = $(element);

        options = that.options = $.extend({trigger: 'contextmenu'}, ContextMenu.DEFAULTS, this.$.data(), options);

        var trigger = options.trigger;

        that.id = $.zui.uuid();
        var eventHandler = function(e) {
            if (e.type === 'mousedown' && e.button !== 2) {
                return;
            }
            var config = {
                x: e.clientX,
                y: e.clientY,
                event: e
            };
            if (options.itemsCreator) {
                config.items = options.itemsCreator.call(this, e);
            }
            that.show(config);
            e.preventDefault();
            e.returnValue = false; // 解决IE8右键弹出
            return false;
        };
        var eventName = trigger + '.' + NAME;
        if (options.selector) {
            that.$.on(eventName, options.selector, eventHandler);
        } else {
            that.$.on(eventName, eventHandler);
        }
    }
function(element, options) {
        var that = this;
        that.name = NAME;
        that.$ = $(element);

        options = that.options = $.extend({trigger: 'contextmenu'}, ContextMenu.DEFAULTS, this.$.data(), options);

        var trigger = options.trigger;

        that.id = $.zui.uuid();
        var eventHandler = function(e) {
            if (e.type === 'mousedown' && e.button !== 2) {
                return;
            }
            var config = {
                x: e.clientX,
                y: e.clientY,
                event: e
            };
            if (options.itemsCreator) {
                config.items = options.itemsCreator.call(this, e);
            }
            that.show(config);
            e.preventDefault();
            e.returnValue = false; // 解决IE8右键弹出
            return false;
        };
        var eventName = trigger + '.' + NAME;
        if (options.selector) {
            that.$.on(eventName, options.selector, eventHandler);
        } else {
            that.$.on(eventName, eventHandler);
        }
    }
function ( element , options ) { var that = this ; that . name = NAME ; that . $ = $ ( element ) ; options = that . options = $ . extend ( { trigger : 'contextmenu' } , ContextMenu . DEFAULTS , this . $ . data ( ) , options ) ; var trigger = options . trigger ; that . id = $ . zui . uuid ( ) ; var eventHandler = function ( e ) { if ( e . type === 'mousedown' && e . button !== 2 ) { return ; } var config = { x : e . clientX , y : e . clientY , event : e } ; if ( options . itemsCreator ) { config . items = options . itemsCreator . call ( this , e ) ; } that . show ( config ) ; e . preventDefault ( ) ; e . returnValue = false ; // 解决IE8右键弹出 return false ; } ; var eventName = trigger + '.' + NAME ; if ( options . selector ) { that . $ . on ( eventName , options . selector , eventHandler ) ; } else { that . $ . on ( eventName , eventHandler ) ; } }
The contextmenu model class
The contextmenu model class