%PDF- %PDF-
Direktori : /home/bitrix/www/bitrix/components/bitrix/main.ui.grid/templates/.default/js/ |
Current File : //home/bitrix/www/bitrix/components/bitrix/main.ui.grid/templates/.default/js/data.min.js |
(function(){"use strict";BX.namespace("BX.Grid");BX.Grid.Data=function(t){this.parent=t;this.reset()};BX.Grid.Data.prototype.reset=function(){this.response=null;this.xhr=null;this.headRows=null;this.bodyRows=null;this.footRows=null;this.moreButton=null;this.pagination=null;this.counterDisplayed=null;this.counterSelected=null;this.counterTotal=null;this.limit=null;this.actionPanel=null;this.rowsByParentId={};this.rowById={};this.isValidResponse=null};BX.Grid.Data.prototype.getParent=function(){return this.parent};BX.Grid.Data.prototype.validateResponse=function(){if(!BX.type.isBoolean(this.isValidResponse)){this.isValidResponse=!!this.getResponse()&&!!BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classContainer"),true)}return this.isValidResponse};BX.Grid.Data.prototype.request=function(t,e,i,s,r,n){if(!BX.type.isString(t)){t=""}if(!BX.type.isNotEmptyString(e)){e="GET"}if(!BX.type.isPlainObject(i)){i={}}var a={gridId:this.parent.getId(),url:t,method:e,data:i};BX.onCustomEvent(window,"Grid::beforeRequest",[this,a]);t=a.url;if(!BX.type.isNotEmptyString(t)){t=this.parent.baseUrl}t=BX.Grid.Utils.addUrlParams(t,{sessid:BX.bitrix_sessid(),internal:"true",grid_id:this.parent.getId()});if("apply_filter"in i&&i.apply_filter==="Y"){t=BX.Grid.Utils.addUrlParams(t,{apply_filter:"Y"})}else{t=BX.util.remove_url_param(t,"apply_filter")}if("clear_nav"in i&&i.clear_nav==="Y"){t=BX.Grid.Utils.addUrlParams(t,{clear_nav:"Y"})}else{t=BX.util.remove_url_param(t,"clear_nav")}t=BX.Grid.Utils.addUrlParams(t,{grid_action:s||"showpage"});e=a.method;i=a.data;this.reset();var o=this;setTimeout(function(){var a=BX.ajax({url:BX.Grid.Utils.ajaxUrl(t,o.getParent().getAjaxId()),data:i,method:e,dataType:"html",headers:[{name:"X-Ajax-Grid-UID",value:o.getParent().getAjaxId()},{name:"X-Ajax-Grid-Req",value:JSON.stringify({action:s||"showpage"})}],processData:true,scriptsRunFirst:false,onsuccess:function(t){o.response=BX.create("div",{html:t});o.response=o.response.querySelector("#"+o.parent.getContainerId());o.xhr=a;if(BX.type.isFunction(r)){BX.delegate(r,o)(t,a)}},onerror:function(t){o.error=n;o.xhr=a;if(BX.type.isFunction(n)){BX.delegate(n,o)(a,t)}}})},0)};BX.Grid.Data.prototype.getResponse=function(){return this.response};BX.Grid.Data.prototype.getHeadRows=function(){if(!this.headRows){this.headRows=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classHeadRow"))}return this.headRows};BX.Grid.Data.prototype.getBodyRows=function(){if(!this.bodyRows){this.bodyRows=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classBodyRow"))}return this.bodyRows};BX.Grid.Data.prototype.getRowsByParentId=function(t){if(!(t in this.rowsByParentId)){this.rowsByParentId[t]=BX.Grid.Utils.getBySelector(this.getResponse(),"."+this.getParent().settings.get("classBodyRow")+'[data-parent-id="'+t+'"]')}return this.rowsByParentId[t]};BX.Grid.Data.prototype.getRowById=function(t){if(!(t in this.rowById)){this.rowById[t]=BX.Grid.Utils.getBySelector(this.getResponse(),"."+this.getParent().settings.get("classBodyRow")+'[data-id="'+t+'"]',true)}return this.rowById[t]};BX.Grid.Data.prototype.getFootRows=function(){if(!this.footRows){this.footRows=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classFootRow"))}return this.footRows};BX.Grid.Data.prototype.getMoreButton=function(){if(!this.moreButton){this.moreButton=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classMoreButton"),true)}return this.moreButton};BX.Grid.Data.prototype.getPagination=function(){if(!this.pagination){this.pagination=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classPagination"),true);if(BX.type.isDomNode(this.pagination)){this.pagination=BX.firstChild(this.pagination)}}return this.pagination};BX.Grid.Data.prototype.getCounterDisplayed=function(){if(!this.counterDisplayed){this.counterDisplayed=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classCounterDisplayed"),true)}return this.counterDisplayed};BX.Grid.Data.prototype.getCounterSelected=function(){if(!this.counterSelected){this.counterSelected=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classCounterSelected"),true)}return this.counterSelected};BX.Grid.Data.prototype.getCounterTotal=function(){if(!BX.type.isDomNode(this.counterTotal)){var t="."+this.getParent().settings.get("classCounterTotal")+" ."+this.getParent().settings.get("classPanelCellContent");this.counterTotal=BX.Grid.Utils.getBySelector(this.getResponse(),t,true)}return this.counterTotal};BX.Grid.Data.prototype.getLimit=function(){if(!this.limit){this.limit=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classPageSize"),true)}return this.limit};BX.Grid.Data.prototype.getPageSize=function(){return this.getLimit()};BX.Grid.Data.prototype.getActionPanel=function(){if(!this.actionPanel){this.actionPanel=BX.Grid.Utils.getByClass(this.getResponse(),this.getParent().settings.get("classActionPanel"),true)}return this.actionPanel}})();