(function(){"use strict";u8.Crm.Widgets.ActivityResponseSelectorPopup=function(t,e){$.extend(this,u8.Crm.Widgets.ActivityResponseSelectorPopup.defaults,e);this.WidgetContainer();$assert(this.model,"Property 'model' must not be null.");this.element=t;this.$=$w(t).$;this.id=u8.Base.Dom.uniqueId();this._popup=null;this._editor=null;if(this.parent&&this.parent.children){this.parent.children.add(this)}this.commandBindings={Ok:this._onOk.bind(this),Cancel:this._onCancel.bind(this)};this.bind()};u8.Crm.Widgets.ActivityResponseSelectorPopup.makeClass({name:"ActivityResponseSelectorPopup",deriveFrom:u8.Base.Widgets.WidgetContainer,events:["Close"]});u8.Crm.Widgets.ActivityResponseSelectorPopup.defaults={popup:{sizing:"fit",allowResize:false,position:"center",showArrow:true}};$.extend(u8.Crm.Widgets.ActivityResponseSelectorPopup.prototype,{open:function(){u8.using({texts:["button_text","Campaign_Designer"]},function(){var t=$.extend(this.popup,{autoShow:false,parent:this,onCreate:this._onPopupCreate.bind(this),onClose:this._onPopupClose.bind(this),title:$t("TXT_Campaign_Designer_0")+" ("+this.model.activityDisplayText+")"});this._popup=new u8.Base.Widgets.Popup("<div></div>",t);this._popup.open()}.bind(this))},dispose:function(){if(this._isDisposed){return}this.unbind();this._popup=null;this._editor=null;this.WidgetContainer_dispose();if(this.parent&&this.parent.children){this.parent.children.remove(this.id)}},setValue:function(t){this.model=t||null},getValue:function(){return this.model},_createHtml:function(){var t="<div style='width: 240px;height: 190px;' class='u8-vstack spaced u8-padding-l'>";t+="<div id='${id}_editor' style='height:150px;overflow:auto'></div>";t+="<div id='${id}_buttons' class='u8-buttons'>";t+='{{Button({ textId:"TXT_button_text_11", isDefault: true, command:"Ok" })}}';t+='{{Button({ textId:"TXT_button_text_10", isCancel: true, command:"Cancel" })}}';t+="</div></div>";return t},_onPopupCreate:function(t,e){this._popup.getContent().utml({template:this._createHtml(),itemOptions:{parent:this._popup},data:this});this._createEditor()},_onPopupClose:function(){this.dispose()},_createEditor:function(){var t=this._popup.getWindow().$el(this.id+"_editor");if(!t){return}var e=this.$.extend({responsesState:this.model,parent:this._popup},this.editor);u8.tools.addEventHandler(e,"Create",this._onEditorCreate.bind(this));this._editor=new u8.Crm.Widgets.ActivityResponseSelector(t,e)},_onEditorCreate:function(){this._popup.autoSizeAndPosition().show()},_onOk:function(){if(!this._editor.verify()){return}var t=this._editor.getValue();this.setValue(t);this.raise("Close",{ok:true});if(this._isDisposed){return}this._popup.close()},_onCancel:function(){this.raise("Close",{ok:false,cancel:true});if(this._isDisposed){return}this._popup.close()}})})();