1function data() { 2 function getThemeFromLocalStorage() { 3 // if user already changed the theme, use it 4 if (window.localStorage.getItem('dark')) { 5 return JSON.parse(window.localStorage.getItem('dark')) 6 } 7 8 // else return their preferences 9 return ( 10 !!window.matchMedia && 11 window.matchMedia('(prefers-color-scheme: dark)').matches 12 ) 13 } 14 15 function setThemeToLocalStorage(value) { 16 window.localStorage.setItem('dark', value) 17 } 18 19 return { 20 dark: getThemeFromLocalStorage(), 21 toggleTheme() { 22 this.dark = !this.dark 23 setThemeToLocalStorage(this.dark) 24 }, 25 isSideMenuOpen: false, 26 toggleSideMenu() { 27 this.isSideMenuOpen = !this.isSideMenuOpen 28 }, 29 closeSideMenu() { 30 this.isSideMenuOpen = false 31 }, 32 isNotificationsMenuOpen: false, 33 toggleNotificationsMenu() { 34 this.isNotificationsMenuOpen = !this.isNotificationsMenuOpen 35 }, 36 closeNotificationsMenu() { 37 this.isNotificationsMenuOpen = false 38 }, 39 isProfileMenuOpen: false, 40 toggleProfileMenu() { 41 this.isProfileMenuOpen = !this.isProfileMenuOpen 42 }, 43 closeProfileMenu() { 44 this.isProfileMenuOpen = false 45 }, 46 isSearchMenuOpen: false, 47 toggleSearchMenu() { 48 this.isSearchMenuOpen = !this.isSearchMenuOpen 49 }, 50 closeSearchMenu() { 51 this.isSearchMenuOpen = false 52 }, 53 isLangMenuOpen: false, 54 toggleLangMenu() { 55 this.isLangMenuOpen = !this.isLangMenuOpen 56 }, 57 closeLangMenu() { 58 this.isLangMenuOpen = false 59 }, 60 isPagesMenuOpen: false, 61 togglePagesMenu() { 62 this.isPagesMenuOpen = !this.isPagesMenuOpen 63 }, 64 // Modal 65 isModalOpen: false, 66 trapCleanup: null, 67 openModal() { 68 this.isModalOpen = true 69 this.trapCleanup = focusTrap(document.querySelector('#modal')) 70 }, 71 closeModal() { 72 this.isModalOpen = false 73 this.trapCleanup() 74 }, 75 } 76}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.