Your IP : 13.59.173.134
(function(window){function SectionController(t,e,i){if(!e.sections)e.sections=[];this.calendar=t;this.sections=[];this.sectionIndex={};this.hiddenSections=i.hiddenSections||[];this.prepareData({sections:e.sections});if(this.calendar.showTasks){var s=new TaskSection(this.calendar,i.sectionCustomization.tasks);this.sections.push(s);this.sectionIndex[s.id]=this.sections.length-1}this.sortSections()}SectionController.prototype={prepareData:function(t){var e,i;for(e=0;e<t.sections.length;e++){i=new Section(this.calendar,t.sections[e]);this.sections.push(i);this.sectionIndex[i.id]=this.sections.length-1}},sortSections:function(){var t;this.sectionIndex={};this.sections=this.sections.sort(function(t,e){if(t.isPseudo()){return 1}else if(e.isPseudo()){return-1}return t.name.localeCompare(e.name)});for(t=0;t<this.sections.length;t++){this.sectionIndex[this.sections[t].id]=t}},getCurrentSection:function(){var t=false,e,i=this.calendar.util.getUserOption("lastUsedSection");if(i){t=this.getSection(i);if(!t||!t.name||!t.canDo("add")||!t.belongsToView()||t.isPseudo()||!t.isActive()){t=false}}if(!t){for(e=0;e<this.sections.length;e++){if(this.sections[e].canDo("add")&&this.sections[e].belongsToView()&&!this.sections[e].isPseudo()&&this.sections[e].isActive()){t=this.sections[e];break}}}if(!t&&this.calendar.isExternalMode()&&this.sections.length>0){t=this.sections[0]}return t},getSectionList:function(){var t,e=[];for(t=0;t<this.sections.length;t++){if(this.sections[t].canDo("view_event")&&this.sections[t].isActive()){e.push(this.sections[t])}}return e},getSuperposedSectionList:function(){var t,e=[];for(t=0;t<this.sections.length;t++){if(this.sections[t].canDo("view_event")&&this.sections[t].isSuperposed()&&this.sections[t].isActive()){e.push(this.sections[t])}}return e},getSectionListForEdit:function(){var t,e=[];for(t=0;t<this.sections.length;t++){if(this.sections[t].canDo("add")&&(!this.sections[t].isSuperposed()||this.sections[t].belongsToView())&&!this.sections[t].isPseudo()&&this.sections[t].isActive()){e.push(this.sections[t])}}return e},getSection:function(t){return this.sections[this.sectionIndex[t]]||{}},getDefaultSectionName:function(){return BX.message("EC_DEFAULT_SECTION_NAME")},getDefaultSectionColor:function(){var t=this.getSectionListForEdit(),e={},i,s,n=this.calendar.util.getDefaultColors();for(i=0;i<t.length;i++){e[t[i].color]=true}for(i=0;i<n.length;i++){s=n[i];if(!e[s]){return s}}return n[this.calendar.util.randomInt(0,n.length)]},getDefaultSectionAccess:function(){return this.calendar.util.config.new_section_access||{}},saveSection:function(t,e,i,s){if(s.section.id){BX.onCustomEvent(this.calendar,"BXCalendar:onSectionChange",[s.section.id,{name:t,color:e}])}else{BX.onCustomEvent(this.calendar,"BXCalendar:onSectionAddBefore",[{name:t,color:e}])}var n=this.calendar.util.getActionUrl();n+=n.indexOf("?")==-1?"?":"&";n+="&markAction="+(s.section.id?"editSection":"newSection");n+="&markType="+this.calendar.util.type;this.calendar.request({url:n,type:"post",data:{action:"section_edit",id:s.section.id||0,name:t,color:e,access:i},handler:BX.delegate(function(i){if(s.section.id){this.sections[this.sectionIndex[s.section.id]].updateData(i.calendar)}else{this.prepareData({sections:[i.calendar]})}this.sortSections();BX.onCustomEvent(this.calendar,"BXCalendar:onSectionAdd",[{name:t,color:e}])},this)})},sectionIsShown:function(t){return!BX.util.in_array(t,this.hiddenSections)},getHiddenSections:function(){return this.hiddenSections||[]},setHiddenSections:function(t){this.hiddenSections=t},getSectionsInfo:function(){var t,e=[],i=[],s=[],n=[];for(t=0;t<this.sections.length;t++){if(this.sections[t].canDo("view_time")){if(this.sections[t].isShown()){if(this.sections[t].isSuperposed()){i.push(this.sections[t].id)}else{s.push(this.sections[t].id)}e.push(this.sections[t].id)}else{n.push(this.sections[t].id)}}}return{superposed:i,active:s,hidden:n,allActive:e}}};function Section(t,e){this.calendar=t;this.updateData(e)}Section.prototype={updateData:function(t){this.data=t||{};this.color=t.COLOR;this.textColor=t.TEXT_COLOR||"";this.name=t.NAME||"";this.type=t.CAL_TYPE||"";Object.defineProperties(this,{id:{value:t.ID,writable:false,enumerable:true},color:{value:t.COLOR,writable:true,enumerable:true},textColor:{value:t.TEXT_COLOR,writable:true,enumerable:true}})},isShown:function(){return this.calendar.sectionController.sectionIsShown(this.id)},show:function(){if(!this.isShown()){var t=this.calendar.sectionController.getHiddenSections();t=BX.util.deleteFromArray(t,BX.util.array_search(this.id,t));this.calendar.sectionController.setHiddenSections(t);BX.userOptions.save("calendar","hidden_sections","hidden_sections",t)}},hide:function(){if(this.isShown()){var t=this.calendar.sectionController.getHiddenSections();t.push(this.id);this.calendar.sectionController.setHiddenSections(t);BX.userOptions.save("calendar","hidden_sections","hidden_sections",t)}},remove:function(){if(confirm(BX.message("EC_SEC_DELETE_CONFIRM"))){BX.onCustomEvent(this.calendar,"BXCalendar:onSectionDelete",[this.id]);this.calendar.request({type:"post",data:{action:"section_delete",id:this.id},handler:BX.delegate(function(t){this.calendar.reload()},this)})}},hideGoogle:function(){if(confirm(BX.message("EC_CAL_GOOGLE_HIDE_CONFIRM"))){this.hide();BX.onCustomEvent(this.calendar,"BXCalendar:onSectionDelete",[this.id]);this.calendar.request({type:"post",data:{action:"section_caldav_hide",id:this.id},handler:BX.delegate(function(t){this.calendar.reload()},this)})}},getLink:function(){return this.data&&this.data.LINK?this.data.LINK:""},canBeConnectedToOutlook:function(){return!this.isPseudo()&&this.data.OUTLOOK_JS&&!(this.data.CAL_DAV_CAL&&this.data.CAL_DAV_CON)&&!BX.browser.IsMac()},connectToOutlook:function(){if(!window.jsOutlookUtils){BX.loadScript("/bitrix/js/calendar/outlook.js",BX.delegate(function(){try{eval(this.data.OUTLOOK_JS)}catch(t){}},this))}else{try{eval(this.data.OUTLOOK_JS)}catch(t){}}},canDo:function(t){if(BX.util.in_array(t,["access","add","edit"])&&this.isVirtual()){return false}if(BX.util.in_array(t,["access","add","edit","edit_section"])&&this.isSuperposed()&&!this.belongsToView()){return false}if(t=="view_event")t="view_time";return this.data.PERM&&this.data.PERM[t]},isSuperposed:function(){return!this.isPseudo()&&!!this.data.SUPERPOSED},isPseudo:function(){return false},isVirtual:function(){return this.data.CAL_DAV_CAL&&this.data.CAL_DAV_CAL.indexOf("@virtual/events/")!==-1||this.data.GAPI_CALENDAR_ID&&this.data.GAPI_CALENDAR_ID.indexOf("@group.v.calendar.google.com")!==-1},isGoogle:function(){return this.data.GAPI_CALENDAR_ID},isCalDav:function(){return!this.isPseudo()&&this.data.CAL_DAV_CAL&&this.data.CAL_DAV_CON},isCompanyCalendar:function(){return!this.isPseudo()&&this.type!="user"&&this.type!="group"&&!parseInt(this.data.OWNER_ID)},belongsToView:function(){return this.type==this.calendar.util.type&&this.data.OWNER_ID==this.calendar.util.ownerId},belongToOwner:function(){return this.data.CAL_TYPE=="user"&&this.data.OWNER_ID==this.calendar.util.userId&&this.data.ACTIVE!=="N"},isActive:function(){return this.data.ACTIVE!=="N"}};function TaskSection(t,e){this.calendar=t;var i="#ff5b55",s;if(!e)e={};if(this.calendar.util.userIsOwner()){s=BX.message("EC_SEC_MY_TASK_DEFAULT")}else if(this.calendar.util.isUserCalendar()){s=BX.message("EC_SEC_USER_TASK_DEFAULT")}else if(this.calendar.util.isGroupCalendar()){s=BX.message("EC_SEC_GROUP_TASK_DEFAULT")}var n={ID:"tasks",NAME:e.name||s,COLOR:e.color||i,PERM:{edit_section:true,view_full:true,view_time:true,view_title:true}};Section.apply(this,[t,n])}TaskSection.prototype=Object.create(Section.prototype);TaskSection.prototype.constructor=TaskSection;TaskSection.prototype.isPseudo=function(){return true};if(window.BXEventCalendar){window.BXEventCalendar.SectionController=SectionController;window.BXEventCalendar.Section=Section}else{BX.addCustomEvent(window,"onBXEventCalendarInit",function(){window.BXEventCalendar.SectionController=SectionController;window.BXEventCalendar.Section=Section})}})(window);