(function(){"use strict";u8.Base.Widgets.DockPanel=function(e,i){this.Panel(e,$.extend({},u8.Base.Widgets.DockPanel.defaults,i));this._isCreated=false;if(this.designer){delete this.splitters}this.commandBindings={"Widget/size":this.update.bind(this,"layout")};this._create()};u8.Base.Widgets.DockPanel.makeClass({name:"DockPanel",deriveFrom:u8.Base.Widgets.Panel,events:["Create"]});u8.Base.Widgets.DockPanel.defaults={items:[],height:"100%",padding:5};$.extend(u8.Base.Widgets.DockPanel.prototype,{dispose:function(){if(this._isDisposed){return}if(this.designer){var e=$w(this.element);this.$(e).unbind("resize."+this.id);var i=u8.Base.Widgets.Tools.closest(this,"FormDesignerView");if(this.designer.widgetId==="root"){$$(i.element).removeClass("u8-layout-fill")}}this.Panel_dispose()},update:function(e){if(e=="layout"){u8.Base.Dom.layout(this.element,{name:"dock",splitters:this.splitters,padding:this.padding})}else{this._create()}},_create:function(){this.empty();var e=this.$(this.element).addClass("u8-dockpanel").css("visibility","hidden");if(this.height){e.css("height",this.height)}for(var i=0;i<this.items.length;i++){var t=this.items[i];var s=this._createItemElement(t).appendTo(e);this._createItemContent(s,t);s.addClass(t.position)}var n=this;u8.tools.ready(this.children,function(){if(this.designer){if(this._requiresAutoSize()){this._autoSize();var i=$w(this.element);this.$(i).unbind("resize."+this.id).bind("resize."+this.id,this._autoSize.bind(this))}}n.update("layout");e.css("visibility","inherit");u8.tools.created(this)}.bind(this))},_requiresAutoSize:function(){var i=this.designer.formDesigner.model.formModel.widgets[this.designer.widgetId];var t=i.attr;var s=i.css;return(!this.height||e(this.height))&&(!t||!t.height)&&(!s||!s.height&&!s.minHeight&&!s["min-height"])},_autoSize:function(){if(this._isDisposed){return}var e=u8.Base.Widgets.Tools.closest(this,"FormDesignerView");var i=$$(e.element);var t="";if(this.designer.widgetId=="root"){i.addClass("u8-layout-fill");t=i.height()}this.$(this.element).css("height",t)}});function e(e){return typeof e=="string"&&e.endsWith("%")}$.extend(u8.Base.Widgets.DockPanel,{"Designer.prepareModelForDesignMode":function(e){var i=e.model.options&&e.model.options.items;if(!i){return}var t=["top","left","right","bottom","center"];for(var s=0;s<i.length;s++){t.remove(i[s].position)}for(s=0;s<t.length;s++){i.push({position:t[s]})}}})})();