/// class ProspectDirector.Types.Core.ContextMenu

/**
Base class from which all other Prospect Director context menus should inherit from. This class is a wrapper for the 3rd party component "Medialize jQuery Context Menu". For more information on this component refer to <a href="http://medialize.github.com/jQuery-contextMenu/index.html" target="_">http://medialize.github.com/jQuery-contextMenu/index.html</a> 
@class ContextMenu
@namespace ProspectDirector.Types.Core
**/
ProspectDirector.Types.Core.ContextMenu = Class.extend({

    //---------------------------
    //--- CONSTRUCTOR
    //---------------------------

    init: function (options) {

        this.options = $.extend({
        }, options);

        this._init_contextMenu();

    },

    //---------------------------
    //--- PROPERTIES
    //---------------------------

    /**
    This property <b><u>must</u></b> be overridden.
    @property get_contextMenuSelector {String}
    @protected
    **/
    get_contextMenuSelector: function () {
        return "";
    },

    //---------------------------
    //--- EVENT HANDLERS
    //---------------------------

    /**
    @method _contextMenu_onBuild
    @private
    **/
    _contextMenu_onBuild: function (sender, e) {

        var that = this;

        var config = {

            callback: function (command, e) {
                that._autoHide(e.$menu);
                that._executeCommand(command, e);
            },

            items: {
            }

        };

        this._configureContextMenu(sender, $.extend({
            config: config
        }, e));

        return config;

    },

    //---------------------------
    //--- PROTECTED METHODS
    //---------------------------

    /**
    This method <b><u>must</u></b> be overridden.
    @method _executeCommand
    @protected
    **/
    _executeCommand: function (command, e) {
        alert("The _excuteCommand method must be overridden!");
    },

    /**
    This method <b><u>must</u></b> be overridden.
    @method _configureContextMenu
    @protected
    **/
    _configureContextMenu: function (sender, e) {
        alert("The _configureContextMenu method must be overridden!");
    },

    //---------------------------
    //--- PRIVATE METHODS
    //---------------------------

    /**
    @method _init_contextMenu
    @private
    **/
    _init_contextMenu: function () {

        $.contextMenu('destroy', this.get_contextMenuSelector());

        $.contextMenu({

            selector: this.get_contextMenuSelector(),

            build: $.proxy(this._contextMenu_onBuild, this)

        });

    },

    _autoHide: function (menu) {
        //e.$layer.css({ display: "none" });
        menu.css({ display: "none" });
    }

});