Your IP : 3.149.244.228


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-section-slider.min.js

(function(e){function t(e){this.calendar=e.calendar;this.button=e.button;this.zIndex=e.zIndex||3100;this.SLIDER_WIDTH=400;this.SLIDER_DURATION=80;this.sliderId="calendar:section-slider";this.denyClose=false;BX.bind(this.button,"click",BX.delegate(this.show,this))}t.prototype={show:function(){BX.SidePanel.Instance.open(this.sliderId,{contentCallback:BX.delegate(this.create,this),width:this.SLIDER_WIDTH,animationDuration:this.SLIDER_DURATION,events:{onCloseByEsc:BX.proxy(this.escHide,this),onClose:BX.proxy(this.hide,this),onCloseComplete:BX.proxy(this.destroy,this)}});BX.addCustomEvent("BXCalendar:onSectionDelete",BX.proxy(this.deleteSectionHandler,this));BX.addCustomEvent("BXCalendar:onSectionChange",BX.proxy(this.changeSectionHandler,this));BX.addCustomEvent("BXCalendar:onSectionAdd",BX.proxy(this.addSectionHandler,this));this.calendar.disableKeyHandler()},escHide:function(e){if(e&&e.getSliderPage&&e.getSliderPage().getUrl()===this.sliderId&&this.denyClose){e.denyAction()}},hide:function(e){if(e&&e.getSliderPage&&e.getSliderPage().getUrl()===this.sliderId){this.closeForms();BX.removeCustomEvent("SidePanel.Slider:onClose",BX.proxy(this.hide,this));BX.removeCustomEvent("SidePanel.Slider:onCloseByEsc",BX.proxy(this.escHide,this));BX.removeCustomEvent("BXCalendar:onSectionDelete",BX.proxy(this.deleteSectionHandler,this));BX.removeCustomEvent("BXCalendar:onSectionChange",BX.proxy(this.changeSectionHandler,this));BX.removeCustomEvent("BXCalendar:onSectionAdd",BX.proxy(this.addSectionHandler,this))}},close:function(){BX.SidePanel.Instance.close()},destroy:function(e){if(e&&e.getSliderPage&&e.getSliderPage().getUrl()===this.sliderId){BX.removeCustomEvent("SidePanel.Slider:onCloseComplete",BX.proxy(this.destroy,this));BX.SidePanel.Instance.destroy(this.sliderId);delete this.sectionListWrap;this.calendar.enableKeyHandler();if(this.sectionActionMenu)this.sectionActionMenu.close()}},create:function(){this.outerWrap=BX.create("DIV",{props:{className:"calendar-list-slider-wrap"}});this.titleWrap=this.outerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-title-container"},html:'<div class="calendar-list-slider-title">'+BX.message("EC_SECTION_BUTTON")+"</div>"}));if(!this.calendar.util.readOnlyMode()){this.createAddButton();this.editSectionFormWrap=this.outerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-widget calendar-list-slider-form-wrap"},html:'<div class="calendar-list-slider-card-widget-title"><span class="calendar-list-slider-card-widget-title-text">'+BX.message("EC_SEC_SLIDER_NEW_SECTION")+"</span></div>"}));this.trackingCompanyFormWrap=this.outerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-widget calendar-list-slider-form-wrap"},html:'<div class="calendar-list-slider-card-widget-title"><span class="calendar-list-slider-card-widget-title-text">'+BX.message("EC_SEC_SLIDER_POPUP_MENU_ADD_COMP")+"</span></div>"}));this.trackingUsersFormWrap=this.outerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-widget calendar-list-slider-form-wrap"},html:'<div class="calendar-list-slider-card-widget-title"><span class="calendar-list-slider-card-widget-title-text">'+BX.message("EC_SEC_SLIDER_POPUP_MENU_ADD_USER")+"</span></div>"}));this.trackingGroupsFormWrap=this.outerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-widget calendar-list-slider-form-wrap"},html:'<div class="calendar-list-slider-card-widget-title"><span class="calendar-list-slider-card-widget-title-text">'+BX.message("EC_SEC_SLIDER_POPUP_MENU_ADD_GROUP")+"</span></div>"}))}this.createSectionList();return this.outerWrap},createSectionList:function(){var e,t;this.sliderSections=this.calendar.sectionController.getSectionList();if(this.calendar.util.type=="user"){t=BX.message("EC_SEC_SLIDER_MY_CALENDARS_LIST")}else if(this.calendar.util.type=="group"){t=BX.message("EC_SEC_SLIDER_GROUP_CALENDARS_LIST")}else{t=BX.message("EC_SEC_SLIDER_TYPE_CALENDARS_LIST")}if(this.sectionListWrap){BX.cleanNode(this.sectionListWrap);BX.adjust(this.sectionListWrap,{props:{className:"calendar-list-slider-card-widget"},html:'<div class="calendar-list-slider-card-widget-title"><span class="calendar-list-slider-card-widget-title-text">'+t+"</span></div>"})}else{this.sectionListWrap=this.outerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-widget"},html:'<div class="calendar-list-slider-card-widget-title"><span class="calendar-list-slider-card-widget-title-text">'+t+"</span></div>"}))}this.createSectionBlock({wrap:this.sectionListWrap,sectionList:this.sliderSections.filter(function(e){return e.belongsToView()||e.isPseudo()})});e=this.sliderSections.filter(function(e){return e.isCompanyCalendar()&&!e.belongsToView()});if(e.length>0){this.sectionListWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-section-title"},html:'<span class="calendar-list-slider-card-section-title-text">'+BX.message("EC_SEC_SLIDER_TITLE_COMP_CAL")+"</span>"}));this.createSectionBlock({wrap:this.sectionListWrap,sectionList:this.sliderSections.filter(function(e){return e.isCompanyCalendar()})})}this.calendar.util.getSuperposedTrackedUsers().forEach(function(e){var t=this.sliderSections.filter(function(t){return!t.belongsToView()&&t.isSuperposed()&&t.type=="user"&&t.data.OWNER_ID==e.ID});if(t.length>0){this.sectionListWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-section-title"},html:'<span class="calendar-list-slider-card-section-title-text">'+BX.util.htmlspecialchars(e.FORMATTED_NAME)+"</span>"}));this.createSectionBlock({wrap:this.sectionListWrap,sectionList:t})}},this);e=this.sliderSections.filter(function(e){return!e.belongsToView()&&e.type=="group"&&e.isSuperposed()});if(e.length>0){this.sectionListWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-section-title"},html:'<span class="calendar-list-slider-card-section-title-text">'+BX.message("EC_SEC_SLIDER_TITLE_GROUP_CAL")+"</span>"}));this.createSectionBlock({wrap:this.sectionListWrap,sectionList:e})}},createAddButton:function(){this.addButtonOuter=this.titleWrap.appendChild(BX.create("SPAN",{props:{className:"ui-btn-double ui-btn-light-border"},style:{marginRight:0}}));this.addButton=this.addButtonOuter.appendChild(BX.create("SPAN",{props:{className:"ui-btn-main"},text:BX.message("EC_ADD")}));this.addButtonMore=this.addButtonOuter.appendChild(BX.create("SPAN",{props:{className:"ui-btn-extra"}}));this.addButtonMorePopupId="add_btn_popup_"+this.calendar.id;BX.bind(this.addButtonMore,"click",BX.proxy(this.showAddBtnPopup,this));BX.bind(this.addButton,"click",BX.proxy(this.showEditSectionForm,this))},showAddBtnPopup:function(e){if(this.addBtnMenu&&this.addBtnMenu.popupWindow&&this.addBtnMenu.popupWindow.isShown()){return this.addBtnMenu.close()}var t=this,s="main-buttons-submenu-separator main-buttons-submenu-item main-buttons-hidden-label",i=[{text:"<span>"+BX.message("EC_SEC_SLIDER_POPUP_NEW_TITLE")+"</span>",className:s},{text:BX.message("EC_SEC_SLIDER_POPUP_NEW_MENU"),onclick:BX.proxy(function(){this.addBtnMenu.close();this.showEditSectionForm()},this)},{text:"<span>"+BX.message("EC_SEC_SLIDER_POPUP_EXIST_TITLE")+"</span>",className:s},{text:BX.message("EC_SEC_SLIDER_POPUP_MENU_ADD_COMP"),onclick:BX.proxy(function(){this.addBtnMenu.close();this.showTrackingTypesForm()},this)},{text:BX.message("EC_SEC_SLIDER_POPUP_MENU_ADD_USER"),onclick:BX.proxy(function(){this.addBtnMenu.close();this.showTrackingUsersForm()},this)},{text:BX.message("EC_SEC_SLIDER_POPUP_MENU_ADD_GROUP"),onclick:BX.proxy(function(){this.addBtnMenu.close();this.showTrackingGroupsForm()},this)}];this.addBtnMenu=BX.PopupMenu.create(this.addButtonMorePopupId,this.addButtonMore,i,{closeByEsc:true,autoHide:true,zIndex:this.zIndex,offsetTop:0,offsetLeft:15,angle:true});this.addBtnMenu.show();this.denySliderClose();BX.addCustomEvent(this.addBtnMenu.popupWindow,"onPopupClose",function(){t.allowSliderClose();BX.PopupMenu.destroy(t.addButtonMorePopupId);t.addBtnMenu=null})},createSectionBlock:function(e){var t=false;if(e.sectionList&&e.sectionList.length){var s=e.wrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-widget-content"}})).appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-widget-content-block"}})).appendChild(BX.create("UL",{props:{className:"calendar-list-slider-container"}}));BX.bind(s,"click",BX.proxy(this.sectionClickHandler,this));var i,a,n,c,o;for(i=0;i<e.sectionList.length;i++){a=s.appendChild(BX.create("LI",{props:{className:"calendar-list-slider-item"},attrs:{"data-bx-calendar-section":e.sectionList[i].id.toString()}}));n=a.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-item-checkbox"+(e.sectionList[i].isShown()?" calendar-list-slider-item-checkbox-checked":"")},style:{backgroundColor:e.sectionList[i].color}}));c=a.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-item-name"},text:e.sectionList[i].name}));o=a.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-item-actions-container"},attrs:{"data-bx-calendar-section-menu":e.sectionList[i].id.toString()},html:'<span class="calendar-list-slider-item-context-menu"></span>'}));if(!e.sectionList[i].DOM){e.sectionList[i].DOM={}}e.sectionList[i].DOM.item=a;e.sectionList[i].DOM.checkbox=n;e.sectionList[i].DOM.title=c;e.sectionList[i].DOM.actionCont=o}}return t},sectionClickHandler:function(e){var t=this.calendar.util.findTargetNode(e.target||e.srcElement,this.outerWrap);if(t&&t.getAttribute){if(t.getAttribute("data-bx-calendar-section-menu")!==null){this.showSectionMenu(this.calendar.sectionController.getSection(t.getAttribute("data-bx-calendar-section-menu")))}else if(t.getAttribute("data-bx-calendar-section")!==null){this.switchSection(this.calendar.sectionController.getSection(t.getAttribute("data-bx-calendar-section")))}}},switchSection:function(e){if(BX.hasClass(e.DOM.checkbox,"calendar-list-slider-item-checkbox-checked")){BX.removeClass(e.DOM.checkbox,"calendar-list-slider-item-checkbox-checked");e.hide()}else{BX.addClass(e.DOM.checkbox,"calendar-list-slider-item-checkbox-checked");e.show()}this.calendar.refresh()},showSectionMenu:function(t){var s=this,i=[],a=this.calendar.id+"_section_"+t.id;BX.addClass(t.DOM.item,"active");if(t.getLink()&&!t.belongsToView()){i.push({text:BX.message("EC_SEC_OPEN_LINK"),href:t.getLink()})}if(!this.calendar.util.readOnlyMode()&&t.canDo("edit_section")&&!t.isPseudo()){i.push({text:BX.message("EC_SEC_EDIT"),onclick:function(){s.sectionActionMenu.close();s.showEditSectionForm({section:t})}})}if(t.isSuperposed()&&!t.belongsToView()){i.push({text:BX.message("EC_SEC_HIDE"),onclick:function(){s.hideSuperposedHandler(t);s.sectionActionMenu.close()}})}if(t.canBeConnectedToOutlook()){i.push({text:BX.message("EC_SEC_CONNECT_TO_OUTLOOK"),onclick:function(){s.sectionActionMenu.close();t.connectToOutlook();s.close()}})}if(!t.isPseudo()&&t.data.EXPORT.LINK){i.push({text:BX.message("EC_ACTION_EXPORT"),onclick:BX.delegate(function(){s.sectionActionMenu.close();if(!s.calendar.syncSlider){s.calendar.syncSlider=new e.BXEventCalendar.SyncSlider({calendar:s.calendar})}s.calendar.syncSlider.showICalExportDialog(t)},this)})}if(t.canDo("edit_section")&&t.belongsToView()&&!t.isPseudo()){i.push({text:BX.message("EC_SEC_DELETE"),onclick:function(){s.sectionActionMenu.close();t.remove()}})}if((t.isGoogle()||t.isCalDav())&&t.canDo("edit_section")){i.push({text:BX.message("EC_ACTION_REFRESH"),onclick:BX.delegate(function(){this.sectionActionMenu.close();this.calendar.reload({syncGoogle:true});this.close()},this)});if(this.calendar.syncSlider){i.push({text:BX.message("EC_ACTION_EXTERNAL_ADJUST"),onclick:function(){s.sectionActionMenu.close();s.calendar.syncSlider.showCalDavSyncDialog()}})}i.push({text:BX.message("EC_ACTION_HIDE"),onclick:BX.delegate(function(){this.sectionActionMenu.close();t.hideGoogle()},this)})}if(i&&i.length>0){this.sectionActionMenu=BX.PopupMenu.create(a,t.DOM.actionCont,i,{closeByEsc:true,autoHide:true,zIndex:this.zIndex,offsetTop:0,offsetLeft:9,angle:true});this.sectionActionMenu.show();this.denySliderClose();BX.addCustomEvent(this.sectionActionMenu.popupWindow,"onPopupClose",function(){if(t.DOM.item)BX.removeClass(t.DOM.item,"active");s.allowSliderClose();BX.PopupMenu.destroy(a);s.sectionActionMenu=null})}},denySliderClose:function(){this.denyClose=true},allowSliderClose:function(){this.denyClose=false},closeForms:function(){if(this.addBtnMenu)this.addBtnMenu.close();if(this.editSectionForm)this.editSectionForm.close();if(this.trackingUsersForm)this.trackingUsersForm.close();if(this.trackingGroupsForm)this.trackingGroupsForm.close();if(this.trackingTypesForm)this.trackingTypesForm.close()},showEditSectionForm:function(e){if(!e)e={};if(this.editSectionForm&&this.editSectionForm.isOpenedState)return this.closeForms();this.closeForms();this.editSectionFormTitle=this.editSectionFormWrap.querySelector(".calendar-list-slider-card-widget-title-text");this.editSectionForm=new s({calendar:this.calendar,wrap:this.editSectionFormWrap,zIndex:this.zIndex,closeCallback:BX.delegate(function(){this.allowSliderClose()},this)});var t=true;if(e.section&&(!e.section.belongsToView()||e.section.isPseudo())){this.editSectionFormTitle.innerHTML=BX.message("EC_SEC_SLIDER_EDIT_SECTION_PERSONAL");t=false}else if(e.section&&e.section.id){this.editSectionFormTitle.innerHTML=BX.message("EC_SEC_SLIDER_EDIT_SECTION")}else{this.editSectionFormTitle.innerHTML=BX.message("EC_SEC_SLIDER_NEW_SECTION")}this.editSectionForm.show({showAccess:t,section:e.section||{color:this.calendar.sectionController.getDefaultSectionColor(),access:this.calendar.sectionController.getDefaultSectionAccess()}});this.denySliderClose()},showTrackingTypesForm:function(){this.closeForms();if(!this.trackingTypesForm){this.trackingTypesForm=new a({calendar:this.calendar,wrap:this.trackingCompanyFormWrap,superposedSections:this.calendar.sectionController.getSuperposedSectionList(),closeCallback:BX.delegate(function(){this.allowSliderClose()},this)})}this.trackingTypesForm.show();this.denySliderClose()},showTrackingUsersForm:function(){this.closeForms();if(!this.trackingUsersForm){this.trackingUsersForm=new i({calendar:this.calendar,wrap:this.trackingUsersFormWrap,trackingUsers:this.calendar.util.getSuperposedTrackedUsers(),superposedSections:this.calendar.sectionController.getSuperposedSectionList(),closeCallback:BX.delegate(function(){this.allowSliderClose()},this)})}this.trackingUsersForm.show();this.denySliderClose()},showTrackingGroupsForm:function(){this.closeForms();if(!this.trackingGroupsForm){var e=this.calendar.sectionController.getSuperposedSectionList(),t=this.calendar.util.getSuperposedTrackedGroups();if(!t.length){e.forEach(function(e){if(e.type=="group"){var s=e.data.OWNER_ID;if(!BX.util.in_array(s,t)){t.push(s)}}},this)}this.trackingGroupsForm=new n({calendar:this.calendar,wrap:this.trackingGroupsFormWrap,trackingGroups:t,superposedSections:e})}this.trackingGroupsForm.show()},deleteSectionHandler:function(e){this.sliderSections.forEach(function(t,s){if(t.id==e&&t.DOM&&t.DOM.item){BX.addClass(t.DOM.item,"calendar-list-slider-item-disappearing");setTimeout(BX.delegate(function(){BX.cleanNode(t.DOM.item,true);this.sliderSections=BX.util.deleteFromArray(this.sliderSections,s)},this),300)}},this)},hideSuperposedHandler:function(e){var t=this.calendar.sectionController.getSuperposedSectionList(),s=[],i;for(i=0;i<t.length;i++){if(e.id!=parseInt(t[i].id))s.push(parseInt(t[i].id))}this.calendar.request({data:{action:"set_tracking_sections",sect:s},handler:BX.delegate(function(e){BX.reload()},this)})},changeSectionHandler:function(e,t){this.sliderSections.forEach(function(s){if(s.id==e&&s.DOM&&s.DOM.item){s.DOM.title.innerHTML=BX.util.htmlspecialchars(t.name);s.DOM.checkbox.style.backgroundColor=t.color}},this)},addSectionHandler:function(){this.createSectionList()}};function s(e){this.calendar=e.calendar;this.outerWrap=e.wrap;this.zIndex=e.zIndex;this.closeCallback=e.closeCallback;this.isCreated=false}s.prototype={show:function(e){this.create();this.showAccess=e.showAccess!==false;if(this.showAccess){this.accessLink.style.display="";this.accessWrap.style.display=""}else{this.accessLink.style.display="none";this.accessWrap.style.display="none"}BX.bind(document,"keydown",BX.proxy(this.keyHandler,this));BX.addClass(this.outerWrap,"show");this.section=e.section;if(e.section){if(e.section.color){this.setColor(e.section.color)}this.setAccess(e.section.access||e.section.data.ACCESS||{});if(e.section.name){this.sectionTitleInput.value=e.section.name}}BX.focus(this.sectionTitleInput);if(this.sectionTitleInput.value!=="")this.sectionTitleInput.select();this.isOpenedState=true},close:function(){this.isOpenedState=false;BX.unbind(document,"keydown",BX.proxy(this.keyHandler,this));BX.removeClass(this.outerWrap,"show");if(this.closeCallback)this.closeCallback()},isOpened:function(){return this.isOpenedState},create:function(){this.wrap=this.outerWrap.querySelector(".calendar-form-content");if(this.wrap)BX.cleanNode(this.wrap);else this.wrap=this.outerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-form-content"}}));this.formFieldsWrap=this.wrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-widget-content"}})).appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-widget-content-block"}}));this.sectionTitleInput=this.formFieldsWrap.appendChild(BX.create("DIV",{props:{className:"calendar-field-container calendar-field-container-string"}})).appendChild(BX.create("DIV",{props:{className:"calendar-field-block"}})).appendChild(BX.create("INPUT",{attrs:{type:"text",placeholder:BX.message("EC_SEC_SLIDER_SECTION_TITLE")},props:{className:"calendar-field calendar-field-string"}}));var e=this.formFieldsWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-new-calendar-options-container"}}));this.colorContWrap=e.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-new-calendar-option-color"},html:BX.message("EC_SEC_SLIDER_COLOR")}));this.colorIcon=this.colorContWrap.appendChild(BX.create("SPAN",{props:{className:"calendar-list-slider-new-calendar-option-color-selected"}}));this.colorChangeLink=this.colorContWrap.appendChild(BX.create("SPAN",{props:{className:"calendar-list-slider-new-calendar-option-color-change"},html:BX.message("EC_SEC_SLIDER_CHANGE")}));this.initSectionColorSelector();this.accessLink=e.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-new-calendar-option-more"},html:BX.message("EC_SEC_SLIDER_ACCESS")}));this.accessWrap=this.formFieldsWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-access-container"}}));this.initAccessController();this.buttonsWrap=this.formFieldsWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-btn-container"}}));this.saveBtn=this.buttonsWrap.appendChild(BX.create("DIV",{props:{className:"ui-btn ui-btn-success"},text:BX.message("EC_SEC_SLIDER_SAVE"),events:{click:BX.proxy(this.save,this)}}));this.cancelBtn=this.buttonsWrap.appendChild(BX.create("SPAN",{props:{className:"ui-btn ui-btn-link"},text:BX.message("EC_SEC_SLIDER_CANCEL"),events:{click:BX.proxy(this.checkClose,this)}}));this.isCreated=true},keyHandler:function(e){if(e.keyCode==this.calendar.util.KEY_CODES["escape"]){this.checkClose()}else if(e.keyCode==this.calendar.util.KEY_CODES["enter"]){this.save()}},checkClose:function(){this.close()},save:function(){this.calendar.sectionController.saveSection(this.sectionTitleInput.value,this.color,this.access,{section:this.section});this.close()},initSectionColorSelector:function(){BX.bind(this.colorIcon,"click",BX.delegate(this.showSimplePicker,this));BX.bind(this.colorChangeLink,"click",BX.delegate(this.showSimplePicker,this))},showSimplePicker:function(e){var t=BX.clone(this.calendar.util.getDefaultColors(),true),s=BX.create("DIV",{props:{className:"calendar-simple-color-wrap calendar-field-container-colorpicker-square"}}),i=s.appendChild(BX.create("DIV",{events:{click:BX.delegate(this.simplePickerClick,this)}})),a=s.appendChild(BX.create("DIV",{props:{className:"calendar-simple-color-more-link-wrap"}})),n=a.appendChild(BX.create("SPAN",{props:{className:"calendar-simple-color-more-link"},html:BX.message("EC_COLOR"),events:{click:BX.delegate(this.showFullPicker,this)}}));this.simplePickerColorWrap=i;this.colors=[];if(!BX.util.in_array(this.color,t))t.push(this.color);for(var c=0;c<t.length;c++){this.colors.push({color:t[c],node:i.appendChild(BX.create("SPAN",{props:{className:"calendar-field-colorpicker-color-item"},style:{backgroundColor:t[c]},attrs:{"data-bx-calendar-color":t[c]},html:'<span class="calendar-field-colorpicker-color"></span>'}))})}this.lastActiveNode=this.colors[BX.util.array_search(this.color,t)||0].node;BX.addClass(this.lastActiveNode,"active");this.simpleColorPopup=BX.PopupWindowManager.create(this.calendar.id+"-simple-color-popup",this.colorIcon,{zIndex:this.zIndex,autoHide:true,closeByEsc:true,offsetTop:0,offsetLeft:9,lightShadow:true,content:s});this.simpleColorPopup.setAngle({offset:10});this.simpleColorPopup.show(true);BX.addCustomEvent(this.simpleColorPopup,"onPopupClose",BX.delegate(function(){this.simpleColorPopup.destroy()},this))},simplePickerClick:function(e){var t=this.calendar.util.findTargetNode(e.target||e.srcElement,this.outerWrap);if(t&&t.getAttribute){var s=t.getAttribute("data-bx-calendar-color");if(s!==null){if(this.lastActiveNode){BX.removeClass(this.lastActiveNode,"active")}BX.addClass(t,"active");this.lastActiveNode=t;this.setColor(s)}}},showFullPicker:function(){if(this.simpleColorPopup)this.simpleColorPopup.close();if(!this.fullColorPicker){this.fullColorPicker=new BX.ColorPicker({bindElement:this.colorIcon,onColorSelected:BX.delegate(function(e){this.setColor(e)},this),popupOptions:{zIndex:this.zIndex,events:{onPopupClose:BX.delegate(function(){},this)}}})}this.fullColorPicker.open()},setColor:function(e){this.colorIcon.style.backgroundColor=e;this.color=e},setAccess:function(e){var t=0;for(var s in e){if(e.hasOwnProperty(s)){t++}}this.accessRowsCount=t;this.access=e;for(s in e){if(e.hasOwnProperty(s)){this.insertAccessRow(this.calendar.util.getAccessName(s),s,e[s])}}this.checkAccessTableHeight()},initAccessController:function(){this.accessControls={};this.accessTasks=this.calendar.util.getSectionAccessTasks();BX.bind(this.accessLink,"click",BX.delegate(function(){if(BX.hasClass(this.accessWrap,"shown")){BX.removeClass(this.accessWrap,"shown")}else{BX.addClass(this.accessWrap,"shown")}this.checkAccessTableHeight()},this));BX.Access.Init();this.accessWrapInner=this.accessWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-access-inner-wrap"}}));this.accessTable=this.accessWrapInner.appendChild(BX.create("TABLE",{props:{className:"calendar-section-slider-access-table"}}));this.accessButtonWrap=this.accessWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-new-calendar-options-container"}}));this.accessButton=this.accessButtonWrap.appendChild(BX.create("SPAN",{props:{className:"calendar-list-slider-new-calendar-option-add"},html:BX.message("EC_SEC_SLIDER_ACCESS_ADD")}));BX.bind(this.accessButton,"click",BX.proxy(function(){BX.Access.ShowForm({showSelected:false,callback:BX.proxy(function(e){var t,s;for(t in e){if(e.hasOwnProperty(t)){for(s in e[t]){if(e[t].hasOwnProperty(s)){this.calendar.util.setAccessName(s,BX.Access.GetProviderName(t)+" "+e[t][s].name);this.insertAccessRow(this.calendar.util.getAccessName(s),s)}}}}this.checkAccessTableHeight()},this),bind:this.calendar.id+"_calendar_section_"+Math.round(Math.random()*1e5)});if(BX.Access.popup&&BX.Access.popup.popupContainer){BX.Access.popup.popupContainer.style.zIndex=this.zIndex+10}},this));BX.bind(this.accessWrapInner,"click",BX.proxy(function(e){var t,s=this.calendar.util.findTargetNode(e.target||e.srcElement,this.outerWrap);if(s&&s.getAttribute){if(s.getAttribute("data-bx-calendar-access-selector")!==null){t=s.getAttribute("data-bx-calendar-access-selector");if(this.accessControls[t]){this.showAccessSelectorPopup({node:this.accessControls[t].removeIcon,setValueCallback:BX.delegate(function(e){if(this.accessTasks[e]&&this.accessControls[t]){this.accessControls[t].valueNode.innerHTML=BX.util.htmlspecialchars(this.accessTasks[e].title);this.access[t]=e}},this)})}}else if(s.getAttribute("data-bx-calendar-access-remove")!==null){t=s.getAttribute("data-bx-calendar-access-remove");if(this.accessControls[t]){BX.remove(this.accessControls[t].rowNode);this.accessControls[t]=null;delete this.access[t]}}}},this))},insertAccessRow:function(e,t,s){if(!this.accessControls[t]){if(s===undefined){s=this.calendar.util.getDefaultSectionAccessTask()}var i=BX.adjust(this.accessTable.insertRow(-1),{props:{className:"calendar-section-slider-access-table-row"}}),a=BX.adjust(i.insertCell(-1),{props:{className:"calendar-section-slider-access-table-cell"},html:'<span class="calendar-section-slider-access-title">'+BX.util.htmlspecialchars(e)+":</span>"}),n=BX.adjust(i.insertCell(-1),{props:{className:"calendar-section-slider-access-table-cell"},attrs:{"data-bx-calendar-access-selector":t}}),c=n.appendChild(BX.create("SPAN",{props:{className:"calendar-section-slider-access-value"}})),o=c.appendChild(BX.create("SPAN",{text:this.accessTasks[s]?this.accessTasks[s].title:""})),r=c.appendChild(BX.create("SPAN",{props:{className:"calendar-section-slider-access-remove"},attrs:{"data-bx-calendar-access-remove":t}}));this.access[t]=s;this.accessControls[t]={rowNode:i,titleNode:a,valueNode:o,removeIcon:r}}},checkAccessTableHeight:function(){if(this.checkTableTimeout){this.checkTableTimeout=clearTimeout(this.checkTableTimeout)}this.checkTableTimeout=setTimeout(BX.delegate(function(){if(BX.hasClass(this.accessWrap,"shown")){if(this.accessWrap.offsetHeight-this.accessTable.offsetHeight<36){this.accessWrap.style.maxHeight=parseInt(this.accessTable.offsetHeight)+100+"px"}}else{this.accessWrap.style.maxHeight=""}},this),300)},showAccessSelectorPopup:function(e){if(this.accessPopupMenu&&this.accessPopupMenu.popupWindow&&this.accessPopupMenu.popupWindow.isShown()){return this.accessPopupMenu.close()}var t=this.calendar.id+"_section_access_popup",s,i=this,a=[];for(s in this.accessTasks){if(this.accessTasks.hasOwnProperty(s)){a.push({text:this.accessTasks[s].title,onclick:function(t){return function(){e.setValueCallback(t);i.accessPopupMenu.close()}}(s)})}}this.accessPopupMenu=BX.PopupMenu.create(t,e.node,a,{closeByEsc:true,autoHide:true,zIndex:this.zIndex,offsetTop:-5,offsetLeft:0,angle:true});this.accessPopupMenu.show();BX.addCustomEvent(this.accessPopupMenu.popupWindow,"onPopupClose",function(){BX.PopupMenu.destroy(t);i.accessPopupMenu=null})}};function i(e){this.calendar=e.calendar;this.outerWrap=e.wrap;this.trackingUsers=e.trackingUsers||[];this.selectedCodes={};this.CHECKED_CLASS="calendar-list-slider-item-checkbox-checked";this.selectorId=this.calendar.id+"_tracking_users";this.selectGroups=false;this.selectUsers=true;this.addLinkMessage=BX.message("EC_SEC_SLIDER_SELECT_USERS");this.closeCallback=e.closeCallback;this.selected={};e.superposedSections.forEach(function(e){this.selected[e.id]=true},this);this.isCreated=false}i.prototype={show:function(){if(!this.innerWrap){this.innerWrap=this.outerWrap.appendChild(BX.create("DIV"))}this.trackingUsers.forEach(function(e){this.selectedCodes["U"+e.ID]="users"},this);if(!this.isCreated){this.create()}BX.addClass(this.outerWrap,"show");this.checkInnerWrapHeight();BX.bind(document,"keydown",BX.proxy(this.keyHandler,this));this.updateSectionList();this.isOpenedState=true},close:function(){BX.bind(document,"keydown",BX.proxy(this.keyHandler,this));this.isOpenedState=false;BX.removeClass(this.outerWrap,"show");this.outerWrap.style.cssText="";if(this.closeCallback)this.closeCallback()},isOpened:function(){return this.isOpenedState},create:function(){this.selectorWrap=this.innerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-selector-wrap"}}));this.destinationSelector=new e.BXEventCalendar.DestinationSelector(this.selectorId,{calendar:this.calendar,wrapNode:this.selectorWrap,itemsSelected:this.selectedCodes,addLinkMessage:this.addLinkMessage,selectGroups:this.selectGroups,selectUsers:this.selectUsers});BX.addCustomEvent("OnDestinationAddNewItem",BX.proxy(this.updateSectionList,this));BX.addCustomEvent("OnDestinationUnselect",BX.proxy(this.updateSectionList,this));this.sectionsWrap=this.innerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-sections-wrap"}}));this.buttonsWrap=this.innerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-btn-container"}}));this.saveBtn=this.buttonsWrap.appendChild(BX.create("DIV",{props:{className:"webform-small-button webform-small-button-blue"},text:BX.message("EC_SEC_SLIDER_SAVE"),events:{click:BX.proxy(this.save,this)}}));this.cancelBtn=this.buttonsWrap.appendChild(BX.create("SPAN",{props:{className:"webform-button-link"},text:BX.message("EC_SEC_SLIDER_CANCEL"),events:{click:BX.proxy(this.close,this)}}));this.isCreated=true},save:function(){var e=this.calendar.sectionController.getSuperposedSectionList(),t=[],s=[],i,a;for(a=0;a<e.length;a++){if(e[a].type!="user"){t.push(parseInt(e[a].id))}}for(i in this.sectionIndex){if(this.sectionIndex.hasOwnProperty(i)){if(BX.hasClass(this.sectionIndex[i].checkbox,this.CHECKED_CLASS)){if(!BX.util.in_array(i,t)){t.push(parseInt(i))}}else if(BX.util.in_array(i,t)){t=BX.util.deleteFromArray(t,BX.util.array_search(i,t))}}}this.calendar.request({data:{action:"set_tracking_sections",codes:this.destinationSelector.getCodes(),sect:t,type:"users"},handler:BX.delegate(function(e){BX.reload()},this)});this.close()},updateSectionList:function(){var e=this.destinationSelector.getCodes();this.sectionsWrap.appendChild(BX.adjust(this.calendar.util.getLoader(),{style:{height:"140px"}}));this.checkInnerWrapHeight();this.calendar.request({data:{action:"get_tracking_sections",codes:e||[],type:"users"},handler:BX.delegate(function(e){BX.cleanNode(this.sectionsWrap);this.sectionIndex={};this.checkInnerWrapHeight();e.users.forEach(function(t){var s=e.sections.filter(function(e){return e.OWNER_ID==t.ID});this.sectionsWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-card-section-title"},html:'<span class="calendar-list-slider-card-section-title-text">'+BX.util.htmlspecialchars(t.FORMATTED_NAME)+"</span>"}));if(s.length>0){this.createSectionBlock({sectionList:s,wrap:this.sectionsWrap})}else{this.sectionsWrap.appendChild(BX.create("DIV",{props:{className:""},html:'<span class="">'+BX.message("EC_SEC_SLIDER_NO_SECTIONS")+"</span>"}))}},this)},this)})},createSectionBlock:function(e){var t=false;if(e.sectionList&&e.sectionList.length){var s=e.wrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-widget-content"}})).appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-widget-content-block"}})).appendChild(BX.create("UL",{props:{className:"calendar-list-slider-container"}}));BX.bind(s,"click",BX.proxy(this.sectionClick,this));var i,a,n,c,o;for(i=0;i<e.sectionList.length;i++){o=e.sectionList[i].ID.toString();a=s.appendChild(BX.create("LI",{props:{className:"calendar-list-slider-item"},attrs:{"data-bx-calendar-section":o}}));n=a.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-item-checkbox"},style:{backgroundColor:e.sectionList[i].COLOR}}));c=a.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-item-name"},text:e.sectionList[i].NAME}));this.sectionIndex[o]={item:a,checkbox:n};if(this.selected[o]){BX.addClass(n,this.CHECKED_CLASS)}}}return t},sectionClick:function(e){var t=this.calendar.util.findTargetNode(e.target||e.srcElement,this.outerWrap);if(t&&t.getAttribute){if(t.getAttribute("data-bx-calendar-section")!==null){var s=t.getAttribute("data-bx-calendar-section");if(this.sectionIndex[s]&&this.sectionIndex[s].checkbox){if(BX.hasClass(this.sectionIndex[s].checkbox,this.CHECKED_CLASS)){BX.removeClass(this.sectionIndex[s].checkbox,this.CHECKED_CLASS)}else{BX.addClass(this.sectionIndex[s].checkbox,this.CHECKED_CLASS)}}}}},keyHandler:function(e){if(e.keyCode==this.calendar.util.KEY_CODES["escape"]){this.close()}else if(e.keyCode==this.calendar.util.KEY_CODES["enter"]){this.save()}},checkInnerWrapHeight:function(){if(this.checkHeightTimeout){this.checkHeightTimeout=clearTimeout(this.checkHeightTimeout)}this.checkHeightTimeout=setTimeout(BX.delegate(function(){if(BX.hasClass(this.outerWrap,"show")){if(this.outerWrap.offsetHeight-this.innerWrap.offsetHeight<36){this.outerWrap.style.maxHeight=parseInt(this.innerWrap.offsetHeight)+200+"px"}}else{this.outerWrap.style.maxHeight=""}},this),300)}};function a(e){i.apply(this,arguments);this.trackingGroups=e.trackingGroups||[];this.selectGroups=true;this.selectUsers=false;this.addLinkMessage=BX.message("EC_SEC_SLIDER_SELECT_GROUPS")}a.prototype=Object.create(i.prototype);a.prototype.constructor=a;a.prototype.create=function(){if(!this.innerWrap){this.innerWrap=this.outerWrap.appendChild(BX.create("DIV"))}this.sectionsWrap=this.innerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-sections-wrap"}}));this.buttonsWrap=this.innerWrap.appendChild(BX.create("DIV",{props:{className:"calendar-list-slider-btn-container"}}));this.saveBtn=this.buttonsWrap.appendChild(BX.create("DIV",{props:{className:"webform-small-button webform-small-button-blue"},text:BX.message("EC_SEC_SLIDER_SAVE"),events:{click:BX.proxy(this.save,this)}}));this.cancelBtn=this.buttonsWrap.appendChild(BX.create("SPAN",{props:{className:"webform-button-link"},text:BX.message("EC_SEC_SLIDER_CANCEL"),events:{click:BX.proxy(this.close,this)}}));this.isCreated=true};a.prototype.show=function(){if(!this.isCreated){this.create()}this.updateSectionList();this.isOpenedState=true;BX.addClass(this.outerWrap,"show")};a.prototype.updateSectionList=function(){this.sectionsWrap.appendChild(BX.adjust(this.calendar.util.getLoader(),{style:{height:"140px"}}));this.calendar.request({data:{action:"get_tracking_sections",type:"company"},handler:BX.delegate(function(e){BX.cleanNode(this.sectionsWrap);this.sectionIndex={};this.createSectionBlock({sectionList:e.sections,wrap:this.sectionsWrap});this.checkInnerWrapHeight()},this)});this.checkInnerWrapHeight()};a.prototype.save=function(){var e=this.calendar.sectionController.getSuperposedSectionList(),t=[],s,i;for(i=0;i<e.length;i++){t.push(parseInt(e[i].id))}for(s in this.sectionIndex){if(this.sectionIndex.hasOwnProperty(s)){if(BX.hasClass(this.sectionIndex[s].checkbox,this.CHECKED_CLASS)){if(!BX.util.in_array(s,t)){t.push(parseInt(s))}}else if(BX.util.in_array(s,t)){t=BX.util.deleteFromArray(t,BX.util.array_search(s,t))}}}this.calendar.request({data:{action:"set_tracking_sections",sect:t},handler:BX.delegate(function(e){BX.reload()},this)});this.close()};function n(e){i.apply(this,arguments);this.trackingGroups=e.trackingGroups||[];this.selectorId=this.calendar.id+"_tracking_groups";this.selectGroups=true;this.selectUsers=false;this.addLinkMessage=BX.message("EC_SEC_SLIDER_SELECT_GROUPS")}n.prototype=Object.create(i.prototype);n.prototype.constructor=n;n.prototype.show=function(){this.trackingGroups.forEach(function(e){this.selectedCodes["SG"+e]="sonetgroups"},this);i.prototype.show.apply(this,arguments)};n.prototype.save=function(){var e=this.calendar.sectionController.getSuperposedSectionList(),t=[],s,i;for(i=0;i<e.length;i++){t.push(parseInt(e[i].id))}for(s in this.sectionIndex){if(this.sectionIndex.hasOwnProperty(s)){if(BX.hasClass(this.sectionIndex[s].checkbox,this.CHECKED_CLASS)){if(!BX.util.in_array(s,t)){t.push(parseInt(s))}}else if(BX.util.in_array(s,t)){t=BX.util.deleteFromArray(t,BX.util.array_search(s,t))}}}this.calendar.request({data:{action:"set_tracking_sections",codes:this.destinationSelector.getCodes(),sect:t,type:"groups"},handler:BX.delegate(function(e){BX.reload()},this)});this.close()};n.prototype.updateSectionList=function(){var e=this.destinationSelector.getCodes();this.sectionsWrap.appendChild(BX.adjust(this.calendar.util.getLoader(),{style:{height:"140px"}}));this.calendar.request({data:{action:"get_tracking_sections",codes:e||[],type:"groups"},handler:BX.delegate(function(e){BX.cleanNode(this.sectionsWrap);this.sectionIndex={};this.createSectionBlock({sectionList:e.sections,wrap:this.sectionsWrap});this.checkInnerWrapHeight()},this)});this.checkInnerWrapHeight()};if(e.BXEventCalendar){e.BXEventCalendar.SectionSlider=t}else{BX.addCustomEvent(e,"onBXEventCalendarInit",function(){e.BXEventCalendar.SectionSlider=t})}})(window);