(function(){"use strict";var e={QuickView:{image:"u8-img-quickview-s",title:"{TXT_net_ListIconLabels_12}"},"BusinessObjects/Menu":{image:"u8-img-contextmenu-s",title:"{TXT_net_ListIconLabels_4}"}};u8.Crm.Widgets.TableCaption=function(e,t){this.Widget(e,$.extend({},u8.Crm.Widgets.TableCaption.defaults,t));if(this.model){this._model=this.model;delete this.model}this._isCreated=false;this._using(this._create.bind(this).ifAlive(this))};u8.Crm.Widgets.TableCaption.defaults={showImage:true,showActions:true,imageDecorator:"s",styles:[],theme:{css:{root:"u8-tablecaption-root",actions:"u8-tablecaption-actions",action:"u8-tablecaption-action",image:"u8-tablecaption-image"}}};u8.Crm.Widgets.TableCaption.makeClass({name:"TableCaption",deriveFrom:u8.Base.Widgets.Widget,events:["Created","ValueChange"],mixins:[u8.Base.Widgets.ActionsMixIn],attributes:{supportsActions:true}});$.extend(u8.Crm.Widgets.TableCaption.prototype,{getValue:function(){return this.value},setValue:function(e){if(u8.equalsRecordUid(this.value,e)){return}this.value=e;if(this._isCreated){this.update({args:{reload:true}});this.raise("ValueChange")}},update:function(e){if(e&&e.reason=="attr"){if(!this._isCreated){return}delete this._model}if(e&&e.args&&e.args.reload){delete this._model}this._create()},_using:function(e){u8.using({texts:"net_ListIconLabels"},e)},_create:function(){var e=this;Function.chain(this._createModel,this._createView.ifAlive(this)).call(this,function(){u8.tools.created(e)})},_createModel:function(t){var i=this,s=this.getValue();if(!u8.isValidRecordUid(s)){this._model=null;return t()}if(this.actions){for(var a=0;a<this.actions.length;a++){u8.tools.defaults(this.actions[a],e[this.actions[a].command])}}if(this._model){return t()}u8.services.tableCaptions.read({uid:s,tableCaptionName:this.tableCaptionName},function(e,s){i._model=s.tableCaption;t()})},_createView:function(e){var t=this.$(this.element).addClass(this.theme.css.root),i=this._model;if(i){var s=u8.services.tableCaptions.createView(i,{tagName:this.level&&"h"+this.level,showImage:this.showImage,imageDecorator:this.imageDecorator,allowLineBreaks:true});t.html(s);var a=t.find("span.image");if(a.length){this.$("<div/>").addClass(this.theme.css.image).append(a).prependTo(t)}if(this.showActions&&this.actions){t.append(this["Actions.createView"]());this["Actions.update"]("layout")}if(this.styles.length){var n=u8.tools.ifThen(this.styles,{value:i.text,get:function(e){return i[e]},model:i});t.addClass(n)}}else{t.empty()}e()},"Actions.layout":false,"Actions.onPreExecute":function(e){e.commandArguments.uid=this.getValue()}})})();