Mini Kabibi Habibi
ASPxMenuPreviewHelper = function(controlClientObject, embedded) {
var res = new ASPxControlPreviewHelper(controlClientObject, embedded);
res.PrepareControlClientObject = function() {
var stdDoHidePopupMenu = this.controlClientObject.DoHidePopupMenu;
this.controlClientObject.DoHidePopupMenu = function(evt, element){
if(!ASPxTBHelper.selectionMode)
stdDoHidePopupMenu.call(this, evt, element);
};
var stdOnItemClick = this.controlClientObject.OnItemClick;
this.controlClientObject.OnItemClick = function(indexPath, evt) {
if(!ASPxTBHelper.selectionMode)
stdOnItemClick.call(this, indexPath, evt);
};
var stdOnItemDropDownClick = this.controlClientObject.OnItemDropDownClick;
this.controlClientObject.OnItemDropDownClick = function(indexPath, evt) {
if(!ASPxTBHelper.selectionMode)
stdOnItemDropDownClick(this, indexPath, evt);
};
var stdOnItemOverTimer = this.controlClientObject.OnItemOverTimer;
this.controlClientObject.OnItemOverTimer = function(indexPath) {
if(!ASPxTBHelper.selectionMode)
stdOnItemOverTimer.call(this, indexPath);
};
var stdOnItemOutTimer = this.controlClientObject.OnItemOutTimer;
this.controlClientObject.OnItemOutTimer = function() {
if(!ASPxTBHelper.selectionMode)
stdOnItemOutTimer.call(this);
};
var stdOnBeforeItemOver = this.controlClientObject.OnBeforeItemOver;
this.controlClientObject.OnBeforeItemOver = function(hoverItem, hoverElement) {
if(!ASPxTBHelper.selectionMode)
stdOnBeforeItemOver.call(this, hoverItem, hoverElement);
};
var stdOnAfterItemOver = this.controlClientObject.OnAfterItemOver;
this.controlClientObject.OnAfterItemOver = function(hoverItem, hoverElement){
if(!ASPxTBHelper.selectionMode)
stdOnAfterItemOver.call(this, hoverItem, hoverElement);
};
var stdPrepareScrolling = this.controlClientObject.PrepareScrolling;
this.controlClientObject.PrepareScrolling = function(element, scrollHelper, excessTop, excessBottom) {
var indexPath = this.GetIndexPathById(element.id, true);
if(this.GetItemText(indexPath).indexOf("with scrolling") > -1) {
//Note: show scroll buttons if element height is greather than heightLimit
var heightLimit = 100;
if(element.offsetHeight >= heightLimit) {
excessTop = 0;
excessBottom = 150;
}
}
stdPrepareScrolling.call(this, element, scrollHelper, excessTop, excessBottom);
};
var stdStartScrolling = this.controlClientObject.StartScrolling;
this.controlClientObject.StartScrolling = function(buttonId, delay, step) {
if(!ASPxTBHelper.selectionMode)
stdStartScrolling.call(this, buttonId, delay, step);
};
var stdStopScrolling = this.controlClientObject.StopScrolling;
this.controlClientObject.StopScrolling = function(buttonId) {
if(!ASPxTBHelper.selectionMode)
stdStopScrolling.call(this, buttonId);
};
};
res.OnSelectionModeChanged = function(selectionMode) {
if(this.IsAnySubMenuVisible() && !this.shouldHideSubMenu)
return;
this.SetSubMenuVisibility('0', selectionMode);
this.shouldHideSubMenu = selectionMode;
};
res.IsAnySubMenuVisible = function() {
return ASPxClientMenuBase.GetMenuCollection().IsAnyMenuVisible();
};
res.SetSubMenuVisibility = function(indexPath, visible) {
var subMenu = this.controlClientObject.GetMenuElement(indexPath);
if(visible){
var element = this.controlClientObject.GetItemTextCell(indexPath);
if(element)
aspxGetStateController().SetCurrentHoverElementBySrcElement(element);
this.controlClientObject.ShowSubMenu(indexPath);
}
else
this.controlClientObject.OnHideByItemOut();
};
res.SetLoadingPanelVisibility = function(visible) {
var menu = this.controlClientObject;
//Note: Show loading panel in SubMenu container of the first menu root item
var mainCell = menu.GetMenuMainCell(menu.GetMenuElement(0));
if(visible) {
this.storedMainCellHtml = mainCell.innerHTML;
menu.CreateLoadingPanelInsideContainer(mainCell);
} else if(this.storedMainCellHtml) {
_aspxSetInnerHtml(mainCell, this.storedMainCellHtml);
this.storedMainCellHtml = null;
}
};
return res;
};