/*
Product Name: dhtmlxSuite
Version: 4.0.3
Edition: Professional
License: content of this file is covered by DHTMLX Commercial or Enterprise license. Usage without proper license is prohibited. To obtain it contact sales@dhtmlx.com
Copyright UAB Dinamenta http://www.dhtmlx.com
*/
/**
* @desc: enable pop up menu which allows hidding/showing columns
* @edition: Professional
* @type: public
*/
dhtmlXGridObject.prototype.enableHeaderMenu=function(columns)
{
if (typeof columns == "string")
columns = columns.split(",");
this._hm_config = columns;
var that=this;
this.attachEvent("onInit",function(){
this.hdr.oncontextmenu = function(e){ return that._doHContClick(e||window.event); };
{
this.startColResizeA=this.startColResize;
this.startColResize=function(e){
if (e.button==2 || (_isMacOS&&e.ctrlKey))
return this._doHContClick(e)
return this.startColResizeA(e);
}
}
this._chm_ooc=this.obj.onclick;
this._chm_hoc=this.hdr.onclick;
this.hdr.onclick=function(e){
if (e && ( e.button==2 || (_isMacOS&&e.ctrlKey))) return false;
that._showHContext(false);
return that._chm_hoc.apply(this,arguments)
}
this.obj.onclick=function(){
that._showHContext(false);
return that._chm_ooc.apply(this,arguments)
}
});
dhtmlxEvent(document.body,"click",function(){
if (that._hContext)
that._showHContext(false);
})
if (this.hdr.rows.length) this.callEvent("onInit",[]);
this.enableHeaderMenu=function(){};
}
dhtmlXGridObject.prototype._doHContClick=function(ev)
{
function mouseCoords(ev){
if(ev.pageX || ev.pageY){
return {x:ev.pageX, y:ev.pageY};
}
var d = ((_isIE)&&(document.compatMode != "BackCompat"))?document.documentElement:document.body;
return {
x:ev.clientX + d.scrollLeft - d.clientLeft,
y:ev.clientY + d.scrollTop - d.clientTop
};
}
this._createHContext();
var coords = mouseCoords(ev);
this._showHContext(true,coords.x,coords.y);
ev[_isIE?"srcElement":"target"].oncontextmenu = function(e){ (e||event).cancelBubble=true; return false; };
ev.cancelBubble=true;
if (ev.preventDefault) ev.preventDefault();
return false;
}
dhtmlXGridObject.prototype._createHContext=function()
{
if (this._hContext) return this._hContext;
var d = document.createElement("DIV");
d.oncontextmenu = function(e){ (e||event).cancelBubble=true; return false; };
d.onclick=function(e){
(e||event).cancelBubble=true;
return true;
}
d.className="dhx_header_cmenu";
d.style.width=d.style.height="5px";
d.style.display="none";
var a=[];
var i=0;
if (this._fake)
i=this._fake._cCount;
var true_ind=i;
for (var i; i]*>/gi,"");
a.push("");
}
true_ind+=(c.colSpan||1);
}
d.innerHTML=a.join("");
var that=this;
var f=function(){
var c=this.getAttribute("column");
if (!this.checked && !that._checkLast(c)) return this.checked=true;
if (that._realfake) that=that._fake;
for (var i=0; i