|
|
|
@ -13,16 +13,42 @@ define('categorySearch', function () {
|
|
|
|
|
}
|
|
|
|
|
var categoryEls = el.find('[component="category/list"] [data-cid]');
|
|
|
|
|
el.on('show.bs.dropdown', function () {
|
|
|
|
|
function revealParents(cid) {
|
|
|
|
|
var parentCid = el.find('[component="category/list"] [data-cid="' + cid + '"]').attr('data-parentCid');
|
|
|
|
|
if (parentCid) {
|
|
|
|
|
el.find('[component="category/list"] [data-cid="' + parentCid + '"]').removeClass('hidden');
|
|
|
|
|
revealParents(parentCid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function revealChildren(cid) {
|
|
|
|
|
var els = el.find('[component="category/list"] [data-parentCid="' + cid + '"]');
|
|
|
|
|
els.each(function (index, el) {
|
|
|
|
|
var $el = $(el);
|
|
|
|
|
$el.removeClass('hidden');
|
|
|
|
|
revealChildren($el.attr('data-cid'));
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateList() {
|
|
|
|
|
var val = searchEl.find('input').val().toLowerCase();
|
|
|
|
|
var noMatch = true;
|
|
|
|
|
var cids = [];
|
|
|
|
|
categoryEls.each(function () {
|
|
|
|
|
var liEl = $(this);
|
|
|
|
|
var isMatch = liEl.attr('data-name').toLowerCase().indexOf(val) !== -1;
|
|
|
|
|
if (noMatch && isMatch) {
|
|
|
|
|
noMatch = false;
|
|
|
|
|
}
|
|
|
|
|
liEl.toggleClass('hidden', !isMatch);
|
|
|
|
|
if (isMatch && val) {
|
|
|
|
|
cids.push(liEl.attr('data-cid'));
|
|
|
|
|
}
|
|
|
|
|
liEl.toggleClass('hidden', !isMatch).find('[component="category-markup"]').css({ 'font-weight': val && isMatch ? 'bold' : 'normal' });
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
cids.forEach(function (cid) {
|
|
|
|
|
revealParents(cid);
|
|
|
|
|
revealChildren(cid);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
el.find('[component="category/list"] [component="category/no-matches"]').toggleClass('hidden', !noMatch);
|
|
|
|
|