public_html/layouts/basic/modules/Vtiger/resources/Header.min.js
'use strict';
/*+***********************************************************************************
* The contents of this file are subject to the vtiger CRM Public License Version 1.0
* ("License"); You may not use this file except in compliance with the License
* The Original Code is: vtiger CRM Open Source
* The Initial Developer of the Original Code is vtiger.
* Portions created by vtiger are Copyright (C) vtiger.
* All Rights Reserved.
* Contributor(s): YetiForce S.A.
*************************************************************************************/"use strict";//Show Alert if user is on a unsupported browser (IE7, IE8, ..etc)
(/MSIE 6.0/.test(navigator.userAgent)||/MSIE 7.0/.test(navigator.userAgent)||/MSIE 8.0/.test(navigator.userAgent)||/MSIE 9.0/.test(navigator.userAgent))&&"true"!=app.getCookie("oldbrowser")&&(app.setCookie("oldbrowser",!0,365),window.location.href="layouts/basic/modules/Vtiger/browsercompatibility/Browser_compatibility.html"),$.Class("Vtiger_Header_Js",{self:!1,getInstance:function getInstance(){return !1==this.self?(this.self=new Vtiger_Header_Js,this.self):this.self}},{menuContainer:!1,contentContainer:!1,init:function init(){this.setContentsContainer(".js-base-container");},setContentsContainer:function setContentsContainer(element){return this.contentContainer=element instanceof $?element:$(element),this},getContentsContainer:function getContentsContainer(){return this.contentContainer},registerQuickCreateSearch:function registerQuickCreateSearch(){$(".js-quickcreate-search").on("keyup",function(){var value=$(this).val().toLowerCase();$(".quickCreateModules .js-quickcreate-search-item a").filter(function(){var item=$(this).closest(".js-quickcreate-search-item");-1<$(this).text().toLowerCase().indexOf(value)?item.removeClass("d-none"):item.addClass("d-none");}),$(".js-quickcreate-search-block").hide(),$(".js-quickcreate-search-item").not(".d-none").each(function(){$(this).closest(".js-quickcreate-search-block").show();});});},showAnnouncement:function showAnnouncement(){var thisInstance=this,announcementContainer=$("#announcements"),announcements=announcementContainer.find(".announcement");if(0<announcements.length){var announcement=announcements.first(),aid=announcement.data("id");app.showModalWindow(announcement.find(".modal"),function(modal){announcement.remove(),modal.find("button").on("click",function(){AppConnector.request({module:"Announcements",action:"BasicAjax",mode:"mark",record:aid,type:$(this).data("type")}).done(function(){app.hideModalWindow(),thisInstance.showAnnouncement();});});},"",{backdrop:"static",keyboard:!1});}},registerAnnouncements:function registerAnnouncements(){var thisInstance=this,announcementContainer=$("#announcements");return 0!=announcementContainer.length&&void thisInstance.showAnnouncement()},registerCalendarButtonClickEvent:function registerCalendarButtonClickEvent(){var element=$("#calendarBtn"),currentDate=element.data("date");element.on("click",function(e){e.stopImmediatePropagation(),element.closest("div.nav").find("div.open").removeClass("open");var calendar=$("#"+element.data("datepickerId"));$(calendar).is(":visible")?element.DatePickerHide():element.DatePickerShow();}),element.DatePicker({format:App.Fields.Date.convertToDatePickerFormat(element.data("dateFormat")),date:currentDate,calendars:1,starts:1,className:"globalCalendar"});},isFreeDay:function isFreeDay(dayOfWeek){return !(0!=dayOfWeek&&6!=dayOfWeek)},basicSearch:function basicSearch(){var thisInstance=this;$(".js-global-search__value").on("keypress",function(e){var currentTarget=$(e.currentTarget);13==e.which&&(thisInstance.hideSearchMenu(),thisInstance.labelSearch(currentTarget));}),$(".js-global-search-operator").on("click",function(e){var currentTarget=$(e.target),block=currentTarget.closest(".js-global-search__input");block.find(".js-global-search__value").data("operator",currentTarget.data("operator")),block.find(".js-global-search-operator .dropdown-item").removeClass("active"),currentTarget.closest(".dropdown-item").addClass("active");}),1==$("#gsAutocomplete").val()&&($.widget("custom.gsAutocomplete",$.ui.autocomplete,{_create:function _create(){this._super(),this.widget().menu("option","items","> :not(.ui-autocomplete-category)");},_renderMenu:function _renderMenu(ul,items){var that=this,currentCategory="";$.each(items,function(index,item){item.category!=currentCategory&&(ul.append("<li class='ui-autocomplete-category'>"+item.category+"</li>"),currentCategory=item.category),that._renderItemData(ul,item);});},_renderItemData:function _renderItemData(ul,item){return this._renderItem(ul,item).data("ui-autocomplete-item",item)},_renderItem:function _renderItem(ul,item){var url="index.php?module="+item.module+"&view=Detail&record="+item.id;return $("<li>").data("item.autocomplete",item).append($("<a href='"+url+"' title='"+item.label+"'></a>").html(item.label)).appendTo(ul)}}),$(".js-global-search__value").gsAutocomplete({minLength:app.getMainParams("gsMinLength"),source:function source(request,response){var basicSearch=new Vtiger_BasicSearch_Js;basicSearch.reduceNumberResults=app.getMainParams("gsAmountResponse"),basicSearch.returnHtml=!1,basicSearch.setMainContainer(this.element.closest(".js-global-search__input")),basicSearch.search(request.term).done(function(data){data=JSON.parse(data);var serverDataFormat=data.result,reponseDataList=[];for(var id in serverDataFormat){var responseData=serverDataFormat[id];reponseDataList.push(responseData);}response(reponseDataList);});},classes:{"ui-autocomplete":"u-overflow-y-auto u-overflow-x-hidden u-max-h-70vh u-max-w-sm-70 u-max-w-lg-40"},select:function select(event,ui){var selectedItemData=ui.item;if(selectedItemData.permitted){var url="index.php?module="+selectedItemData.module+"&view=Detail&record="+selectedItemData.id;window.location.href=url;}return !1},close:function close(){//$('.js-global-search__value').val('');
}}));},labelSearch:function labelSearch(currentTarget){var val=currentTarget.val();if(""==val)return app.showAlert(app.vtranslate("JS_PLEASE_ENTER_SOME_VALUE")),currentTarget.focus(),!1;var progress=$.progressIndicator({position:"html",blockInfo:{enabled:!0}}),basicSearch=new Vtiger_BasicSearch_Js;basicSearch.setMainContainer(currentTarget.closest(".js-global-search__input")),basicSearch.search(val).done(function(data){basicSearch.showSearchResults(data),progress.progressIndicator({mode:"hide"});});},registerHotKeys:function registerHotKeys(){$(".hotKey").each(function(){var thisObject=this,key=$(thisObject).data("hotkeys");""!=key&&Mousetrap.bind(key,function(){thisObject.click();});});},registerReminderNotice:function registerReminderNotice(){var self=this;$("#page").before("<div class=\"remindersNoticeContainer\" tabindex=\"-1\" role=\"dialog\" aria-label=\"".concat(app.vtranslate("JS_REMINDER"),"\" aria-hidden=\"true\"></div>"));var block=$(".remindersNoticeContainer"),remindersNotice=$(".remindersNotice");remindersNotice.on("click",function(){remindersNotice.hasClass("autoRefreshing")||Vtiger_Index_Js.requestReminder(),self.hideActionMenu(),self.hideBreadcrumbActionMenu(),block.toggleClass("toggled"),self.hideReminderNotification(),app.closeSidebar(),self.hideSearchMenu();});},registerReminderNotification:function registerReminderNotification(){var self=this;$("#page").before("<div class=\"remindersNotificationContainer\" tabindex=\"-1\" role=\"dialog\"></div>");var block=$(".remindersNotificationContainer"),remindersNotice=$(".notificationsNotice");remindersNotice.on("click",function(){remindersNotice.hasClass("autoRefreshing")||Vtiger_Index_Js.getNotificationsForReminder(),self.hideActionMenu(),self.hideBreadcrumbActionMenu(),block.toggleClass("toggled"),self.hideReminderNotice(),app.closeSidebar(),self.hideSearchMenu();});},toggleBreadcrumbActions:function toggleBreadcrumbActions(container){var actionsContainer=container.find(".js-header-toggle__actions");if(actionsContainer.length){var actionBtn=container.find(".js-header-toggle__actions-btn");if(!actionsContainer.closest(".js-btn-toolbar").length){var cssActionsTop={top:actionBtn.offset().top+actionBtn.outerHeight()+5};actionsContainer.css(cssActionsTop);}actionBtn.on("click",function(){actionsContainer.toggleClass("is-active");});}},registerMobileEvents:function registerMobileEvents(){var self=this,container=this.getContentsContainer();$(".rightHeaderBtnMenu").on("click",function(){self.hideActionMenu(),self.hideBreadcrumbActionMenu(),self.hideSearchMenu(),self.hideReminderNotice(),self.hideReminderNotification(),$(".mobileLeftPanel ").toggleClass("mobileMenuOn");}),$(".js-quick-action-btn").on("click",function(){var currentTarget=$(this);app.closeSidebar(),self.hideBreadcrumbActionMenu(),self.hideSearchMenu(),self.hideReminderNotice(),self.hideReminderNotification(),$(".actionMenu").toggleClass("actionMenuOn"),currentTarget.hasClass("active")?(currentTarget.removeClass("active"),currentTarget.attr("aria-expanded","false"),currentTarget.popover()):(currentTarget.addClass("active"),currentTarget.attr("aria-expanded","true"),currentTarget.popover("disable")),$(".quickCreateModules").on("click",function(){self.hideActionMenu();});}),$(".searchMenuBtn").on("click",function(){var currentTarget=$(this);app.closeSidebar(),self.hideActionMenu(),self.hideBreadcrumbActionMenu(),self.hideReminderNotice(),self.hideReminderNotification(),$(".searchMenu").toggleClass("toogleSearchMenu"),currentTarget.hasClass("active")?(currentTarget.removeClass("active"),$(".searchMenuBtn .c-header__btn").attr("aria-expanded","false")):(currentTarget.addClass("active"),$(".searchMenuBtn .c-header__btn").attr("aria-expanded","true"));}),$(".js-header__btn--mail .dropdown").on("show.bs.dropdown",function(){app.closeSidebar(),self.hideActionMenu(),self.hideBreadcrumbActionMenu(),self.hideReminderNotice(),self.hideReminderNotification(),self.hideSearchMenu();}),this.toggleBreadcrumbActions(container);},hideMobileMenu:function hideMobileMenu(){$(".mobileLeftPanel ").removeClass("mobileMenuOn");},hideSearchMenu:function hideSearchMenu(){$(".searchMenu").removeClass("toogleSearchMenu");},hideActionMenu:function hideActionMenu(){$(".actionMenu").removeClass("actionMenuOn");},hideBreadcrumbActionMenu:function hideBreadcrumbActionMenu(){$(".js-header-toggle__actions").removeClass("is-active");},hideReminderNotice:function hideReminderNotice(){$(".remindersNoticeContainer").removeClass("toggled");},hideReminderNotification:function hideReminderNotification(){$(".remindersNotificationContainer").removeClass("toggled");},registerFooTable:function registerFooTable(){var container=$(".tableRWD");container.find("thead tr th:gt(1)").attr("data-hide","phone"),container.find("thead tr th:gt(3)").attr("data-hide","tablet,phone"),container.find("thead tr th:last").attr("data-hide","");var whichColumnEnable=container.find("thead").attr("col-visible-alltime");container.find("thead tr th:eq("+whichColumnEnable+")").attr("data-hide",""),$(".tableRWD, .customTableRWD").footable({breakpoints:{phone:768,tablet:1024},addRowToggle:!0,toggleSelector:" > tbody > tr:not(.footable-row-detail)"}),$(".footable-toggle").on("click",function(event){event.stopPropagation(),$(this).trigger("footable_toggle_row");});var records=$(".customTableRWD").find("[data-toggle-visible=false]");records.find(".footable-toggle").css("display","none");},registerSiteBarButton:function registerSiteBarButton(container){var _this=this,key="ShowHideRightPanel"+app.getModuleName(),cache=!container.find(".toggleSiteBarRightButton").data("nocache");cache&&"show"==app.cacheGet(key)?this.toggleSiteBar(container.find(".toggleSiteBarRightButton")):cache&&null==app.cacheGet(key)&&1==container.find(".siteBarRight").data("showpanel")&&this.toggleSiteBar(container.find(".toggleSiteBarRightButton")),container.find(".toggleSiteBarRightButton").on("click",function(e){var toggleButton=$(e.currentTarget);toggleButton.data("nocache")||(toggleButton.closest(".siteBarRight").hasClass("hideSiteBar")?app.cacheSet(key,"show"):app.cacheSet(key,"hide")),_this.toggleSiteBar(toggleButton);});},toggleSiteBar:function toggleSiteBar(toogleButton){$(".rowContent").toggleClass("js-sitebar--active"),toogleButton.closest(".siteBarRight").toggleClass("hideSiteBar"),toogleButton.find(".fas").toggleClass("fa-chevron-right fa-chevron-left"),toogleButton.toggleClass("hideToggleSiteBarRightButton");},registerToggleButton:function registerToggleButton(){$(".buttonTextHolder .dropdown-menu a").on("click",function(){$(this).parents(".d-inline-block").find(".dropdown-toggle .textHolder").html($(this).text());});},registerKnowledgeBaseModal:function registerKnowledgeBaseModal(){$(".js-knowledge-base-modal").on("click",function(){window.KnowledgeBaseModalVueComponent.mounted===void 0?(window.KnowledgeBaseModalVueComponent.mount({el:"#KnowledgeBaseModal",state:{moduleName:"KnowledgeBase",dialog:!0}}),KnowledgeBaseModalVueComponent.mounted=!0):vuexStore.commit("KnowledgeBase/setDialog",!0);});},registerChat:function registerChat(){window===window.parent&&window.ChatModalVueComponent!==void 0&&window.ChatModalVueComponent.mount({el:"#ChatModalVue"});},registerEvents:function registerEvents(){var thisInstance=this,container=thisInstance.getContentsContainer(),menuContainer=container.find(".js-menu--scroll"),quickCreateModal=container.find(".quickCreateModules");//Enable footable
//this.registerCalendarButtonClickEvent();
//After selecting the global search module, focus the input element to type
app.showNewScrollbarLeft(menuContainer,{suppressScrollX:!0}),app.showNewScrollbar(menuContainer.find(".subMenu").last(),{suppressScrollX:!0}),thisInstance.registerFooTable(),$(".js-clear-history").on("click",function(){app.clearBrowsingHistory();}),$(".globalSearch").on("click",function(){var currentTarget=$(this);thisInstance.hideSearchMenu();var advanceSearchInstance=new Vtiger_AdvanceSearch_Js;advanceSearchInstance.setParentContainer(currentTarget.closest(".js-global-search__input")),advanceSearchInstance.initiateSearch();}),$(".searchIcon").on("click",function(){var currentTarget=$(this).closest(".js-global-search__input").find(".js-global-search__value"),pressEvent=$.Event("keypress");pressEvent.which=13,currentTarget.trigger(pressEvent);}),thisInstance.registerAnnouncements(),thisInstance.registerHotKeys(),thisInstance.registerToggleButton(),thisInstance.registerSiteBarButton($("#centerPanel")),$(".basicSearchModulesList").on("change",function(){var value=$(this).closest(".js-global-search__input").find(".js-global-search__value");setTimeout(function(){value.focus();},100);}),thisInstance.basicSearch(),quickCreateModal.on("click",".quickCreateModule",function(e){var moduleName=$(e.currentTarget).data("name");quickCreateModal.modal("hide"),App.Components.QuickCreate.createRecord(moduleName);}),thisInstance.registerReminderNotification(),thisInstance.registerMobileEvents(),thisInstance.registerReminderNotice(),thisInstance.registerQuickCreateSearch(),thisInstance.registerKnowledgeBaseModal(),thisInstance.registerChat();}}),jQuery(function(){window.addEventListener("popstate",function(event){event.state&&(window.location.href=event.state);}),Vtiger_Header_Js.getInstance().registerEvents();});
//# sourceMappingURL=Header.min.js.map