(function(){"use strict";u8.Base.Widgets.MenuModel=function(t){if(t instanceof u8.Base.Widgets.MenuModel){return t}$.extend(this,t);if(this.rootItem){this.rootItem=new u8.Base.Widgets.MenuItem(this.rootItem);this.rootItem.model=this}this.bind(t)};u8.Base.Widgets.MenuModel.makeClass({name:"MenuModel",events:["Update"]});$.extend(u8.Base.Widgets.MenuModel.prototype,{dispose:function(){if(this._isDisposed){return}this.rootItem=null;this.unbind();this._isDisposed=true},setRootItem:function(t){if(!u8.tools.isInstanceOfClass(t,"MenuItem")){t=new u8.Base.Widgets.MenuItem(t)}if(this.rootItem){delete this.rootItem.model}this.rootItem=t;if(this.rootItem){this.rootItem.model=this}this.update({menuItem:t,reason:"updateRootItem"});return this},find:function(t){return this.rootItem&&this.rootItem.find(t)},findByName:function(t){return this.rootItem&&this.rootItem.findByName(t)},load:function(t,e){var s=new u8.Base.Widgets.MenuItem({menuName:this.menuName,menuType:this.menuType,processState:this.processState});s.model=this;this.rootItem=s;if(s.menuName||s.menuType){this.loadMenuItem(s,t,e)}else{this.update({menuItem:s,reason:"load"});if(e){e(this,{})}}return this},loadMenuItem:function(t,e,s){var i=this;t.load(e,o);function o(){if(i._isDisposed){return}i.update({menuItem:t,reason:"load"});if(s){s(i,{})}}return this},update:function(t){if(u8.tools.isInstanceOfClass(t,"MenuItem")){t={menuItem:t}}this.raise("Update",t);return this},prettify:function(){if(this.rootItem){this.rootItem.prettify()}return this}})})();