diff options
Diffstat (limited to 'apps/bookmarks/js/bookmarks.js')
-rw-r--r-- | apps/bookmarks/js/bookmarks.js | 84 |
1 files changed, 24 insertions, 60 deletions
diff --git a/apps/bookmarks/js/bookmarks.js b/apps/bookmarks/js/bookmarks.js index fadbbd5513a..7317a154a76 100644 --- a/apps/bookmarks/js/bookmarks.js +++ b/apps/bookmarks/js/bookmarks.js @@ -3,19 +3,12 @@ var bookmarks_loading = false; var bookmarks_sorting = 'bookmarks_sorting_recent'; -$(document).ready(function() { - $('.bookmarks_addBtn').click(function(event){ - $('.bookmarks_add').slideToggle(); - }); - +$(document).ready(function() { $('#bookmark_add_submit').click(addOrEditBookmark); $(window).scroll(updateOnBottom); - $('#bookmark_add_url').focusout(getMetadata); - $('.bookmarks_list').empty(); getBookmarks(); - }); function getBookmarks() { @@ -35,6 +28,10 @@ function getBookmarks() { for(var i in bookmarks.data) { updateBookmarksList(bookmarks.data[i]); + $("#firstrun").hide(); + } + if($('.bookmarks_list').is(':empty')) { + $("#firstrun").show(); } $('.bookmark_link').click(recordClick); @@ -46,20 +43,6 @@ function getBookmarks() { }); } -function getMetadata() { - var url = encodeEntities($('#bookmark_add_url').val()); - $('.loading_meta').css('display','inline'); - $.ajax({ - url: 'ajax/getMeta.php', - data: 'url=' + encodeURIComponent(url), - success: function(pageinfo){ - $('#bookmark_add_url').val(pageinfo.data.url); - $('#bookmark_add_title').val(pageinfo.data.title); - $('.loading_meta').css('display','none'); - } - }); -} - // function addBookmark() { // Instead of creating editBookmark() function, Converted the one above to // addOrEditBookmark() to make .js file more compact. @@ -69,35 +52,17 @@ function addOrEditBookmark(event) { var url = encodeEntities($('#bookmark_add_url').val()); var title = encodeEntities($('#bookmark_add_title').val()); var tags = encodeEntities($('#bookmark_add_tags').val()); - var taglist = tags.split(' '); - var tagshtml = ''; - for ( var i=0, len=taglist.length; i<len; ++i ){ - tagshtml += '<a class="bookmark_tag" href="?tag=' + encodeURI(taglist[i]) + '">' + taglist[i] + '</a> '; - } + $("#firstrun").hide(); if (id == 0) { $.ajax({ url: 'ajax/addBookmark.php', data: 'url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags), success: function(response){ - var bookmark_id = response.data; - $('.bookmarks_add').slideToggle(); - $('.bookmarks_add').children('p').children('.bookmarks_input').val(''); - $('.bookmarks_list').prepend( - '<div class="bookmark_single" data-id="' + bookmark_id + '" >' + - '<p class="bookmark_actions">' + - '<span class="bookmark_delete">' + - '<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' + - '</span> ' + - '<span class="bookmark_edit">' + - '<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' + - '</span>' + - '</p>' + - '<p class="bookmark_title"><a href="' + url + '" target="_blank" class="bookmark_link">' + title + '</a></p>' + - '<p class="bookmark_tags">' + tagshtml + '</p>' + - '<p class="bookmark_url">' + url + '</p>' + - '</div>' - ); + $('.bookmarks_input').val(''); + $('.bookmarks_list').empty(); + bookmarks_page = 0; + getBookmarks(); } }); } @@ -106,18 +71,11 @@ function addOrEditBookmark(event) { url: 'ajax/editBookmark.php', data: 'id=' + id + '&url=' + encodeURI(url) + '&title=' + encodeURI(title) + '&tags=' + encodeURI(tags), success: function(){ - $('.bookmarks_add').slideToggle(); - $('.bookmarks_add').children('p').children('.bookmarks_input').val(''); + $('.bookmarks_input').val(''); $('#bookmark_add_id').val('0'); - - var record = $('.bookmark_single[data-id = "' + id + '"]'); - record.children('.bookmark_url:first').text(url); - - var record_title = record.children('.bookmark_title:first').children('a:first'); - record_title.attr('href', url); - record_title.text(title); - - record.children('.bookmark_tags:first').html(tagshtml); + $('.bookmarks_list').empty(); + bookmarks_page = 0; + getBookmarks(); } }); } @@ -129,7 +87,12 @@ function delBookmark(event) { $.ajax({ url: 'ajax/delBookmark.php', data: 'url=' + encodeURI($(this).parent().parent().children('.bookmark_url:first').text()), - success: function(data){ record.animate({ opacity: 'hide' }, 'fast'); } + success: function(data){ + record.remove(); + if($('.bookmarks_list').is(':empty')) { + $("#firstrun").show(); + } + } }); } @@ -159,15 +122,16 @@ function updateBookmarksList(bookmark) { if(!hasProtocol(bookmark.url)) { bookmark.url = 'http://' + bookmark.url; } + if(bookmark.title == '') bookmark.title = bookmark.url; $('.bookmarks_list').append( '<div class="bookmark_single" data-id="' + bookmark.id +'" >' + '<p class="bookmark_actions">' + - '<span class="bookmark_delete">' + - '<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' + - '</span> ' + '<span class="bookmark_edit">' + '<img class="svg" src="'+OC.imagePath('core', 'actions/rename')+'" title="Edit">' + '</span>' + + '<span class="bookmark_delete">' + + '<img class="svg" src="'+OC.imagePath('core', 'actions/delete')+'" title="Delete">' + + '</span> ' + '</p>' + '<p class="bookmark_title">'+ '<a href="' + encodeEntities(bookmark.url) + '" target="_blank" class="bookmark_link">' + encodeEntities(bookmark.title) + '</a>' + |