diff --git a/resources/js/app.js b/resources/js/app.js index 0b7949816..e4422fc9d 100644 --- a/resources/js/app.js +++ b/resources/js/app.js @@ -5,6 +5,7 @@ import Choices from 'choices.js'; import 'choices.js/public/assets/styles/choices.css'; require('./bootstrap'); +require('./nav'); require('./search'); require('./editor'); diff --git a/resources/js/nav.js b/resources/js/nav.js new file mode 100644 index 000000000..c231c1eed --- /dev/null +++ b/resources/js/nav.js @@ -0,0 +1,23 @@ +window.navConfig = () => { + return { + nav: false, + searchVisible: false, + searchQuery: '', + community: false, + chat: false, + settings: false, + + // Show search modal + showSearch: function (event) { + // Abort if trying to open while the following elements are focused + if ( + event instanceof KeyboardEvent && + (event.target.tagName === 'INPUT' || event.target.tagName === 'TEXTAREA') + ) { + return false; + } + + this.searchVisible = true; + }, + }; +}; diff --git a/resources/views/layouts/_nav.blade.php b/resources/views/layouts/_nav.blade.php index 1cec48397..9ea909f70 100644 --- a/resources/views/layouts/_nav.blade.php +++ b/resources/views/layouts/_nav.blade.php @@ -1,5 +1,5 @@