CmsMenuKeepNodeExtended=function(aHiddenId,aMenuId,aElementId){
this._hiddenId=aHiddenId;
this._menuId=aMenuId;
this._elementId=aElementId;
this._cierreManual=false;
this._aperturaManual=false;
}
CmsMenuKeepNodeExtended.prototype={
GetMenuId:function(){return this._menuId},
OnClientLoad:function(sender){
var menu=$find(this._menuId);
var menuItem=menu.findItemByValue(this._elementId);
if(menuItem){
if(this.ParentIsNotMenu(menuItem)){
menuItem.get_parent().open();
}
else{
menuItem.open();
}
var status=$get(this._hiddenId);
status.value="expanded";
}
},
ItemClosing:function(menu,args){
var item=args.get_item();
var status=$get(this._hiddenId);
var menuItem=menu.findItemByValue(this._elementId);
if(item.get_value()==this._elementId){
if(!this._cierreManual){
args.set_cancel(true);
return;
}else{
this._cierreManual=!this._cierreManual;
}
}
else{
if(menuItem){
this._aperturaManual=true;
if(this.ParentIsNotMenu(menuItem)){
menuItem.get_parent().open();
}
else{
menuItem.open();
}
}
}
if(menuItem){
if(TLK.ContainsChild(item,this._elementId)){
if(status.value=="expanded"){
args.set_cancel(true);
}
else{
args.set_cancel(false);
}
}
else{
if(this.ParentIsNotMenu(menuItem)){
menuItem.get_parent().open();
}
}
}
},
ItemOpening:function(menu,args){
var item=args.get_item();
var status=$get(this._hiddenId);
var menuItem=menu.findItemByValue(this._elementId);
if(menuItem){
status.value="collapsed"
this._cierreManual=true;
if(this.ParentIsNotMenu(menuItem)){
if(!this._aperturaManual){
menuItem.get_parent().close();
}
else{
this._aperturaManual=!this._aperturaManual;
}
}else{
if(!this._aperturaManual){
menuItem.close();
}
else{
this._aperturaManual=!this._aperturaManual;
}
}
}
},
ParentIsNotMenu:function(aItem){
var parentItem=aItem.get_parent();
return(parentItem!=aItem.get_menu());
}
}
CmsMenuAutoHorizontalCenterExtender=function(){}
CmsMenuAutoHorizontalCenterExtender.prototype={
OnClientItemOpened:function(sender,args){
var rExp=/px/gi;
var item=args.get_item();
var itemW=item.get_element().offsetWidth;
var itemL=item.get_element().offsetLeft;
var slideW=args.get_item()._slide._element.clientWidth;
var senderContainerW=sender.get_element().parentNode.offsetWidth;
var slideLeft=args.get_item()._slide._element.style.left.replace(rExp,'');
if(itemL+slideW>senderContainerW)
{
i=senderContainerW-slideW-itemL-10;
if(i<0){
args.get_item()._slide._element.style.left=i+"px";
}
else{
args.get_item()._slide._element.style.left="-"+i+"px";
}
}
else
args.get_item()._slide._element.style.left="-20px";
}
}
