Your IP : 18.118.139.79
BX.namespace("BX.Crm.Activity");if(typeof BX.CrmActivityProvider=="undefined"){BX.CrmActivityProvider=function(){this._settings={};this._options={};this._ttlWrapper=null;this._dlg=null;this._dlgMode=BX.CrmDialogMode.view;this._dlgCfg={};this._onSaveHandlers=[];this._onDlgCloseHandlers=[];this._editor=null;this._isChanged=false;this._buttonId=BX.CrmActivityDialogButton.undefined;this._owner=null;this._salt="";this._callCreationHandler=BX.delegate(this._handleCallCreation,this);this._meetingCreationHandler=BX.delegate(this._handleMeetingCreation,this);this._emailCreationHandler=BX.delegate(this._handleEmailCreation,this);this._taskCreationHandler=BX.delegate(this._handleTaskCreation,this);this._titleMenu=null;this._contentNode=null};BX.CrmActivityProvider.prototype={initialize:function(t,e,i){this._settings=t?t:{};this._editor=e;this._options=i?i:{};this._isChanged=this.getOption("markChanged",false);var n=this.getSetting("ownerType","");var r=this.getSetting("ownerID","");this._salt=Math.random().toString().substring(2)},getMode:function(){return this._dlgMode},getSetting:function(t,e){return typeof this._settings[t]!="undefined"?this._settings[t]:e},setSetting:function(t,e){this._settings[t]=e},getOption:function(t,e){return typeof this._options[t]!="undefined"?this._options[t]:e},getMessage:function(t){return BX.CrmActivityProvider.messages&&BX.CrmActivityProvider.messages[t]?BX.CrmActivityProvider.messages[t]:""},getType:function(){return this.getSetting("typeID",BX.CrmActivityType.provider)},getId:function(){return parseInt(this.getSetting("ID","0"))},getMessageType:function(){return this.getSetting("messageType","")},getOwnerType:function(){return this.getSetting("ownerType","")},getOwnerId:function(){return this.getSetting("ownerID","")},openDialog:function(t){var e=this.getId();if(e<=0||t!==BX.CrmDialogMode.view)throw"not supported.";this._dlgMode=t;var i="CrmActivityProvider"+(t===BX.CrmDialogMode.edit?"Edit":"View")+e;if(BX.CrmActivityProvider.dialogs[i]){return}var n={sessid:BX.bitrix_sessid(),ajax_action:"ACTIVITY_VIEW",activity_id:e};var r=this;BX.ajax({method:"POST",dataType:"html",url:"/bitrix/components/bitrix/crm.activity.planner/ajax.php?site_id="+BX.message("SITE_ID"),data:n,onsuccess:function(t){var e=BX.create("div");e.innerHTML=t;r._dlg=new BX.PopupWindow(i,null,{autoHide:false,draggable:true,offsetLeft:0,offsetTop:0,bindOptions:{forceBindPosition:false},closeByEsc:true,closeIcon:true,zIndex:-12,contentNoPaddings:true,titleBar:{content:r._prepareViewDlgTitle()},events:{onPopupClose:BX.delegate(function(){BX.CrmActivityEditor.hideUploader(r.getSetting("uploadID",""),r.getSetting("uploadControlID",""));BX.CrmActivityEditor.hideLhe(r.getSetting("lheContainerID",""));r._dlg.destroy()},r),onPopupDestroy:BX.proxy(function(){r._dlg=null;r._wrapper=null;r._ttlWrapper=null;delete BX.CrmActivityProvider.dialogs[i]},r)},content:e,buttons:r._prepareViewDlgButtons()});r._contentNode=e;r._prepareDialogContent();BX.CrmActivityProvider.dialogs[i]=r._dlg;r._dlg.show()}})},_getNode:function(t){return this._contentNode?this._contentNode.querySelector('[data-role="'+t+'"]'):null},_prepareDialogContent:function(){var t=this;var e=this._getNode("additional-switcher");var i=this._getNode("additional-fields");if(e&&i){BX.bind(e,"click",function(){BX.toggleClass(i,"active")})}var n=this._getNode("com-slider-left");if(n){BX.bind(n,"click",function(){t._changeCommunicationSlide(-1)})}var r=this._getNode("com-slider-right");if(r){BX.bind(r,"click",function(){t._changeCommunicationSlide(1)})}var s=this._getNode("field-completed");if(s){var o=this.getOption("enableInstantEdit",true);if(o){BX.bind(s,"click",function(){s.setAttribute("disabled","disabled");t._editor.setActivityCompleted(t.getId(),s.checked,function(e){t._settings["completed"]=!!e["COMPLETED"];s.removeAttribute("disabled")})})}else{s.setAttribute("disabled","disabled")}}},_changeCommunicationSlide:function(t){var e=this._getNode("com-slider-nav");var i=this._getNode("com-slider-slides");if(!e||!i)return false;var n=parseInt(e.getAttribute("data-current"));var r=parseInt(e.getAttribute("data-cnt"));if(isNaN(r)||r<1)return false;if(isNaN(n)||n<1)n=1;n+=t<0?-1:1;if(n>r)n=r;if(n<1)n=1;e.setAttribute("data-current",n.toString());e.innerHTML=n.toString()+" / "+r.toString();i.style.marginLeft=((n-1)*-269).toString()+"px"},closeDialog:function(){if(this._titleMenu){this._titleMenu.removeCreateTaskListener(this._taskCreationHandler);this._titleMenu.removeCreateCallListener(this._callCreationHandler);this._titleMenu.removeCreateMeetingListener(this._meetingCreationHandler);this._titleMenu.cleanLayout()}if(!this._dlg){return}this._notifyDialogClose();this._dlg.close()},addOnSave:function(t){if(!BX.type.isFunction(t)){return}for(var e=0;e<this._onSaveHandlers.length;e++){if(this._onSaveHandlers[e]==t){return}}this._onSaveHandlers.push(t)},removeOnSave:function(t){if(!BX.type.isFunction(t)){return}for(var e=0;e<this._onSaveHandlers.length;e++){if(this._onSaveHandlers[e]==t){this._onSaveHandlers.splice(e,1);return}}},addOnDialogClose:function(t){if(!BX.type.isFunction(t)){return}for(var e=0;e<this._onDlgCloseHandlers.length;e++){if(this._onDlgCloseHandlers[e]==t){return}}this._onDlgCloseHandlers.push(t)},removeOnDialogClose:function(t){if(!BX.type.isFunction(t)){return}for(var e=0;e<this._onDlgCloseHandlers.length;e++){if(this._onDlgCloseHandlers[e]==t){this._onDlgCloseHandlers.splice(e,1);return}}},isChanged:function(){return this._isChanged},getButtonId:function(){return this._buttonId},_prepareViewDlgTitle:function(){var t=this.getSetting("subject","");this._titleMenu=BX.CrmActivityMenu.create("",{enableTasks:this._editor.isTasksEnabled(),enableCalendarEvents:this._editor.isCalendarEventsEnabled(),enableEmails:this._editor.isEmailsEnabled()},{createTask:this._taskCreationHandler,createCall:this._callCreationHandler,createMeeting:this._meetingCreationHandler,createEmail:this._emailCreationHandler});var e=this._ttlWrapper=BX.CrmActivityEditor.prepareDialogTitle(t);this._titleMenu.layout(e);return e},_notifyDialogClose:function(){for(var t=0;t<this._onDlgCloseHandlers.length;t++){try{this._onDlgCloseHandlers[t](this)}catch(e){}}},_prepareViewDlgButtons:function(){var t=[];t.push({type:"button",settings:{text:BX.CrmActivityEditor.getMessage("closeDlgButton"),className:"popup-window-button-accept",events:{click:BX.delegate(this._handleCloseBtnClick,this)}}});if(this.getType()===BX.CrmActivityType.call||this.getType()===BX.CrmActivityType.meeting){var e=this;t.push({type:"link",settings:{text:BX.CrmActivityEditor.getMessage("editDlgButton"),className:"popup-window-button-link-cancel",events:{click:function(){(new BX.Crm.Activity.Planner).showEdit({ID:e.getId()});e.closeDialog()}}}})}return BX.CrmActivityEditor.prepareDialogButtons(t)},_handleCallCreation:function(t){var e=this.getSetting("ownerType","");var i=parseInt(this.getSetting("ownerID",0));if(typeof BX.Crm.Activity.Planner!=="undefined"){(new BX.Crm.Activity.Planner).showEdit({TYPE_ID:BX.CrmActivityType.call,OWNER_TYPE:e,OWNER_ID:i,FROM_ACTIVITY_ID:this.getId()})}},_handleMeetingCreation:function(t){var e=this.getSetting("ownerType","");var i=parseInt(this.getSetting("ownerID",0));if(typeof BX.Crm.Activity.Planner!=="undefined"){(new BX.Crm.Activity.Planner).showEdit({TYPE_ID:BX.CrmActivityType.meeting,OWNER_TYPE:e,OWNER_ID:i,FROM_ACTIVITY_ID:this.getId()})}},_handleEmailCreation:function(t){var e={};var i=this.getSetting("ownerType","");var n=parseInt(this.getSetting("ownerID",0));if(i!==""&&n>0){e["ownerType"]=i;e["ownerID"]=n;e["ownerTitle"]=this.getSetting("ownerTitle","");e["ownerUrl"]=this.getSetting("ownerUrl","")}if(this.getSetting("ownerType","")==="DEAL"){var r=this.getSetting("communications",[]);var s=BX.type.isArray(r)&&r.length>0?r[0]:null;if(s){var o=s["entityType"];if(!BX.type.isNotEmptyString(o)){o=i}var a=parseInt(s["entityId"]);if(isNaN(a)||a<=0){a=n}var l=BX.CrmActivityEditor.getDefaultCommunication(o,a,BX.CrmCommunicationType.email,this.getSetting("serviceUrl",""));if(l){e["communications"]=[l.getSettings()]}}}this._editor.addEmail(e)},_handleTaskCreation:function(t){var e={};var i=this.getSetting("ownerType","");var n=parseInt(this.getSetting("ownerID",0));if(i!==""&&n>0){e["ownerType"]=i;e["ownerID"]=n}this._editor.addTask(e)},_handleCloseBtnClick:function(t){this._buttonId=BX.CrmActivityDialogButton.cancel;this.closeDialog()}};BX.CrmActivityProvider.dialogs={};BX.CrmActivityProvider.create=function(t,e,i){var n=new BX.CrmActivityProvider;n.initialize(t,e,i);return n}}
//# sourceMappingURL=activity_provider.map.js