2b4785af7c64705d02fbba0bb1ccfa5b51b9b92bb911c9bf8ad717ce1573d336

Source Code:

// Gaia Ajax Copyright (C) 2008 - 2011 Gaiaware AS. details at http://gaiaware.net/
if(!Gaia.Extensions)
Gaia.Extensions=Class.create();Gaia.Extensions.ToolbarItem=Class.create(Gaia.Panel,{initialize:function(element,options){this.initializeToolbarItem(element,options);},initializeToolbarItem:function(element,options){options.effects=Object.extend({gaiahidechildren:function(e){Element.hide(this._getDropper());},gaiashowchildren:function(e){Element.show(this._getDropper());}},options.effects);this.initializePanel(element,Object.extend({isTop:0,closeOnClick:1},options));if(this._getDropper(true)===null)
this.element.appendChild(new Element('ul',{'id':this.element.id+'_children','style':'display:none'}));this.setNested(this.options.isTop);this.setDropDownMethod(this.options.dropMethod);},setIconCssClass:function(value){var icon=Element.down(this.element,'span-for-image');if(icon!==null)
icon.className=value;return this;},setNested:function(value){this.options.isTop=value;return this;},setCssClassRoot:function(value){this.element.className=value;return this;},_mouseOver:function(evt){this._showDropDown();},_mouseLeave:function(evt){this.hideToolbar();},_bodyClicked:function(evt){if(evt.$toolbaritemClicked$)return;this.hideToolbar();},_itemClicked:function(evt){evt.$toolbaritemClicked$=true;var dropper=this._getDropper();if(dropper!==null){if(!Element.visible(dropper)){this._showDropDown();Event.stop(evt);}else if(this.options.closeOnClick){this.hideChildren(dropper);}}else if(!this.options.closeOnClick){evt.stopPropagation();}},setDropDownMethod:function(value){this.unsetDropDownMethods();switch(value){case'Hover':this.onMouseOver=this._mouseOver.bindAsEventListener(this);Element.observe(this.element,'mouseover',this.onMouseOver);this.onMouseLeave=this._mouseLeave.bindAsEventListener(this);Element.observe(this.element,'mouseleave',this.onMouseLeave);this.onDropperMouseLeave=this._mouseLeave.bindAsEventListener(this);Element.observe(this._getDropper(true),'mouseleave',this.onDropperMouseLeave);break;case'Click':this.onItemClicked=this._itemClicked.bindAsEventListener(this);Element.observe(this.element,'click',this.onItemClicked);this.onBodyClicked=this._bodyClicked.bindAsEventListener(this);Element.observe(document.documentElement||document.body,'click',this.onBodyClicked);break;}
return this;},_showDropDown:function(){var dropper=this._getDropper();if(dropper===null||Element.visible(dropper))return;if(this.options.isTop){Position.clone(this.element,dropper,{offsetTop:Element.getHeight(this.element),setWidth:false,setHeight:false});}else{Position.clone(this.element,dropper,{offsetLeft:Element.getWidth(this.element.parentNode),setWidth:false,setHeight:false});}
this.showChildren(dropper);var items=Gaia.Control._registeredControls.values();for(var index=0,length=items.length;index<length;++index){var control=items[index];var isToolbar=control!==this&&Object.isFunction(control.initializeToolbarItem);if(!isToolbar)continue;var isChild=control.element!==null&&control.element.id!==this.element.id&&!Element.descendantOf(this.element,control.element);if(isChild)
control.hideToolbar();}},showChildren:function(drop){Element.fire(this.element,'gaia:showchildren',{afterFinish:function(){drop.style.height='';}.bind(drop)});},hideChildren:function(drop){Element.fire(this.element,'gaia:hidechildren',{afterFinish:function(){drop.style.height='';}.bind(drop)});},hideToolbar:function(){var dropper=this._getDropper();if(dropper===null||!Element.visible(dropper))return;this.hideChildren(dropper);},_getDropper:function(takeIfEmpty){var dropper=$(this.element.id+'_children');return!takeIfEmpty&&Element.firstDescendant(dropper)===null?null:dropper;},setCloseOnClick:function(value){this.options.closeOnClick=value;return this;},unsetDropDownMethods:function(){if(this.onItemClicked!==null)
Element.stopObserving(this.element,'click',this.onItemClicked);if(this.onBodyClicked!==null)
Element.stopObserving(document.documentElement||document.body,'click',this.onBodyClicked);if(this.onMouseOver!==null)
Element.stopObserving(this.element,'mouseover',this.onMouseOver);if(this.onMouseLeave!==null)
Element.stopObserving(this.element,'mouseleave',this.onMouseLeave);if(this.onDropperMouseLeave!==null)
Element.stopObserving(this._getDropper(true),'mouseleave',this.onDropperMouseLeave);},setAnimation:function(value){this.options.animation=value;return this;},setClose:function(){this.hideToolbar();return this;},destroy:function(){this.unsetDropDownMethods();this._panelDestroy();}});Gaia.Extensions.ToolbarItem.browserFinishedLoading=true;