diff --git a/node_modules/note.js b/node_modules/note.js index b5cd910b..7d551c67 100644 --- a/node_modules/note.js +++ b/node_modules/note.js @@ -1356,6 +1356,7 @@ var Note = { }, // 彻底删除笔记时调用 updateTagCount: function(tags) { + var me = this; if(!tags) { return; } diff --git a/node_modules/tag.js b/node_modules/tag.js index 502ae672..8a5bd74d 100644 --- a/node_modules/tag.js +++ b/node_modules/tag.js @@ -82,9 +82,9 @@ var Tag = { updateTagCount: function(title, count) { userId = User.getCurActiveUserId(); // 更新Tag's Count - Tags.update({UserId: userId, Tag: title}, {$set: {Count: cnt}}); + Tags.update({UserId: userId, Tag: title}, {$set: {Count: count}}); // 更新web - Web.updateTagCount({Tag: title, Count: cnt}); + Web.updateTagCount({Tag: title, Count: count}); }, getTag: function(title, callback) { diff --git a/node_modules/web.js b/node_modules/web.js index 95a97d39..36f7d7a3 100644 --- a/node_modules/web.js +++ b/node_modules/web.js @@ -81,7 +81,7 @@ var Web = { // TODO test updateTagCount: function(tag) { var me = this; - me.Tag.updateTagCount(tag); + // me.Tag.updateTagCount(tag); }, // diff --git a/public/css/theme/basic.less b/public/css/theme/basic.less index 5f1e41c7..eac6fbab 100644 --- a/public/css/theme/basic.less +++ b/public/css/theme/basic.less @@ -1467,6 +1467,7 @@ top: 4px; } .tag-delete { display: none; + margin-left: 3px; font-size: 12px; } li:hover { diff --git a/public/css/theme/default.css b/public/css/theme/default.css index 9b2374fa..6b96d014 100644 --- a/public/css/theme/default.css +++ b/public/css/theme/default.css @@ -1328,6 +1328,7 @@ h3 { } #tagNav .tag-delete { display: none; + margin-left: 3px; font-size: 12px; } #tagNav li:hover .tag-delete { diff --git a/public/css/theme/simple.css b/public/css/theme/simple.css index 83dbe73f..4ccb34b4 100644 --- a/public/css/theme/simple.css +++ b/public/css/theme/simple.css @@ -1328,6 +1328,7 @@ h3 { } #tagNav .tag-delete { display: none; + margin-left: 3px; font-size: 12px; } #tagNav li:hover .tag-delete { diff --git a/public/css/theme/writting-overwrite.css b/public/css/theme/writting-overwrite.css index bacafdc7..f39981fc 100644 --- a/public/css/theme/writting-overwrite.css +++ b/public/css/theme/writting-overwrite.css @@ -1328,6 +1328,7 @@ h3 { } #tagNav .tag-delete { display: none; + margin-left: 3px; font-size: 12px; } #tagNav li:hover .tag-delete { diff --git a/public/css/theme/writting.css b/public/css/theme/writting.css index be5f3cfb..215dc3c0 100644 --- a/public/css/theme/writting.css +++ b/public/css/theme/writting.css @@ -1328,6 +1328,7 @@ h3 { } #tagNav .tag-delete { display: none; + margin-left: 3px; font-size: 12px; } #tagNav li:hover .tag-delete { diff --git a/public/js/app/note.js b/public/js/app/note.js index 42a49d9e..4c9bb00f 100644 --- a/public/js/app/note.js +++ b/public/js/app/note.js @@ -102,7 +102,7 @@ Note.clearCacheByNotebookId = function(notebookId) { Note.notebookHasNotes = function(notebookId) { var notes = Note.getNotesByNotebookId(notebookId); return !isEmpty(notes); -} +}; // 得到notebook下的notes, 按什么排序 updatedTime? Note.getNotesByNotebookId = function(notebookId, sortBy, isAsc) { @@ -1201,6 +1201,18 @@ Note.deleteNote = function(target, contextmenuItem, isShared) { Notebook.minusNotebookNumberNotes(note.NotebookId); } + if(note.IsNew) { + Note.changeToNext(target); + $(target).remove(); + // 删除缓存 + if(note) { + Note.clearCacheByNotebookId(note.NotebookId); + delete Note.cache[noteId]; + } + + return; + } + serverFunc.call(NoteService, noteId, function(ret) { if(ret) { Note.changeToNext(target); diff --git a/public/js/app/notebook.js b/public/js/app/notebook.js index cb261af3..ac9b1ffa 100644 --- a/public/js/app/notebook.js +++ b/public/js/app/notebook.js @@ -39,8 +39,24 @@ Notebook._updateNotebookNumberNotes = function(notebookId, n) { if(notebook.NumberNotes < 0) { notebook.NumberNotes = 0; } - $("#numberNotes_" + notebookId).html(notebook.NumberNotes); + + // 得到笔记本下笔记的数量, v2, 重新统计 + var notes = Note.getNotesByNotebookId(notebookId); + var cnt = notes ? notes.length : 0; + + if(!cnt) { + $("#numberNotes_" + notebookId).html(notebook.NumberNotes); + } else { + if(n == -1) { + cnt += n; + } + if(cnt < 0) { + cnt = 0; + } + $("#numberNotes_" + notebookId).html(cnt); + } }; + // addNote, copyNote, moveNote Notebook.incrNotebookNumberNotes = function(notebookId) { var self = this; @@ -712,7 +728,7 @@ Notebook.hideNoteAndEditorLoading = function() { // called by Note Notebook.isCurNotebook = function(notebookId) { return $(tt('#notebookList [notebookId="?"], #shareNotebooks [notebookId="?"]', notebookId, notebookId)).attr("class") == "active"; -} +}; // 改变nav, 为了新建note // called by Note @@ -953,12 +969,12 @@ $(function() { var notebookListMenu = { width: 180, items: [ - { text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo}, - { type: "splitLine" }, - { text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Notebook.setNotebook2Blog }, - { text: getMsg("cancelPublic"), alias: 'unset2Blog',faIcon: "fa-undo", action: Notebook.setNotebook2Blog }, // Unset - { type: "splitLine" }, - { text: getMsg("addChildNotebook"), faIcon: "fa-sitemap", action: Notebook.addChildNotebook }, + // { text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo}, + // { type: "splitLine" }, + // { text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Notebook.setNotebook2Blog }, + // { text: getMsg("cancelPublic"), alias: 'unset2Blog',faIcon: "fa-undo", action: Notebook.setNotebook2Blog }, // Unset + // { type: "splitLine" }, + { text: 'Add sub notebook', faIcon: "fa-sitemap", action: Notebook.addChildNotebook }, { text: getMsg("rename"), faIcon: "fa-pencil", action: Notebook.updateNotebookTitle }, { text: getMsg("delete"), icon: "", alias: 'delete', faIcon: "fa-trash-o", action: Notebook.deleteNotebook } ], @@ -972,11 +988,11 @@ $(function() { var notebookListMenu2 = { width: 180, items: [ - { text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo}, - { type: "splitLine" }, - { text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Notebook.setNotebook2Blog }, - { text: getMsg("cancelPublic"), alias: 'unset2Blog',faIcon: "fa-undo", action: Notebook.setNotebook2Blog }, // Unset - { type: "splitLine" }, + // { text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo}, + // { type: "splitLine" }, + // { text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Notebook.setNotebook2Blog }, + // { text: getMsg("cancelPublic"), alias: 'unset2Blog',faIcon: "fa-undo", action: Notebook.setNotebook2Blog }, // Unset + // { type: "splitLine" }, { text: getMsg("rename"), icon: "", action: Notebook.updateNotebookTitle }, { text: getMsg("delete"), icon: "", alias: 'delete', faIcon: "fa-trash-o", action: Notebook.deleteNotebook } ], diff --git a/public/js/app/service.js b/public/js/app/service.js index d8c4a1c4..8dd71a0a 100644 --- a/public/js/app/service.js +++ b/public/js/app/service.js @@ -51,7 +51,7 @@ Service.dispatch = function(router, param, callback) { */ // 右键菜单 -$(document).on('contextmenu', function (e) { +$('#noteTitle, #searchNoteInput, #searchNotebookForList, #addTagInput, #wmd-input, #editorContent').on('contextmenu', function (e) { e.preventDefault(); var $target = $(e.target); // var selectionType = window.getSelection().type.toUpperCase(); diff --git a/public/js/app/tag.js b/public/js/app/tag.js index 6d3204be..1c018392 100644 --- a/public/js/app/tag.js +++ b/public/js/app/tag.js @@ -261,7 +261,8 @@ Tag.renderTagNav = function(tags) { } */ var classes = Tag.classes[tag] || "label label-default"; - $("#tagNav").append(tt('