summaryrefslogtreecommitdiffstats
path: root/apps/bookmarks
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2011-08-25 12:55:13 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2011-08-25 12:55:13 +0200
commite0a69bbeaccf45ec6f407090d3dfc50bc4f04101 (patch)
tree174bcb885a7badf230c204acd8b4d160a842ecf5 /apps/bookmarks
parent55a8ee34bdf9e4a357f347ae5ab3320e50589a10 (diff)
downloadnextcloud-server-e0a69bbeaccf45ec6f407090d3dfc50bc4f04101.tar.gz
nextcloud-server-e0a69bbeaccf45ec6f407090d3dfc50bc4f04101.zip
Make bookmarks sortable by clicks
Diffstat (limited to 'apps/bookmarks')
-rw-r--r--apps/bookmarks/ajax/updateList.php9
-rw-r--r--apps/bookmarks/css/bookmarks.css21
-rw-r--r--apps/bookmarks/js/bookmarks.js19
-rw-r--r--apps/bookmarks/templates/list.php7
4 files changed, 53 insertions, 3 deletions
diff --git a/apps/bookmarks/ajax/updateList.php b/apps/bookmarks/ajax/updateList.php
index 9290757d0b1..61983cc0f5b 100644
--- a/apps/bookmarks/ajax/updateList.php
+++ b/apps/bookmarks/ajax/updateList.php
@@ -50,6 +50,13 @@ if($filterTag){
$offset = isset($_GET['page']) ? intval($_GET['page']) * 10 : 0;
$params[] = $offset;
+$sort = isset($_GET['sort']) ? ($_GET['sort']) : 'bookmarks_sorting_recent';
+if($sort == 'bookmarks_sorting_clicks') {
+ $sqlSort = 'clickcount DESC';
+} else {
+ $sqlSort = 'id DESC';
+}
+
if( $CONFIG_DBTYPE == 'sqlite' or $CONFIG_DBTYPE == 'sqlite3' ){
$_gc_separator = ', \' \'';
} else {
@@ -72,7 +79,7 @@ $query = OC_DB::prepare('
AND *PREFIX*bookmarks.user_id = ?
GROUP BY url
'.$sqlFilterTag.'
- ORDER BY *PREFIX*bookmarks.id DESC
+ ORDER BY *PREFIX*bookmarks.'.$sqlSort.'
LIMIT ?, 10');
$bookmarks = $query->execute($params)->fetchAll();
diff --git a/apps/bookmarks/css/bookmarks.css b/apps/bookmarks/css/bookmarks.css
index 0fa4a3b6b2d..96559172448 100644
--- a/apps/bookmarks/css/bookmarks.css
+++ b/apps/bookmarks/css/bookmarks.css
@@ -23,6 +23,21 @@
text-decoration: underline;
}
+.bookmarks_sorting {
+ float: left;
+ margin-left: 2em;
+}
+
+.bookmarks_sorting li {
+ padding: 1ex 1em;
+ border: 1px solid gray;
+ -moz-border-radius:1em; -webkit-border-radius:1em; border-radius:1em;
+}
+
+.bookmarks_sorting_active {
+ font-weight: bold;
+}
+
.bookmarks_add {
display: none;
}
@@ -64,4 +79,8 @@
.bookmark_tags {
color: #ff3333;
-} \ No newline at end of file
+}
+
+.clear {
+ clear:both;
+}
diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js
index ad3aefde204..93b21c3243e 100644
--- a/apps/bookmarks/js/bookmarks.js
+++ b/apps/bookmarks/js/bookmarks.js
@@ -1,6 +1,8 @@
var bookmarks_page = 0;
var bookmarks_loading = false;
+var bookmarks_sorting = 'bookmarks_sorting_recent';
+
$(document).ready(function() {
$('.bookmarks_addBtn').click(function(event){
$('.bookmarks_add').slideToggle();
@@ -10,6 +12,9 @@ $(document).ready(function() {
$(window).scroll(updateOnBottom);
$('#bookmark_add_url').focusout(getMetadata);
+ $('.' + bookmarks_sorting).addClass('bookmarks_sorting_active');
+
+ $('.bookmarks_sorting li').click(function(event){changeSorting(this)});
$('.bookmarks_list').empty();
getBookmarks();
@@ -20,9 +25,10 @@ function getBookmarks() {
//have patience :)
return;
}
+
$.ajax({
url: 'ajax/updateList.php',
- data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page,
+ data: 'tag=' + encodeURI($('#bookmarkFilterTag').val()) + '&page=' + bookmarks_page + '&sort=' + bookmarks_sorting,
success: function(bookmarks){
bookmarks_page += 1;
$('.bookmark_link').unbind('click', recordClick);
@@ -50,6 +56,17 @@ function getMetadata() {
});
}
+function changeSorting(sortEl) {
+ $('.' + bookmarks_sorting).removeClass('bookmarks_sorting_active');
+ bookmarks_sorting = sortEl.className;
+ $('.' + bookmarks_sorting).addClass('bookmarks_sorting_active');
+
+ $('.bookmarks_list').empty();
+ bookmarks_page = 0;
+ bookmarks_loading = false;
+ getBookmarks();
+}
+
function addBookmark(event) {
var url = encodeEntities($('#bookmark_add_url').val())
var title = encodeEntities($('#bookmark_add_title').val())
diff --git a/apps/bookmarks/templates/list.php b/apps/bookmarks/templates/list.php
index 203b48e1cb6..a2c89b310a2 100644
--- a/apps/bookmarks/templates/list.php
+++ b/apps/bookmarks/templates/list.php
@@ -12,6 +12,13 @@
<p><label class="bookmarks_label"> </label><label class="bookmarks_hint">Hint: Use space to separate tags.</label></p>
<p><label class="bookmarks_label"></label><input type="submit" id="bookmark_add_submit" /></p>
</div>
+<div class="bookmarks_sorting pager">
+ <ul>
+ <li class="bookmarks_sorting_recent">Recent Bookmarks</li>
+ <li class="bookmarks_sorting_clicks">Most clicks</li>
+ </ul>
+</div>
+<div class="clear"></div>
<div class="bookmarks_list">
<noscript>
JavaScript is needed to display your Bookmarks