PluginProbe
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses / 2.4.01
FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses v2.4.01
2.10.0 2.10.01 2.9.1 2.9.0 2.8.1 2.8.0 2.7.7 2.7.5 2.7.0 2.6.01 2.6.0 2.5.0 2.4.01 trunk 1.0.90 1.0.91 1.0.92 1.0.93 1.0.94 1.0.95 1.0.96 1.0.97 1.0.98 1.0.99 1.1.0 All 77 releases
fluent-community / assets / portal_general.js

portal_general.js in FluentCommunity – Ultra-Fast High-Performance Social Network, Community, LMS & Online Courses 2.4.01, at assets/portal_general.js

2 lines 6.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 window.fluentComPortalGeneral={init(){let e=localStorage.getItem("fcom_global_storage");e?this.globalStates=JSON.parse(e):e={},this.initColorSwitch(),document.addEventListener("DOMContentLoaded",()=>{this.initDocReady(),window.fcom_portal_general.scope=="wp"&&this.maybeSetActiveLink()})},initDocReady(){var e=this;if(document.querySelector(".fcom_top_menu")){const r=document.querySelector(".fcom_top_menu").offsetHeight;document.body.style.setProperty("--fcom-header-height",r+"px");let l=0;const c=document.querySelector(".fcom_mobile_menu");if(c&&(l=c.offsetHeight),document.body.style.setProperty("--fcom-mobile-menu-height",l+"px"),c&&window.visualViewport){var t=window.visualViewport.height;window.visualViewport.addEventListener("resize",function(){var s=window.visualViewport.height<t*.75;document.documentElement.classList.toggle("fcom_keyboard_open",s),document.body.style.setProperty("--fcom-mobile-menu-height",s?"0px":l+"px")})}}this.initMobileSidebar();const o=document.getElementById("fluent_community_sidebar_menu");o&&(o.addEventListener("click",function(){const r=event.target.closest(".space_section_title");if(!r)return;let l=r.getAttribute("data-group_id"),c=r.closest(".fcom_communities_menu");c&&c.classList.toggle("fcom_group_collapsed");let s=c&&c.classList.contains("fcom_group_collapsed");e.setGroupState("fcom_group_"+l,s?"collapsed":"expanded")}),this.applySidebarGroupStates());let i=document.querySelector(".feeds_main");if(i){let r=function(l){let c=l.offsetWidth;document.body.style.setProperty("--fcom-main-content-width",c+"px")};var n=r;r(i),window.addEventListener("resize",function(){r(i)})}this.profileMenuInit(),this.watchSpaceCreateLink(),document.addEventListener("sidebar_menu_reloaded",()=>{this.watchSpaceCreateLink(),this.applySidebarGroupStates()}),document.dispatchEvent(new CustomEvent("fluentComPortalGeneral",{}))},maybeSetActiveLink(){let e=document.querySelectorAll("li a.fcom_custom_link");e.length&&e.forEach(t=>{let o=t.getAttribute("href");window.location.origin+window.location.pathname===o?t.classList.add("router-link-exact-active"):t.classList.remove("router-link-exact-active")})},setCookie(e,t,o=30){let i="";if(o){const n=new Date;n.setTime(n.getTime()+o*24*60*60*1e3),i="; expires="+n.toUTCString()}document.cookie=e+"="+encodeURIComponent(t)+i+"; path=/"},getCookie(e){const t=e+"=",o=document.cookie.split(";");for(let i of o)if(i=i.trim(),i.indexOf(t)===0)return decodeURIComponent(i.substring(t.length));return null},getFromStorage(e,t=""){return this.globalStates&&this.globalStates[e]||t},setToStorage(e,t){this.globalStates||(this.globalStates={}),this.globalStates[e]=t,localStorage.setItem("fcom_global_storage",JSON.stringify(this.globalStates))},getGroupState(e){return this.getFromStorage("groupStates",{})[e]??""},setGroupState(e,t){let o=this.getFromStorage("groupStates",{});o[e]=t,this.setToStorage("groupStates",o)},applySidebarGroupStates(){const e=!!(window.fcom_portal_general&&window.fcom_portal_general.collapse_sidebar_groups),t=window.location.pathname.replace(/\/$/,"");document.querySelectorAll(".space_section_title").forEach(o=>{let i=o.getAttribute("data-group_id"),n=this.getGroupState("fcom_group_"+i),r=o.closest(".fcom_communities_menu");if(r){if(this.groupHasActiveLink(r,t)){r.classList.remove("fcom_group_collapsed");return}n==="collapsed"?r.classList.add("fcom_group_collapsed"):n==="expanded"?r.classList.remove("fcom_group_collapsed"):e&&r.classList.add("fcom_group_collapsed")}})},groupHasActiveLink(e,t){if(e.querySelector("a.router-link-exact-active, a.router-link-active"))return!0;const o=e.querySelectorAll("a[href]");for(let i=0;i<o.length;i++){let n=o[i].pathname;if(n.length>1&&n.endsWith("/")&&(n=n.slice(0,-1)),n===t)return!0}return!1},initMobileSidebar(){let e=document.querySelectorAll(".fcom_space_opener_btn");if(!e.length)return;function t(o){o.target.closest(".fcom_group_title")||o.target.closest(".fcom_space_opener_btn")||(document.querySelector(".space_opened")&&document.querySelector(".space_opened").classList.remove("space_opened"),document.removeEventListener("click",t))}e.forEach(o=>{o.addEventListener("click",function(){document.querySelector(".feed_layout")&&document.querySelector(".feed_layout").classList.toggle("space_opened"),document.querySelector(".feed_layout").classList.contains("space_opened")?setTimeout(()=>{document.addEventListener("click",t)},0):document.removeEventListener("click",t)})})},initColorSwitch(){var o;if(!window.fcom_portal_general||!window.fcom_portal_general.has_color_scheme||document.body.classList.contains("fcom_disable_dark_mode"))return document.querySelectorAll(".fcom_mode_switch").forEach(n=>{n.style.display="none"}),!1;var e=this;document.querySelectorAll(".fcom_mode_switch").forEach(i=>{i.addEventListener("click",function(){var n=document.documentElement.classList.contains("dark")?"light":"dark";e.fcomSetColorMode(n),document.querySelector(".feed_layout")&&document.querySelector(".feed_layout").classList.remove("space_opened")})});let t=e.getFromStorage("fcom_color_mode","");if((o=window.fcom_portal_general)!=null&&o.color_switch_cookie_name){let i=this.getCookie(window.fcom_portal_general.color_switch_cookie_name);(i=="dark"||i=="light")&&(t=i)}t&&this.fcomSetColorMode(t)},fcomSetColorMode(e){var i;if(!["dark","light"].includes(e))return!1;let o="dark";e=="dark"&&(o="light"),document.documentElement.classList.remove(o),e&&(document.documentElement.classList.add(e),document.documentElement.setAttribute("data-color-mode",e),(i=window.fcom_portal_general)!=null&&i.color_switch_cookie_name&&this.setCookie(window.fcom_portal_general.color_switch_cookie_name,e)),this.setToStorage("fcom_color_mode",e)},profileMenuInit(){const e=document.getElementsByClassName("fcom_profile_extend");e.length&&[...e].forEach(t=>{let o=t.querySelector(".fcom_profile_menu"),i=t.querySelector(".fcom_profile_sub_menu");if(!o||!i)return;function n(r){t.classList.remove("fcom_extend_menu"),document.removeEventListener("click",n)}o.addEventListener("click",function(r){t.classList.toggle("fcom_extend_menu"),t.classList.contains("fcom_extend_menu")&&setTimeout(()=>{document.addEventListener("click",n)},0)})})},watchSpaceCreateLink(){let e=document.querySelectorAll(".fcom_space_create_link");e.length&&e.forEach(t=>{t.addEventListener("click",function(o){const i=window.fluentFrameworkApp;if(!i||!i.$eventBus)return;const n=t.getAttribute("data-parent_id");n&&(o.stopPropagation(),o.preventDefault(),i.$eventBus.emit("createSpaceModal",{parent_id:n}))})})}};window.fluentComPortalGeneral.init();
2