Your IP : 3.141.38.137


Current Path : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/js/crm/
Upload File :
Current File : /home/bitrix/ext_www/crm.klimatlend.ua/bitrix/js/crm/category.min.js

BX.namespace("BX.Crm");if(typeof BX.Crm.DealCategoryChanger==="undefined"){BX.Crm.DealCategoryChanger=function(){this._id="";this._settings=null;this._selector=null;this._selectListener=BX.delegate(this.onSelect,this);this._serviceUrl="";this._entityId=0;this._confirmationDialog=null;this._errorDialog=null};BX.Crm.DealCategoryChanger.prototype={initialize:function(e,t){this._id=e;this._settings=t?t:{};this._serviceUrl=BX.prop.getString(this._settings,"serviceUrl","");this._entityId=BX.prop.getInteger(this._settings,"entityId",0)},getId:function(){return this._id},getEntityId:function(){return this._entityId},getMessage:function(e){return BX.prop.getString(BX.Crm.DealCategoryChanger.messages,e,e)},getFilteredCategories:function(){var e=BX.prop.getArray(this._settings,"categoryIds",[]);if(e.length===0){return BX.CrmDealCategory.infos}return BX.CrmDealCategory.infos.filter(function(t){for(var i=0,n=e.length;i<n;i++){if(t["id"]==e[i]){return true}}return false})},process:function(e){if(!BX.type.isPlainObject(e)){e={}}if(BX.prop.getBoolean(e,"usePopupMenu",false)){this.openPopupMenu(BX.prop.getElementNode(e,"anchor",null))}else{this.openSelector()}},openConfirmationDialog:function(e,t){this._confirmationDialog=new BX.PopupWindow(this._id+"_confirm",null,{autoHide:false,draggable:true,bindOptions:{forceBindPosition:false},closeByEsc:true,closeIcon:{top:"10px",right:"15px"},zIndex:0,titleBar:this.getMessage("dialogTitle"),content:this.getMessage("dialogSummary"),className:"crm-text-popup",lightShadow:true,buttons:[new BX.PopupWindowButton({text:BX.message("JS_CORE_WINDOW_CONTINUE"),className:"ui-btn ui-btn-success ui-btn-lg",events:{click:e}}),new BX.PopupWindowButtonLink({text:BX.message("JS_CORE_WINDOW_CANCEL"),className:"ui-btn ui-btn-link ui-btn ui-btn-lg",events:{click:t}})],events:{onPopupShow:BX.delegate(this.onOpenConfirmationDialog,this)}});this._confirmationDialog.show()},onOpenConfirmationDialog:function(){this._confirmationDialog.contentContainer.className="ui-alert ui-alert-icon-warning"},closeConfirmationDialog:function(){if(this._confirmationDialog){this._confirmationDialog.close();this._confirmationDialog.destroy();this._confirmationDialog=null}},openErrorDialog:function(e){this._errorDialog=new BX.PopupWindow(this._id+"_error",null,{autoHide:true,draggable:false,bindOptions:{forceBindPosition:false},closeByEsc:true,zIndex:0,content:e,className:"crm-text-popup",lightShadow:true,buttons:[new BX.PopupWindowCustomButton({text:BX.message("JS_CORE_WINDOW_CLOSE"),className:"ui-btn ui-btn-lg",events:{click:BX.delegate(this.closeErrorDialog,this)}})],events:{onPopupShow:BX.delegate(this.onOpenErrorDialog,this)}});this._errorDialog.show()},onOpenErrorDialog:function(){this._errorDialog.contentContainer.className="ui-alert ui-alert-warning"},closeErrorDialog:function(){if(this._errorDialog){this._errorDialog.close();this._errorDialog.destroy();this._errorDialog=null}},openSelector:function(){if(!this._selector){this._selector=BX.CrmDealCategorySelectDialog.create(this._id,{value:-1,categoryIds:BX.prop.getArray(this._settings,"categoryIds",[])});this._selector.addCloseListener(this._selectListener)}this._selector.open()},onSelect:function(e,t){if(!(BX.type.isBoolean(t["isCanceled"])&&t["isCanceled"]===false)){return}this.startRequest(e.getValue())},openPopupMenu:function(e){BX.PopupMenu.show(this._id+"_menu",e,this.prepareMenuItems(),{angle:false,autoHide:true,closeByEsc:true})},prepareMenuItems:function(){var e=[];var t=BX.delegate(this.onMenuItemClick,this);var i=this.getFilteredCategories();for(var n=0,o=i.length;n<o;n++){e.push({id:i[n]["id"],text:BX.Text.encode(i[n]["name"]),onclick:t})}return e},onMenuItemClick:function(e,t){if(t.menuWindow){t.menuWindow.close()}this.startRequest(BX.prop.getInteger(t,"id",0))},startRequest:function(e){BX.ajax({url:this._serviceUrl,method:"POST",dataType:"json",data:{ACTION:BX.prop.getString(this._settings,"action","MOVE_TO_CATEGORY"),ACTION_ENTITY_ID:this._entityId,CATEGORY_ID:e},onsuccess:BX.delegate(this.onRequestSuccess,this)})},onRequestSuccess:function(e){var t=BX.prop.getString(e,"ERROR","");if(t!==""){this.openErrorDialog(t)}else{window.location.reload()}}};if(typeof BX.Crm.DealCategoryChanger.messages==="undefined"){BX.Crm.DealCategoryChanger.messages={}}BX.Crm.DealCategoryChanger.items={};BX.Crm.DealCategoryChanger.getByEntityId=function(e){for(var t in this.items){if(!this.items.hasOwnProperty(t)){continue}var i=this.items[t];if(i.getEntityId()===e){return i}}return null};BX.Crm.DealCategoryChanger.processEntity=function(e,t){var i=this.getByEntityId(e);if(i){i.process(t)}};BX.Crm.DealCategoryChanger.create=function(e,t){var i=new BX.Crm.DealCategoryChanger;i.initialize(e,t);this.items[i.getId()]=i;return i}}
//# sourceMappingURL=category.map.js