NEW Link "add to bookmark" always on top in the bookmark popup

This commit is contained in:
Laurent Destailleur 2022-09-02 11:27:16 +02:00
parent c9a2dea3d8
commit d17f0c57e2
4 changed files with 22 additions and 16 deletions

View File

@ -64,11 +64,6 @@ function printDropdownBookmarksList()
$searchForm .= '<form id="top-menu-action-bookmark" name="actionbookmark" method="POST" action=""'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' onsubmit="return false"' : '').'>'; $searchForm .= '<form id="top-menu-action-bookmark" name="actionbookmark" method="POST" action=""'.(empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) ? ' onsubmit="return false"' : '').'>';
$searchForm .= '<input type="hidden" name="token" value="'.newToken().'">'; $searchForm .= '<input type="hidden" name="token" value="'.newToken().'">';
// Url to list bookmark
$listbtn = '<a class="top-menu-dropdown-link" title="'.dol_escape_htmltag($langs->trans('Bookmarks')).'" href="'.DOL_URL_ROOT.'/bookmarks/list.php">';
$listbtn .= img_picto('', 'bookmark', 'class="paddingright"').$langs->trans('Bookmarks').'</a>';
// Url to go on create new bookmark page // Url to go on create new bookmark page
$newbtn = ''; $newbtn = '';
if (!empty($user->rights->bookmark->creer)) { if (!empty($user->rights->bookmark->creer)) {
@ -80,6 +75,10 @@ function printDropdownBookmarksList()
} }
} }
// Url to list/edit bookmark
$listbtn = '<a class="top-menu-dropdown-link" title="'.dol_escape_htmltag($langs->trans('Bookmarks')).'" href="'.DOL_URL_ROOT.'/bookmarks/list.php">';
$listbtn .= img_picto('', 'edit', 'class="paddingright opacitymedium"').$langs->trans('EditBookmarks').'</a>';
// Menu with list of bookmarks // Menu with list of bookmarks
$sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark"; $sql = "SELECT rowid, title, url, target FROM ".MAIN_DB_PREFIX."bookmark";
$sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)"; $sql .= " WHERE (fk_user = ".((int) $user->id)." OR fk_user is NULL OR fk_user = 0)";
@ -171,27 +170,28 @@ function printDropdownBookmarksList()
'; ';
$html .= ' $html .= '
<!-- Menu Body --> <!-- Menu bookmark tools-->
<div class="bookmark-body dropdown-body">
'.$bookmarkList.'
</div>
';
$html .= '
<!-- Menu Footer-->
<div class="bookmark-footer"> <div class="bookmark-footer">
'.$newbtn.$listbtn.' '.$newbtn.$listbtn.'
<div style="clear:both;"></div> <div style="clear:both;"></div>
</div> </div>
'; ';
$html .= '
<!-- Menu Body -->
<div class="bookmark-body dropdown-body">
'.$bookmarkList.'
<span id="top-bookmark-search-nothing-found" class="hidden-search-result opacitymedium">'.dol_escape_htmltag($langs->trans("NoBookmarkFound")).'</span>
</div>
';
$html .= '<!-- script to open/close the popup --> $html .= '<!-- script to open/close the popup -->
<script> <script>
$( document ).on("keyup", "#top-bookmark-search-input", function () { $( document ).on("keyup", "#top-bookmark-search-input", function () {
console.log("keyup in bookmark search input");
var filter = $(this).val(), count = 0; var filter = $(this).val(), count = 0;
$("#dropdown-bookmarks-list .bookmark-item").each(function () { $("#dropdown-bookmarks-list .bookmark-item").each(function () {
if ($(this).text().search(new RegExp(filter, "i")) < 0) { if ($(this).text().search(new RegExp(filter, "i")) < 0) {
$(this).addClass("hidden-search-result"); $(this).addClass("hidden-search-result");
} else { } else {
@ -200,6 +200,11 @@ function printDropdownBookmarksList()
} }
}); });
$("#top-bookmark-search-filter-count").text(count); $("#top-bookmark-search-filter-count").text(count);
if (count == 0) {
jQuery("#top-bookmark-search-nothing-found").removeClass("hidden-search-result");
} else {
jQuery("#top-bookmark-search-nothing-found").addClass("hidden-search-result");
}
}); });
</script>'; </script>';
} }

View File

@ -20,3 +20,4 @@ ChooseIfANewWindowMustBeOpenedOnClickOnBookmark=Choose if the linked page should
BookmarksManagement=Bookmarks management BookmarksManagement=Bookmarks management
BookmarksMenuShortCut=Ctrl + shift + m BookmarksMenuShortCut=Ctrl + shift + m
NoBookmarks=No bookmarks defined NoBookmarks=No bookmarks defined
NoBookmarkFound=No bookmark found

View File

@ -257,7 +257,7 @@ a.top-menu-dropdown-link {
.dropdown-menu > .user-body, .dropdown-body { .dropdown-menu > .user-body, .dropdown-body {
padding: 15px; padding: 15px;
border-bottom: 1px solid #f4f4f4; border-bottom: 1px solid #f4f4f4;
border-top: 1px solid #dddddd; border-top: 1px solid #f0f0f0;
white-space: normal; white-space: normal;
} }

View File

@ -260,7 +260,7 @@ a.top-menu-dropdown-link {
.dropdown-menu > .user-body, .dropdown-body{ .dropdown-menu > .user-body, .dropdown-body{
padding: 15px; padding: 15px;
border-bottom: 1px solid #f4f4f4; border-bottom: 1px solid #f4f4f4;
border-top: 1px solid #dddddd; border-top: 1px solid #f0f0f0;
white-space: normal; white-space: normal;
} }