Your IP : 13.59.19.39


Current Path : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/pullmanager/dist/
Upload File :
Current File : /var/www/www-root/data/www/www.monolith-realty.ru/bitrix/js/ui/pullmanager/dist/pullmanager.min.js

this.BX=this.BX||{};(function(e,t,i){"use strict";function a(e,t){s(e,t);t.add(e)}function l(e,t,i){s(e,t);t.set(e,i)}function s(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}function r(e,t,i){if(!t.has(e)){throw new TypeError("attempted to get private field on non-instance")}return i}var n=5e3;var u=30;var c=new WeakMap;var v=new WeakMap;var o=new WeakMap;var b=new WeakMap;var d=new WeakMap;var h=new WeakMap;var f=new WeakMap;var p=new WeakSet;var P=new WeakSet;var y=new WeakSet;var F=function(){function e(t){babelHelpers.classCallCheck(this,e);a(this,y);a(this,P);a(this,p);l(this,c,{writable:true,value:new Map});l(this,v,{writable:true,value:false});l(this,o,{writable:true,value:false});l(this,b,{writable:true,value:null});l(this,d,{writable:true,value:void 0});l(this,h,{writable:true,value:n});l(this,f,{writable:true,value:u});if(i.Type.isPlainObject(t.callbacks)){babelHelpers.classPrivateFieldSet(this,d,t.callbacks)}if(i.Type.isNumber(t.loadItemsDelay)){babelHelpers.classPrivateFieldSet(this,h,t.loadItemsDelay)}if(i.Type.isNumber(t.maxPendingItems)){babelHelpers.classPrivateFieldSet(this,f,t.maxPendingItems)}}babelHelpers.createClass(e,[{key:"loadItem",value:function e(){var t=this;var i=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;var a=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;if(babelHelpers.classPrivateFieldGet(this,b)&&!a){return}babelHelpers.classPrivateFieldSet(this,b,setTimeout((function(){return t.loadItemHandler(i)}),a?0:babelHelpers.classPrivateFieldGet(this,h)))}},{key:"loadItemHandler",value:function e(){var t=this;var a=arguments.length>0&&arguments[0]!==undefined?arguments[0]:false;if(r(this,p,H).call(this,a)||r(this,P,m).call(this)){babelHelpers.classPrivateFieldSet(this,b,null);return}var l=this.getAllAsArray();babelHelpers.classPrivateFieldGet(this,c).clear();if(!i.Type.isArrayFilled(l)){return}var s=null;var n=babelHelpers.classPrivateFieldGet(this,d),u=n.onBeforeExecute;if(i.Type.isFunction(u)){s=new Promise((function(e){return u(l).then(e)}))}else{s=Promise.resolve()}s.then((function(){return t.process(l)}))}},{key:"process",value:function e(t){babelHelpers.classPrivateFieldSet(this,v,true);var a=babelHelpers.classPrivateFieldGet(this,d),l=a.onExecute;if(i.Type.isFunction(l)){l(t).then(this.loadNextOnSuccess.bind(this),this.doNothingOnError.bind(this))["catch"]((function(){return console.error("error")}))}else{this.loadNextOnSuccess()}}},{key:"loadNextOnSuccess",value:function e(){babelHelpers.classPrivateFieldSet(this,b,null);if(!this.isEmpty()){this.loadItem(true)}babelHelpers.classPrivateFieldSet(this,v,false)}},{key:"doNothingOnError",value:function e(){babelHelpers.classPrivateFieldSet(this,b,null)}},{key:"push",value:function e(t,i){if(this.has(t)){this["delete"](t)}babelHelpers.classPrivateFieldGet(this,c).set(t,i);return this}},{key:"getAllAsArray",value:function e(){return Array.from(babelHelpers.classPrivateFieldGet(this,c),(function(e){var t=babelHelpers.slicedToArray(e,2),i=t[0],a=t[1];return{id:i,data:a}}))}},{key:"delete",value:function e(t){babelHelpers.classPrivateFieldGet(this,c)["delete"](t)}},{key:"has",value:function e(t){return babelHelpers.classPrivateFieldGet(this,c).has(t)}},{key:"clear",value:function e(){babelHelpers.classPrivateFieldGet(this,c).clear()}},{key:"isOverflow",value:function e(){return babelHelpers.classPrivateFieldGet(this,c).size>babelHelpers.classPrivateFieldGet(this,f)}},{key:"isEmpty",value:function e(){return babelHelpers.classPrivateFieldGet(this,c).size===0}},{key:"freeze",value:function e(){babelHelpers.classPrivateFieldSet(this,o,true)}},{key:"unfreeze",value:function e(){babelHelpers.classPrivateFieldSet(this,o,false)}},{key:"getLoadItemsDelay",value:function e(){return babelHelpers.classPrivateFieldGet(this,h)}}]);return e}();function H(e){return babelHelpers.classPrivateFieldGet(this,v)&&!e}function m(){return document.hidden||this.isOverflow()||r(this,y,k).call(this)}function k(){return babelHelpers.classPrivateFieldGet(this,o)}function w(e,t,i){E(e,t);t.set(e,i)}function E(e,t){if(t.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}var G=new WeakMap;var g=new WeakMap;var I=new WeakMap;var S=new WeakMap;var T=function(){babelHelpers.createClass(e,null,[{key:"registerRandomEventId",value:function e(){var t=arguments.length>0&&arguments[0]!==undefined?arguments[0]:null;var a=i.Text.getRandom(12);if(i.Type.isStringFilled(t)){a="".concat(t,"-").concat(a)}this.registerEventId(a);return a}},{key:"registerEventId",value:function e(t){this.eventIds.add(t)}}]);function e(t){var a=this;babelHelpers.classCallCheck(this,e);w(this,G,{writable:true,value:void 0});w(this,g,{writable:true,value:void 0});w(this,I,{writable:true,value:void 0});w(this,S,{writable:true,value:void 0});babelHelpers.classPrivateFieldSet(this,G,t);var l=t.config,s=t.callbacks;babelHelpers.classPrivateFieldSet(this,g,new F({loadItemsDelay:l===null||l===void 0?void 0:l.loadItemsDelay,maxPendingItems:l===null||l===void 0?void 0:l.maxPendingItems,callbacks:{onBeforeExecute:s.onBeforeQueueExecute,onExecute:s.onQueueExecute}}));babelHelpers.classPrivateFieldSet(this,S,0);this.initEventEmitter();var r=t.moduleId,n=t.userId;if(i.Type.isStringFilled(r)&&n>0){i.Event.ready((function(){return a.init()}));this.bindEvents()}}babelHelpers.createClass(e,[{key:"initEventEmitter",value:function e(){this.eventEmitter=new t.EventEmitter;this.eventEmitter.setEventNamespace("BX.UI.PullManager")}},{key:"init",value:function e(){if(!BX.PULL){console.error("BX.PULL is not initialized");return}this.subscribe()}},{key:"subscribe",value:function e(){var t=this;var i=babelHelpers.classPrivateFieldGet(this,G),a=i.moduleId,l=i.pullTag;BX.PULL.subscribe({moduleId:a,callback:function e(i){return t.onPullSubscribeCallback(i)}});BX.PULL.extendWatch(l)}},{key:"bindEvents",value:function e(){var a=this;if(i.Type.isPlainObject(babelHelpers.classPrivateFieldGet(this,G).events)){var l=function e(){var t=babelHelpers.slicedToArray(r[s],2),l=t[0],n=t[1];if(i.Type.isFunction(n)){a.eventEmitter.subscribe(l,(function(e){return n(e)}))}};for(var s=0,r=Object.entries(babelHelpers.classPrivateFieldGet(this,G).events);s<r.length;s++){l()}}i.Event.bind(document,"visibilitychange",(function(){return a.onDocumentVisibilityChange()}));t.EventEmitter.subscribe("SidePanel.Slider:onOpen",(function(e){var t,i;babelHelpers.classPrivateFieldSet(a,S,(t=babelHelpers.classPrivateFieldGet(a,S),i=t++,t)),i;babelHelpers.classPrivateFieldGet(a,g).freeze()}));t.EventEmitter.subscribe("SidePanel.Slider:onClose",(function(e){var t,i;babelHelpers.classPrivateFieldSet(a,S,(t=babelHelpers.classPrivateFieldGet(a,S),i=t--,t)),i;if(babelHelpers.classPrivateFieldGet(a,S)<=0){babelHelpers.classPrivateFieldSet(a,S,0);babelHelpers.classPrivateFieldGet(a,g).unfreeze();a.onTabActivated()}}))}},{key:"onDocumentVisibilityChange",value:function e(){if(!document.hidden){this.onTabActivated()}}},{key:"onPullSubscribeCallback",value:function a(l){var s=this;var r=babelHelpers.classPrivateFieldGet(this,G),n=r.pullTag;if(l.command!==n){return}var u=new t.BaseEvent({data:{pullData:l,queueItems:babelHelpers.classPrivateFieldGet(this,g).getAllAsArray(),options:babelHelpers.classPrivateFieldGet(this,G),promises:[]}});this.eventEmitter.emit("onBeforePull",u);if(u.isDefaultPrevented()){return}var c=l.params;if(!i.Type.isStringFilled(c.eventName)){return}if(e.eventIds.has(c.eventId)){return}if(babelHelpers.classPrivateFieldGet(this,g).isOverflow()){return}this.eventEmitter.emit("onPull",u);if(u.isDefaultPrevented()){return}Promise.all(u.data.promises).then((function(e){if(!i.Type.isArrayFilled(e)){return}e.forEach((function(e){var t=e.data;babelHelpers.classPrivateFieldGet(s,g).push(t.id,t)}));babelHelpers.classPrivateFieldGet(s,g).loadItem(false,c.ignoreDelay||false)}))}},{key:"showOutdatedDataDialog",value:function e(){var t,a=this;var e=(t=babelHelpers.classPrivateFieldGet(this,G).config)===null||t===void 0?void 0:t.showOutdatedDataDialog;var l=babelHelpers.classPrivateFieldGet(this,G).callbacks.onReload;if(i.Type.isBoolean(e)&&e===false||!i.Type.isFunction(l)){return}if(babelHelpers.classPrivateFieldGet(this,I)){babelHelpers.classPrivateFieldGet(this,I).show();return}babelHelpers.classPrivateFieldSet(this,I,BX.UI.Notification.Center.notify({content:i.Loc.getMessage("UI_PULLMANAGER_NOTIFY_OUTDATED_DATA"),closeButton:false,autoHide:false,actions:[{title:i.Loc.getMessage("UI_PULLMANAGER_RELOAD"),events:{click:function e(t,i,s){i.close();l();babelHelpers.classPrivateFieldGet(a,g).clear()}}}]}))}},{key:"onTabActivated",value:function e(){if(babelHelpers.classPrivateFieldGet(this,g).isOverflow()){this.showOutdatedDataDialog();return}if(!babelHelpers.classPrivateFieldGet(this,g).isEmpty()){babelHelpers.classPrivateFieldGet(this,g).loadItem()}}},{key:"hasInQueue",value:function e(t){return babelHelpers.classPrivateFieldGet(this,g).has(t)}},{key:"deleteFromQueue",value:function e(t){babelHelpers.classPrivateFieldGet(this,g)["delete"](t)}},{key:"getLoadItemsDelay",value:function e(){return babelHelpers.classPrivateFieldGet(this,g).getLoadItemsDelay()}}]);return e}();babelHelpers.defineProperty(T,"eventIds",new Set);e.PullManager=T})(this.BX.UI=this.BX.UI||{},BX.Event,BX);
//# sourceMappingURL=pullmanager.map.js