diff --git a/admin/themes/default/js/tags.js b/admin/themes/default/js/tags.js index f1c03d7b3..8b915c8a0 100644 --- a/admin/themes/default/js/tags.js +++ b/admin/themes/default/js/tags.js @@ -142,7 +142,7 @@ function setupTagbox(tagBox) { }); tagBox.on('click', function() { - if (tagBox.hasClass('selection')) { + if ($('.tag-container').hasClass('selection')) { if (tagBox.attr('data-selected') == '1') { tagBox.attr('data-selected', '0'); } else { @@ -315,7 +315,7 @@ function duplicateTag(id, name) { /*------- Selection mode -------*/ -numberItemDisplayed = 5; +maxItemDisplayed = 5; $("#toggleSelectionMode").attr("checked", false) $("#toggleSelectionMode").click(function () { @@ -324,14 +324,14 @@ $("#toggleSelectionMode").click(function () { function selectionMode(isSelection) { if (isSelection) { - $(".in-selection-mode").show(); - $(".not-in-selection-mode").hide(); - $(".tag-box").addClass("selection"); + $(".in-selection-mode").addClass('show'); + $(".not-in-selection-mode").addClass('hide'); + $(".tag-container").addClass("selection"); $(".tag-box").removeClass('edit-name'); } else { - $(".in-selection-mode").removeAttr('style'); - $(".not-in-selection-mode").removeAttr('style'); - $(".tag-box").removeClass("selection"); + $(".in-selection-mode").removeClass('show'); + $(".not-in-selection-mode").removeClass('hide'); + $(".tag-container").removeClass("selection"); $(".tag-box").attr("data-selected", '0'); updateListItem(); } @@ -341,7 +341,6 @@ function updateListItem() { let nowSelected = []; let selected = []; - let shouldBeItem = []; let shouldNotBeItem = []; let names = {}; $('.tag-box[data-selected="1"]').each(function () { @@ -350,54 +349,60 @@ function updateListItem() { names[id] = $(this).find('.tag-name').html(); }); - $('.selection-mode-tag .tag-list div').each(function () { - let id = $(this).attr('data-id'); - selected.push(id); - }); + selected = $('.selection-mode-tag .tag-list').data('list'); + $('.selection-mode-tag .tag-list').attr('data-list', nowSelected); shouldNotBeItem = [...selected]; shouldNotBeItem = shouldNotBeItem.filter(x => !nowSelected.includes(x)); - shouldBeItem = [...nowSelected]; - shouldBeItem = shouldBeItem.filter(x => !selected.includes(x)); - selected = nowSelected; - - shouldBeItem.forEach(function(id) { - let newItemStructure = $('

'+names[id]+'

'); - $('.selection-mode-tag .tag-list').prepend(newItemStructure); - $('.selection-mode-tag .tag-list div[data-id='+id+'] a').on('click', function () { - $('.tag-box[data-id='+id+']').attr('data-selected', '0'); - updateListItem(); - }) - }) shouldNotBeItem.forEach(function(id) { $('.selection-mode-tag .tag-list div[data-id='+id+']').remove(); }) + + $('.selection-mode-tag .tag-list').html(''); + let i = 0; + while(i < nowSelected.length && $('.selection-mode-tag .tag-list div').length < maxItemDisplayed) { + let item = nowSelected[i++]; + let newItemStructure = $('

'+names[item]+'

'); + $('.selection-mode-tag .tag-list').prepend(newItemStructure); + $('.selection-mode-tag .tag-list div[data-id='+item+'] a').on('click', function () { + $('.tag-box[data-id='+item+']').attr('data-selected', '0'); + updateListItem(); + }); + } - $('#MergeOptionsChoices').html(''); - nowSelected.forEach(id => { - $('#MergeOptionsChoices').append( - $('') - ) - }) - - if (selected.length > 5) { + if (nowSelected.length > maxItemDisplayed) { $('.selection-other-tags').show(); - $('.selection-other-tags').html(str_and_others_tags.replace('%s', selected.length - 5)) + $('.selection-other-tags').html(str_and_others_tags.replace('%s', nowSelected.length - maxItemDisplayed)) } else { $('.selection-other-tags').hide(); } - - updateSelectionContent() } +function updateMergeItems () { + let ids = []; + let names = []; + $('.tag-box[data-selected="1"]').each(function () { + ids.push($(this).attr('data-id')); + names[$(this).attr('data-id')] = $(this).find('.tag-name').html(); + }) + + $('#MergeOptionsChoices').html(''); + ids.forEach(id => { + $('#MergeOptionsChoices').append( + $('') + ) + }) +} + mergeOption = false; function updateSelectionContent() { number = $('.tag-box[data-selected="1"]').length; if (number == 0) { + mergeOption = false; $('#nothing-selected').show(); $('.selection-mode-tag').hide(); $('#MergeOptionsBlock').hide(); @@ -408,10 +413,12 @@ function updateSelectionContent() { $('#MergeOptionsBlock').hide(); $('#MergeSelectionMode').addClass('unavailable'); } else if (number > 1) { + $('#nothing-selected').hide(); $('#MergeSelectionMode').removeClass('unavailable'); if (mergeOption) { $('#MergeOptionsBlock').show(); $('.selection-mode-tag').hide(); + updateMergeItems(); } else { $('#MergeOptionsBlock').hide(); $('.selection-mode-tag').show(); @@ -422,7 +429,7 @@ function updateSelectionContent() { $('#MergeSelectionMode').on('click', function() { mergeOption = true; - updateSelectionContent() + updateSelectionContent(); }); $('#CancelMerge').on('click', function() { @@ -585,6 +592,8 @@ function tagListToString(list) { Filter research -------*/ +var maxShown = 100; + $("#search-tag .search-input").on("input", function() { let text = $(this).val().toLowerCase(); var searchNumber = 0; @@ -607,6 +616,27 @@ $("#search-tag .search-input").on("input", function() { } else { $('.emptyResearch').hide(); } + hideLastTags(); +}); + +function hideLastTags () { + let tagBoxes = $('.tag-box:visible'); + if (tagBoxes.length > maxShown) { + for (let i = maxShown; i < tagBoxes.length; i++) { + $(tagBoxes[i]).hide(); + } + + str = str_others_tags_available.replace('%s', tagBoxes.length - maxShown); + + $('.moreTagMessage').html(str); + $('.moreTagMessage').show(); + } else { + $('.moreTagMessage').hide(); + } +} + +$(document).ready(function() { + hideLastTags(); }) /*------- diff --git a/admin/themes/default/template/group_list.tpl b/admin/themes/default/template/group_list.tpl index b9bfb375f..223b085e4 100644 --- a/admin/themes/default/template/group_list.tpl +++ b/admin/themes/default/template/group_list.tpl @@ -214,9 +214,10 @@ var rootUrl = '{$ROOT_URL}'

Showing 39 users out of 251

- -

Filter

- +
+ + +
diff --git a/admin/themes/default/template/plugins_installed.tpl b/admin/themes/default/template/plugins_installed.tpl index 18a08c8bb..356152ebb 100644 --- a/admin/themes/default/template/plugins_installed.tpl +++ b/admin/themes/default/template/plugins_installed.tpl @@ -189,8 +189,8 @@ jQuery(".pluginMiniBox").each(function(index){ {counter start=0 assign=i} {* *}
-

{'Filter'|@translate}

- + +
{'No plugins found'|@translate}
diff --git a/admin/themes/default/template/tags.tpl b/admin/themes/default/template/tags.tpl index 99672ac8a..1573cf538 100644 --- a/admin/themes/default/template/tags.tpl +++ b/admin/themes/default/template/tags.tpl @@ -17,6 +17,7 @@ var str_copy = '{' (copy)'|@translate}'; var str_other_copy = '{' (copy %s)'|@translate}'; var str_merged_into = '{'Tag(s) \{%s1\} succesfully merged into "%s2"'|@translate}'; var str_and_others_tags = '{'and %s others'|@translate}'; +var str_others_tags_available = '{'%s other tags available...'|@translate}' {/footer_script} {combine_script id='common' load='footer' path='admin/themes/default/js/common.js'} @@ -70,12 +71,12 @@ var str_and_others_tags = '{'and %s others'|@translate}';

{'Your selection'|@translate}

-
+
- +
@@ -94,8 +95,8 @@ var str_and_others_tags = '{'and %s others'|@translate}';
- - + +
@@ -132,6 +133,7 @@ var str_and_others_tags = '{'and %s others'|@translate}'; {/foreach}
{'No tag found'|@translate}
+