Your IP : 3.137.222.204


Current Path : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/calendar/new/
Upload File :
Current File : /home/bitrix/ext_www/klimatlend.ua/bitrix/js/calendar/new/calendar-view-custom.min.js

(function(e){var t=e.BXEventCalendarView;function a(e,a){t.apply(this,arguments);this.appView=a;this.name="custom_"+a.ID;this.type="custom";this.placementCode=this.calendar.util.config.placementParams.gridPlacementCode;this.title=a.TITLE||this.appView.APP_NAME||BX.message("EC_REQUEST_APP_NONAME_TAB");this.contClassName="calendar-custom-view";this.preBuild()}a.prototype=Object.create(t.prototype);a.prototype.constructor=a;a.prototype.preBuild=function(){this.viewCont=BX.create("DIV",{props:{className:this.contClassName},style:{display:"none"}});var e=BX.rest.AppLayout.initializePlacement(this.placementCode);if(e){e.prototype.getEvents=BX.proxy(this.appGetEntries,this);e.prototype.viewEvent=BX.proxy(this.appViewEvent,this);e.prototype.addEvent=BX.proxy(this.appAddEvent,this);e.prototype.editEvent=BX.proxy(this.appEditEvent,this);e.prototype.deleteEvent=BX.proxy(this.appDeleteEvent,this);e.prototype.events.push("Calendar.customView:refreshEntries");e.prototype.events.push("Calendar.customView:decreaseViewRangeDate");e.prototype.events.push("Calendar.customView:increaseViewRangeDate");e.prototype.events.push("Calendar.customView:adjustToDate")}};a.prototype.build=function(){this.titleCont=this.viewCont.appendChild(BX.create("DIV",{props:{className:"calendar-custom-view-title"}}));this.appWrap=this.viewCont.appendChild(BX.create("DIV",{props:{className:"calendar-app-wrap"},style:{height:this.calendar.util.getViewHeight()+"px"}}))};a.prototype.adjustViewRangeToDate=function(e){if(this.calendar.currentViewName!==this.name||!this.isBuilt){this.show();if(this.name)this.appLoader=this.appWrap.appendChild(BX.adjust(this.calendar.util.getLoader(),{style:{height:"100px"}}));var t=this.calendar.getDisplayedViewRange();this.appRequestIsRunning=true;BX.ajax({url:this.calendar.util.config.placementParams.serviceUrl,method:"POST",dataType:"html",data:{LOADER_ID:Math.round(Math.random()*1e6),PARAMS:{params:{ID:this.appView.APP_ID,PLACEMENT:this.calendar.util.config.placementParams.gridPlacementCode,PLACEMENT_ID:this.appView.ID,PLACEMENT_OPTIONS:{viewRangeFrom:BX.date.format("Y-m-d",t?t.start:this.calendar.getViewRangeDate()),viewRangeTo:BX.date.format("Y-m-d",t?t.end:this.calendar.getViewRangeDate())}}}},onsuccess:BX.delegate(this.appRequestOnSuccess,this),onfailure:BX.delegate(this.appRequestOnFailure,this)})}BX.onCustomEvent("Calendar.customView:adjustToDate",[BX.date.format("Y-m-d",e)])};a.prototype.appRequestOnSuccess=function(e){BX.remove(this.appLoader);this.appRequestIsRunning=false;BX.html(this.appWrap,e).then(BX.defer(function(){var e=BX.rest.AppLayout.get(this.calendar.util.config.placementParams.gridPlacementCode);if(e){e.allowInterface(["resizeWindow"])}},this))};a.prototype.appRequestOnFailure=function(){BX.remove(this.appLoader);this.appRequestIsRunning=false;this.appWrap.innerHTML='<div class="ui-alert ui-alert-warning"><span class="ui-alert-message">'+BX.message("EC_REQUEST_APP_FAILURE").replace("#APPNAME#",this.appView.APP_NAME)+"</span></div>"};a.prototype.appGetEntries=function(e,t){var a=new Date(e.dateFrom)||new Date,i=new Date(e.dateTo)||new Date(a.getFullYear(),a.getMonth()+1,a.getDate());a.setHours(0,0,0,0);i.setHours(0,0,0,0);this.calendar.setDisplayedViewRange({start:a,end:i});this.entries=this.entryController.getList({startDate:a,finishDate:i,viewRange:this.calendar.getDisplayedViewRange(),finishCallback:BX.delegate(function(e){e.entries.forEach(function(e){e.UID=this.calendar.entryController.getUniqueId(e)},this);this.entries=this.entryController.getList({startDate:a,finishDate:i,viewRange:this.calendar.getDisplayedViewRange()});if(BX.type.isArray(this.entries)){var n,s;for(n=0;n<this.entries.length;n++){s=this.entries[n];this.entriesIndex[s.uid]=n}}t(e.entries)},this)});if(BX.type.isArray(this.entries)){var n=[];this.entries.forEach(function(e){e.data.UID=this.calendar.entryController.getUniqueId(e.data);n.push(e.data)},this);t(n);var s,r;for(s=0;s<this.entries.length;s++){r=this.entries[s];this.entriesIndex[r.uid]=s}}};a.prototype.getEntryByParams=function(e){var t=e.uid;if(!t&&e.id){if(e.dateFrom&&this.getEntryById(e.id+"|"+e.dateFrom)){t=e.id+"|"+e.dateFrom}else if(this.getEntryById(e.id)){t=e.id}}return this.getEntryById(t)||false};a.prototype.appViewEvent=function(e,t){var a=this.getEntryByParams(e);if(a){this.showViewSlider({entry:a})}t({result:!!a})};a.prototype.appAddEvent=function(e,t){this.showEditSlider();t({result:true})};a.prototype.appEditEvent=function(e,t){var a=this.getEntryByParams(e);if(a){this.calendar.entryController.editEntry({entry:a})}t({result:!!a})};a.prototype.appDeleteEvent=function(e,t){var a=this.getEntryByParams(e);if(a){this.calendar.entryController.deleteEntry(a)}t()};a.prototype.displayEntries=function(){BX.onCustomEvent("Calendar.customView:refreshEntries",[{}])};a.prototype.decreaseViewRangeDate=function(){BX.onCustomEvent("Calendar.customView:decreaseViewRangeDate",[{}])};a.prototype.increaseViewRangeDate=function(){BX.onCustomEvent("Calendar.customView:increaseViewRangeDate",[{}])};if(e.BXEventCalendar){e.BXEventCalendar.CalendarCustomView=a}else{BX.addCustomEvent(e,"onBXEventCalendarInit",function(){e.BXEventCalendar.CalendarCustomView=a})}})(window);