From 398daa7e9f888212d892f2c3305ffa2ea430948b Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Fri, 10 Aug 2012 22:13:43 +0000 Subject: [PATCH] Correct Sidebar and renaming events for tags --- js/bookmarks.js | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/js/bookmarks.js b/js/bookmarks.js index 2bd330f8..754b227b 100644 --- a/js/bookmarks.js +++ b/js/bookmarks.js @@ -21,7 +21,7 @@ $(document).ready(function() { }).tagit('option', 'onTagAdded', filterTagsChanged); getBookmarks(); - if(init_sidebar == 'true') + if(init_sidebar != 'true') toggleSideBar(); bookmark_view = init_view; switchView(); @@ -41,7 +41,7 @@ var formatString = (function() { })(); function clickSideBar() { - $.post(OC.filePath('bookmarks', 'ajax', 'changescreen.php'), {sidebar: $('#leftcontent').is(':visible')}); + $.post(OC.filePath('bookmarks', 'ajax', 'changescreen.php'), {sidebar: $('.right_img').is(':visible')}); toggleSideBar(); } @@ -322,32 +322,39 @@ function hasProtocol(url) { function renameTag(event) { if($('input[name="tag_new_name"]').length) return; // Do nothing if a tag is currenlty edited tag_el = $(this).closest('li'); - tag_el.append(''); + tag_el.append('
'); + var form = tag_el.find('form'); tag_el.find('.tags_actions').hide(); tag_name = tag_el.find('.tag').hide().text(); - tag_el.find('input').val(tag_name).focus().bind('blur',submitTagName); - + tag_el.find('input').val(tag_name).focus().bind('blur',function() { + form.trigger('submit'); + }); + form.bind('submit',submitTagName); } function submitTagName(event) { + event.preventDefault(); tag_el = $(this).closest('li') new_tag_name = tag_el.find('input').val(); old_tag_name = tag_el.find('.tag').show().text(); tag_el.find('.tag_edit').show(); tag_el.find('.tags_actions').show(); - tag_el.find('input').remove(); + tag_el.find('input').unbind('blur'); + tag_el.find('form').unbind('submit').remove(); - //submit - $.ajax({ - type: 'POST', - url: OC.filePath('bookmarks', 'ajax', 'renameTag.php'), - data: { old_name: old_tag_name, new_name: new_tag_name}, - success: function(bookmarks){ - if (bookmarks.status =='success') { - filterTagsChanged(); + if(new_tag_name != old_tag_name && new_tag_name != '') { + //submit + $.ajax({ + type: 'POST', + url: OC.filePath('bookmarks', 'ajax', 'renameTag.php'), + data: { old_name: old_tag_name, new_name: new_tag_name}, + success: function(bookmarks){ + if (bookmarks.status =='success') { + filterTagsChanged(); + } } - } - }); + }); + } } function deleteTag(event){