%PDF- %PDF-
Direktori : /home/bitrix/www/bitrix/components/bitrix/lists.list/templates/.default/ |
Current File : /home/bitrix/www/bitrix/components/bitrix/lists.list/templates/.default/script.min.js |
BX.namespace("BX.Lists");BX.Lists.ListClass=function(){var t=function(t){this.iblockTypeId=t.iblockTypeId;this.iblockId=t.iblockId;this.sectionId=t.sectionId;this.randomString=t.randomString;this.socnetGroupId=t.socnetGroupId;this.listAction=t.listAction;this.listActionAdd=t.listActionAdd;this.gridId=t.gridId;this.init()};t.prototype.init=function(){this.ajaxUrl="/bitrix/components/bitrix/lists.list/ajax.php";this.actionButton=BX("lists-title-action");this.addButton=BX("lists-title-action-add");this.selectAddButton=BX("lists-title-action-select-add");this.addPopupItems=[];this.addPopupObject=null;this.addPopupId="lists-title-add";this.actionPopupItems=[];this.actionPopupObject=null;this.actionPopupId="lists-title-action";this.actionItemChanges=false;BX.bind(this.actionButton,"click",BX.delegate(this.showListAction,this));BX.bind(this.selectAddButton,"click",BX.delegate(this.showListAdd,this))};t.prototype.showListAction=function(){if(!this.actionPopupItems.length){for(var t=0;t<this.listAction.length;t++){var s={id:this.listAction[t].hasOwnProperty("id")?this.listAction[t].id:"",text:this.listAction[t].text,onclick:this.listAction[t].action};if(this.listAction[t].hasOwnProperty("items")){s.items=[];for(var e=0;e<this.listAction[t].items.length;e++){s.items.push({text:this.listAction[t].items[e].text,onclick:this.listAction[t].items[e].action})}}this.actionPopupItems.push(s)}}if(this.actionItemChanges){if(this.actionPopupObject){this.actionPopupObject.popupWindow.destroy();BX.PopupMenu.destroy(this.actionPopupId)}}if(!BX.PopupMenu.getMenuById(this.actionPopupId)){var i=this.actionButton.getBoundingClientRect();this.actionPopupObject=BX.PopupMenu.create(this.actionPopupId,this.actionButton,this.actionPopupItems,{closeByEsc:true,angle:true,offsetLeft:i.width/2,events:{onPopupShow:BX.proxy(function(){BX.addClass(this.actionButton,"webform-button-active")},this),onPopupClose:BX.proxy(function(){BX.removeClass(this.actionButton,"webform-button-active")},this)}});this.actionItemChanges=false}if(this.actionPopupObject)this.actionPopupObject.popupWindow.show()};t.prototype.showListAdd=function(){if(!this.addPopupItems.length){for(var t=0;t<this.listActionAdd.length;t++){this.addPopupItems.push({text:this.listActionAdd[t].text,onclick:this.listActionAdd[t].action})}}if(!BX.PopupMenu.getMenuById(this.addPopupId)){var s=this.addButton.getBoundingClientRect();this.addPopupObject=BX.PopupMenu.create(this.addPopupId,this.addButton,this.addPopupItems,{closeByEsc:true,angle:true,offsetLeft:s.width/2})}if(this.addPopupObject)this.addPopupObject.popupWindow.show()};t.prototype.addSection=function(){BX.Lists.modalWindow({modalId:"bx-lists-add-section",title:BX.message("CT_BLL_ADD_SECTION_POPUP_TITLE"),draggable:true,contentClassName:"",contentStyle:{width:"400px",padding:"25px 25px 50px 25px"},events:{onPopupClose:function(){this.destroy()}},content:[BX.create("span",{props:{id:"lists-popup-error",className:"bx-lists-popup-error"}}),BX.create("label",{props:{className:"bx-lists-popup-label",for:"lists-section-name-input"},children:[BX.create("span",{props:{className:"req"},text:"*"}),BX.message("CT_BLL_ADD_SECTION_POPUP_INPUT_NAME")]}),BX.create("input",{props:{id:"lists-section-name-input",className:"bx-lists-popup-input",type:"text",value:""},style:{fontSize:"16px",marginTop:"10px"}})],buttons:[BX.create("span",{text:BX.message("CT_BLL_ADD_SECTION_POPUP_BUTTON_ADD"),props:{className:"webform-small-button webform-small-button-accept"},events:{click:BX.delegate(function(){if(!BX("lists-section-name-input").value){BX("lists-popup-error").innerHTML=BX.message("CT_BLL_ADD_SECTION_POPUP_ERROR_NAME");BX.show(BX("lists-popup-error"));return false}BX.hide(BX("lists-popup-error"));BX.Lists.ajax({method:"POST",dataType:"json",url:BX.Lists.addToLinkParam(this.ajaxUrl,"action","addSection"),data:{iblockTypeId:this.iblockTypeId,iblockId:this.iblockId,sectionId:this.sectionId,sectionName:BX("lists-section-name-input").value,socnetGroupId:this.socnetGroupId},onsuccess:BX.delegate(function(t){if(t.status=="success"){BX.PopupWindowManager.getCurrentPopup().close();var s={},e;e=BX.Main.gridManager.getById(this.gridId);if(e.hasOwnProperty("instance"))e.instance.reloadTable("POST",s)}else{t.errors=t.errors||[{}];BX.Lists.showModalWithStatusAction({status:"error",message:t.errors.pop().message})}},this)})},this)}}),BX.create("span",{text:BX.message("CT_BLL_ADD_SECTION_POPUP_BUTTON_CLOSE"),props:{className:"webform-small-button webform-button-cancel"},events:{click:BX.delegate(function(){BX.PopupWindowManager.getCurrentPopup().close()},this)}})]})};t.prototype.performActionBp=function(t,s,e){BX.Lists.ajax({method:"POST",dataType:"json",url:BX.Lists.addToLinkParam(this.ajaxUrl,"action","performActionBp"),data:{iblockTypeId:this.iblockTypeId,iblockId:this.iblockId,sectionId:this.sectionId,workflowId:t,elementId:s,action:e,socnetGroupId:this.socnetGroupId,sessid:BX.bitrix_sessid()},onsuccess:BX.delegate(function(t){if(t.status=="success"){BX.Lists.showModalWithStatusAction({status:"success",message:t.message});setTimeout("location.reload()",1e3)}else{t.errors=t.errors||[{}];BX.Lists.showModalWithStatusAction({status:"error",message:t.errors.pop().message})}},this)})};t.prototype.editSection=function(t){if(!t)return false;BX.Lists.ajax({method:"POST",dataType:"json",url:BX.Lists.addToLinkParam(this.ajaxUrl,"action","getSection"),data:{iblockTypeId:this.iblockTypeId,iblockId:this.iblockId,sectionId:this.sectionId,socnetGroupId:this.socnetGroupId,currentSectionId:t},onsuccess:BX.delegate(function(s){if(s.status=="success"){var e=s.data;BX.Lists.modalWindow({modalId:"bx-lists-add-section",title:BX.message("CT_BLL_EDIT_SECTION_POPUP_TITLE"),draggable:true,contentClassName:"",contentStyle:{width:"400px",padding:"25px 25px 50px 25px"},events:{onPopupClose:function(){this.destroy()}},content:[BX.create("span",{props:{id:"lists-popup-error",className:"bx-lists-popup-error"}}),BX.create("label",{props:{className:"bx-lists-popup-label",for:"lists-section-name-input"},children:[BX.create("span",{props:{className:"req"},text:"*"}),BX.message("CT_BLL_ADD_SECTION_POPUP_INPUT_NAME")]}),BX.create("input",{props:{id:"lists-section-name-input",className:"bx-lists-popup-input",type:"text",value:e.NAME},style:{fontSize:"16px",marginTop:"10px"}})],buttons:[BX.create("span",{text:BX.message("CT_BLL_ADD_SECTION_POPUP_BUTTON_EDIT"),props:{className:"webform-small-button webform-small-button-accept"},events:{click:BX.delegate(function(){if(!BX("lists-section-name-input").value){BX("lists-popup-error").innerHTML=BX.message("CT_BLL_ADD_SECTION_POPUP_ERROR_NAME");BX.show(BX("lists-popup-error"));return false}BX.hide(BX("lists-popup-error"));BX.Lists.ajax({method:"POST",dataType:"json",url:BX.Lists.addToLinkParam(this.ajaxUrl,"action","editSection"),data:{iblockTypeId:this.iblockTypeId,iblockId:this.iblockId,sectionId:this.sectionId,sectionName:BX("lists-section-name-input").value,socnetGroupId:this.socnetGroupId,currentSectionId:t},onsuccess:BX.delegate(function(t){if(t.status=="success"){BX.PopupWindowManager.getCurrentPopup().close();var s={},e;e=BX.Main.gridManager.getById(this.gridId);if(e.hasOwnProperty("instance"))e.instance.reloadTable("POST",s)}else{t.errors=t.errors||[{}];BX.Lists.showModalWithStatusAction({status:"error",message:t.errors.pop().message})}},this)})},this)}}),BX.create("span",{text:BX.message("CT_BLL_ADD_SECTION_POPUP_BUTTON_CLOSE"),props:{className:"webform-small-button webform-button-cancel"},events:{click:BX.delegate(function(){BX.PopupWindowManager.getCurrentPopup().close()},this)}})]})}else{s.errors=s.errors||[{}];BX.Lists.showModalWithStatusAction({status:"error",message:s.errors.pop().message})}},this)})};t.prototype.deleteSection=function(t,s){BX.Lists.modalWindow({modalId:"bx-lists-migrate-list",title:BX.message("CT_BLL_DELETE_POPUP_TITLE"),draggable:true,contentClassName:"",contentStyle:{width:"400px",padding:"20px 20px 20px 20px"},events:{onPopupClose:function(){this.destroy()}},content:BX.message("CT_BLL_TOOLBAR_SECTION_DELETE_WARNING"),buttons:[BX.create("span",{text:BX.message("CT_BLL_DELETE_POPUP_ACCEPT_BUTTON"),props:{className:"webform-small-button webform-small-button-accept"},events:{click:BX.delegate(function(){BX.Lists.ajax({method:"POST",dataType:"json",url:BX.Lists.addToLinkParam(this.ajaxUrl,"action","deleteSection"),data:{iblockTypeId:this.iblockTypeId,iblockId:this.iblockId,sectionId:this.sectionId,socnetGroupId:this.socnetGroupId,sectionIdForDelete:s},onsuccess:BX.delegate(function(e){if(e.status=="success"){BX.Lists.showModalWithStatusAction({status:"success",message:e.message});var i={},o;o=BX.Main.gridManager.getById(t);if(o.hasOwnProperty("instance")){o.instance.reloadTable("POST",i);var n=o.instance.getRows().getById(s);if(n)n.closeActionsMenu()}}else{e.errors=e.errors||[{}];BX.Lists.showModalWithStatusAction({status:"error",message:e.errors.pop().message})}},this)});BX.PopupWindowManager.getCurrentPopup().close()},this)}}),BX.create("span",{text:BX.message("CT_BLL_DELETE_POPUP_CANCEL_BUTTON"),props:{className:"popup-window-button popup-window-button-link popup-window-button-link-cancel"},events:{click:BX.delegate(function(){BX.PopupWindowManager.getCurrentPopup().close()},this)}})]})};t.prototype.deleteElement=function(t,s){BX.Lists.modalWindow({modalId:"bx-lists-migrate-list",title:BX.message("CT_BLL_DELETE_POPUP_TITLE"),draggable:true,contentClassName:"",contentStyle:{width:"400px",padding:"20px 20px 20px 20px"},events:{onPopupClose:function(){this.destroy()}},content:BX.message("CT_BLL_TOOLBAR_ELEMENT_DELETE_WARNING"),buttons:[BX.create("span",{text:BX.message("CT_BLL_DELETE_POPUP_ACCEPT_BUTTON"),props:{className:"webform-small-button webform-small-button-accept"},events:{click:BX.delegate(function(){var e={},i;e["action_button_"+t]="delete";e["ID"]=[s];i=BX.Main.gridManager.getById(t);if(i.hasOwnProperty("instance")){i.instance.reloadTable("POST",e);var o=i.instance.getRows().getById(s);if(o)o.closeActionsMenu()}BX.PopupWindowManager.getCurrentPopup().close()},this)}}),BX.create("span",{text:BX.message("CT_BLL_DELETE_POPUP_CANCEL_BUTTON"),props:{className:"popup-window-button popup-window-button-link popup-window-button-link-cancel"},events:{click:BX.delegate(function(){BX.PopupWindowManager.getCurrentPopup().close()},this)}})]})};t.prototype.toogleSectionGrid=function(){BX.Lists.ajax({method:"POST",dataType:"json",url:BX.Lists.addToLinkParam(this.ajaxUrl,"action","toogleSectionGrid"),data:{gridId:this.gridId},onsuccess:BX.delegate(function(t){if(t.status=="success"){var s=BX.message("CT_BLL_SHOW_SECTION_GRID");if(t.currentValue=="Y"){s=BX.message("CT_BLL_HIDE_SECTION_GRID")}for(var e=0;e<this.actionPopupItems.length;e++){if(this.actionPopupItems[e].hasOwnProperty("id")&&this.actionPopupItems[e].id=="showSectionGrid"){this.actionPopupItems[e].text=s;this.actionItemChanges=true}}if(this.actionPopupObject)this.actionPopupObject.popupWindow.close();if(BX.Main.gridManager.getById(this.gridId)){BX.Main.gridManager.getById(this.gridId).instance.reload()}}else{t.errors=t.errors||[{}];BX.Lists.showModalWithStatusAction({status:"error",message:t.errors.pop().message})}},this)})};return t}();