(function(){"use strict";u8.Crm.Widgets.ContactsSynchronizationTaskEditor=function(t,e){this.Widget(t,$.extend({},u8.Crm.Widgets.ContactsSynchronizationTaskEditor.defaults,e));this._create()};u8.Crm.Widgets.ContactsSynchronizationTaskEditor.makeClass({name:"ContactsSynchronizationTaskEditor",deriveFrom:u8.Base.Widgets.Widget,events:[]});u8.Crm.Widgets.ContactsSynchronizationTaskEditor.defaults={};$.extend(u8.Crm.Widgets.ContactsSynchronizationTaskEditor.prototype,{_create:function(){Function.chain({onError:"abort"},this._using,this._createModel,this._createContext,this._initTemplate,function(t){self.raise("Create");t()}).call(this)},_using:function(t){u8.using({texts:["button_text","ContactsSynchronization"]},t)},_createContext:function(t){this._context=u8.create("Model",{properties:{templateName:this.model.templateName}});t()},_createModel:function(t){var e=this;u8.services.contactsSynchronization.newTask(function(i){e._createModelFromNewTaskResponse(i);t()})},_createModelFromNewTaskResponse:function(t){this.model=t;this.model.onShowTemplatePreviewClick=this._onShowTemplatePreviewClick.bind(this)},_onShowTemplatePreviewClick:function(){var t=this._context.get("templateName");u8.services.contactsSynchronization.getTemplatePreview(t,this._openTemplatePreviewPopup.bind(this))},_openTemplatePreviewPopup:function(t){var e=this.$(this.element).find("#showContactsSynchronizationTemplatePreview")[0];var i=this;var n=new u8.Crm.Widgets.ContactsSynchronizationTemplatePreviewPopup(document.body,{parent:i,model:t,popup:{position:"center-top",alignTo:e,size:{width:.4,height:.6}}});n.open()},_initTemplate:function(){this.$(this.element).utml({url:"~/crm/ContactsSynchronizationTaskEditor.utml.htm",data:this.model,itemOptions:{parent:this,context:this._context}})}})})();