(function(){"use strict";u8.Crm.Widgets.LyrisSetResponseUrlPopup=function(e,t){$.extend(this,u8.Crm.Widgets.LyrisSetResponseUrlPopup.defaults,t);this.WidgetContainer();this.element=e;this.$=$w(e).$;this.id=u8.Base.Dom.uniqueId();this._popup=null;this._editor=null;this._createContext();if(this.parent&&this.parent.children){this.parent.children.add(this)}this.commandBindings={Ok:this._onOk.bind(this),Clear:this._onClear.bind(this),Cancel:this._onCancel.bind(this)};this.bind()};u8.Crm.Widgets.LyrisSetResponseUrlPopup.makeClass({name:"LyrisSetResponseUrlPopup",deriveFrom:u8.Base.Widgets.WidgetContainer,events:["Close","LyrisEmailResponseUrlSet"]});u8.Crm.Widgets.LyrisSetResponseUrlPopup.defaults={popup:{allowResize:false,position:"center",showArrow:true}};$.extend(u8.Crm.Widgets.LyrisSetResponseUrlPopup.prototype,{open:function(){var e=this;u8.using({texts:["button_text","Lyris_Integration"]},function(){var t=$.extend(this.popup,{autoShow:false,parent:e,onCreate:e._onPopupCreate.bind(e),onClose:e._onPopupClose.bind(e),title:$t("TXT_Lyris_Integration_112"),size:{width:.25,height:.1}});e._popup=new u8.Base.Widgets.Popup("<div></div>",t);e._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(e){this.model=e||null},getValue:function(){return this.model},_createContext:function(){this._context=u8.create("Model",{properties:{lyrisEmailResponseUrl:this.model.lyrisEmailResponseUrl}})},_updateContext:function(){this._context.set("lyrisEmailResponseUrl",this.model.lyrisEmailResponseUrl)},_onPopupCreate:function(e,t){this.model.id=this.id;this._popup.getContent().utml({url:"~/crm/LyrisSetResponseUrlPopup.utml.htm",itemOptions:{parent:this._popup,context:this._context},data:this.model});this._popup.show()},_onPopupClose:function(){this.dispose()},_onOk:function(){var e=this;u8.services.lyris.saveLyrisEmailResponseUrl(this.model.responseUid,this._context.get("lyrisEmailResponseUrl"),function(t){e.raise("LyrisEmailResponseUrlSet",{});if(e._isDisposed){return}e.raise("Close",{ok:true,cancel:false});e._popup.close()})},_onCancel:function(){this.raise("Close",{ok:false,cancel:true});if(this._isDisposed){return}this._popup.close()},_onClear:function(){this.model.lyrisEmailResponseUrl="";this._updateContext()}})})();