* search: refactor the index page.
This commit is contained in:
@@ -9,11 +9,12 @@ function searchWords()
|
||||
return false;
|
||||
}
|
||||
|
||||
const type = $target.data('type') || $form.find('input[name=type]').val();
|
||||
const form = new FormData();
|
||||
form.append('type[]', type);
|
||||
form.append('words', words);
|
||||
|
||||
const types = $form.find('select[name^=type]').val();
|
||||
types.forEach(type => form.append('type[]', type));
|
||||
|
||||
postAndLoadPage($.createLink('search', 'index'), form);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,35 +14,6 @@ jsVar('inputWords', $lang->search->inputWords);
|
||||
|
||||
to::header();
|
||||
|
||||
if(is_array($type)) $type = reset($type);
|
||||
|
||||
$labels = array();
|
||||
foreach(array_slice($lang->search->modules, 0, 10) as $module => $moduleName)
|
||||
{
|
||||
$labels[] = btn
|
||||
(
|
||||
setClass('light-pale mr-3' . ($type == $module ? ' primary' : '')),
|
||||
set(array('data-type' => $module)),
|
||||
on::click('searchWords'),
|
||||
$moduleName
|
||||
);
|
||||
}
|
||||
|
||||
$moreItems = array();
|
||||
foreach(array_slice($lang->search->modules, 10) as $module => $moduleName)
|
||||
{
|
||||
$moreItems[$module] = array('text' => $moduleName, 'url' => $url . "&type={$module}");
|
||||
}
|
||||
$labels[] = dropdown
|
||||
(
|
||||
btn
|
||||
(
|
||||
setClass('light-pale' . (isset($moreItems[$type]) ? ' primary' : '')),
|
||||
$lang->other,
|
||||
),
|
||||
set::items($moreItems)
|
||||
);
|
||||
|
||||
$items = array();
|
||||
foreach($results as $object)
|
||||
{
|
||||
@@ -117,12 +88,6 @@ form
|
||||
set::value($words),
|
||||
set::placeholder($lang->search->inputWords)
|
||||
),
|
||||
input
|
||||
(
|
||||
set::type('hidden'),
|
||||
set::name('type'),
|
||||
set::value($type)
|
||||
),
|
||||
span
|
||||
(
|
||||
setClass('input-group-btn'),
|
||||
@@ -134,6 +99,14 @@ form
|
||||
icon('close')
|
||||
)
|
||||
),
|
||||
picker
|
||||
(
|
||||
set::className('shadow-none border-l'),
|
||||
set::name('type[]'),
|
||||
set::value($type),
|
||||
set::items($lang->searchObjects),
|
||||
set::multiple(true)
|
||||
),
|
||||
span
|
||||
(
|
||||
setClass('input-group-btn border-l'),
|
||||
@@ -146,15 +119,11 @@ form
|
||||
)
|
||||
)
|
||||
);
|
||||
div
|
||||
(
|
||||
setClass('py-4'),
|
||||
$labels,
|
||||
);
|
||||
|
||||
panel
|
||||
(
|
||||
setID('searchResult'),
|
||||
setClass('shadow-none'),
|
||||
setClass('shadow-none mt-4'),
|
||||
set::title($lang->search->result . ' :'),
|
||||
set::titleClass('text-md font-normal'),
|
||||
set::titleProps(array('style' => array('line-height' => '22px'))),
|
||||
|
||||
Reference in New Issue
Block a user