File diff suppressed because one or more lines are too long
2
public/js/app/note-min.js
vendored
2
public/js/app/note-min.js
vendored
File diff suppressed because one or more lines are too long
@ -14,15 +14,15 @@ Note.interval = ""; // 定时器
|
||||
Note.itemIsBlog = '<div class="item-blog"><i class="fa fa-bold" title="blog"></i></div><div class="item-setting"><i class="fa fa-cog" title="setting"></i></div>';
|
||||
// for render
|
||||
Note.itemTplNoImg = '<li href="#" class="item ?" noteId="?">'
|
||||
Note.itemTplNoImg += Note.itemIsBlog +'<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
Note.itemTplNoImg += Note.itemIsBlog +'<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
|
||||
// 有image
|
||||
Note.itemTpl = '<li href="#" class="item ? item-image" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>'
|
||||
Note.itemTpl +=Note.itemIsBlog + '<div class="item-desc" style=""><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
Note.itemTpl +=Note.itemIsBlog + '<div class="item-desc" style=""><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
|
||||
// for new
|
||||
Note.newItemTpl = '<li href="#" class="item item-active ?" fromUserId="?" noteId="?">'
|
||||
Note.newItemTpl += Note.itemIsBlog + '<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></li>';
|
||||
Note.newItemTpl += Note.itemIsBlog + '<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-clock-o"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></li>';
|
||||
|
||||
Note.noteItemListO = $("#noteItemList");
|
||||
|
||||
@ -178,10 +178,9 @@ Note.renderNotesAndFirstOneContent = function(ret) {
|
||||
Note.renderNotes(ret);
|
||||
// 渲染第一个
|
||||
if(!isEmpty(ret[0])) {
|
||||
Note.changeNote(ret[0].NoteId);
|
||||
Note.changeNoteForPjax(ret[0].NoteId, true, false);
|
||||
} else {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 当前的note是否改变过了?
|
||||
@ -255,10 +254,12 @@ Note.curHasChanged = function(force) {
|
||||
// 从html中得到...
|
||||
var c = preview || content;
|
||||
|
||||
hasChanged.Desc = Note.genDesc(c);
|
||||
hasChanged.ImgSrc = Note.getImgSrc(c);
|
||||
hasChanged.Abstract = Note.genAbstract(c);
|
||||
|
||||
// 不是博客或没有自定义设置的
|
||||
if(!cacheNote.HasSelfDefined || !cacheNote.IsBlog) {
|
||||
hasChanged.Desc = Note.genDesc(c);
|
||||
hasChanged.ImgSrc = Note.getImgSrc(c);
|
||||
hasChanged.Abstract = Note.genAbstract(c);
|
||||
}
|
||||
} else {
|
||||
log("text相同");
|
||||
log(cacheNote.Content == content);
|
||||
@ -315,6 +316,9 @@ Note.genDesc = function(content) {
|
||||
|
||||
// 得到摘要
|
||||
Note.genAbstract = function(content, len) {
|
||||
if(!content) {
|
||||
return "";
|
||||
}
|
||||
if(len == undefined) {
|
||||
len = 1000;
|
||||
}
|
||||
@ -392,11 +396,14 @@ Note.curChangedSaveIt = function(force) {
|
||||
|
||||
// 保存之
|
||||
showMsg(getMsg("saving"));
|
||||
ajaxPost("/note/UpdateNoteOrContent", hasChanged, function(ret) {
|
||||
ajaxPost("/note/updateNoteOrContent", hasChanged, function(ret) {
|
||||
if(hasChanged.IsNew) {
|
||||
// 缓存之, 后台得到其它信息
|
||||
ret.IsNew = false;
|
||||
Note.setNoteCache(ret, false);
|
||||
|
||||
// 新建笔记也要change history
|
||||
Pjax.changeNote(ret);
|
||||
}
|
||||
showMsg(getMsg("saveSuccess"), 1000);
|
||||
});
|
||||
@ -418,14 +425,93 @@ Note.selectTarget = function(target) {
|
||||
// 2. ajax得到现在的note
|
||||
Note.showContentLoading = function() {
|
||||
$("#noteMaskForLoading").css("z-index", 99999);
|
||||
}
|
||||
};
|
||||
Note.hideContentLoading = function() {
|
||||
$("#noteMaskForLoading").css("z-index", -1);
|
||||
}
|
||||
};
|
||||
|
||||
Note.directToNote = function(noteId) {
|
||||
var $p = $("#noteItemList");
|
||||
var pHeight = $p.height();
|
||||
// 相对于父亲的位置
|
||||
var pTop = $("[noteId='" + noteId + "']").position().top;
|
||||
var scrollTop = $p.scrollTop();
|
||||
pTop += scrollTop;
|
||||
/*
|
||||
log("..");
|
||||
log(noteId);
|
||||
log(pTop + ' ' + pHeight + ' ' + scrollTop);
|
||||
*/
|
||||
|
||||
// 当前的可视范围的元素位置是[scrollTop, pHeight + scrollTop]
|
||||
if(pTop >= scrollTop && pTop <= pHeight + scrollTop) {
|
||||
} else {
|
||||
var top = pTop;
|
||||
log("定位到特定note, 在可视范围内");
|
||||
// 手机不用slimScroll
|
||||
if(!LEA.isMobile && !Mobile.isMobile()) {
|
||||
$("#noteItemList").scrollTop(top);
|
||||
$("#noteItemList").slimScroll({ scrollTo: top + 'px', height: "100%", onlyScrollBar: true});
|
||||
} else {
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// mustPush表示是否将状态push到state中, 默认为true
|
||||
// 什么时候为false, 在popstate时
|
||||
// needTargetNobook默认为false, 在点击notebook, renderfirst时为false
|
||||
Note.changeNoteForPjax = function(noteId, mustPush, needTargetNotebook) {
|
||||
var me = this;
|
||||
var note = me.getNote(noteId);
|
||||
if(!note) {
|
||||
return;
|
||||
}
|
||||
var isShare = note.Perm != undefined;
|
||||
if(needTargetNotebook == undefined) {
|
||||
needTargetNotebook = true;
|
||||
}
|
||||
me.changeNote(noteId, isShare, true, function(note) {
|
||||
// push state
|
||||
if(mustPush == undefined) {
|
||||
mustPush = true;
|
||||
}
|
||||
if(mustPush) {
|
||||
Pjax.changeNote(note);
|
||||
}
|
||||
|
||||
// popstate时虽然选中了note, 但位置可能不可见
|
||||
if(needTargetNotebook) {
|
||||
Note.directToNote(noteId);
|
||||
}
|
||||
});
|
||||
|
||||
// 第一次render时定位到第一个笔记的notebook 12.06 life
|
||||
// 或通过pop时
|
||||
// 什么时候需要? 1. 第一次changeNote, 2. pop时, 只有当点击了notebook后才不要
|
||||
|
||||
// 这里, 万一是共享笔记呢?
|
||||
// 切换到共享中
|
||||
if(needTargetNotebook) {
|
||||
if(isShare) {
|
||||
if($("#myShareNotebooks").hasClass("closed")) {
|
||||
$("#myShareNotebooks .folderHeader").trigger("click");
|
||||
}
|
||||
} else {
|
||||
if($("#myNotebooks").hasClass("closed")) {
|
||||
$("#myNotebooks .folderHeader").trigger("click");
|
||||
}
|
||||
}
|
||||
// 如果是子笔记本, 那么要展开父笔记本
|
||||
Notebook.expandNotebookTo(note.NotebookId);
|
||||
}
|
||||
};
|
||||
|
||||
// 点击notebook时调用, 渲染第一个笔记
|
||||
Note.contentAjax = null;
|
||||
Note.contentAjaxSeq = 1;
|
||||
Note.changeNote = function(selectNoteId, isShare, needSaveChanged) {
|
||||
Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
|
||||
var self = this;
|
||||
|
||||
// -1 停止定时器
|
||||
Note.stopInterval();
|
||||
|
||||
@ -486,6 +572,8 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged) {
|
||||
Note.renderNoteContentReadOnly(ret);
|
||||
}
|
||||
self.hideContentLoading();
|
||||
|
||||
callback && callback(ret);
|
||||
}
|
||||
|
||||
if(cacheNote.Content) {
|
||||
@ -493,10 +581,10 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged) {
|
||||
return;
|
||||
}
|
||||
|
||||
var url = "/note/GetNoteContent";
|
||||
var url = "/note/getNoteContent";
|
||||
var param = {noteId: selectNoteId};
|
||||
if(isShare) {
|
||||
url = "/share/GetShareNoteContent";
|
||||
url = "/share/getShareNoteContent";
|
||||
param.sharedUserId = cacheNote.UserId // 谁的笔记
|
||||
}
|
||||
|
||||
@ -891,7 +979,7 @@ Note.deleteNote = function(target, contextmenuItem, isShared) {
|
||||
// 显示共享信息
|
||||
Note.listNoteShareUserInfo = function(target) {
|
||||
var noteId = $(target).attr("noteId");
|
||||
showDialogRemote("share/listNoteShareUserInfo", {noteId: noteId});
|
||||
showDialogRemote("/share/listNoteShareUserInfo", {noteId: noteId});
|
||||
}
|
||||
|
||||
// 共享笔记
|
||||
@ -918,7 +1006,7 @@ Note.listNoteContentHistories = function() {
|
||||
options.show = true;
|
||||
$("#leanoteDialog").modal(options);
|
||||
|
||||
ajaxGet("noteContentHistory/listHistories", {noteId: Note.curNoteId}, function(re) {
|
||||
ajaxGet("/noteContentHistory/listHistories", {noteId: Note.curNoteId}, function(re) {
|
||||
if(!isArray(re)) {$content.html(getMsg("noHistories")); return}
|
||||
// 组装成一个tab
|
||||
var str = "<p>" + getMsg("historiesNum") + '</p><div id="historyList"><table class="table table-hover">';
|
||||
@ -1587,7 +1675,8 @@ $(function() {
|
||||
}
|
||||
// 当前的和所选的是一个, 不改变
|
||||
if(Note.curNoteId != noteId) {
|
||||
Note.changeNote(noteId);
|
||||
// 不用重定向到notebook
|
||||
Note.changeNoteForPjax(noteId, true, false);
|
||||
}
|
||||
});
|
||||
|
||||
@ -1658,7 +1747,7 @@ $(function() {
|
||||
e.stopPropagation();
|
||||
// 得到ID
|
||||
var noteId = $(this).parent().attr('noteId');
|
||||
window.open("/blog/post/" + noteId);
|
||||
window.open("/blog/view/" + noteId);
|
||||
});
|
||||
|
||||
// note setting
|
||||
|
2
public/js/app/notebook-min.js
vendored
2
public/js/app/notebook-min.js
vendored
File diff suppressed because one or more lines are too long
@ -60,13 +60,13 @@ Notebook.getNotebookTitle = function(notebookId) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的notebooks
|
||||
/**
|
||||
* 我的notebooks
|
||||
<ul class="folderBody" id="notebookList">
|
||||
<li><a class="active">所有</a></li>
|
||||
<li><a class="active">Hadoop</a></li>
|
||||
<li><a>August 13, 2013</a></li>
|
||||
</ul>
|
||||
<li><a class="active">所有</a></li>
|
||||
<li><a class="active">Hadoop</a></li>
|
||||
<li><a>August 13, 2013</a></li>
|
||||
</ul>
|
||||
*/
|
||||
|
||||
Notebook.getTreeSetting = function(isSearch, isShare){
|
||||
@ -236,7 +236,7 @@ Notebook.getTreeSetting = function(isSearch, isShare){
|
||||
}
|
||||
|
||||
return setting;
|
||||
}
|
||||
}
|
||||
Notebook.allNotebookId = "0";
|
||||
Notebook.trashNotebookId = "-1";
|
||||
Notebook.curNotebookIsTrashOrAll = function() {
|
||||
@ -289,6 +289,41 @@ Notebook.cacheAllNotebooks = function(notebooks) {
|
||||
}
|
||||
}
|
||||
|
||||
// 展开到笔记本
|
||||
Notebook.expandNotebookTo = function(notebookId, userId) {
|
||||
var me = this;
|
||||
var selected = false;
|
||||
var tree = me.tree;
|
||||
|
||||
// 共享的
|
||||
if(userId) {
|
||||
tree = Share.trees[userId];
|
||||
}
|
||||
if(!tree) {
|
||||
return;
|
||||
}
|
||||
var curNode = tree.getNodeByTId(notebookId);
|
||||
if(!curNode) {
|
||||
return;
|
||||
}
|
||||
while(true) {
|
||||
var pNode = curNode.getParentNode();
|
||||
if(pNode) {
|
||||
tree.expandNode(pNode, true);
|
||||
if(!selected) {
|
||||
Notebook.changeNotebookNav(notebookId);
|
||||
selected = true;
|
||||
}
|
||||
curNode = pNode;
|
||||
} else {
|
||||
if(!selected) {
|
||||
Notebook.changeNotebookNav(notebookId);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// RenderNotebooks调用,
|
||||
// nav 为了新建, 快速选择, 移动笔记
|
||||
@ -401,38 +436,38 @@ Notebook.changeNav = function() {
|
||||
log(t2-t1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 我的共享notebooks
|
||||
<div id="shareNotebooks">
|
||||
<div class="folderNote closed">
|
||||
<div class="folderHeader">
|
||||
<a>
|
||||
<h1>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
Life's</h1>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="folderBody">
|
||||
<li><a>Hadoop</a></li>
|
||||
<li><a>Node webkit</a></li>
|
||||
<li><a>Hadoop</a></li>
|
||||
<li><a>Node webkit</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
*/
|
||||
/**
|
||||
* 我的共享notebooks
|
||||
<div id="shareNotebooks">
|
||||
<div class="folderNote closed">
|
||||
<div class="folderHeader">
|
||||
<a>
|
||||
<h1>
|
||||
<i class="fa fa-angle-right"></i>
|
||||
Life's</h1>
|
||||
</a>
|
||||
</div>
|
||||
<ul class="folderBody">
|
||||
<li><a>Hadoop</a></li>
|
||||
<li><a>Node webkit</a></li>
|
||||
<li><a>Hadoop</a></li>
|
||||
<li><a>Node webkit</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
*/
|
||||
// TODO 层级
|
||||
Notebook.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
|
||||
if(isEmpty(sharedUserInfos)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(!shareNotebooks || typeof shareNotebooks != "object" || shareNotebooks.length < 0) {
|
||||
return;
|
||||
|
||||
if(!shareNotebooks || typeof shareNotebooks != "object" || shareNotebooks.length < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var $shareNotebooks = $("#shareNotebooks");
|
||||
var user2ShareNotebooks = {};
|
||||
for(var i in shareNotebooks) {
|
||||
var user2ShareNotebooks = {};
|
||||
for(var i in shareNotebooks) {
|
||||
var userNotebooks = shareNotebooks[i];
|
||||
user2ShareNotebooks[userNotebooks.UserId] = userNotebooks;
|
||||
}
|
||||
@ -442,17 +477,17 @@ Notebook.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
|
||||
|
||||
userNotebooks.ShareNotebooks = [{NotebookId: "-2", Title: "默认共享"}].concat(userNotebooks.ShareNotebooks)
|
||||
|
||||
var username = userInfo.Username || userInfo.Email;
|
||||
var header = tt('<div class="folderNote closed"><div class="folderHeader"><a><h1 title="? 的共享"><i class="fa fa-angle-right"></i>?</h1></a></div>', username, username);
|
||||
var body = '<ul class="folderBody">';
|
||||
for(var j in userNotebooks.ShareNotebooks) {
|
||||
var notebook = userNotebooks.ShareNotebooks[j];
|
||||
body += tt('<li><a notebookId="?">?</a></li>', notebook.NotebookId, notebook.Title)
|
||||
}
|
||||
body += "</ul>";
|
||||
|
||||
$shareNotebooks.append(header + body + "</div>")
|
||||
}
|
||||
var username = userInfo.Username || userInfo.Email;
|
||||
var header = tt('<div class="folderNote closed"><div class="folderHeader"><a><h1 title="? 的共享"><i class="fa fa-angle-right"></i>?</h1></a></div>', username, username);
|
||||
var body = '<ul class="folderBody">';
|
||||
for(var j in userNotebooks.ShareNotebooks) {
|
||||
var notebook = userNotebooks.ShareNotebooks[j];
|
||||
body += tt('<li><a notebookId="?">?</a></li>', notebook.NotebookId, notebook.Title)
|
||||
}
|
||||
body += "</ul>";
|
||||
|
||||
$shareNotebooks.append(header + body + "</div>")
|
||||
}
|
||||
}
|
||||
|
||||
// 左侧导航, 选中某个notebook
|
||||
@ -507,10 +542,11 @@ Notebook.toggleToMyNav = function(userId, notebookId) {
|
||||
$("#tagSearch").hide();
|
||||
}
|
||||
Notebook.changeNotebookNav = function(notebookId) {
|
||||
Notebook.curNotebookId = notebookId;
|
||||
Notebook.toggleToMyNav();
|
||||
|
||||
// 1
|
||||
Notebook.selectNotebook($(tt('#notebookList [notebookId="?"]', notebookId)));
|
||||
// 1 改变当前的notebook
|
||||
Notebook.selectNotebook($(tt('#notebook [notebookId="?"]', notebookId)));
|
||||
|
||||
var notebook = Notebook.cache[notebookId];
|
||||
|
||||
@ -542,7 +578,9 @@ Notebook.curActiveNotebookIsAll = function() {
|
||||
// 1. 改变note, 此时需要先保存
|
||||
// 2. ajax得到该notebook下的所有note
|
||||
// 3. 使用Note.RederNotes()
|
||||
Notebook.changeNotebook = function(notebookId) {
|
||||
// callback Pjax, 当popstate时调用
|
||||
Notebook.changeNotebook = function(notebookId, callback) {
|
||||
var me = this;
|
||||
Notebook.changeNotebookNav(notebookId);
|
||||
|
||||
Notebook.curNotebookId = notebookId;
|
||||
@ -553,7 +591,7 @@ Notebook.changeNotebook = function(notebookId) {
|
||||
// 2 先清空所有
|
||||
Note.clearAll();
|
||||
|
||||
var url = "/note/ListNotes/";
|
||||
var url = "/note/listNotes/";
|
||||
var param = {notebookId: notebookId};
|
||||
|
||||
// 废纸篓
|
||||
@ -565,22 +603,46 @@ Notebook.changeNotebook = function(notebookId) {
|
||||
// 得到全部的...
|
||||
cacheNotes = Note.getNotesByNotebookId();
|
||||
if(!isEmpty(cacheNotes)) { // 万一真的是没有呢?
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
if(callback) {
|
||||
callback(cacheNotes);
|
||||
} else {
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
cacheNotes = Note.getNotesByNotebookId(notebookId);
|
||||
if(!isEmpty(cacheNotes)) { // 万一真的是没有呢?
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
if(!isEmpty(cacheNotes)) { // 万一真的是没有呢? 执行后面的ajax
|
||||
if(callback) {
|
||||
callback(cacheNotes);
|
||||
} else {
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 2 得到笔记本
|
||||
// 这里可以缓存起来, note按notebookId缓存
|
||||
ajaxGet(url, param, Note.renderNotesAndFirstOneContent);
|
||||
me.showNoteAndEditorLoading();
|
||||
ajaxGet(url, param, function(cacheNotes) {
|
||||
if(callback) {
|
||||
callback(cacheNotes);
|
||||
} else {
|
||||
Note.renderNotesAndFirstOneContent(cacheNotes);
|
||||
}
|
||||
me.hideNoteAndEditorLoading();
|
||||
});
|
||||
}
|
||||
|
||||
// 笔记列表与编辑器的mask loading
|
||||
Notebook.showNoteAndEditorLoading = function() {
|
||||
$("#noteAndEditorMask").show();
|
||||
};
|
||||
Notebook.hideNoteAndEditorLoading = function() {
|
||||
$("#noteAndEditorMask").hide();
|
||||
};
|
||||
|
||||
// 是否是当前选中的notebookId
|
||||
// 还包括共享
|
||||
// called by Note
|
||||
@ -596,10 +658,10 @@ Notebook.changeNotebookForNewNote = function(notebookId) {
|
||||
return;
|
||||
}
|
||||
|
||||
Notebook.changeNotebookNav(notebookId);
|
||||
Notebook.changeNotebookNav(notebookId, true);
|
||||
Notebook.curNotebookId = notebookId;
|
||||
|
||||
var url = "/note/ListNotes/";
|
||||
var url = "/note/listNotes/";
|
||||
var param = {notebookId: notebookId};
|
||||
|
||||
// 2 得到笔记本
|
||||
@ -614,7 +676,7 @@ Notebook.changeNotebookForNewNote = function(notebookId) {
|
||||
// 显示共享信息
|
||||
Notebook.listNotebookShareUserInfo = function(target) {
|
||||
var notebookId = $(target).attr("notebookId");
|
||||
showDialogRemote("share/listNotebookShareUserInfo", {notebookId: notebookId});
|
||||
showDialogRemote("/share/listNotebookShareUserInfo", {notebookId: notebookId});
|
||||
}
|
||||
// 共享笔记本
|
||||
Notebook.shareNotebooks= function(target) {
|
||||
@ -657,7 +719,7 @@ Notebook.setNotebook2Blog = function(target) {
|
||||
}
|
||||
});
|
||||
}
|
||||
ajaxPost("notebook/setNotebook2Blog", {notebookId: notebookId, isBlog: isBlog}, function(ret) {
|
||||
ajaxPost("/notebook/setNotebook2Blog", {notebookId: notebookId, isBlog: isBlog}, function(ret) {
|
||||
if(ret) {
|
||||
// 这里要设置notebook下的note的blog状态
|
||||
Note.setAllNoteBlogStatus(notebookId, isBlog);
|
||||
@ -846,12 +908,6 @@ $(function() {
|
||||
} else {
|
||||
items.push("set2Blog");
|
||||
}
|
||||
|
||||
//asktalk bebug#23
|
||||
if(notebookId=="548125adf4e872105c000007"){
|
||||
items.push("delete");
|
||||
}
|
||||
|
||||
// 是否还有笔记
|
||||
if(Note.notebookHasNotes(notebookId)) {
|
||||
items.push("delete");
|
||||
|
2
public/js/app/page-min.js
vendored
2
public/js/app/page-min.js
vendored
File diff suppressed because one or more lines are too long
@ -4,10 +4,9 @@
|
||||
//----------------------
|
||||
// 编辑器模式
|
||||
function editorMode() {
|
||||
this.writingHash = "#writing";
|
||||
this.normalHash = "#normal";
|
||||
this.isWritingMode = location.hash == this.writingHash;
|
||||
|
||||
this.writingHash = "writing";
|
||||
this.normalHash = "normal";
|
||||
this.isWritingMode = location.hash.indexOf(this.writingHash) >= 0;
|
||||
this.toggleA = null;
|
||||
}
|
||||
|
||||
@ -17,27 +16,33 @@ editorMode.prototype.toggleAText = function(isWriting) {
|
||||
var toggleA = $(".toggle-editor-mode a");
|
||||
var toggleSpan = $(".toggle-editor-mode span");
|
||||
if(isWriting) {
|
||||
toggleA.attr("href", self.normalHash);
|
||||
toggleA.attr("href", "#" + self.normalHash);
|
||||
toggleSpan.text(getMsg("normalMode"));
|
||||
} else {
|
||||
toggleA.attr("href", self.writingHash);
|
||||
toggleA.attr("href", "#" + self.writingHash);
|
||||
toggleSpan.text(getMsg("writingMode"));
|
||||
}
|
||||
}, 0);
|
||||
}
|
||||
editorMode.prototype.isWriting = function(hash) {
|
||||
return hash == this.writingHash;
|
||||
return hash.indexOf(this.writingHash) >= 0
|
||||
}
|
||||
editorMode.prototype.init = function() {
|
||||
this.changeMode(this.isWritingMode);
|
||||
var self = this;
|
||||
$(".toggle-editor-mode").click(function() {
|
||||
//
|
||||
$(".toggle-editor-mode").click(function(e) {
|
||||
e.preventDefault();
|
||||
saveBookmark();
|
||||
var $a = $(this).find("a");
|
||||
var isWriting = self.isWriting($a.attr("href"));
|
||||
self.changeMode(isWriting);
|
||||
//
|
||||
if(isWriting) {
|
||||
setHash("m", self.writingHash);
|
||||
} else {
|
||||
setHash("m", self.normalHash);
|
||||
}
|
||||
|
||||
restoreBookmark();
|
||||
});
|
||||
}
|
||||
@ -123,7 +128,7 @@ editorMode.prototype.writtingMode = function() {
|
||||
|
||||
editorMode.prototype.getWritingCss = function() {
|
||||
if(this.isWritingMode) {
|
||||
return ["css/editor/editor-writting-mode.css"];
|
||||
return ["/css/editor/editor-writting-mode.css"];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
@ -276,6 +281,7 @@ Mobile = {
|
||||
noteO: $("#note"),
|
||||
bodyO: $("body"),
|
||||
setMenuO: $("#setMenu"),
|
||||
// 弃用, 统一使用Pjax
|
||||
hashChange: function() {
|
||||
var self = Mobile;
|
||||
var hash = location.hash;
|
||||
@ -292,8 +298,8 @@ Mobile = {
|
||||
init: function() {
|
||||
var self = this;
|
||||
self.isMobile();
|
||||
$(window).on("hashchange", self.hashChange);
|
||||
self.hashChange();
|
||||
// $(window).on("hashchange", self.hashChange);
|
||||
// self.hashChange();
|
||||
/*
|
||||
$("#noteItemList").on("tap", ".item", function(event) {
|
||||
$(this).click();
|
||||
@ -320,6 +326,8 @@ Mobile = {
|
||||
}
|
||||
return LEA.isMobile;
|
||||
},
|
||||
// 改变笔记, 此时切换到编辑器模式下
|
||||
// note.js click事件处理, 先切换到纯编辑器下, 再调用Note.changeNote()
|
||||
changeNote: function(noteId) {
|
||||
var self = this;
|
||||
if(!LEA.isMobile) {return true;}
|
||||
@ -331,21 +339,25 @@ Mobile = {
|
||||
var self = this;
|
||||
self.bodyO.addClass("full-editor");
|
||||
self.noteO.addClass("editor-show");
|
||||
/*
|
||||
if(changeHash) {
|
||||
if(!noteId) {
|
||||
noteId = Note.curNoteId;
|
||||
}
|
||||
location.hash = "noteId=" + noteId;
|
||||
}
|
||||
*/
|
||||
},
|
||||
toNormal: function(changeHash) {
|
||||
var self = this;
|
||||
self.bodyO.removeClass("full-editor");
|
||||
self.noteO.removeClass("editor-show");
|
||||
|
||||
/*
|
||||
if(changeHash) {
|
||||
location.hash = "notebookAndNote";
|
||||
}
|
||||
*/
|
||||
},
|
||||
switchPage: function() {
|
||||
var self = this;
|
||||
@ -410,13 +422,13 @@ function initEditor() {
|
||||
|
||||
// 初始化编辑器
|
||||
tinymce.init({
|
||||
// inline: true,
|
||||
setup: function(ed) {
|
||||
ed.on('keydown', Note.saveNote);
|
||||
// indent outdent
|
||||
ed.on('keydown', function(e) {
|
||||
var num = e.which ? e.which : e.keyCode;
|
||||
if (num == 9) { // tab pressed
|
||||
|
||||
if(!e.shiftKey) {
|
||||
// ed.execCommand('Indent');
|
||||
// TODO 如果当前在li, ul, ol下不执行!!
|
||||
@ -458,7 +470,8 @@ function initEditor() {
|
||||
selector : "#editorContent",
|
||||
// height: 100,//这个应该是文档的高度, 而其上层的高度是$("#content").height(),
|
||||
// parentHeight: $("#content").height(),
|
||||
content_css : ["css/bootstrap.css", "css/editor/editor.css"].concat(em.getWritingCss()),
|
||||
content_css : ["/css/bootstrap.css", "/css/editor/editor.css"].concat(em.getWritingCss()),
|
||||
// content_css : ["/css/editor/editor.css"].concat(em.getWritingCss()),
|
||||
skin : "custom",
|
||||
language: LEA.locale, // 语言
|
||||
plugins : [
|
||||
@ -797,3 +810,177 @@ $(function() {
|
||||
Mobile.init();
|
||||
});
|
||||
|
||||
|
||||
//------------
|
||||
// pjax
|
||||
//------------
|
||||
var Pjax = {
|
||||
init: function() {
|
||||
var me = this;
|
||||
// 当history改变时
|
||||
window.addEventListener('popstate', function(evt){
|
||||
var state = evt.state;
|
||||
if(!state) {
|
||||
return;
|
||||
}
|
||||
document.title = state.title || "Untitled";
|
||||
log("pop");
|
||||
me.changeNotebookAndNote(state.noteId);
|
||||
}, false);
|
||||
|
||||
// ie9
|
||||
if(!history.pushState) {
|
||||
$(window).on("hashchange", function() {
|
||||
var noteId = getHash("noteId");;
|
||||
if(noteId) {
|
||||
me.changeNotebookAndNote(noteId);
|
||||
}
|
||||
});
|
||||
}
|
||||
},
|
||||
// pjax调用
|
||||
// popstate事件发生时, 转换到noteId下, 此时要转换notebookId
|
||||
changeNotebookAndNote: function(noteId) {
|
||||
var note = Note.getNote(noteId);
|
||||
if(!note) {
|
||||
return;
|
||||
}
|
||||
var isShare = note.Perm != undefined;
|
||||
|
||||
var notebookId = note.NotebookId;
|
||||
// 如果是在当前notebook下, 就不要转换notebook了
|
||||
if(Notebook.curNotebookId == notebookId) {
|
||||
// 不push state
|
||||
Note.changeNoteForPjax(noteId, false);
|
||||
return;
|
||||
}
|
||||
|
||||
// 自己的
|
||||
if(!isShare) {
|
||||
// 先切换到notebook下, 得到notes列表, 再changeNote
|
||||
Notebook.changeNotebook(notebookId, function(notes) {
|
||||
Note.renderNotes(notes);
|
||||
// 不push state
|
||||
Note.changeNoteForPjax(noteId, false, true);
|
||||
});
|
||||
// 共享笔记
|
||||
} else {
|
||||
Share.changeNotebook(note.UserId, notebookId, function(notes) {
|
||||
Note.renderNotes(notes);
|
||||
// 不push state
|
||||
Note.changeNoteForPjax(noteId, false, true);
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
// ajax后调用
|
||||
changeNote: function(noteInfo) {
|
||||
var me = this;
|
||||
log("push");
|
||||
var noteId = noteInfo.NoteId;
|
||||
var title = noteInfo.Title;
|
||||
var url = '/note/' + noteId;
|
||||
if(location.hash) {
|
||||
url += location.hash;
|
||||
}
|
||||
// 如果支持pushState
|
||||
if(history.pushState) {
|
||||
var state=({
|
||||
url: url,
|
||||
noteId: noteId,
|
||||
title: title,
|
||||
});
|
||||
history.pushState(state, title, url);
|
||||
document.title = title || 'Untitled';
|
||||
// 不支持, 则用hash
|
||||
} else {
|
||||
setHash("noteId", noteId);
|
||||
}
|
||||
}
|
||||
};
|
||||
$(function() {
|
||||
Pjax.init();
|
||||
});
|
||||
|
||||
// note.html调用
|
||||
// 实始化页面
|
||||
function initPage() {
|
||||
$(function() {
|
||||
Notebook.renderNotebooks(notebooks);
|
||||
Share.renderShareNotebooks(sharedUserInfos, shareNotebooks);
|
||||
|
||||
// 如果初始打开的是共享的笔记
|
||||
// 那么定位到我的笔记
|
||||
if(curSharedNoteNotebookId) {
|
||||
Share.firstRenderShareNote(curSharedUserId, curSharedNoteNotebookId, curNoteId);
|
||||
// 初始打开的是我的笔记
|
||||
} else {
|
||||
Note.setNoteCache(noteContentJson);
|
||||
Note.renderNotes(notes);
|
||||
if(curNoteId) {
|
||||
// 指定某个note时才target notebook, /note定位到最新
|
||||
// ie10&+要setTimeout
|
||||
setTimeout(function() {
|
||||
Note.changeNoteForPjax(curNoteId, true, curNotebookId);
|
||||
});
|
||||
if(!curNotebookId) {
|
||||
Notebook.selectNotebook($(tt('#notebook [notebookId="?"]', Notebook.allNotebookId)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 指定笔记, 也要保存最新笔记
|
||||
if(latestNotes.length > 0) {
|
||||
for(var i = 0; i < latestNotes.length; ++i) {
|
||||
Note.addNoteCache(latestNotes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
Tag.renderTagNav(tagsJson);
|
||||
// init notebook后才调用
|
||||
initSlimScroll();
|
||||
});
|
||||
}
|
||||
|
||||
//----------
|
||||
// aceeditor
|
||||
|
||||
var aceEditors = {};
|
||||
function initAce(id, val){
|
||||
var aceEditor = ace.edit(id);
|
||||
aceEditor.setTheme("ace/theme/tomorrow");
|
||||
aceEditor.session.setMode("ace/mode/javascript");
|
||||
aceEditor.setAutoScrollEditorIntoView(true);
|
||||
aceEditor.setOption("maxLines", 100);
|
||||
if(val) {
|
||||
aceEditor.setValue(val);
|
||||
}
|
||||
aceEditors [id] = aceEditor;
|
||||
return aceEditor;
|
||||
}
|
||||
|
||||
function getAce(id) {
|
||||
return aceEditors[id];
|
||||
}
|
||||
// 是否在node内
|
||||
function isInAce(node, brush) {
|
||||
var $node = $(node);
|
||||
var node = $node.get(0);
|
||||
if(node.nodeName == "PRE") {
|
||||
$node.data('brush', brush);
|
||||
var id = $node.attr('id');
|
||||
var aceEditor = getAce(id);
|
||||
if(aceEditor) {
|
||||
return [aceEditor, $node];
|
||||
}
|
||||
return false;
|
||||
} else {
|
||||
// 找到父是pre
|
||||
$pre = $node.closest("pre");
|
||||
if($pre.length == 0) {
|
||||
return false;
|
||||
}
|
||||
return isInAce($pre, brush);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
2
public/js/app/share-min.js
vendored
2
public/js/app/share-min.js
vendored
File diff suppressed because one or more lines are too long
@ -243,25 +243,47 @@ Share.toggleToSharedNav = function(userId, notebookId) {
|
||||
$("#tagSearch").hide();
|
||||
}
|
||||
|
||||
// 刷新加载共享的笔记本, page.js调用
|
||||
Share.firstRenderShareNote = function(ownerUserId, notebookId, noteId) {
|
||||
$("#myShareNotebooks .folderHeader").trigger("click");
|
||||
// 这里, 可能这个笔记本是子笔记本, 所以先扩展
|
||||
Notebook.expandNotebookTo(notebookId, ownerUserId);
|
||||
Share.changeNotebook(ownerUserId, notebookId, function(notes) {
|
||||
Note.renderNotes(notes);
|
||||
// 不push state
|
||||
Note.changeNoteForPjax(noteId, false, false);
|
||||
});
|
||||
};
|
||||
|
||||
//改变笔记本
|
||||
//0. 改变样式
|
||||
//1. 改变note, 此时需要先保存
|
||||
//2. ajax得到该notebook下的所有note
|
||||
//3. 使用Note.RederNotes()
|
||||
Share.changeNotebook = function(userId, notebookId) {
|
||||
Share.changeNotebook = function(userId, notebookId, callback) {
|
||||
var me = this;
|
||||
Notebook.curNotebookId = notebookId;
|
||||
// 选中
|
||||
Notebook.selectNotebook($(tt('#friendContainer_? a[notebookId="?"]', userId, notebookId)));
|
||||
var $t = $(tt('#friendContainer_? a[notebookId="?"]', userId, notebookId));
|
||||
if($t.length == 0) {
|
||||
// 切换到默认共享中
|
||||
// 表示是popstate的默认共享笔记本下
|
||||
Notebook.selectNotebook($(tt('#friendContainer_? a[notebookId="?"]', userId, me.defaultNotebookId)));
|
||||
notebookId = me.defaultNotebookId;
|
||||
} else {
|
||||
Notebook.selectNotebook($t);
|
||||
}
|
||||
|
||||
// 改变nav!!!! TODO
|
||||
Share.toggleToSharedNav(userId, notebookId);
|
||||
|
||||
|
||||
// 1
|
||||
Note.curChangedSaveIt();
|
||||
|
||||
// 2 先清空所有
|
||||
Note.clearAll();
|
||||
|
||||
var url = "/share/ListShareNotes/";
|
||||
var url = "/share/listShareNotes";
|
||||
var param = {userId: userId};
|
||||
if(!Share.isDefaultNotebookId(notebookId)) {
|
||||
param.notebookId = notebookId;
|
||||
@ -276,13 +298,17 @@ Share.changeNotebook = function(userId, notebookId) {
|
||||
if(param.notebookId) {
|
||||
|
||||
}
|
||||
Note.renderNotes(ret, false, true);
|
||||
// 渲染第一个
|
||||
// 这里, 有点小复杂, 还要判断权限...
|
||||
if(!isEmpty(ret)) {
|
||||
// 定位
|
||||
Note.changeNote(ret[0].NoteId, true);
|
||||
if(callback) {
|
||||
callback(ret);
|
||||
} else {
|
||||
Note.renderNotes(ret, false, true);
|
||||
// 渲染第一个
|
||||
// 这里, 有点小复杂, 还要判断权限...
|
||||
if(!isEmpty(ret)) {
|
||||
// 定位
|
||||
Note.changeNoteForPjax(ret[0].NoteId, true, false);
|
||||
} else {
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -338,7 +364,7 @@ Share.changeNotebookForNewNote = function(notebookId) {
|
||||
Share.toggleToSharedNav(userId, notebookId);
|
||||
|
||||
// 得到笔记本
|
||||
var url = "/share/ListShareNotes/";
|
||||
var url = "/share/listShareNotes";
|
||||
var param = {userId: userId, notebookId: notebookId};
|
||||
|
||||
// 2 得到笔记本
|
||||
@ -401,7 +427,7 @@ Share.initContextmenu = function(notebooksCopy) {
|
||||
}
|
||||
|
||||
Share.contextmenu = $("#noteItemList .item-shared").contextmenu(noteListMenu);
|
||||
}
|
||||
};
|
||||
|
||||
$(function() {
|
||||
// note setting
|
||||
@ -413,8 +439,6 @@ $(function() {
|
||||
Share.contextmenu.showMenu(e, $p);
|
||||
});
|
||||
|
||||
|
||||
|
||||
//---------------------------
|
||||
// 新建笔记
|
||||
// 1. 直接点击新建 OR
|
||||
@ -453,10 +477,10 @@ $(function() {
|
||||
toHtml = getMsg("readOnly");
|
||||
toPerm = "0";
|
||||
}
|
||||
var url = "/share/UpdateShareNotebookPerm";
|
||||
var url = "/share/updateShareNotebookPerm";
|
||||
var param = {perm: toPerm, toUserId: toUserId};
|
||||
if(Share.dialogIsNote) {
|
||||
url = "/share/UpdateShareNotePerm";
|
||||
url = "/share/updateShareNotePerm";
|
||||
param.noteId = noteOrNotebookId;
|
||||
} else {
|
||||
param.notebookId = noteOrNotebookId;
|
||||
@ -474,10 +498,10 @@ $(function() {
|
||||
var noteOrNotebookId = $(this).attr("noteOrNotebookId");
|
||||
var toUserId = $(this).attr("toUserId");
|
||||
|
||||
var url = "/share/DeleteShareNotebook";
|
||||
var url = "/share/deleteShareNotebook";
|
||||
var param = {toUserId: toUserId};
|
||||
if(Share.dialogIsNote) {
|
||||
url = "/share/DeleteShareNote";
|
||||
url = "/share/deleteShareNote";
|
||||
param.noteId = noteOrNotebookId;
|
||||
} else {
|
||||
param.notebookId = noteOrNotebookId;
|
||||
@ -533,10 +557,10 @@ function addShareNoteOrNotebook(trSeq) {
|
||||
var shareNotePerm = $(trId + ' input[name="perm' + trSeq + '"]:checked').val() || 0;
|
||||
var perm = shareNotePerm;
|
||||
// emails = emails.split(";");
|
||||
var url = "share/addShareNote";
|
||||
var url = "/share/addShareNote";
|
||||
var data = {noteId: id, emails: [emails], perm: shareNotePerm};
|
||||
if(!Share.dialogIsNote) {
|
||||
url = "share/addShareNotebook";
|
||||
url = "/share/addShareNotebook";
|
||||
data = {notebookId: id, emails: [emails], perm: shareNotePerm};
|
||||
}
|
||||
hideAlert("#shareMsg");
|
||||
|
2
public/js/common-min.js
vendored
2
public/js/common-min.js
vendored
File diff suppressed because one or more lines are too long
@ -1146,4 +1146,45 @@ var vd = {
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
// 返回hash的#a=1&b=3 返回{a:1, b:3}
|
||||
function getHashObject() {
|
||||
var hash = location.hash; // #life
|
||||
if(!hash) {
|
||||
return {};
|
||||
}
|
||||
var hashKV = hash.substr(1);
|
||||
var kvs = hashKV.split("&");
|
||||
var kvsObj = {};
|
||||
for(var i = 0; i < kvs.length; ++i) {
|
||||
var kv = kvs[i].split('=');
|
||||
if(kv.length == 2) {
|
||||
kvsObj[kv[0]] = kv[1];
|
||||
}
|
||||
}
|
||||
return kvsObj;
|
||||
}
|
||||
function getHash(key, value) {
|
||||
var kvs = getHashObject();
|
||||
return kvs[key];
|
||||
}
|
||||
function setHash(key, value) {
|
||||
var hash = location.hash; // #life
|
||||
if(!hash) {
|
||||
location.href = "#" + key + "=" + value;
|
||||
return;
|
||||
}
|
||||
var kvs = getHashObject();
|
||||
kvs[key] = value;
|
||||
var str = "";
|
||||
for(var i in kvs) {
|
||||
if(kvs[i]) {
|
||||
if(str) {
|
||||
str += "&";
|
||||
}
|
||||
str += i + '=' + kvs[i];
|
||||
}
|
||||
}
|
||||
location.href = "#" + str;
|
||||
}
|
||||
|
Reference in New Issue
Block a user