(function(){"use strict";var e=['<div class="u8-processphase-left" style="float:left;"></div>','<div class="u8-processphase-right" style="float:right;"></div>','<div class="u8-processphase-center">','<h3 class="u8-processphase-title">',"{{if !!text}}","${text}","{{else}}","&nbsp;","{{/if}}","</h3>",'<table align="center" class="u8-processphase-metrics">',"<tbody>","<tr>","{{each metrics}}",'<td class="u8-processphase-metric">',"{{widget($value)}}","</td>","{{/each}}","</tr>","</tbody>","</table>","</div>"].join("");u8.Base.Widgets.ProcessPhaseView=function(e,t){$.extend(true,this,u8.Base.Widgets.ProcessPhaseView.defaults,t);this.Widget(e,t);$assert(this.phase,"Required field 'phase' has not been set.");this.phase.bind("PropertyChange",this._onModelPropertyChange.bind(this),this.id);this._load(this._create.bind(this))};u8.Base.Widgets.ProcessPhaseView.makeClass({name:"ProcessPhaseView",deriveFrom:u8.Base.Widgets.Widget,events:["ActiveChange"]});$.extend(u8.Base.Widgets.ProcessPhaseView.prototype,{dispose:function(){if(this._isDisposed){return}this.phase.unbind("PropertyChange",this.id);this.Widget_dispose()},_load:function(e){return e()},_create:function(){this._createModel();this._createView()},_createModel:function(){var e=null;var t=this.phase.metrics;if(t){e=[];for(var s=0;s<t.length;s++){var i=t[s];var a=i.view&&i.view.type;if(!a){continue}var h=i&&i.helpText||"";e.push($.extend(i.view&&i.view.options,{type:a,metrics:i,context:i,bindings:"@value",title:h,element:{attr:{title:h}}}))}}this._model={text:this.phase.text,metrics:e}},_createView:function(){this.empty();var t=this.$(this.element).addClass("u8-processphase").bind("click",this._onClick.bind(this)).utml({name:"processphase-template",template:e,data:this._model,itemOptions:{parent:this}});if(this.phase.canActivateConditions&&this.phase.canActivateConditions.length){t.addClass("u8-processphase-startpoint")}this._updateIsActive();this._updateCanActivate();this._updateCollapsed()},_onClick:function(){this.phase.activate()},_onModelPropertyChange:function(e,t){switch(t.propertyName){case"isActive":this._updateIsActive();break;case"canActivate":this._updateCanActivate();break;case"isCollapsed":this._updateCollapsed();break}},_updateIsActive:function(){if(this._isProcessExecuting()){var e=this.phase.isActive();this.$(this.element).toggleClass("u8-processphase-active",e);this.phase.metrics.each(function(e){e.update()});this.raise("ActiveChange",{active:e})}},_updateCanActivate:function(){if(this._isProcessExecuting()){this.$(this.element).toggleClass("u8-processphase-startpoint-active",this.phase.canActivate())}},_updateCollapsed:function(){var e=this.phase.isCollapsed();var t=this.$(this.element);t.toggleClass("collapsed",e);var s=this._model.text;if(e){s=s&&s.substring(0,1)}var i=t.find(".u8-processphase-title");i.text(s);var a=t.find(".u8-processphase-metrics");a.toggle(!e)},_isProcessExecuting:function(){var e=this.phase.process.state;return e!="error"&&e!="disposed"}})})();