笔记本数量, contextmenu

This commit is contained in:
life
2015-03-01 23:03:21 +08:00
parent 1f03f3b710
commit e00a35a845
12 changed files with 54 additions and 19 deletions

1
node_modules/note.js generated vendored
View File

@@ -1356,6 +1356,7 @@ var Note = {
},
// 彻底删除笔记时调用
updateTagCount: function(tags) {
var me = this;
if(!tags) {
return;
}

4
node_modules/tag.js generated vendored
View File

@@ -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) {

2
node_modules/web.js generated vendored
View File

@@ -81,7 +81,7 @@ var Web = {
// TODO test
updateTagCount: function(tag) {
var me = this;
me.Tag.updateTagCount(tag);
// me.Tag.updateTagCount(tag);
},
//

View File

@@ -1467,6 +1467,7 @@ top: 4px;
}
.tag-delete {
display: none;
margin-left: 3px;
font-size: 12px;
}
li:hover {

View File

@@ -1328,6 +1328,7 @@ h3 {
}
#tagNav .tag-delete {
display: none;
margin-left: 3px;
font-size: 12px;
}
#tagNav li:hover .tag-delete {

View File

@@ -1328,6 +1328,7 @@ h3 {
}
#tagNav .tag-delete {
display: none;
margin-left: 3px;
font-size: 12px;
}
#tagNav li:hover .tag-delete {

View File

@@ -1328,6 +1328,7 @@ h3 {
}
#tagNav .tag-delete {
display: none;
margin-left: 3px;
font-size: 12px;
}
#tagNav li:hover .tag-delete {

View File

@@ -1328,6 +1328,7 @@ h3 {
}
#tagNav .tag-delete {
display: none;
margin-left: 3px;
font-size: 12px;
}
#tagNav li:hover .tag-delete {

View File

@@ -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);

View File

@@ -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 }
],

View File

@@ -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();

View File

@@ -261,7 +261,8 @@ Tag.renderTagNav = function(tags) {
}
*/
var classes = Tag.classes[tag] || "label label-default";
$("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">? <em>(?)</em></span> <i class="tag-delete">X</i></li>', tag, classes, text, noteTag.Count));
// 笔记数量先隐藏, 不准确
$("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">? <em style="display: none">(?)</em></span> <i class="tag-delete">X</i></li>', tag, classes, text, noteTag.Count));
}
};