%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /home/bitrix/www/bitrix/js/im/ui/list/js/
Upload File :
Create Path :
Current File : /home/bitrix/www/bitrix/js/im/ui/list/js/markup.min.js

(function(){"use strict";BX.namespace("BX.im.list.markup");BX.im.list.markup=function(t){t=t||{};this.controller=t.list;this.outerContainer=t.container;this.container=null;this.containerWrapper=null;this.cssClass="bx-im-ui-list-";this.const={TYPE_ADD:"add",TYPE_UPDATE:"update",TYPE_DELETE:"delete",BLOCK_HEIGHT_AUTO:"auto",BLOCK_HEIGHT_DEFAULT:"default"};this.queue={};this.queue[this.const.TYPE_ADD]=[];this.queue[this.const.TYPE_UPDATE]=[];this.queue[this.const.TYPE_DELETE]=[];this.queueCount=0;this.updateIntervalId=null;this.config={};if(typeof t.sectionHeight=="number"){this.config.sectionHeight=t.sectionHeight}else{this.config.sectionHeight=this.const.BLOCK_HEIGHT_DEFAULT}if(typeof t.itemHeight=="number"){this.config.itemHeight=t.itemHeight}else{this.config.itemHeight=t.itemHeight==this.const.BLOCK_HEIGHT_AUTO?this.const.BLOCK_HEIGHT_AUTO:this.const.BLOCK_HEIGHT_DEFAULT;if(this.config.itemHeight==this.const.BLOCK_HEIGHT_AUTO){t.animation=false}}this.config.animation=t.animation===true?new BX.im.list.animation({controller:this.controller,view:this}):null;this.drawGrid()};BX.im.list.markup.prototype.drawGrid=function(){BX.cleanNode(this.outerContainer);this.container=BX.create("div",{props:{className:this.cssClass+"container"},children:[this.containerWrapper=BX.create("div",{props:{className:this.cssClass+"wrapper"}})]});this.outerContainer.appendChild(this.container);return true};BX.im.list.markup.prototype.drawSections=function(){BX.cleanNode(this.containerWrapper);var t=document.createDocumentFragment();this.controller.sections.forEach(function(e){var i=BX.create("div",{props:{className:this.cssClass+"section-wrapper"},children:[e._nodes.box=BX.create("div",{props:{className:this.cssClass+"section-box"+(e.title.length>0?"":" section-box-without-title")},children:this.getSectionView(e)}),e._nodes.items=BX.create("div",{props:{className:this.cssClass+"section-items "+this.cssClass+"section-"+e.id+"-items"}})]});t.appendChild(i)},this);this.drawItemsStub();this.containerWrapper.appendChild(t)};BX.im.list.markup.prototype.drawItemsStub=function(){this.controller.sections.forEach(function(t){if(!t._nodes.items||!this.controller.sectionItems[t.id])return false;BX.cleanNode(t._nodes.items);t._nodes.itemsLenght=0;var e=this.controller.sectionItems[t.id].length;for(var i=0;i<e;i++){t._nodes.items.appendChild(this.drawItemStub(i));t._nodes.itemsLenght++}return true},this);return true};BX.im.list.markup.prototype.drawItemStub=function(t){var e="";var i="";if(this.config.itemHeight==this.const.BLOCK_HEIGHT_DEFAULT){e=" "+this.cssClass+"item-size-default"}else if(this.config.itemHeight==this.const.BLOCK_HEIGHT_AUTO){e=" "+this.cssClass+"item-size-auto"}else{e=" "+this.cssClass+"item-size-custom";i="height: "+this.config.itemHeight+"px;"}return BX.create("div",{props:{className:this.cssClass+"item-position "+this.cssClass+"item-position-"+t+e,style:i},html:t})};BX.im.list.markup.prototype.getSectionView=function(t){if(t.title.length<=0)return null;var e="";var i="";if(this.config.itemHeight==this.const.BLOCK_HEIGHT_DEFAULT){e=" "+this.cssClass+"section-size-default"}else{e=" "+this.cssClass+"section-size-custom";i="height: "+this.config.itemHeight+"px;"}return[BX.create("div",{props:{className:this.cssClass+"section "+this.cssClass+"section-"+t.id+e},children:[BX.create("div",{html:t.id})]})]};BX.im.list.markup.prototype.change=function(t,e){var i=this.queueCount++;this.queue[t][i]=e;if(t==this.const.TYPE_ADD){e.section._nodes.items.appendChild(this.drawItemStub(e.section._nodes.itemsLenght));e.section._nodes.itemsLenght++}console.warn(i,t,e.item.id,e.position);this._start();return true};BX.im.list.markup.prototype.clear=function(){this.queue[this.const.TYPE_ADD]={};this.queue[this.const.TYPE_UPDATE]={};this.queue[this.const.TYPE_DELETE]={};this._stop();return true};BX.im.list.markup.prototype.worker=function(){if(this.pause){return false}var t=new Date;var e=[];for(var i in this.queue[this.const.TYPE_ADD]){if(!this.queue[this.const.TYPE_ADD].hasOwnProperty(i)){continue}e.push(this.queue[this.const.TYPE_ADD][i]);delete this.queue[this.const.TYPE_ADD][i]}if(e.length>0){}var s=[];for(var i in this.queue[this.const.TYPE_UPDATE]){if(!this.queue[this.const.TYPE_UPDATE].hasOwnProperty(i)){continue}s.push(this.queue[this.const.TYPE_UPDATE][i]);delete this.queue[this.const.TYPE_UPDATE][i]}if(s.length>0){}var n=[];for(var i in this.queue[this.const.TYPE_DELETE]){if(!this.queue[this.const.TYPE_DELETE].hasOwnProperty(i)){continue}n.push(this.queue[this.const.TYPE_DELETE][i]);delete this.queue[this.const.TYPE_DELETE][i]}if(n.length>0){}if(e.length+s.length+n.length==0){this._stop()}else{console.info("BX.im.list.markup.worker: added - "+e.length+" / updated - "+s.length+"  / deleted - "+n.length+" ("+(new Date-t)+"ms)",{add:e,update:s,delete:n})}return true};BX.im.list.markup.prototype.destroy=function(){clearInterval(this.updateIntervalId);this.updateIntervalId=null;return true};BX.im.list.markup.prototype._start=function(){if(!this.updateIntervalId){clearInterval(this.updateIntervalId);this.updateIntervalId=setInterval(this.worker.bind(this),0)}};BX.im.list.markup.prototype._stop=function(){return this.destroy()}})();

Zerion Mini Shell 1.0