写作模式, sync问题

This commit is contained in:
life
2015-03-08 01:52:30 +08:00
parent 4a48b11a10
commit 49bec63ded
20 changed files with 522 additions and 7318 deletions

View File

@@ -109,9 +109,9 @@ var win = gui.Window.get();
win.resizeTo(258, 326);
win.setPosition('center');
$('body').on('keydown', function(e) {
commonCmd(e);
});
// $('body').on('keydown', function(e) {
// commonCmd(e);
// });
</script>

2
node_modules/api.js generated vendored
View File

@@ -226,7 +226,7 @@ var Api = {
getNoteContent: function(noteId, callback) {
var me = this;
var url = this.getUrl('note/getNoteContent', {noteId: noteId});
log(url);
console.log(url);
needle.get(url, function(error, response) {
me.checkError(error, response);
if(error) {

12
node_modules/file.js generated vendored
View File

@@ -258,16 +258,16 @@ var File = {
// 访问api, 得到图片
function getImageFromApi() {
log('从远程得到图片 ' + fileId);
console.log('fetch servers image ' + fileId);
Api.getImage(fileId, function(fileLocalPath, filename) {
if(fileLocalPath) {
log('图片保存到本地成功');
console.log('save image to local');
// 保存到本地数据库中
me.addImageForce(fileId, fileLocalPath, function(doc) {
if(doc) {
log('保存到本地数据库成功');
console.log('save image to local success');
} else {
log('保存到数据库失败');
console.log('save image to local error');
}
callback(fileLocalPath);
// return me.retImage(fileLocalPath, res);
@@ -275,7 +275,7 @@ var File = {
} else {
// 远程取不到图片, 是没有网络? 还是远程真的没有了
// TODO
log('取不远程的图片' + fileId);
console.log("cann't get server's image" + fileId);
callback(false);
// return me.e404(res);
}
@@ -285,7 +285,7 @@ var File = {
// has表示本地数据库有记录
me.getImageLocalPath(fileId, function(has, fileLocalPath) {
// 本地有
log('re img')
console.log('re img')
console.log(fileLocalPath);
// console.log(fs.exists(fileLocalPath));
if(has && fileLocalPath) {

43
node_modules/note.js generated vendored
View File

@@ -429,37 +429,52 @@ var Note = {
// 得到笔记内容
// noteId是本地Id
inSyncContent: {}, // 正在同步中的
inSyncTimes: {}, // 10次就要再尝试了
getNoteContent: function(noteId, callback) {
var me = this;
console.log('getNoteContent------')
console.log('getNoteContent------' + noteId);
// 如果是正在sync的话, 返回
/*
if(me.inSyncContent[noteId]) {
console.log('in sync now' + noteId); // 下周分享 node-webkit
return;
}
*/
me.inSyncContent[noteId] = true;
me.inSyncTimes[noteId]++;
if(me.inSyncTimes[noteId] > 10) {
callback && callback(false);
}
me.getNote(noteId, function(note) {
if(!Common.isOk(note)) {
log('not ok');
log(note);
me.inSyncContent[noteId] = false;
console.log('not ok');
console.log(note);
callback && callback(false);
} else {
// 如果笔记是刚同步过来的, 那么内容要重新获取
if(note.InitSync) {
log('need load from server');
console.log('need load from server');
if(!Api) {
Api = require('api')
}
var serverNoteId = note.ServerNoteId;
// 远程获取
me.getServerNoteIdByNoteId(noteId, function(serverNoteId) {
// me.getServerNoteIdByNoteId(noteId, function(serverNoteId) {
if(!serverNoteId) {
console.error(noteId + ' getServerNoteIdByNoteId error');
me.inSyncContent[noteId] = false;
return callback && callback(false);
}
Api.getNoteContent(serverNoteId, function(noteContent) {
me.inSyncContent[noteId] = false;
// 同步到本地
if(Common.isOk(noteContent)) {
me.updateNoteContentForce(noteId, noteContent.Content, function(content) {
@@ -468,15 +483,25 @@ var Note = {
callback && callback(noteContent);
});
} else {
callback && callback(false);
console.error(noteId + ' api.getNoteContent error');
// 这里, 可能太多的要同步了
setTimeout(function() {
me.getNoteContent(noteId, callback);
}, 500);
// callback && callback(false);
}
});
});
// });
} else {
me.inSyncContent[noteId] = false;
log('not need');
console.log('not need');
callback && callback(note);
// Web.alertWeb("NONO");
}
}
});
@@ -1266,6 +1291,8 @@ var Note = {
if(content) {
me.syncImages(content);
}
} else {
// Web.alertWeb(note.NoteId + ' ' + note.Title + ' getContent error!!');
}
});

6
node_modules/sync.js generated vendored
View File

@@ -36,17 +36,17 @@ var Sync = {
_syncNotebookIsLastChunk: false,
_totalSyncNotebookNum: 0, // 需要同步的数量
_tocalHasSyncNotebookNum: 0, // 已同步的数量
_notebookMaxEntry: 1,
_notebookMaxEntry: 200,
// note
_syncNoteIsLastChunk: false,
_totalSyncNoteNum: 0, // 需要同步的数量
_noteMaxEntry: 1,
_noteMaxEntry: 200,
// tag
_syncTagIsLastChunk: false,
_totalSyncTagNum: 0, // 需要同步的数量
_tagMaxEntry: 1,
_tagMaxEntry: 200,
_initSyncInfo: function() {
var me = this;

4
node_modules/web.js generated vendored
View File

@@ -20,6 +20,10 @@ var Web = {
me.Note.notLogin();
},
alertWeb: function(msg) {
var me = this;
me.Note.alertWeb(msg);
},
// 注入前端变量
set: function(notebook, note, attach, tag) {

View File

@@ -21,6 +21,7 @@
<link rel="stylesheet" href="public/css/theme/simple.css" type="text/css"/>
<link rel="stylesheet" href="public/css/theme/blue.css" type="text/css" id="theme"/>
<link rel="stylesheet" href="public/css/theme/presentation.css" type="text/css" disabled id="themePresentation"/>
<link rel="stylesheet" href="public/css/theme/writting.css" type="text/css" disabled id="themeWritting"/>
<!-- context-menu -->
<link rel="stylesheet" href="public/js/contextmenu/css/contextmenu.css" type="text/css" />
@@ -37,6 +38,7 @@ function log(o) {
</script>
</head>
<body class="clearfix init">
<div id="topDrag"></div>
<!-- 关闭, 最小化, 最大 -->
<div id="winTool" class="win-tool clearfix">
<a class="tool-close"></a>
@@ -413,8 +415,8 @@ function log(o) {
<span class="fa fa-history"></span>
</a></li>
<li><a class="ios7-a " id="expand"
data-toggle="dropdown" title="Expand">
<li><a class="ios7-a " id="writtingToggle"
data-toggle="dropdown" title="Toggle writting mode">
<span class="fa fa-expand"></span>
</a></li>
</ul>
@@ -428,7 +430,8 @@ function log(o) {
style="position: absolute; right: 30px; left: 0"></div>
<a
style="dispaly: block; position: absolute; cursor: pointer; right: 10px; padding: 3px 10px"
id="moreBtn"> <i class="fa fa-angle-down"></i>
id="moreBtn">
<i class="more-fa fa fa-angle-down"></i>
</a>
</div>
<div class="editorBg"></div>
@@ -443,18 +446,20 @@ function log(o) {
<!-- leaui image drop image to editor-->
<form id="upload" method="post" action="/file/uploadImageLeaui" enctype="multipart/form-data" style="margin-top: 5px;">
<div id="drop">
Drop images to here
<input type="file" name="file" multiple style="display: none"/>
</div>
<ul id="uploadMsg">
</ul>
</form>
<div id="drop">
Drop images to here
<input type="file" name="file" multiple style="display: none"/>
</div>
<ul id="uploadMsg">
</ul>
</form>
<!-- 由此可以算高度 -->
<div id="editorContent" name="editorContent" tabindex="2" />
{{.noteContent}}
</div>
<div id="editorContentWrap">
<div id="editorContent" name="editorContent" tabindex="2" >
{{.noteContent}}
</div>
</div>
</div>
<div id="mdEditor">

View File

@@ -6,8 +6,8 @@
"window": {
"toolbar": true,
"frame": false,
"transparent": true,
"frame": true,
"transparent": false,
"min_width": 400,
"min_height": 200,

View File

@@ -1577,7 +1577,7 @@ html,body, #page, #pageInner {
body {
// display: none;
-webkit-user-select: none; // input, textarea还是可以选择的
-webkit-app-region: drag;
// -webkit-app-region: drag;
border: 1px solid #ccc;
// for shadow
left: 5px;
@@ -1604,10 +1604,46 @@ body {
}
}
}
#topDrag {
-webkit-app-region: drag;
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10px;
z-index: 1000;
cursor: move;
// background-color: red;
}
#searchNoteInput,
#searchNotebookForList,
#addTagInput,
.noteSplit,
#notebook,
#editor,
#mdEditor,
#right-column *
{
// -webkit-app-region: no-drag;
}
#page {
#pageInner {
}
}
#noteList {
top: 5px;
}
#note {
top: 5px;
}
#noteAndEditor {
// top: 5px !important;
// padding-top: 50px;
// background-color: #fff;
}
#leftNotebook {
overflow: hidden;
// opacity: 0.5;
@@ -1618,8 +1654,13 @@ body {
border-radius: 5px 0 0 0;
}
#notebook {
top: 25px !important;
top: 40px !important;
background: transparent !important;
#myStarredNotes {
.folderHeader {
border-top: 1px solid rgba(0, 0, 0, 0.05);
}
}
}
#leftNotebook {
// background-color: rgba(245, 246, 248, 0.98) !important;
@@ -1635,17 +1676,6 @@ body {
// -webkit-app-region: drag;
}
#noteTitle,
#searchNoteInput,
#searchNotebookForList,
#addTagInput,
#wmd-input,
#editorContent,
.noteSplit,
#notebook
{
-webkit-app-region: no-drag;
}
#mainMask {
position: absolute;
@@ -1682,6 +1712,27 @@ body {
display: none;
}
#editor {
#mceToolbar {
height: 30px;
}
// 所有都展开
&.all-tool {
#mceToolbar {
height: 60px;
}
.more-fa:before {
content: "\f106";
}
#editorContent {
top: 60px;
}
}
.more-fa:before {
content: "\f107";
}
}
@import '../traffic.less';
@import '../ani.less';

View File

@@ -1429,7 +1429,6 @@ body,
}
body {
-webkit-user-select: none;
-webkit-app-region: drag;
border: 1px solid #ccc;
left: 5px;
right: 5px;
@@ -1450,6 +1449,22 @@ body.init .loading-footer {
body.init #pageInner {
display: none;
}
#topDrag {
-webkit-app-region: drag;
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10px;
z-index: 1000;
cursor: move;
}
#noteList {
top: 5px;
}
#note {
top: 5px;
}
#leftNotebook {
overflow: hidden;
border-radius: 5px 0 0 0;
@@ -1460,9 +1475,12 @@ body.init #pageInner {
border-radius: 5px 0 0 0;
}
#notebook {
top: 25px !important;
top: 40px !important;
background: transparent !important;
}
#notebook #myStarredNotes .folderHeader {
border-top: 1px solid rgba(0, 0, 0, 0.05);
}
#leftNotebook {
background: url(images/mohu.png) !important;
background-repeat: repeat;
@@ -1474,16 +1492,6 @@ body.init #pageInner {
.win-tool {
-webkit-user-select: none;
}
#noteTitle,
#searchNoteInput,
#searchNotebookForList,
#addTagInput,
#wmd-input,
#editorContent,
.noteSplit,
#notebook {
-webkit-app-region: no-drag;
}
#mainMask {
position: absolute;
left: 0;
@@ -1518,6 +1526,21 @@ body.init #pageInner {
#presentation {
display: none;
}
#editor #mceToolbar {
height: 30px;
}
#editor.all-tool #mceToolbar {
height: 60px;
}
#editor.all-tool .more-fa:before {
content: "\f106";
}
#editor.all-tool #editorContent {
top: 60px;
}
#editor .more-fa:before {
content: "\f107";
}
.win-tool {
padding: 5px;
position: absolute;

View File

@@ -1429,7 +1429,6 @@ body,
}
body {
-webkit-user-select: none;
-webkit-app-region: drag;
border: 1px solid #ccc;
left: 5px;
right: 5px;
@@ -1450,6 +1449,22 @@ body.init .loading-footer {
body.init #pageInner {
display: none;
}
#topDrag {
-webkit-app-region: drag;
position: absolute;
top: 0;
left: 0;
right: 0;
height: 10px;
z-index: 1000;
cursor: move;
}
#noteList {
top: 5px;
}
#note {
top: 5px;
}
#leftNotebook {
overflow: hidden;
border-radius: 5px 0 0 0;
@@ -1460,9 +1475,12 @@ body.init #pageInner {
border-radius: 5px 0 0 0;
}
#notebook {
top: 25px !important;
top: 40px !important;
background: transparent !important;
}
#notebook #myStarredNotes .folderHeader {
border-top: 1px solid rgba(0, 0, 0, 0.05);
}
#leftNotebook {
background: url(images/mohu.png) !important;
background-repeat: repeat;
@@ -1474,16 +1492,6 @@ body.init #pageInner {
.win-tool {
-webkit-user-select: none;
}
#noteTitle,
#searchNoteInput,
#searchNotebookForList,
#addTagInput,
#wmd-input,
#editorContent,
.noteSplit,
#notebook {
-webkit-app-region: no-drag;
}
#mainMask {
position: absolute;
left: 0;
@@ -1518,6 +1526,21 @@ body.init #pageInner {
#presentation {
display: none;
}
#editor #mceToolbar {
height: 30px;
}
#editor.all-tool #mceToolbar {
height: 60px;
}
#editor.all-tool .more-fa:before {
content: "\f106";
}
#editor.all-tool #editorContent {
top: 60px;
}
#editor .more-fa:before {
content: "\f107";
}
.win-tool {
padding: 5px;
position: absolute;
@@ -1820,16 +1843,15 @@ a.raw:hover {
top: 0;
right: 0;
left: 170px;
border-left: 1px solid #ebeff2;
}
#noteList {
width: 250px;
border-right: 1px solid #ebeff2;
border-left: 1px solid #ebeff2;
}
#note {
position: absolute;
bottom: 0;
top: 0;
left: 250px;
right: 0;
padding-left: 0;

View File

@@ -253,18 +253,18 @@ a.raw:hover {
top: 0;
right: 0;
left: @leftNotebookWidth;
border-left: 1px solid @borderColor;
}
#noteList {
width: @noteListWidth;
border-right: 1px solid @borderColor;
border-left: 1px solid @borderColor;
// border-left: 1px solid @borderColor;
}
#note {
position: absolute;
bottom: 0;
top: 0;
left: @noteListWidth;
right: 0;
padding-left: 0;

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,423 +1,120 @@
@import "basic.less";
@bgColor: #fff;
@headerBgColor: #25313e;
@fontFamily: 'Open Sans','Helvetica Neue',Arial,'Hiragino Sans GB','Microsoft YaHei','WenQuanYi Micro Hei',sans-serif;
@aWhiteColor: #fff;
@aBlackColor: #000;
@borderColor: #EBEFF2;
@headerHeight: 60px;
@headerHeightNoBorder: 59px;
@hColor: #0fb264; // #47a447;// 更深 #198764; // boostrap: #5cb85c; bootstrap:hover #47a447; // #5AD4A0; // #47a447
@titleColor: @hColor;
@fontSize: 14px;
@leftNotebookWidth: 170px;
@noteListWidth: 250px;
@noteActiveBg: #65bd77;
@bgColor: #fbfcf7;
@headerBgColor: #fbfcf7;
@fontFamily: 'Open Sans','Helvetica Neue',Arial,'Hiragino Sans GB','Microsoft YaHei','WenQuanYi Micro Hei',sans-serif;
@aWhiteColor: #fff;
@aBlackColor: #000;
@borderColor: #EBEFF2;
@headerHeight: 60px;
@hColor: #0fb264; // #47a447;// 更深 #198764; // boostrap: #5cb85c; bootstrap:hover #47a447; // #5AD4A0; // #47a447
@titleColor: @hColor;
@fontSize: 16px;
@leftNotebookWidth: 170px;
@noteListWidth: 250px;
@noteActiveBg: #65bd77;
@editorWidth: 700px;
// font
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 300;
src: local('Open Sans Light'), local('OpenSans-Light'), url('../../fonts/open-sans2/DXI1ORHCpsQm3Vp6mXoaTXhCUOGz7vYGh680lGh-uXM.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans'), local('OpenSans'), url('../../fonts/open-sans2/cJZKeOuBrn4kERxqtaUH3T8E0i7KZn-EPnyo3HZu7kw.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: local('Open Sans Bold'), local('OpenSans-Bold'), url('../../fonts/open-sans2/k3k702ZOKiLJc3WVjuplzHhCUOGz7vYGh680lGh-uXM.woff') format('woff');
}
@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: local('Open Sans Italic'), local('OpenSans-Italic'), url('../../fonts/open-sans2/xjAJXh38I15wypJXxuGMBobN6UDyHWBl620a-IRfuBk.woff') format('woff');
}
/*"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue", Helvetica, "Microsoft Yahei", Verdana, Simsun, "Segoe UI", "Segoe UI Web Regular", "Segoe UI Symbol", "BBAlpha Sans", "S60 Sans", Arial, sans-serif;*/
@selectionBg: @aBlackColor;
@selectionColor: #fff;
::selection { background:@selectionBg; color:@selectionColor; }
::-moz-selection { background:@selectionBg; color:@selectionColor; }
::-webkit-selection { background:@selectionBg; color:@selectionColor; }
html,body {
background-color: @bgColor;
}
*, body {
font-family: @fontFamily;
font-weight: 300;
font-size: @fontSize;
}
h1, h2, h3 {
font-family: @fontFamily;
font-weight: 300 !important;
}
a {
color: @aBlackColor;
cursor: pointer;
}
a:hover {
text-decoration: none !important;
color: @aBlackColor;
}
// 原生的a
a.raw {
color: #428bca;
}
a.raw:hover {
color: #2a6496;
}
/* header */
#header {
height: @headerHeight;
background-color: @headerBgColor;
color: @aWhiteColor;
a {
color: #ccc;//@aWhiteColor;
/**
* 写作模式
*/
body.writting {
&.init #pageInner {
display: block;
}
li {
color: @aBlackColor;
#mainMask,
#leftNotebook,
.noteSplit,
#noteList
{
display: none;
}
li a {
color: @aBlackColor;
#noteAndEditor {
left: 0 !important;
}
border-bottom: 1px solid @borderColor;
/* for app */
webkit-user-select: none; /* 还不知 */
-webkit-app-region: drag; /* -webkit-app-region: no-drag; */
}
#note {
left: 0 !important;
// left: 100px !important;
// right: 100px !important;
#searchWrap, #logo, #switcher,
#leftNotebook,
.noteSplit
{
display: none;
}
// padding: 0 100px;
#header ul {
margin:0;
padding:0;
list-style: none;
}
#header ul li.dropdown {
display: inline-block;
height: @headerHeight;
}
#header ul > li > a.dropdown-toggle {
display: block;
padding: 15px 5px 0 0;
position: relative;
}
#header span.icon {
display: inline-block;
font-size: 28px;
color: #999999;
}
.dropdown-menu {
border-radius: 0;
margin:0;
-webkit-box-shadow: none;
box-shadow: none;
border: 1px solid @hColor;
overflow-x: hidden;
overflow-y: auto;
}
.dropdown-menu li {
padding-left: 10px;
width: 100%;
height: 30px; // 父设置了line-height, 子下拉也受影响, "新建笔记"
line-height: 30px;
}
.dropdown-menu > li > a {
color: @aBlackColor;
display: inline-block;
padding: 3px 3px;
}
.dropdown-menu>li:hover, .dropdown-menu>li:focus {
background-color: @borderColor;
}
.dropdown-menu > li > a:hover, .dropdown-menu > li > a:focus {
background-color: @borderColor;
}
.ios7-a {
display: inline-block;
padding: 0 10px 0 5px;
height: 40px;
vertical-align: middle;
line-height: 38px;
cursor: pointer;
}
/*********************/
#page {
overflow: auto;
position: absolute;
top: 0;
left: 0;
bottom: 0;
right: 0;
}
#pageInner {
position: absolute;
top: 0;
left: 0;
height: 100%;
width: 100%;
overflow: hidden;
}
#mainContainer {
position: absolute;
top: 0;
left: 0;
right: 0;
bottom: 0;
overflow: auto;
zoom: 1;
}
#search {
border: #bababa 1px solid;
background-color: #fff;
white-space: nowrap;
position: absolute;
height: 30px;
left:3px;
right:60px;
margin-top: 3px;
}
#search label {
display: none;
}
#searchButton {
border: 0 none;
width: 16px;
height: 16px;
overflow: hidden;
cursor: pointer;
position: absolute;
right:3px;
top: 5px;
}
#searchInput {
border: 0 none;
overflow: hidden;
position: absolute;
right:20px;
left: 0px;
padding-left: 10px;
height: 28px;
}
#searchInput:focus {
border: none;
outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px
}
#notesAndSort {
background-color: #eee; // #65bd77; // @bgColor;
border-bottom: 1px solid @borderColor;
a.dropdown-toggle {
// color: #fff;
}
}
/* item list */
#noteItemList {
position: absolute;
left:0;
right:0;
bottom: 0;
top: 0;
width: 100%;
overflow-y: hidden;
background-color: #f7f7f7;
padding: 0 5px;
}
#noteItemList .item {
position: relative;
height: 110px;
overflow: hidden;
cursor: pointer;
padding: 5px;
border: 1px solid @borderColor;
border-radius: 3px;
margin-top: 5px;
background-color: #fff;
}
#noteItemList .item:hover,
#noteItemList .contextmenu-hover {
background-color: #ddd !important;
color: @aBlackColor;
.item-title {
// color: @aBlackColor;
//font-weight: 800;
}
}
#noteItemList .item-thumb {
padding-left: 10px;
width: 100px;
height: 100px;
overflow: hidden;
position: absolute;
right: 0px;
height: 100px;
background-color: #fff;
margin-right: 5px;
}
.item-thumb img {
width: 100px;
}
#noteItemList .item-desc {
position: absolute;
left: 0;
right: 100px;
margin-left: 4px;
.fa { // folder, calender 颜色暗些
color: #666;
}
}
// blog
#noteItemList .item-blog {
position: absolute;
right: 1px;
font-size: 10px;
z-index: 2;
top: 1px;
padding: 3px;
cursor: pointer;
.fa {
color: #fff !important;
}
width: 20px;
text-align: center;
opacity: 0.5;
&:hover {
opacity: 0.8;
}
background-color: #464C5E;
}
.item-title {
/*font-weight: 400;*/
font-size: 16px;
height: 22px;
line-height: 20px;
overflow: hidden;
margin-bottom: 0px;
color: @aBlackColor;
border-bottom: dashed 1px @borderColor;
}
/* note */
/* editor */
#editorTool {
margin: 0;
padding: 0;
list-style: none;
// width: 200px;
}
#editorTool li {
display: inline-block;
}
#noteTitle:focus {
// outline:thin dotted #333;outline:1px auto -webkit-focus-ring-color;outline-offset:-2px
outline: none !important;
// border: 1px solid @hColor;
}
#editor, #mdEditor{
z-index: 2;
top: 71px;
bottom: 0px;
right: 0;
left: 0;
padding: 0; // 0px 0px 0px 0px;
display: none;
}
#mdEditor {
z-index: 1;
background-color: #fff;
bottom: 10px;
#md-section-helper, #wmd-input {
font-size: 14px;
line-height: 22px;
#tool {
}
}
#editorContent {
position: absolute;
top:30px;
bottom: 10px;
right: 0;
left: 0;
overflow: auto; // 不设置editor隐藏时没有scroll
}
#editorContent_ifr {
// padding-top: 10px;
#noteTitleDiv {
left: 100px;
}
#noteTitle {
text-align: center;
}
#editor, #mdEditor {
bottom: 0;
}
#editor {
background-color: @bgColor;
}
#editorContentWrap {
position: absolute;
padding: 5px 0;
top: 40px;
left: 0;
right: 0;
bottom: 0;
overflow-y: auto;
}
#editorContent {
position: relative;
max-width: 800px;
margin: auto;
background-color: #fff;
top: 0 !important;
// margin-top: 5px;
border-radius: 5px;
min-height: 100%;
box-shadow: 0 1px 10px #ccc;
font-size: 16px;
p {
margin: 10px 0;
}
}
#editorBottom {
display: none;
}
}
#editor {
#mceToolbar {
height: 40px;
}
// 所有都展开
&.all-tool {
#mceToolbar {
height: 70px;
}
#editorContentWrap {
top: 70px;
}
}
}
}
/* 包裹iframe */
#editor .mce-ifr {
border: none;
// padding: 10px;
overflow: hidden !important; /*不知道哪里设置了auto*/
/*border-radius: 5px;*/
// border: 1px solid @borderColor;
// border-top-left-radius: 5px;
// border-bottom-left-radius: 5px;
}
/* 最顶层 */
#editor .mce-tinymce {
border: none;
}
#editor iframe {
}
/*编辑器按钮*/
#mceToolbar, #wmd-button-bar {
#mceToolbar,
#mdEditor .navbar-default,
#wmd-button-bar {
position: relative;
height: 30px;
height: 40px;
padding: 5px 0;
overflow: hidden;
background-color: @bgColor;
background-color: #fbfcf7;
border: none;
box-shadow: 0 3px 10px #eee;
z-index: 10; // 把content覆盖
}
#mdEditor {
.extension-preview-buttons, .layout-wrapper-l3 {
top: 40px !important;
}
}
#left-column, #right-column, #mdSplitter {
top: 3px;
}
/* 编辑器工具 需要important, 因为mce还要有js加载css, 肯定在此之后 */
@@ -436,398 +133,32 @@ a.raw:hover {
font-family: @fontFamily !important;
}
.mce-primary button, .mce-primary button i {
text-shadow: none;
text-shadow: none;
}
.mce-primary {
background-color: #47a447 !important;
border-color: #398439 !important;
background-color: #47a447 !important;
border-color: #398439 !important;
}
// 下拉
.mce-menu-item:hover, .mce-menu-item.mce-selected, .mce-menu-item:focus {
background-color: @borderColor;
span {
color: #000 !important;
}
background-color: @borderColor;
span {
color: #000 !important;
}
}
// 下拉选中
.mce-menu-item-normal.mce-active {
background-color: @borderColor;
}
// tool的分隔
.tool-split {
display: inline-block;
line-height: 25px;
color: #ddd;
background-color: @borderColor;
}
/*标签与其它工具*/
#tool {
display: none;
border-bottom: 1px solid #ddd;
.mce-menubtn.mce-fixed-width.mce-btn-small span {
width: 80px;
}
.mce-menubtn.mce-btn-small span {
font-size: 16px;
}
/* tag */
#tag {
height: 40px;
line-height: 38px
#wmd-input > .editor-content, .preview-container {
font-size: 16px;
font-family: "Helvetica Neue",Helvetica,Arial,sans-serif;
}
// 前面的38影响了dropdown
#tag .dropdown {
line-height: 30px;
}
#addTagInput {
line-height: 25px;
display: none;
padding:0;
border: none;
background-color: @bgColor;
}
#addTagInput:focus {
outline: none;
}
.label-default {
background-color: #464C5E;
}
.label-red {
background-color: #d9534f;
}
.label-yellow {
background-color: #f0ad4e;
}
.label-blue {
background-color: #428bca;
}
.label-green {
background-color: #5cb85c;
}
.label {
border-radius: 0;
font-weight: normal;
}
.label i {
width: 10px;
cursor: pointer;
font-style: normal;
/*border-left: 1px solid #ccc;*/
display: inline-block;
padding-left: 3px;
opacity: 0;
}
.label i:hover {
opacity: 1;
// font-weight: bold;
}
/* leanote nav */
#leanoteNav {
position: absolute;
right: 5px;
border: 1px solid #ccc;
border-radius: 3px;
background-color: #fff;
opacity: 0.5;
// display: none;
z-index: 11;
margin-right: 2px;
h1 {
margin:0;
font-size: 18px;
padding: 3px;
cursor: pointer;
}
i {
padding: 3px;
}
span {
display: none;
}
#leanoteNavContent {
display: none;
overflow: auto;
}
}
#leanoteNav.unfolder {
min-width: 200px;
max-width: 300px;
// bottom: 1px;
opacity: 0.8;
h1 {
border-bottom: 1px dashed @borderColor;
}
span {
display: inline;
}
#leanoteNavContent {
display: block;
min-height: 30px;
}
}
#leanoteNav ul {
margin:0;
padding-left: 23px;
li {
list-style-type: disc;
a {
&:hover {
color: @hColor;
}
}
}
}
#leanoteNav ul .nav-h1 {
}
#leanoteNav ul .nav-h2 {
margin-left: 20px;
}
#leanoteNav ul .nav-h3 {
margin-left: 30px;
}
#leanoteNav ul .nav-h4 {
margin-left: 40px;
}
#leanoteNav ul .nav-h5 {
margin-left: 50px;
}
.scrollTo-a {
cursor: pointer !important;
}
//---------------
// note for read
#noteRead {
position: absolute;
left: 0;
right: 0;
top: 0;
bottom: 0;
display: none;
z-index: 100;
padding-left: 5px;
background-color: #fff;
}
#noteReadContainer {
position: relative;
width: 100%;
height: 100%;
}
@noteReadTopHeight: 60px;
#noteReadTop {
position: absolute;
height: @noteReadTopHeight;
left:0;
right: 0;
border-bottom: 1px solid @borderColor;
}
#noteReadTitle {
margin: 3px 0;
}
#noteReadContent {
position: absolute;
top: @noteReadTopHeight;
bottom: 0;
right: 0;
left: 0;
overflow: auto;
padding: 3px;
}
@sbc: @bgColor;
/*scroll*/
/*
::-webkit-scrollbar {
width: 5px;
height: 8px;
background: none;
}
::-webkit-scrollbar-thumb {
background-color: #41586e;
opacity: 0.1;
}
::-webkit-scrollbar-thumb:hover {
background-color:#dadada
}
::-webkit-scrollbar-thumb:active {
background-color:#606060
}
::-webkit-scrollbar-thumb:disabled {
background-color:#f9f9f9
}
::-webkit-scrollbar-corner {
background-color:#f0f0f0
}
::-webkit-scrollbar-button {
height: 0;
background-color:#f0f0f0;
background-repeat:no-repeat
}
::-webkit-scrollbar-button:vertical {
height:0px
}
::-webkit-scrollbar-button:horizontal {
width:33px
}
::-webkit-scrollbar-button:horizontal:increment {
background-position:0 -444px
}
::-webkit-scrollbar-button:horizontal:decrement {
background-position:12px -425px
}
::-webkit-scrollbar-button:vertical:increment {
background-position:-1px -391px
}
::-webkit-scrollbar-button:vertical:decrement {
background-position:-1px -358px
}
::-webkit-scrollbar-button:hover {
background-color:#dadada
}
::-webkit-scrollbar-button:horizontal:increment:hover {
background-position:0 -548px
}
::-webkit-scrollbar-button:horizontal:decrement:hover {
background-position:12px -529px
}
::-webkit-scrollbar-button:vertical:increment:hover {
background-position:-1px -495px
}
::-webkit-scrollbar-button:vertical:decrement:hover {
background-position:-1px -462px
}
::-webkit-scrollbar-button:active {
background-color:#606060
}
::-webkit-scrollbar-button:horizontal:increment:active {
background-position:0 -652px
}
::-webkit-scrollbar-button:horizontal:decrement:active {
background-position:12px -633px
}
::-webkit-scrollbar-button:vertical:increment:active {
background-position:-1px -599px
}
::-webkit-scrollbar-button:vertical:decrement:active {
background-position:-1px -566px
}
::-webkit-scrollbar-button:disabled {
background-color:#f9f9f9
}
::-webkit-scrollbar-button:horizontal:increment:disabled {
background-position:0 -756px
}
::-webkit-scrollbar-button:horizontal:decrement:disabled {
background-position:12px -737px
}
::-webkit-scrollbar-button:vertical:increment:disabled {
background-position:-1px -703px
}
::-webkit-scrollbar-button:vertical:decrement:disabled {
background-position:-1px -670px
}
*/
/*from notebook*/
/*::-webkit-scrollbar{width:7px;height:7px;}::-webkit-scrollbar-thumb{background-color:rgba(50,50,50,0.3);}::-webkit-scrollbar-thumb:hover{background-color:rgba(50,50,50,0.6);}::-webkit-scrollbar-track{background-color:rgba(50,50,50,0.1);}::-webkit-scrollbar-track:hover{background-color:rgba(50,50,50,0.2);}
*/
#editorContent_ifr {
// border: 1px solid red;
}
.fa-calendar {
color: #666;
}
.dropdown-menu .fa {
width: 15px;
}
.dropdown-menu span, .dropdown-menu a, .dropdown-menu li {
cursor: default;
}
// 顶部导航, 博客
#topNav a {
display: inline-block;
line-height: 60px;
}
.tab-pane {
padding: 5px 0 0 0;
}
.alert {
margin-bottom: 10px;
}
.btn {
border-radius: 0 !important;
}
.mce-container-body iframe {
//overflow-x: hidden; // firefox 不能要
//overflow-y: hidden;
}
// 新建笔记item
#notebookNavForNewNote li, #notebookNavForNewSharedNote > li {
padding-left: 0;
border-bottom: 1px solid @borderColor;
}
#notebookNavForNewNote > li:hover, #notebookNavForNewNote > li:focus,
#notebookNavForNewSharedNote > li:hover, #notebookNavForNewSharedNote > li:focus {
background: none;
}
.new-note-left {
padding: 0 5px;
width: 95px;
overflow: hidden;
white-space:nowrap;
border-right: 1px dashed @borderColor;
&:hover {
background-color:@borderColor;
}
}
.new-note-right {
padding: 0 5px;
&:hover {
background-color:@borderColor;
}
}
// 历史记录
#historyList {
table {
width: 100%;
}
.btns{
border-top: 1px dashed #eee;
padding: 5px 0;
}
}
#left-column {
width: 100% !important;
}
#editorMask {
position: absolute; top: 0px; bottom: 0px; right: 0; left: 0;
background-color: #fff;
z-index: -10;
.fa, a {
font-size: 24px;
}
padding-top: 50px;
text-align: center;
a {
display: inline-block;
border-radius: 3px;
border: 1px solid @borderColor;
padding: 10px;
&:hover {
background-color: @noteActiveBg;
color: #fff;
}
}
}

View File

@@ -1152,7 +1152,8 @@ a.input-group-addon {
line-height: 1.65;
letter-spacing: normal;
border-radius: 0;
color: #5a5a5a;
/*color: #5a5a5a;*/
color: #000;
-webkit-box-shadow: none;
box-shadow: none;
resize: none;

View File

@@ -227,6 +227,10 @@ Note.renderNotesAndTargetNote = function(ret, noteId) {
}
};
Note.alertWeb = function(msg) {
alert(msg);
};
// 当前的note是否改变过了?
// 返回已改变的信息
// force bool true表示content比较是比较HTML, 否则比较text, 默认为true
@@ -630,6 +634,7 @@ Note.changeNoteForPjax = function(noteId, mustPush, needTargetNotebook) {
// 点击notebook时调用, 渲染第一个笔记
Note.contentAjax = null;
Note.contentAjaxSeq = 1;
Note.inChangeNoteId = '';
Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
var self = this;
@@ -651,6 +656,7 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
// 2. 设空, 防止在内容得到之前又发生保存
Note.curNoteId = "";
Note.inChangeNoteId = selectNoteId;
// 2 得到现在的
// ajax之
@@ -718,8 +724,8 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged, callback) {
self.showContentLoading();
console.error('chage note..........');
console.trace();
// console.error('chage note..........');
// console.trace();
Service.noteService.getNoteContent(cacheNote.NoteId, setContent); // ajaxGet(url, param, setContent);
}
@@ -812,8 +818,8 @@ Note.renderNote = function(note) {
// render content
Note.renderNoteContent = function(content) {
console.error('---------------- note:' + note.Title);
console.trace();
// console.error('---------------- note:' + note.Title);
// console.trace();
setEditorContent(content.Content, content.IsMarkdown, content.Preview);
// 只有在renderNoteContent时才设置curNoteId
@@ -825,6 +831,14 @@ Note.renderNoteContent = function(content) {
Note.renderChangedNote(content);
};
Note.renderNoteDesc = function(note) {
// life
// 重新渲染到左侧 desc, 因为笔记传过来是没有desc的
note.Desc = Note.genDesc(note.Content);
note.ImgSrc = Note.getImgSrc(note.Content);
Note.renderChangedNote(note);
};
// 初始化时渲染最初的notes
/**
<div id="noteItemList">
@@ -917,8 +931,9 @@ Note.renderNotes = function(notes, forNewNote, isShared) {
}
})(i), i*2000);
}
}
;
};
Note._getNoteHtmlObjct = function(note, isShared) {
var baseClasses = "item-my";
if(isShared) {
@@ -958,6 +973,10 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
}
var note = notes[i];
if(note.InitSync) {
Note.getNoteContentLazy(note.NoteId);
}
if(!note.Desc && note.Content) {
note.Desc = Note.genDesc(note.Content);
}
@@ -1897,21 +1916,38 @@ Note.showConflictInfo = function(target, e) {
// 内容已同步成功
Note.contentSynced = function(noteId, content) {
var me = this;
var note = me.getCurNote();
var note = me.getNote(noteId);
if(!note) {
// 可能之前还没有
// me.setNoteCache(noteId, {Content: content});
return;
}
if(note.InitSync) {
// 重新render内容
note.InitSync = false;
note.Content = content;
if(me.curNoteId == noteId) {
if(me.curNoteId == noteId || me.inChangeNoteId == noteId) {
// alert(note.Title);
// 重新渲染
Note.changeNote(noteId);
} else {
// 生成desc
me.renderNoteDesc(note);
}
}
};
// 延迟加载内容
Note.getNoteContentLazy = function(noteId) {
setTimeout(function() {
NoteService.getNoteContent(noteId, function(contentO) {
if(typeof contentO == 'object') {
Note.contentSynced(noteId, contentO.Content);
}
});
}, 10);
};
// 这里速度不慢, 很快
Note.getContextNotebooks = function(notebooks) {

View File

@@ -1,138 +1,60 @@
// 主页渲染
//-------------
//----------------------
// 编辑器模式
function editorMode() {
this.writingHash = "writing";
this.normalHash = "normal";
this.isWritingMode = location.hash.indexOf(this.writingHash) >= 0;
this.toggleA = null;
}
var Resize;
editorMode.prototype.toggleAText = function(isWriting) {
var self = this;
setTimeout(function() {
var toggleA = $(".toggle-editor-mode a");
var toggleSpan = $(".toggle-editor-mode span");
if(isWriting) {
toggleA.attr("href", "#" + self.normalHash);
toggleSpan.text(getMsg("normalMode"));
} else {
toggleA.attr("href", "#" + self.writingHash);
toggleSpan.text(getMsg("writingMode"));
}
}, 0);
}
editorMode.prototype.isWriting = function(hash) {
return hash.indexOf(this.writingHash) >= 0
}
editorMode.prototype.init = function() {
this.changeMode(this.isWritingMode);
var self = this;
$(".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);
// 写作模式
var Writting = {
_mode: 'normal', // writting
themeWrittingO: $('#themeWritting'),
writtingToggleO: $('#writtingToggle'),
bodyO: $('body'),
isWriting: function() {
return this._mode != 'normal';
},
init: function() {
var me = this;
me.writtingToggleO.click(function() {
me.toggle();
});
},
// 初始化写作
// 主要是markdown两列宽度问题
initWritting: function() {
var width = UserInfo.MdEditorWidthForWritting;
// 设中间
if(!width) {
width = this.bodyO.width() / 2;
}
restoreBookmark();
});
}
// 改变模式
editorMode.prototype.changeMode = function(isWritingMode) {
this.toggleAText(isWritingMode);
if(isWritingMode) {
this.writtingMode();
} else {
this.normalMode();
}
$("#moreBtn i").removeClass("fa-angle-up").addClass("fa-angle-down");
}
editorMode.prototype.resizeEditor = function() {
// css还没渲染完
setTimeout(function() {
Resize.setMdColumnWidth(width);
// $("#mceToolbar").css("height", "40px");
resizeEditor();
}, 10);
setTimeout(function() {
},
initNormal: function() {
Resize.setMdColumnWidth(UserInfo.MdEditorWidth);
// $("#mceToolbar").css("height", "30px");
resizeEditor();
}, 20);
setTimeout(function() {
resizeEditor();
}, 500);
}
editorMode.prototype.normalMode = function() {
/*
var w = $(document).width();
var h = $(document).height();
$("#lock").css({right:0, bottom:0});
*/
var $c = $("#editorContent_ifr").contents();
$c.contents().find("#writtingMode").remove();
$c.contents().find('link[href$="editor-writting-mode.css"]').remove();
$("#noteItemListWrap, #notesAndSort").show();
$("#noteList").unbind("mouseenter").unbind("mouseleave");
var theme = UserInfo.Theme || "default";
theme += ".css";
$("#themeLink").attr("href", "/css/theme/" + theme);
$("#mceToolbar").css("height", "30px");
// $("#lock").animate({right:w},1000);
this.resizeEditor();
$("#noteList").width(UserInfo.NoteListWidth);
$("#note").css("left", UserInfo.NoteListWidth + 2);
}
editorMode.prototype.writtingMode = function() {
// $("#pageInner").removeClass("animated fadeInUp");
$("#themeLink").attr("href", "/css/theme/writting-overwrite.css");
setTimeout(function() {
var $c = $("#editorContent_ifr").contents();
$c.contents().find("head").append('<link type="text/css" rel="stylesheet" href="/css/editor/editor-writting-mode.css" id="writtingMode">');
}, 0);
$("#noteItemListWrap, #notesAndSort").fadeOut();
$("#noteList").hover(function() {
$("#noteItemListWrap, #notesAndSort").fadeIn();
}, function() {
$("#noteItemListWrap, #notesAndSort").fadeOut();
});
// 点击扩展会使html的height生成, 切换后会覆盖css文件的
$("#mceToolbar").css("height", "40px");
//$("#pageInner").addClass("animated fadeInUp");
},
this.resizeEditor();
$("#noteList").width(250);
$("#note").css("left", 0);
}
toggle: function() {
var me = this;
me.themeWrittingO.attr('disabled', me._mode != 'normal');
me._mode = me._mode == 'normal' ? 'writting' : 'normal';
editorMode.prototype.getWritingCss = function() {
if(this.isWritingMode) {
return ["/css/editor/editor-writting-mode.css"];
}
return [];
}
var em = new editorMode();
// 改变icon
if(me._mode != 'normal') {
$('body').addClass('writting');
me.writtingToggleO.find('.fa').removeClass('fa-expand').addClass('fa-compress');
me.initWritting();
} else {
$('body').removeClass('writting');
me.writtingToggleO.find('.fa').removeClass('fa-compress').addClass('fa-expand');
me.initNormal();
}
},
};
//----------------
// 拖拉改变变宽度
@@ -233,7 +155,12 @@ var Resize = {
var self = this;
if(self.lineMove || self.mdLineMove) {
// ajax保存
UserService.updateG({MdEditorWidth: UserInfo.MdEditorWidth, NotebookWidth: UserInfo.NotebookWidth, NoteListWidth: UserInfo.NoteListWidth}, function() {
UserService.updateG({
MdEditorWidth: UserInfo.MdEditorWidth,
MdEditorWidthForWritting: UserInfo.MdEditorWidthForWritting,
NotebookWidth: UserInfo.NotebookWidth,
NoteListWidth: UserInfo.NoteListWidth
}, function() {
});
}
self.lineMove = false;
@@ -294,11 +221,17 @@ var Resize = {
self.setMdColumnWidth(mdEditorWidth);
}
},
// 设置宽度
setMdColumnWidth: function(mdEditorWidth) {
var self = this;
if(mdEditorWidth > 100) {
UserInfo.MdEditorWidth = mdEditorWidth;
if(Writting.isWriting()) {
UserInfo.MdEditorWidthForWritting = mdEditorWidth;
} else {
UserInfo.MdEditorWidth = mdEditorWidth;
}
// log(mdEditorWidth)
self.leftColumn.width(mdEditorWidth);
self.rightColumn.css("left", mdEditorWidth);
@@ -310,7 +243,7 @@ var Resize = {
MD.onResize();
}
}
}
};
//--------------------------
// 手机端访问之
@@ -337,23 +270,6 @@ Mobile = {
init: function() {
var self = this;
self.isMobile();
// $(window).on("hashchange", self.hashChange);
// self.hashChange();
/*
$("#noteItemList").on("tap", ".item", function(event) {
$(this).click();
});
$(document).on("swipeleft",function(e){
e.stopPropagation();
e.preventDefault();
self.toEditor();
});
$(document).on("swiperight",function(e){
e.stopPropagation();
e.preventDefault();
self.toNormal();
});
*/
},
isMobile: function() {
var u = navigator.userAgent;
@@ -409,31 +325,10 @@ Mobile = {
}
return false;
}
}
};
function initSlimScroll() {
if(Mobile.isMobile()) {
return;
}
$("#notebook").slimScroll({
height: "100%", // $("#leftNotebook").height()+"px"
});
$("#noteItemList").slimScroll({
height: "100%", // ($("#leftNotebook").height()-42)+"px"
});
/*
$("#wmd-input").slimScroll({
height: "100%", // $("#wmd-input").height()+"px"
});
$("#wmd-input").css("width", "100%");
*/
$("#wmd-panel-preview").slimScroll({
height: "100%", // $("#wmd-panel-preview").height()+"px"
});
$("#wmd-panel-preview").css("width", "100%");
return;
}
//-----------
@@ -444,7 +339,16 @@ function initEditor() {
var mceToobarEverHeight = 0;
$("#moreBtn").click(function() {
saveBookmark();
var $editor = $('#editor');
if($editor.hasClass('all-tool')) {
$editor.removeClass('all-tool');
} else {
$editor.addClass('all-tool');
}
restoreBookmark();
return;
var height = $("#mceToolbar").height();
// 现在是折叠的
@@ -473,7 +377,7 @@ function initEditor() {
var num = e.which ? e.which : e.keyCode;
if(e.ctrlKey || e.metaKey) {
if(num == 86) { // ctrl + v
document.execCommand('paste');
// document.execCommand('paste');
}
};
});
@@ -493,8 +397,7 @@ 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 : ["public/css/editor/editor.css"].concat(em.getWritingCss()),
content_css : ["public/css/editor/editor.css"],
skin : "custom",
language: LEA.locale, // 语言
plugins : [
@@ -542,6 +445,9 @@ function initEditor() {
var random = 1;
function scrollTo(self, tagName, text) {
var iframe = $("#editorContent"); // .contents();
if(Writting.isWriting()) {
iframe = $('#editorContentWrap');
}
var target = iframe.find(tagName + ":contains(" + text + ")");
random++;
@@ -566,22 +472,6 @@ function scrollTo(self, tagName, text) {
// log(top);
// iframe.scrollTop(top);
iframe.animate({scrollTop: top}, 300); // 有问题
/*
var d = 200; // 时间间隔
for(var i = 0; i < d; i++) {
setTimeout(
(function(top) {
return function() {
iframe.scrollTop(top);
}
})(nowTop + 1.0*i*(top-nowTop)/d), i);
}
// 最后必然执行
setTimeout(function() {
iframe.scrollTop(top);
}, d+5);
*/
return;
}
}
@@ -629,105 +519,13 @@ $(function() {
function openSetInfoDialog(whichTab) {
showDialogRemote("/user/account", {tab: whichTab});
}
// 帐号设置
$("#setInfo").click(function() {
openSetInfoDialog(0);
});
// 邮箱验证
$("#wrongEmail").click(function() {
openSetInfoDialog(1);
});
$("#setAvatarMenu").click(function() {
showDialog2("#avatarDialog", {title: "头像设置", postShow: function() {
}});
});
$("#setTheme").click(function() {
showDialog2("#setThemeDialog", {title: "主题设置", postShow: function() {
if (!UserInfo.Theme) {
UserInfo.Theme = "default";
}
$("#themeForm input[value='" + UserInfo.Theme + "']").attr("checked", true);
}});
});
//---------
// 主题
$("#themeForm").on("click", "input", function(e) {
var val = $(this).val();
$("#themeLink").attr("href", "/css/theme/" + val + ".css");
ajaxPost("/user/updateTheme", {theme: val}, function(re) {
if(reIsOk(re)) {
UserInfo.Theme = val
}
});
});
//-------------
// 邮箱验证
if(!UserInfo.Verified) {
// $("#leanoteMsg").hide();
// $("#verifyMsg").show();
}
// 禁止双击选中文字
$("#notebook, #newMyNote, #myProfile, #topNav, #notesAndSort", "#leanoteNavTrigger").bind("selectstart", function(e) {
e.preventDefault();
return false;
});
// 左侧隐藏或展示
function updateLeftIsMin(is) {
ajaxGet("/user/updateLeftIsMin", {leftIsMin: is})
}
function minLeft(save) {
$("#leftNotebook").width(30);
$("#notebook").hide();
// 左侧
$("#noteAndEditor").css("left", 30)
$("#notebookSplitter").hide();
// $("#leftSwitcher").removeClass("fa-angle-left").addClass("fa-angle-right");
// logo
$("#logo").hide();
$("#leftSwitcher").hide();
$("#leftSwitcher2").show();
$("#leftNotebook .slimScrollDiv").hide();
if(save) {
updateLeftIsMin(true);
}
}
function maxLeft(save) {
$("#noteAndEditor").css("left", UserInfo.NotebookWidth);
$("#leftNotebook").width(UserInfo.NotebookWidth);
$("#notebook").show();
$("#notebookSplitter").show();
// $("#leftSwitcher").removeClass("fa-angle-right").addClass("fa-angle-left");
$("#leftSwitcher2").hide();
$("#logo").show();
$("#leftSwitcher").show();
$("#leftNotebook .slimScrollDiv").show();
if(save) {
updateLeftIsMin(false);
}
}
$("#leftSwitcher2").on('click', function() {
maxLeft(true);
});
$("#leftSwitcher").click('click', function() {
if(Mobile.switchPage()) {
minLeft(true);
}
});
// 得到最大dropdown高度
// 废弃
function getMaxDropdownHeight(obj) {
@@ -742,26 +540,6 @@ $(function() {
return preHeight < maxHeight ? preHeight : maxHeight;
}
// mini版
// 点击展开
$("#notebookMin div.minContainer").click(function() {
var target = $(this).attr("target");
maxLeft(true);
if(target == "#notebookList") {
if($("#myNotebooks").hasClass("closed")) {
$("#myNotebooks .folderHeader").trigger("click");
}
} else if(target == "#tagNav") {
if($("#myTag").hasClass("closed")) {
$("#myTag .folderHeader").trigger("click");
}
} else {
if($("#myShareNotebooks").hasClass("closed")) {
$("#myShareNotebooks .folderHeader").trigger("click");
}
}
});
//------------------------
// 界面设置, 左侧是否是隐藏的
UserInfo.NotebookWidth = UserInfo.NotebookWidth || $("#notebook").width();
@@ -771,54 +549,6 @@ $(function() {
Resize.set3ColumnsWidth(UserInfo.NotebookWidth, UserInfo.NoteListWidth);
Resize.setMdColumnWidth(UserInfo.MdEditorWidth);
if (UserInfo.LeftIsMin) {
minLeft(false);
}
// 4/25 防止dropdown太高
// dropdown
$('.dropdown').on('shown.bs.dropdown', function () {
var $ul = $(this).find("ul");
// $ul.css("max-height", getMaxDropdownHeight(this));
});
//--------
// 编辑器帮助
$("#tipsBtn").click(function() {
showDialog2("#tipsDialog");
});
//--------
// 建议
$("#yourSuggestions").click(function() {
showDialog2("#suggestionsDialog");
});
$("#suggestionBtn").click(function(e) {
e.preventDefault();
var suggestion = $.trim($("#suggestionTextarea").val());
if(!suggestion) {
$("#suggestionMsg").html("请输入您的建议, 谢谢!").show().addClass("alert-warning").removeClass("alert-success");
$("#suggestionTextarea").focus();
return;
}
$("#suggestionBtn").html("正在处理...").addClass("disabled");
$("#suggestionMsg").html("正在处理...");
$.post("/suggestion", {suggestion: suggestion}, function(ret) {
$("#suggestionBtn").html("提交").removeClass("disabled");
if(ret.Ok) {
$("#suggestionMsg").html("谢谢反馈, 我们会第一时间处理, 祝您愉快!").addClass("alert-success").removeClass("alert-warning").show();
} else {
$("#suggestionMsg").html("出错了").show().addClass("alert-warning").removeClass("alert-success");
}
});
});
// 编辑器模式
em.init();
// 手机端?
Mobile.init();
// markdown preview下的a不能点击
$('#preview-contents').on('click', 'a', function(e) {
e.preventDefault();
@@ -1693,7 +1423,7 @@ var Pren = {
if(e.keyCode == 27) {
if(me._isPren) {
me.togglePren();
} else if(isFullscreen) {
} else if(me._isFullscreen) {
me.toggleFullscreen();
}
}
@@ -1715,6 +1445,7 @@ var Pren = {
}
};
// user
function userMenu() {
//-------------------
@@ -1830,5 +1561,6 @@ function userMenu() {
$(function() {
initUploadImage();
userMenu();
Writting.init();
});

View File

@@ -717,25 +717,10 @@ function getObjectId() {
//-----------------------------------------
function resizeEditor(second) {
var ifrParent = $("#editorContent_ifr").parent();
ifrParent.css("overflow", "auto");
var height = $("#editorContent").height();
ifrParent.height(height);
// log(height + '---------------------------------------')
$("#editorContent_ifr").height(height);
// life 12.9
// inline editor
$("#editorContent").css("top", $("#mceToolbar").height());
/*
// 第一次时可能会被改变
if(!second) {
setTimeout(function() {
resizeEditorHeight(true);
}, 1000);
}
*/
return;
var h = $("#mceToolbar").height()
$("#editorContent").css("top", h);
$("#editorContentWrap").css('top', h);
}
//----------
@@ -1396,6 +1381,7 @@ function commonCmd(e) {
document.execCommand('copy');
} else if(num == 86) { // ctrl + v
document.execCommand('paste');
console.log("paste--------------")
} else if(num == 65) { // ctrl + a
document.execCommand('selectAll');
} else if(num == 88) { // ctrl + x