File indexing completed on 2025-01-26 05:27:58
0001 import React,{useContext, useState,useRef,useEffect} from 'react'; 0002 import {MetaheaderContext} from '../contexts/MetaheaderContext'; 0003 0004 const MoreDropDownMenu = () => { 0005 const {state} = useContext(MetaheaderContext); 0006 const [dropdownClass, setDropdownClass] = useState(''); 0007 const toggleEl = useRef(null); 0008 useEffect(() => { 0009 document.addEventListener('mousedown',handleClick, false); 0010 return () => { 0011 0012 document.removeEventListener('mousedown',handleClick, false); 0013 }; 0014 },[dropdownClass]) 0015 0016 const handleClick= e => { 0017 let cls = ""; 0018 if (toggleEl.current.contains(e.target)){ 0019 if (dropdownClass === "open"){ 0020 if (e.target.className === "more-menu-link-item"){ 0021 cls = ""; 0022 } else { 0023 cls = "open"; 0024 } 0025 } else { 0026 cls = "open"; 0027 } 0028 } 0029 setDropdownClass(cls); 0030 } 0031 0032 0033 let faqLinkItem, apiLinkItem, aboutLinkItem,aboutPlingItem, aboutopencodeItem; 0034 0035 aboutPlingItem = (<li><a id="faq" href={state.baseUrl +"/faq-pling"}>FAQ Pling</a></li>); 0036 aboutopencodeItem = (<li><a id="faq" href={state.baseUrl +"/faq-opencode"}>FAQ Opencode</a></li>); 0037 aboutLinkItem = (<li><a id="about" href={state.baseUrl +"/about"}>About</a></li>); 0038 apiLinkItem = (<li><a href={state.baseUrl +"/ocs-api"}>API</a></li>); 0039 if (state.isAdmin ){ 0040 faqLinkItem = (<li><a className="popuppanel" id="faq" href={"/plings"}>Plings (admin only)</a></li>); 0041 } 0042 return ( 0043 <li ref={toggleEl} id="more-dropdown-menu" className={dropdownClass}> 0044 <a className="more-menu-link-item">More</a> 0045 <ul className="dropdown-menu"> 0046 <li><a href={state.baseUrl + "/community"}>Members</a></li> 0047 <li><a href={state.forumUrl}>Discussion</a></li> 0048 <li><a href={state.baseUrlStore + "/support"}>Become a Supporter</a></li> 0049 <li><a href={state.blogUrl} target="_blank">Blog</a></li> 0050 {faqLinkItem} 0051 {apiLinkItem} 0052 {aboutPlingItem} 0053 {aboutopencodeItem} 0054 {aboutLinkItem} 0055 </ul> 0056 </li> 0057 ) 0058 } 0059 0060 export default MoreDropDownMenu