diff --git a/module/search/ui/buildform.html.php b/module/search/ui/buildform.html.php index bcdc7e750b..b9822815dd 100644 --- a/module/search/ui/buildform.html.php +++ b/module/search/ui/buildform.html.php @@ -1,79 +1,13 @@ - - - - - +render('fragment'); diff --git a/zin/wg/searchtoggle/css/v1.css b/zin/wg/searchtoggle/css/v1.css new file mode 100644 index 0000000000..c5f794c342 --- /dev/null +++ b/zin/wg/searchtoggle/css/v1.css @@ -0,0 +1,3 @@ +.show-search-form #featureBar .search-form-toggle {color: var(--color-primary-500); background-color: var(--color-primary-50);} +#searchFormPanel {display: none;} +.show-search-form #searchFormPanel {display: block;} diff --git a/zin/wg/searchtoggle/js/v1.js b/zin/wg/searchtoggle/js/v1.js new file mode 100644 index 0000000000..13b742860e --- /dev/null +++ b/zin/wg/searchtoggle/js/v1.js @@ -0,0 +1,19 @@ +window.toggleSearchForm = function() +{ + const $body = $('body').toggleClass('show-search-form'); + const show = $body.hasClass('show-search-form'); + zui.bus.emit('searchform.toggle', {show: show}); + if(!show) return; + + let $form = $body.find('#searchFormPanel'); + if(!$form.length) $form = $('
').insertAfter('#mainMenu'); + if(!$form.data('loaded')) + { + const url = zui.createLink('search', 'buildForm', 'module=' + config.currentModule); + fetch(url).then(response => response.text()).then(html => + { + $form.html(html).data('loaded', true); + zui.bus.emit('searchform.loaded'); + }); + } +}; diff --git a/zin/wg/searchtoggle/v1.php b/zin/wg/searchtoggle/v1.php index 593522b43a..09448dc41a 100644 --- a/zin/wg/searchtoggle/v1.php +++ b/zin/wg/searchtoggle/v1.php @@ -3,14 +3,26 @@ namespace zin; class searchToggle extends wg { + public static function getPageCSS() + { + return file_get_contents(__DIR__ . DS . 'css' . DS . 'v1.css'); + } + + public static function getPageJS() + { + return file_get_contents(__DIR__ . DS . 'js' . DS . 'v1.js'); + } + protected function build() { global $lang; return btn ( - set::class('ghost'), + set::class('ghost search-form-toggle'), set::icon('search'), - set::text($lang->searchAB) + set::text($lang->searchAB), + on::click('window.toggleSearchForm'), + to::after() ); } }