Your IP : 3.144.244.100


Current Path : /home/bitrix/ext_www/dev.ballu.in.ua/bitrix/js/main/kanban/
Upload File :
Current File : /home/bitrix/ext_www/dev.ballu.in.ua/bitrix/js/main/kanban/grid.min.js

(function(){"use strict";BX.namespace("BX.Kanban");BX.Kanban.Grid=function(t){if(!BX.type.isPlainObject(t)){throw new Error("BX.Kanban.Grid: 'options' is not an object.")}this.options=t;if(!BX.type.isDomNode(t.renderTo)){throw new Error("BX.Kanban.Grid: 'renderTo' is not a DOMNode.")}this.renderTo=t.renderTo;this.rendered=false;this.layout={outerContainer:null,innerContainer:null,gridContainer:null,earLeft:null,earRight:null,dropzone:null,emptyStub:null};this.itemType=this.getItemType(t.itemType);this.columnType=this.getColumnType(t.columnType);this.dropZoneType=this.getDropZoneType(t.dropZoneType);this.columns=Object.create(null);this.columnsOrder=[];this.items=Object.create(null);this.dropzones=Object.create(null);this.data=BX.type.isPlainObject(t.data)?t.data:Object.create(null);this.bgColor=BX.Kanban.Utils.isValidColor(t.bgColor)?t.bgColor:"ffffff";this.earTimer=null;this.dragMode=BX.Kanban.DragMode.NONE;this.canAddColumn=BX.type.isBoolean(t.canAddColumn)?t.canAddColumn:false;this.canEditColumn=BX.type.isBoolean(t.canEditColumn)?t.canEditColumn:false;this.canRemoveColumn=BX.type.isBoolean(t.canRemoveColumn)?t.canRemoveColumn:false;this.canAddItem=BX.type.isBoolean(t.canAddItem)?t.canAddItem:false;this.data=Object.create(null);this.setData(t.data);this.loadData(t);if(t.events){for(var e in t.events){if(t.events.hasOwnProperty(e)){BX.addCustomEvent(this,"Kanban.Grid:"+e,t.events[e])}}}BX.addCustomEvent(this,"Kanban.Grid:onItemDragStart",BX.delegate(this.onItemDragStart,this));BX.addCustomEvent(this,"Kanban.Grid:onItemDragStop",BX.delegate(this.onItemDragStop,this));BX.addCustomEvent(this,"Kanban.Grid:onColumnDragStart",BX.delegate(this.onColumnDragStart,this));BX.addCustomEvent(this,"Kanban.Grid:onColumnDragStop",BX.delegate(this.onColumnDragStop,this))};BX.Kanban.DragMode={NONE:0,ITEM:1,COLUMN:2};BX.Kanban.Grid.prototype={addColumn:function(t){t=t||{};if(this.getColumn(t.id)!==null){return null}var e=this.getColumnType(t.type);var n=new e(t);if(!n instanceof BX.Kanban.Column){throw new Error("Column type must be an instance of BX.Kanban.Column")}n.setGrid(this);this.columns[n.getId()]=n;var i=this.getColumn(t.targetId);var r=BX.util.array_search(i,this.columnsOrder);if(r>=0){this.columnsOrder.splice(r,0,n)}else{this.columnsOrder.push(n)}if(this.isRendered()){if(i){this.getGridContainer().insertBefore(n.render(),i.getContainer())}else{this.getGridContainer().appendChild(n.render())}}return n},removeColumn:function(t){t=this.getColumn(t);if(!t){return false}this.removeColumnItems(t);this.columnsOrder=this.columnsOrder.filter(function(e){return t!==e});delete this.columns[t.getId()];BX.remove(t.getContainer());return true},updateColumn:function(t,e){t=this.getColumn(t);if(!t){return false}t.setOptions(e);t.render();return true},getNextColumnSibling:function(t){var e=this.getColumnIndex(t);var n=this.getColumns();return e!==-1&&n[e+1]?n[e+1]:null},getPreviousColumnSibling:function(t){var e=this.getColumnIndex(t);var n=this.getColumns();return e>0&&n[e-1]?n[e-1]:null},addItem:function(t){t=t||{};var e=this.getColumn(t.columnId);if(!e){return null}var n=this.getItemType(t.type);var i=new n(t);if(!i instanceof BX.Kanban.Item){throw new Error("Item type must be an instance of BX.Kanban.Item")}if(this.items[i.getId()]){return null}i.setGrid(this);this.items[i.getId()]=i;var r=this.getItem(t.targetId);e.addItem(i,r);return i},removeItem:function(t){var e=this.getItem(t);if(e){var n=e.getColumn();delete this.items[e.getId()];n.removeItem(e)}return e},removeColumnItems:function(t){t=this.getColumn(t);var e=t.getItems();t.removeItems();e.forEach(function(t){this.removeItem(t)},this)},removeItems:function(){this.getColumns().forEach(function(t){this.removeColumnItems(t)},this)},updateItem:function(t,e){t=this.getItem(t);if(!t){return false}if(BX.Kanban.Utils.isValidId(e.columnId)&&e.columnId!==t.getColumn().getId()){this.moveItem(t,this.getColumn(e.columnId),this.getItem(e.targetId))}t.setOptions(e);t.render();return true},addDropZone:function(t){t=t||{};if(this.getDropZone(t.id)!==null){return null}var e=this.getDropZoneType(t.type);var n=new e(t);if(!n instanceof BX.Kanban.DropZone){throw new Error("DropZone type must be an instance of BX.Kanban.DropZone")}n.setGrid(this);this.dropzones[n.getId()]=n;return n},updateDropZone:function(t,e){},getColumn:function(t){var e=t instanceof BX.Kanban.Column?t.getId():t;return this.columns[e]?this.columns[e]:null},getColumns:function(){return this.columnsOrder},getColumnsCount:function(){return this.columnsOrder.length},getColumnIndex:function(t){t=this.getColumn(t);return BX.util.array_search(t,this.getColumns())},getItem:function(t){var e=t instanceof BX.Kanban.Item?t.getId():t;return this.items[e]?this.items[e]:null},getItemByElement:function(t){if(BX.type.isDomNode(t)&&t.dataset.id&&t.dataset.type==="item"){return this.getItem(t.dataset.id)}return null},getItems:function(){return this.items},getDropZone:function(t){return this.dropzones[t]?this.dropzones[t]:null},getDropZones:function(){return this.dropzones},getItemType:function(t){var e=BX.Kanban.Utils.getClass(t);if(BX.type.isFunction(e)){return e}return this.itemType||BX.Kanban.Item},getColumnType:function(t){var e=BX.Kanban.Utils.getClass(t);if(BX.type.isFunction(e)){return e}return this.columnType||BX.Kanban.Column},getDropZoneType:function(t){var e=BX.Kanban.Utils.getClass(t);if(BX.type.isFunction(e)&&e instanceof BX.Kanban.DropZone){return e}return this.columnType||BX.Kanban.DropZone},getData:function(){return this.data},setData:function(t){if(BX.type.isPlainObject(t)){this.data=t}},getBgColor:function(){return this.bgColor},getOptions:function(){return this.options},loadData:function(t){var e=this.isRendered();this.setRenderStatus(false);if(BX.type.isArray(t.columns)){t.columns.forEach(function(t){if(t&&BX.Kanban.Utils.isValidId(t.id)&&this.getColumn(t.id)){this.updateColumn(t.id,t)}else{this.addColumn(t)}},this)}if(BX.type.isArray(t.items)){t.items.forEach(function(t){if(t&&BX.Kanban.Utils.isValidId(t.id)&&this.getItem(t.id)){this.updateItem(t.id,t)}else{this.addItem(t)}},this)}if(BX.type.isArray(t.dropzones)){t.dropzones.forEach(function(t){if(t&&BX.Kanban.Utils.isValidId(t.id)&&this.getDropZone(t.id)){this.updateDropZone(t.id.id,t.id)}else{this.addDropZone(t)}},this)}if(e){this.draw()}},draw:function(){var t=document.createDocumentFragment();var e=this.getColumns();for(var n=0;n<e.length;n++){var i=e[n];t.appendChild(i.render())}BX.cleanNode(this.getGridContainer());this.getGridContainer().appendChild(t);var r=document.createDocumentFragment();for(var a in this.dropzones){r.appendChild(this.dropzones[a].render())}BX.cleanNode(this.getDropZoneContainer());this.getDropZoneContainer().appendChild(r);if(!this.isRendered()){this.renderLayout();this.adjustLayout();this.setRenderStatus(true);BX.onCustomEvent(this,"Kanban.Grid:onFirstRender")}else{this.adjustLayout()}this.adjustEmptyStub()},renderLayout:function(){if(this.getOuterContainer().parentNode){return}var t=this.getInnerContainer();t.appendChild(this.getEmptyStub());t.appendChild(this.getLeftEar());t.appendChild(this.getRightEar());t.appendChild(this.getGridContainer());var e=this.getOuterContainer();e.appendChild(t);this.renderTo.appendChild(this.getOuterContainer());document.body.appendChild(this.getDropZoneContainer());BX.bind(window,"resize",this.adjustLayout.bind(this));BX.bind(window,"scroll",this.adjustHeight.bind(this))},isRendered:function(){return this.rendered},setRenderStatus:function(t){if(BX.type.isBoolean(t)){this.rendered=t}},getLeftEar:function(){if(this.layout.earLeft){return this.layout.earLeft}this.layout.earLeft=BX.create("div",{attrs:{className:"main-kanban-ear-left"},events:{mouseenter:this.scrollToLeft.bind(this),mouseleave:this.stopAutoScroll.bind(this)}});return this.layout.earLeft},getRightEar:function(){if(this.layout.earRight){return this.layout.earRight}this.layout.earRight=BX.create("div",{attrs:{className:"main-kanban-ear-right"},events:{mouseenter:this.scrollToRight.bind(this),mouseleave:this.stopAutoScroll.bind(this)}});return this.layout.earRight},getOuterContainer:function(){if(this.layout.outerContainer){return this.layout.outerContainer}this.layout.outerContainer=BX.create("div",{props:{className:"main-kanban"},style:{backgroundColor:"#"+this.getBgColor()}});return this.layout.outerContainer},getInnerContainer:function(){if(this.layout.innerContainer){return this.layout.innerContainer}this.layout.innerContainer=BX.create("div",{props:{className:"main-kanban-inner"},style:{backgroundColor:"#"+this.getBgColor()}});return this.layout.innerContainer},getGridContainer:function(){if(this.layout.gridContainer){return this.layout.gridContainer}this.layout.gridContainer=BX.create("div",{props:{className:"main-kanban-grid"},events:{scroll:this.adjustEars.bind(this)}});return this.layout.gridContainer},getDropZoneContainer:function(){if(this.layout.dropzone){return this.layout.dropzone}this.layout.dropzone=BX.create("div",{attrs:{className:"main-kanban-dropzone-area"}});return this.layout.dropzone},getEmptyStub:function(){if(this.layout.emptyStub){return this.layout.emptyStub}this.layout.emptyStub=BX.create("div",{attrs:{className:"main-kanban-no-data"},children:[BX.create("div",{attrs:{className:"main-kanban-no-data-inner"},children:[BX.create("div",{attrs:{className:"main-kanban-no-data-image"}}),BX.create("div",{attrs:{className:"main-kanban-no-data-text"},text:BX.message("MAIN_KANBAN_NO_DATA")})]})]});return this.layout.emptyStub},adjustLayout:function(){this.adjustWidth();this.adjustHeight();this.adjustEars();this.adjustDropZoneArea()},adjustEars:function(){var t=this.getGridContainer();var e=t.scrollLeft;var n=e>0;var i=t.scrollWidth>e+t.offsetWidth;this.getOuterContainer().classList[n?"add":"remove"]("main-kanban-left-ear-shown");this.getOuterContainer().classList[i?"add":"remove"]("main-kanban-right-ear-shown")},adjustWidth:function(){this.getOuterContainer().style.width=this.renderTo.offsetWidth+"px"},adjustHeight:function(){var t=this.getOuterContainer();var e=this.getInnerContainer();if(t.getBoundingClientRect().top>=15){var n=document.documentElement.clientHeight-e.getBoundingClientRect().top;e.style.height=n+"px";t.style.minHeight=document.documentElement.clientHeight+"px";e.style.removeProperty("top");e.style.removeProperty("left");e.style.removeProperty("width");e.classList.remove("main-kanban-fixed")}else{var i=this.renderTo.getBoundingClientRect();e.classList.contains("main-kanban-fixed");e.style.left=i.left+"px";e.style.width=i.width+"px";e.style.removeProperty("height");e.classList.add("main-kanban-fixed")}},adjustDropZoneArea:function(){var t=BX.pos(this.getOuterContainer());this.getDropZoneContainer().style.width=t.width+"px";this.getDropZoneContainer().style.left=t.left+"px"},adjustEmptyStub:function(){var t=BX.Kanban.Utils.isEmptyObject(this.getItems());this.getInnerContainer().classList[t?"add":"remove"]("main-kanban-no-data-mode")},moveItem:function(t,e,n){t=this.getItem(t);e=this.getColumn(e);n=this.getItem(n);if(!t||!e||t===n){return false}var i=t.getColumn();i.removeItem(t);e.addItem(t,n);return true},moveColumn:function(t,e){t=this.getColumn(t);e=this.getColumn(e);if(!t||t===e){return false}var n=BX.util.array_search(t,this.columnsOrder);this.columnsOrder.splice(n,1);var i=BX.util.array_search(e,this.columnsOrder);if(i>=0){this.columnsOrder.splice(i,0,t);if(this.isRendered()){t.getContainer().parentNode.insertBefore(t.getContainer(),e.getContainer())}}else{this.columnsOrder.push(t);if(this.isRendered()){t.getContainer().parentNode.appendChild(t.getContainer())}}return true},canAddColumns:function(){return this.canAddColumn},canEditColumns:function(){return this.canEditColumn},canRemoveColumns:function(){return this.canRemoveColumn},canAddItems:function(){return this.canAddItem},scrollToRight:function(){this.earTimer=setInterval(function(){this.getGridContainer().scrollLeft+=10}.bind(this),20)},scrollToLeft:function(){this.earTimer=setInterval(function(){this.getGridContainer().scrollLeft-=10}.bind(this),20)},stopAutoScroll:function(){clearInterval(this.earTimer);jsDD.refreshDestArea()},getDragMode:function(){return this.dragMode},getDragModeCode:function(t){for(var e in BX.Kanban.DragMode){if(BX.Kanban.DragMode[e]===t){return e}}return null},setDragMode:function(t){var e=this.getDragModeCode(t);if(e!==null){this.getOuterContainer().classList.add("main-kanban-drag-mode-"+e.toLowerCase());this.dragMode=t}},resetDragMode:function(){var t=this.getDragModeCode(this.getDragMode());if(t!==null){this.getOuterContainer().classList.remove("main-kanban-drag-mode-"+t.toLowerCase())}this.dragMode=BX.Kanban.DragMode.NONE},onItemDragStart:function(t){this.setDragMode(BX.Kanban.DragMode.ITEM);var e=this.getItems();for(var n in e){e[n].enableDropping()}this.getColumns().forEach(function(t){t.enableDropping()})},onItemDragStop:function(t){this.resetDragMode()},onColumnDragStart:function(t){this.setDragMode(BX.Kanban.DragMode.COLUMN)},onColumnDragStop:function(t){this.resetDragMode()},getEventPromise:function(t,e,n,i){var r=[];e=BX.type.isArray(e)?e:[];BX.onCustomEvent(this,t,[r].concat(e));var a=new BX.Promise;var o=a;for(var s=0;s<r.length;s++){a=a.then(r[s])}a.then(BX.type.isFunction(n)?n:null,BX.type.isFunction(i)?i:null);return o},fadeOut:function(){this.getOuterContainer().classList.add("main-kanban-faded")},fadeIn:function(){this.getOuterContainer().classList.remove("main-kanban-faded")}}})();
//# sourceMappingURL=grid.map.js