Support note list view and sorter

This commit is contained in:
lealife
2017-02-18 20:01:43 +08:00
parent ae29119664
commit d5d853ffd3
21 changed files with 1533 additions and 261 deletions

View File

@ -345,63 +345,74 @@ function log(o) {
</div> </div>
<div id="noteList"> <div id="noteList">
<div class="clearfix" id="notesAndSort" style="position: relative"> <div class="clearfix" id="notesAndSort" style="position: relative">
<div class="pull-left"> <div class="pull-left">
<!-- 我的笔记本 --> <!-- 我的笔记本 -->
<div class="dropdown" id="myNotebookNavForListNav"> <div class="dropdown" id="myNotebookNavForListNav">
<a class="ios7-a dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown"> <a class="ios7-a">
<span id="curNotebookForListNote">{{msg . "all"}}</span> <span id="curNotebookForListNote">{{msg . "all"}}</span>
<!--
<i class="fa fa-angle-down"></i>
-->
</a> </a>
<!-- 如果notebook过多, 则会产生滚动 弃用
<div class="dropdown-menu dropdown-list" style="left: 5px;">
<ul role="menu" aria-labelledby="dropdownMenu1" id="notebookNavForListNote"></ul>
</div>
-->
</div> </div>
<!-- 共享的笔记本 --> <!-- 共享的笔记本 -->
<div class="dropdown" id="sharedNotebookNavForListNav" style="display: none"> <div class="dropdown" id="sharedNotebookNavForListNav" style="display: none">
<a class="ios7-a dropdown-toggle" id="dropdownMenu2" data-toggle="dropdown"> <a class="ios7-a">
<span id="curSharedNotebookForListNote">{{msg . "all"}}</span> <span id="curSharedNotebookForListNote">{{msg . "all"}}</span>
<!--
<i class="fa fa-angle-down"></i>
-->
</a> </a>
<ul class="dropdown-menu" role="menu" </div>
aria-labelledby="dropdownMenu2" style="left: 5px;" id="sharedNotebookNavForListNote">
</ul>
</div> </div>
</div> <!-- tag search -->
<div class="pull-left" id="tagSearch"></div>
<div class="pull-left" id="tagSearch" style="line-height: 38px"> <!-- sort type -->
</div>
<div id="sortType"> <div id="sortType">
<div class="dropdown"> <div class="dropdown">
<a class="ios7-a dropdown-toggle" id="dropdownMenu1" <a class="ios7-a dropdown-toggle" id="dropdownMenu1"
data-toggle="dropdown"> data-toggle="dropdown">
<!-- </i><i class="fa fa-th-list"></i>
<i class="fa fa-sort-alpha-asc">
</i>Sort <i class="fa fa-angle-down"></i>
-->
</a> </a>
<!--
<ul class="dropdown-menu" role="menu" <ul class="dropdown-menu" role="menu"
aria-labelledby="dropdownMenu1" aria-labelledby="dropdownMenu1"
style="right: 3px; ! important; left: -100px; min-width: 100px;"> >
<li role="presentation"><a role="menuitem" tabindex="-1"
href="#">创建日期</a></li> <li role="presentation"><a data-view="snippet" class="view-style view-snippet" role="menuitem">
<li role="presentation"><a role="menuitem" tabindex="-1" <i class="fa fa-check"></i>
href="#">修改日期</a></li> {{leaMsg . "Snippet View"}}
<li role="presentation"><a role="menuitem" tabindex="-1" </a></li>
href="#">标题</a></li> <li role="presentation"><a data-view="list" class="view-style view-list" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "List View"}}
</a></li>
<li role="presentation" class="divider"></li> <li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" <li role="presentation"><a data-sorter="dateCreatedASC" class="sorter-style sorter-dateCreatedASC" role="menuitem">
href="#">Separated </a></li> <i class="fa fa-check"></i>
{{leaMsg . "Date Created"}} <i class="fa fa-sort-alpha-asc"></i>
</a></li>
<li role="presentation"><a data-sorter="dateCreatedDESC" class="sorter-style sorter-dateCreatedDESC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Date Created"}} <i class="fa fa-sort-alpha-desc"></i>
</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a data-sorter="dateUpdatedASC" class="sorter-style sorter-dateUpdatedASC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Date Updated"}} <i class="fa fa-sort-alpha-asc"></i>
</a></li>
<li role="presentation"><a data-sorter="dateUpdatedDESC" class="sorter-style sorter-dateUpdatedDESC checked" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Date Updated"}} <i class="fa fa-sort-alpha-desc"></i>
</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a data-sorter="titleASC" class="sorter-style sorter-titleASC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Title"}} <i class="fa fa-sort-alpha-asc"></i>
</a></li>
<li role="presentation"><a data-sorter="titleDESC" class="sorter-style sorter-titleDESC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Title"}} <i class="fa fa-sort-alpha-desc"></i>
</a></li>
</ul> </ul>
-->
</div> </div>
</div> </div>
</div> </div>
@ -856,7 +867,7 @@ function log(o) {
</div> </div>
<script> <script>
var LEA = {}; var LEA = {sPath: ''};
LEA.locale = "{{.locale}}"; LEA.locale = "{{.locale}}";
var UrlPrefix = '{{.siteUrl}}'; var UrlPrefix = '{{.siteUrl}}';
var UserInfo = {{.userInfo|jsonJs}}; var UserInfo = {{.userInfo|jsonJs}};

View File

@ -333,58 +333,67 @@ function log(o) {
<div class="pull-left"> <div class="pull-left">
<!-- 我的笔记本 --> <!-- 我的笔记本 -->
<div class="dropdown" id="myNotebookNavForListNav"> <div class="dropdown" id="myNotebookNavForListNav">
<a class="ios7-a dropdown-toggle" id="dropdownMenu1" data-toggle="dropdown"> <a class="ios7-a">
<span id="curNotebookForListNote">{{msg . "all"}}</span> <span id="curNotebookForListNote">{{msg . "all"}}</span>
<!--
<i class="fa fa-angle-down"></i>
-->
</a> </a>
<!-- 如果notebook过多, 则会产生滚动 弃用
<div class="dropdown-menu dropdown-list" style="left: 5px;">
<ul role="menu" aria-labelledby="dropdownMenu1" id="notebookNavForListNote"></ul>
</div>
-->
</div> </div>
<!-- 共享的笔记本 --> <!-- 共享的笔记本 -->
<div class="dropdown" id="sharedNotebookNavForListNav" style="display: none"> <div class="dropdown" id="sharedNotebookNavForListNav" style="display: none">
<a class="ios7-a dropdown-toggle" id="dropdownMenu2" data-toggle="dropdown"> <a class="ios7-a">
<span id="curSharedNotebookForListNote">{{msg . "all"}}</span> <span id="curSharedNotebookForListNote">{{msg . "all"}}</span>
<!--
<i class="fa fa-angle-down"></i>
-->
</a> </a>
<ul class="dropdown-menu" role="menu"
aria-labelledby="dropdownMenu2" style="left: 5px;" id="sharedNotebookNavForListNote">
</ul>
</div> </div>
</div> </div>
<div class="pull-left" id="tagSearch" style="line-height: 38px"> <!-- tag search -->
</div> <div class="pull-left" id="tagSearch"></div>
<!-- sort type -->
<div id="sortType"> <div id="sortType">
<div class="dropdown"> <div class="dropdown">
<a class="ios7-a dropdown-toggle" id="dropdownMenu1" <a class="ios7-a dropdown-toggle" id="dropdownMenu1"
data-toggle="dropdown"> data-toggle="dropdown">
<!-- </i><i class="fa fa-th-list"></i>
<i class="fa fa-sort-alpha-asc">
</i>Sort <i class="fa fa-angle-down"></i>
-->
</a> </a>
<!--
<ul class="dropdown-menu" role="menu" <ul class="dropdown-menu" role="menu"
aria-labelledby="dropdownMenu1" aria-labelledby="dropdownMenu1"
style="right: 3px; ! important; left: -100px; min-width: 100px;"> >
<li role="presentation"><a role="menuitem" tabindex="-1" <li role="presentation"><a data-view="snippet" class="view-style view-snippet" role="menuitem">
href="#">创建日期</a></li> <i class="fa fa-check"></i>
<li role="presentation"><a role="menuitem" tabindex="-1" {{leaMsg . "Snippet View"}}
href="#">修改日期</a></li> </a></li>
<li role="presentation"><a role="menuitem" tabindex="-1" <li role="presentation"><a data-view="list" class="view-style view-list" role="menuitem">
href="#">标题</a></li> <i class="fa fa-check"></i>
{{leaMsg . "List View"}}
</a></li>
<li role="presentation" class="divider"></li> <li role="presentation" class="divider"></li>
<li role="presentation"><a role="menuitem" tabindex="-1" <li role="presentation"><a data-sorter="dateCreatedASC" class="sorter-style sorter-dateCreatedASC" role="menuitem">
href="#">Separated </a></li> <i class="fa fa-check"></i>
{{leaMsg . "Date Created"}} <i class="fa fa-sort-alpha-asc"></i>
</a></li>
<li role="presentation"><a data-sorter="dateCreatedDESC" class="sorter-style sorter-dateCreatedDESC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Date Created"}} <i class="fa fa-sort-alpha-desc"></i>
</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a data-sorter="dateUpdatedASC" class="sorter-style sorter-dateUpdatedASC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Date Updated"}} <i class="fa fa-sort-alpha-asc"></i>
</a></li>
<li role="presentation"><a data-sorter="dateUpdatedDESC" class="sorter-style sorter-dateUpdatedDESC checked" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Date Updated"}} <i class="fa fa-sort-alpha-desc"></i>
</a></li>
<li role="presentation" class="divider"></li>
<li role="presentation"><a data-sorter="titleASC" class="sorter-style sorter-titleASC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Title"}} <i class="fa fa-sort-alpha-asc"></i>
</a></li>
<li role="presentation"><a data-sorter="titleDESC" class="sorter-style sorter-titleDESC" role="menuitem">
<i class="fa fa-check"></i>
{{leaMsg . "Title"}} <i class="fa fa-sort-alpha-desc"></i>
</a></li>
</ul> </ul>
-->
</div> </div>
</div> </div>
</div> </div>
@ -828,7 +837,7 @@ function log(o) {
</div> </div>
</div> </div>
<script> <script>
var LEA = {}; var LEA = {sPath: ''};
LEA.locale = "{{.locale}}"; LEA.locale = "{{.locale}}";
var UrlPrefix = '{{.siteUrl}}'; var UrlPrefix = '{{.siteUrl}}';
var UserInfo = {{.userInfo|jsonJs}}; var UserInfo = {{.userInfo|jsonJs}};

5
messages/zh-cn/note.conf Normal file
View File

@ -0,0 +1,5 @@
Snippet View=摘要视图
List View=列表视图
Date Created=创建时间
Date Updated=更新时间

5
messages/zh-hk/note.conf Normal file
View File

@ -0,0 +1,5 @@
Snippet View=摘要視圖
List View=列表視圖
Date Created=創建時間
Date Updated=更新時間

File diff suppressed because one or more lines are too long

View File

@ -16,16 +16,16 @@
@green: #65bd77; @green: #65bd77;
@gray: #ccc; @gray: #ccc;
/* leanote */ @import "../theme/includes/icon.less";
@font-face {
font-family: 'leanote'; #logo {
src:url('../../fonts/leanote-font2/leanote.eot?-vcf23i'); font-size: 24px;
src:url('../../fonts/leanote-font2/leanote.eot?#iefix-vcf23i') format('embedded-opentype'), &:before {
url('../../fonts/leanote-font2/leanote.ttf?-vcf23i') format('truetype'), line-height: 40px;
url('../../fonts/leanote-font2/leanote.woff?-vcf23i') format('woff'), }
url('../../fonts/leanote-font2/leanote.svg?-vcf23i#leanote') format('svg'); }
font-weight: normal; #subTitle {
font-style: normal; padding: 0 0 0 5px;
} }
@selectionBg: @aBlackColor; @selectionBg: @aBlackColor;
@ -65,22 +65,6 @@ a:hover {
float: left; float: left;
} }
} }
#logo {
font-family: 'leanote';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
font-size: 24px;
}
#logo:before {
content: "\e601";
}
#navbar { #navbar {
width: @pwidth; width: @pwidth;

View File

View File

@ -808,10 +808,12 @@ a:hover {
vertical-align: middle; vertical-align: middle;
visibility: hidden; visibility: hidden;
} }
#inviteFriends { #inviteFriends,
#upgradeAccount {
position: relative; position: relative;
} }
#inviteFriends .dot { #inviteFriends .dot,
#upgradeAccount .dot {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: -8px; right: -8px;
@ -821,6 +823,12 @@ a:hover {
border-radius: 50%; border-radius: 50%;
background: #FF9263; background: #FF9263;
} }
#upgradeAccountModal .label {
font-size: 12px;
}
#upgradeAccountModal .a {
color: #428bca;
}
#inviteUrl { #inviteUrl {
width: 400px; width: 400px;
padding: 3px; padding: 3px;
@ -1884,6 +1892,37 @@ textarea#wmd-input {
margin-top: 5px; margin-top: 5px;
background-color: #fff; background-color: #fff;
} }
#noteItemList.list .item {
height: 30px !important;
border: none;
border-radius: 0;
border-bottom: 1px solid #ebeff2;
margin: 0 -5px;
}
#noteItemList.list .item.item-b .item-blog {
display: none;
}
#noteItemList.list .item.item-b:hover .item-blog {
display: block;
}
#noteItemList.list .item-thumb {
display: none;
}
#noteItemList.list .item-blog {
display: none;
top: auto;
bottom: 5px;
right: 25px;
}
#noteItemList.list .item-setting {
bottom: 5px;
}
#noteItemList.list .item-title {
border: none;
}
#noteItemList.list .item-desc {
right: 0 !important;
}
#noteItemList .item:hover, #noteItemList .item:hover,
#noteItemList .contextmenu-hover { #noteItemList .contextmenu-hover {
background-color: #ddd !important; background-color: #ddd !important;
@ -1979,6 +2018,10 @@ textarea#wmd-input {
} }
#noteItemList .item-blog { #noteItemList .item-blog {
top: 1px; top: 1px;
display: none;
}
#noteItemList .item-b .item-blog {
display: block;
} }
#noteItemList .item-setting { #noteItemList .item-setting {
bottom: 0; bottom: 0;
@ -1987,6 +2030,20 @@ textarea#wmd-input {
#noteItemList .item:hover .item-setting { #noteItemList .item:hover .item-setting {
display: block; display: block;
} }
.sorter-style .fa-check:before,
.view-style .fa-check:before {
content: "";
}
.sorter-style.checked .fa-check:before,
.view-style.checked .fa-check:before {
content: "\f00c";
}
#sortType .dropdown-menu {
right: -1px !important;
}
#tagSearch {
line-height: 34px;
}
/** /**
* 工具栏 * 工具栏
* 附件 * 附件

View File

@ -268,7 +268,7 @@ a:hover {
visibility: hidden; visibility: hidden;
} }
#inviteFriends { #inviteFriends, #upgradeAccount {
position: relative; position: relative;
.dot { .dot {
display: inline-block; display: inline-block;
@ -281,6 +281,14 @@ a:hover {
background: #FF9263; background: #FF9263;
} }
} }
#upgradeAccountModal {
.label {
font-size: 12px;
}
.a {
color:#428bca;
}
}
#inviteUrl { #inviteUrl {
width: 400px; width: 400px;

View File

@ -75,7 +75,8 @@
overflow-y: hidden; overflow-y: hidden;
padding: 0 5px; padding: 0 5px;
} }
#noteItemList .item { #noteItemList {
.item {
position: relative; position: relative;
height: 110px; height: 110px;
overflow: hidden; overflow: hidden;
@ -84,6 +85,45 @@
border-radius: 3px; border-radius: 3px;
margin-top: 5px; margin-top: 5px;
background-color: #fff; background-color: #fff;
}
// 列表模式
&.list {
.item {
height: 30px !important;
border: none;
border-radius: 0;
border-bottom: 1px solid #ebeff2;
margin: 0 -5px;
&.item-b {
.item-blog {
display: none;
}
}
&.item-b:hover {
.item-blog {
display: block;
}
}
}
.item-thumb {
display: none;
}
.item-blog {
display: none;
top: auto;
bottom: 5px;
right: 25px;
}
.item-setting {
bottom: 5px;
}
.item-title {
border: none;
}
.item-desc {
right: 0 !important;
}
}
} }
#noteItemList .item:hover, #noteItemList .item:hover,
@ -189,6 +229,13 @@ top: 4px;
.item-blog { .item-blog {
top: 1px; top: 1px;
display: none;
}
.item-b {
.item-blog {
display: block;
}
} }
.item-setting { .item-setting {
@ -202,3 +249,25 @@ top: 4px;
display: block; display: block;
} }
} }
// 视图
.sorter-style, .view-style {
.fa-check:before {
content: "";
}
&.checked {
.fa-check:before {
content: "\f00c";
}
}
}
#sortType {
.dropdown-menu {
right: -1px !important;
}
}
#tagSearch {
line-height: 34px
}

View File

@ -171,3 +171,4 @@
.mce-text { .mce-text {
vertical-align: middle; vertical-align: middle;
} }

View File

@ -808,10 +808,12 @@ a:hover {
vertical-align: middle; vertical-align: middle;
visibility: hidden; visibility: hidden;
} }
#inviteFriends { #inviteFriends,
#upgradeAccount {
position: relative; position: relative;
} }
#inviteFriends .dot { #inviteFriends .dot,
#upgradeAccount .dot {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: -8px; right: -8px;
@ -821,6 +823,12 @@ a:hover {
border-radius: 50%; border-radius: 50%;
background: #FF9263; background: #FF9263;
} }
#upgradeAccountModal .label {
font-size: 12px;
}
#upgradeAccountModal .a {
color: #428bca;
}
#inviteUrl { #inviteUrl {
width: 400px; width: 400px;
padding: 3px; padding: 3px;
@ -1884,6 +1892,37 @@ textarea#wmd-input {
margin-top: 5px; margin-top: 5px;
background-color: #fff; background-color: #fff;
} }
#noteItemList.list .item {
height: 30px !important;
border: none;
border-radius: 0;
border-bottom: 1px solid #ebeff2;
margin: 0 -5px;
}
#noteItemList.list .item.item-b .item-blog {
display: none;
}
#noteItemList.list .item.item-b:hover .item-blog {
display: block;
}
#noteItemList.list .item-thumb {
display: none;
}
#noteItemList.list .item-blog {
display: none;
top: auto;
bottom: 5px;
right: 25px;
}
#noteItemList.list .item-setting {
bottom: 5px;
}
#noteItemList.list .item-title {
border: none;
}
#noteItemList.list .item-desc {
right: 0 !important;
}
#noteItemList .item:hover, #noteItemList .item:hover,
#noteItemList .contextmenu-hover { #noteItemList .contextmenu-hover {
background-color: #ddd !important; background-color: #ddd !important;
@ -1979,6 +2018,10 @@ textarea#wmd-input {
} }
#noteItemList .item-blog { #noteItemList .item-blog {
top: 1px; top: 1px;
display: none;
}
#noteItemList .item-b .item-blog {
display: block;
} }
#noteItemList .item-setting { #noteItemList .item-setting {
bottom: 0; bottom: 0;
@ -1987,6 +2030,20 @@ textarea#wmd-input {
#noteItemList .item:hover .item-setting { #noteItemList .item:hover .item-setting {
display: block; display: block;
} }
.sorter-style .fa-check:before,
.view-style .fa-check:before {
content: "";
}
.sorter-style.checked .fa-check:before,
.view-style.checked .fa-check:before {
content: "\f00c";
}
#sortType .dropdown-menu {
right: -1px !important;
}
#tagSearch {
line-height: 34px;
}
/** /**
* 工具栏 * 工具栏
* 附件 * 附件

View File

@ -808,10 +808,12 @@ a:hover {
vertical-align: middle; vertical-align: middle;
visibility: hidden; visibility: hidden;
} }
#inviteFriends { #inviteFriends,
#upgradeAccount {
position: relative; position: relative;
} }
#inviteFriends .dot { #inviteFriends .dot,
#upgradeAccount .dot {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: -8px; right: -8px;
@ -821,6 +823,12 @@ a:hover {
border-radius: 50%; border-radius: 50%;
background: #FF9263; background: #FF9263;
} }
#upgradeAccountModal .label {
font-size: 12px;
}
#upgradeAccountModal .a {
color: #428bca;
}
#inviteUrl { #inviteUrl {
width: 400px; width: 400px;
padding: 3px; padding: 3px;
@ -1884,6 +1892,37 @@ textarea#wmd-input {
margin-top: 5px; margin-top: 5px;
background-color: #fff; background-color: #fff;
} }
#noteItemList.list .item {
height: 30px !important;
border: none;
border-radius: 0;
border-bottom: 1px solid #ebeff2;
margin: 0 -5px;
}
#noteItemList.list .item.item-b .item-blog {
display: none;
}
#noteItemList.list .item.item-b:hover .item-blog {
display: block;
}
#noteItemList.list .item-thumb {
display: none;
}
#noteItemList.list .item-blog {
display: none;
top: auto;
bottom: 5px;
right: 25px;
}
#noteItemList.list .item-setting {
bottom: 5px;
}
#noteItemList.list .item-title {
border: none;
}
#noteItemList.list .item-desc {
right: 0 !important;
}
#noteItemList .item:hover, #noteItemList .item:hover,
#noteItemList .contextmenu-hover { #noteItemList .contextmenu-hover {
background-color: #ddd !important; background-color: #ddd !important;
@ -1979,6 +2018,10 @@ textarea#wmd-input {
} }
#noteItemList .item-blog { #noteItemList .item-blog {
top: 1px; top: 1px;
display: none;
}
#noteItemList .item-b .item-blog {
display: block;
} }
#noteItemList .item-setting { #noteItemList .item-setting {
bottom: 0; bottom: 0;
@ -1987,6 +2030,20 @@ textarea#wmd-input {
#noteItemList .item:hover .item-setting { #noteItemList .item:hover .item-setting {
display: block; display: block;
} }
.sorter-style .fa-check:before,
.view-style .fa-check:before {
content: "";
}
.sorter-style.checked .fa-check:before,
.view-style.checked .fa-check:before {
content: "\f00c";
}
#sortType .dropdown-menu {
right: -1px !important;
}
#tagSearch {
line-height: 34px;
}
/** /**
* 工具栏 * 工具栏
* 附件 * 附件

View File

@ -808,10 +808,12 @@ a:hover {
vertical-align: middle; vertical-align: middle;
visibility: hidden; visibility: hidden;
} }
#inviteFriends { #inviteFriends,
#upgradeAccount {
position: relative; position: relative;
} }
#inviteFriends .dot { #inviteFriends .dot,
#upgradeAccount .dot {
display: inline-block; display: inline-block;
position: absolute; position: absolute;
right: -8px; right: -8px;
@ -821,6 +823,12 @@ a:hover {
border-radius: 50%; border-radius: 50%;
background: #FF9263; background: #FF9263;
} }
#upgradeAccountModal .label {
font-size: 12px;
}
#upgradeAccountModal .a {
color: #428bca;
}
#inviteUrl { #inviteUrl {
width: 400px; width: 400px;
padding: 3px; padding: 3px;
@ -1884,6 +1892,37 @@ textarea#wmd-input {
margin-top: 5px; margin-top: 5px;
background-color: #fff; background-color: #fff;
} }
#noteItemList.list .item {
height: 30px !important;
border: none;
border-radius: 0;
border-bottom: 1px solid #ebeff2;
margin: 0 -5px;
}
#noteItemList.list .item.item-b .item-blog {
display: none;
}
#noteItemList.list .item.item-b:hover .item-blog {
display: block;
}
#noteItemList.list .item-thumb {
display: none;
}
#noteItemList.list .item-blog {
display: none;
top: auto;
bottom: 5px;
right: 25px;
}
#noteItemList.list .item-setting {
bottom: 5px;
}
#noteItemList.list .item-title {
border: none;
}
#noteItemList.list .item-desc {
right: 0 !important;
}
#noteItemList .item:hover, #noteItemList .item:hover,
#noteItemList .contextmenu-hover { #noteItemList .contextmenu-hover {
background-color: #ddd !important; background-color: #ddd !important;
@ -1979,6 +2018,10 @@ textarea#wmd-input {
} }
#noteItemList .item-blog { #noteItemList .item-blog {
top: 1px; top: 1px;
display: none;
}
#noteItemList .item-b .item-blog {
display: block;
} }
#noteItemList .item-setting { #noteItemList .item-setting {
bottom: 0; bottom: 0;
@ -1987,6 +2030,20 @@ textarea#wmd-input {
#noteItemList .item:hover .item-setting { #noteItemList .item:hover .item-setting {
display: block; display: block;
} }
.sorter-style .fa-check:before,
.view-style .fa-check:before {
content: "";
}
.sorter-style.checked .fa-check:before,
.view-style.checked .fa-check:before {
content: "\f00c";
}
#sortType .dropdown-menu {
right: -1px !important;
}
#tagSearch {
line-height: 34px;
}
/** /**
* 工具栏 * 工具栏
* 附件 * 附件

11
public/js/app.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -74,7 +74,7 @@ Note.setNoteCache = function(content, clear) {
if(clear) { if(clear) {
Note.clearCacheByNotebookId(content.NotebookId); Note.clearCacheByNotebookId(content.NotebookId);
} }
} };
Note.setCurNoteId = function (noteId) { Note.setCurNoteId = function (noteId) {
this.curNoteId = noteId; this.curNoteId = noteId;
@ -90,7 +90,7 @@ Note.getCurNote = function() {
return null; return null;
} }
return self.cache[self.curNoteId]; return self.cache[self.curNoteId];
} };
Note.getNote = function(noteId) { Note.getNote = function(noteId) {
var self = this; var self = this;
return self.cache[noteId]; return self.cache[noteId];
@ -114,35 +114,43 @@ Note.notebookHasNotes = function(notebookId) {
}; };
// 得到notebook下的notes, 按什么排序 updatedTime? // 得到notebook下的notes, 按什么排序 updatedTime?
Note.getNotesByNotebookId = function(notebookId, sortBy, isAsc) { Note.getNotesByNotebookId = function(notebookId) {
if(!sortBy) { var sorterAndOrder = Note.getSorterAndOrder();
sortBy = "UpdatedTime"; var sortBy = sorterAndOrder.sortBy;
} var isAsc = sorterAndOrder.isAsc;
if(isAsc == "undefined") {
isAsc = false; // 默认是降序
}
if(!notebookId) { Note.listIsIn();
if (!notebookId) {
notebookId = "all"; notebookId = "all";
} }
if(!Note.cacheByNotebookId[notebookId]) { if (!Note.cacheByNotebookId[notebookId]) {
return []; return [];
} }
if(Note.cacheByNotebookId[notebookId][sortBy]) { if (Note.cacheByNotebookId[notebookId][sortBy]) {
return Note.cacheByNotebookId[notebookId][sortBy]; if (Note.cacheByNotebookId[notebookId][sortBy][isAsc]) {
} else { return Note.cacheByNotebookId[notebookId][sortBy][isAsc];
}
// 逆序
Note.cacheByNotebookId[notebookId][sortBy][!isAsc].reverse();
var notes = Note.cacheByNotebookId[notebookId][sortBy][!isAsc];
Note.cacheByNotebookId[notebookId][sortBy][!isAsc] = null;
Note.cacheByNotebookId[notebookId][sortBy][isAsc] = notes;
return notes;
} }
// 从所有的notes中找到notebookId的, 并排序之 // 从所有的notes中找到notebookId的, 并排序之
var notes = []; var notes = [];
var sortBys = []; for (var i in Note.cache) {
for(var i in Note.cache) { if (!i) {
if(!i) {
continue; continue;
} }
var note = Note.cache[i]; var note = Note.cache[i];
if (!note) {
continue;
}
// 不要trash的not, 共享的也不要 // 不要trash的not, 共享的也不要
if(note.IsTrash || note.IsShared) { if(note.IsTrash || note.IsShared) {
continue; continue;
@ -151,42 +159,26 @@ Note.getNotesByNotebookId = function(notebookId, sortBy, isAsc) {
notes.push(note); notes.push(note);
} }
} }
// 排序之
notes.sort(function(a, b) {
var t1 = a[sortBy];
var t2 = b[sortBy];
if(isAsc) { Note.sortNotes(notes);
if(t1 < t2) {
return -1;
} else if (t1 > t2) {
return 1;
}
} else {
if(t1 < t2) {
return 1;
} else if (t1 > t2) {
return -1;
}
}
return 0;
});
// 缓存之 // 缓存之
Note.cacheByNotebookId[notebookId][sortBy] = notes; Note.cacheByNotebookId[notebookId][sortBy] = {};
Note.cacheByNotebookId[notebookId][sortBy][isAsc] = notes;
return notes; return notes;
}; };
// called by Notebook // called by Notebook
// render 所有notes, 和第一个note的content // render 所有notes, 和第一个note的content
Note.renderNotesAndFirstOneContent = function(ret) { Note.renderNotesAndFirstOneContent = function(ret, hasSorted) {
// 错误的ret是一个Object // 错误的ret是一个Object
if(!isArray(ret)) { if(!isArray(ret)) {
return; return;
} }
// note 导航 // note 导航
Note.renderNotes(ret); Note.renderNotes(ret, false, false, hasSorted);
// 渲染第一个 // 渲染第一个
if(!isEmpty(ret[0])) { if(!isEmpty(ret[0])) {
Note.changeNoteForPjax(ret[0].NoteId, true, false); Note.changeNoteForPjax(ret[0].NoteId, true, false);
@ -201,7 +193,7 @@ Note.renderNotesAndFirstOneContent = function(ret) {
// 所以不用isDirty() // 所以不用isDirty()
// 只用Note.readOnly, 如果Note.readOnly, 那么不判断内容 // 只用Note.readOnly, 如果Note.readOnly, 那么不判断内容
// //
Note.curHasChanged = function(force) { Note.curHasChanged = function(force, isRefreshOrCtrls) {
var cacheNote = Note.getCurNote(); var cacheNote = Note.getCurNote();
if (!cacheNote) { if (!cacheNote) {
return false; return false;
@ -222,6 +214,11 @@ Note.curHasChanged = function(force) {
if (cacheNote.IsNew) { if (cacheNote.IsNew) {
hasChanged.hasChanged = true; hasChanged.hasChanged = true;
hasChanged.title = title;
// 来源
if (LEA.topInfo) {
hasChanged.Src = LEA.topInfo.src;
}
} }
if(cacheNote.Title != title) { if(cacheNote.Title != title) {
@ -271,6 +268,15 @@ Note.curHasChanged = function(force) {
content = contents; content = contents;
} }
// 如果是插件, 且没有改动任何地方
if ( hasChanged.Src && LEA.topInfo && title === LEA.topInfo.title && !hasChanged.Tags &&
(!content || content == '<p><br></p>')) {
// 如果不是手动ctrl+s, 则不保存
if (!(isRefreshOrCtrls && isRefreshOrCtrls.ctrls)) {
return false;
}
}
// 比较text, 因为note Nav会添加dom会导致content改变 // 比较text, 因为note Nav会添加dom会导致content改变
/* /*
if((force && cacheNote.Content != content) if((force && cacheNote.Content != content)
@ -369,7 +375,7 @@ Note.genAbstract = function(content, len) {
var d = document.createElement("div"); var d = document.createElement("div");
d.innerHTML = result d.innerHTML = result
return d.innerHTML; return d.innerHTML;
} };
Note.getImgSrc = function(content) { Note.getImgSrc = function(content) {
if(!content) { if(!content) {
@ -383,7 +389,7 @@ Note.getImgSrc = function(content) {
} }
} }
return ""; return "";
} };
// 如果当前的改变了, 就保存它 // 如果当前的改变了, 就保存它
// 以后要定时调用 // 以后要定时调用
@ -391,7 +397,7 @@ Note.getImgSrc = function(content) {
// 定时保存传false // 定时保存传false
Note.saveInProcess = {}; // noteId => bool, true表示该note正在保存到服务器, 服务器未响应 Note.saveInProcess = {}; // noteId => bool, true表示该note正在保存到服务器, 服务器未响应
Note.savePool = {}; // 保存池, 以后的保存先放在pool中, id => note Note.savePool = {}; // 保存池, 以后的保存先放在pool中, id => note
Note.curChangedSaveIt = function(force, callback) { Note.curChangedSaveIt = function(force, callback, isRefreshOrCtrls) {
var me = this; var me = this;
// 如果当前没有笔记, 不保存 // 如果当前没有笔记, 不保存
// 或者是共享的只读笔记 // 或者是共享的只读笔记
@ -401,7 +407,7 @@ Note.curChangedSaveIt = function(force, callback) {
} }
var hasChanged; var hasChanged;
try { try {
hasChanged = Note.curHasChanged(force); hasChanged = Note.curHasChanged(force, isRefreshOrCtrls);
} catch(e) { } catch(e) {
// console.error('获取当前改变的笔记错误!'); // console.error('获取当前改变的笔记错误!');
callback && callback(false); callback && callback(false);
@ -450,6 +456,7 @@ Note.curChangedSaveIt = function(force, callback) {
Note.setNoteCache(hasChanged, false); Note.setNoteCache(hasChanged, false);
// 设置更新时间 // 设置更新时间
Note.setNoteCache({"NoteId": hasChanged.NoteId, "UpdatedTime": (new Date()).format("yyyy-MM-ddThh:mm:ss.S")}, false); Note.setNoteCache({"NoteId": hasChanged.NoteId, "UpdatedTime": (new Date()).format("yyyy-MM-ddThh:mm:ss.S")}, false);
Note.clearCacheByNotebookId(hasChanged.NotebookId);
return hasChanged; return hasChanged;
} }
@ -493,13 +500,13 @@ Note.startUpdatePoolNoteInterval = function() {
// 样式 // 样式
Note.clearSelect = function(target) { Note.clearSelect = function(target) {
$(".item").removeClass("item-active"); $(".item").removeClass("item-active");
} };
Note.selectTarget = function(target) { Note.selectTarget = function(target) {
this.clearSelect(); this.clearSelect();
$(target).addClass("item-active"); $(target).addClass("item-active");
// this.batch.reset(); // this.batch.reset();
} };
// 改变note // 改变note
// 可能改变的是share note // 可能改变的是share note
@ -516,7 +523,12 @@ Note.directToNote = function(noteId) {
var $p = $("#noteItemList"); var $p = $("#noteItemList");
var pHeight = $p.height(); var pHeight = $p.height();
// 相对于父亲的位置 // 相对于父亲的位置
var pTop = $("[noteId='" + noteId + "']").position().top; var position = $("[noteId='" + noteId + "']").position();
if (!position) {
console.error('no position: ' + noteId);
return;
}
var pTop = position.top;
var scrollTop = $p.scrollTop(); var scrollTop = $p.scrollTop();
pTop += scrollTop; pTop += scrollTop;
/* /*
@ -816,14 +828,162 @@ Note.hideEditorMask = function() {
$("#editorMask").css("z-index", -10).hide(); $("#editorMask").css("z-index", -10).hide();
}; };
/**
* 切换视图
* @param {[type]} e [description]
* @return {[type]} [description]
*/
Note.toggleView = function (e) {
var view;
if (typeof e == 'object' && e) {
view = $(e.target).data('view');
}
else {
view = e;
}
if (!view) {
view = 'snippet';
}
if (view == 'list') {
$('#noteItemList').addClass('list');
}
else {
$('#noteItemList').removeClass('list');
}
localStorage.setItem('viewStyle', view);
$('.view-style').removeClass('checked');
$('.view-' + view).addClass('checked');
};
// 重新设置sorter, 此时要重新render
// sortType = dateCreatedASC dateCreatedDESC
Note.setNotesSorter = function (e) {
var sorterType = $(e.currentTarget).data('sorter');
if (!sorterType) {
sorterType = 'dateUpdatedDESC';
}
localStorage.setItem("sorterType", sorterType);
// alert(localStorage.getItem("sorterType"));
Note.checkSorter(sorterType);
// 如果当前是tagSearch, search, star 怎么办?
// 重新Render
if (Note._isTag || Note._isSearch || Note._isShare) {
Note.renderNotesAndFirstOneContent(Note._everNotes, false);
} else {
// 其实这里也可以用Note._everNotes, 主要是为了缓存数据
Notebook.changeNotebook(Notebook.curNotebookId);
}
// Note.renderNotesAndTargetNote(Note._everNotes, false, false);
// Api.writeConfig(Config);
};
var $sorterStyles = $('.sorter-style');
Note.checkSorter = function (sorterType) {
// UC无痕浏览
if (!sorterType) {
sorterType = 'dateUpdatedDESC';
}
var $selected = $('.sorter-' + sorterType);
if ($selected.is('.checked')) {
return;
}
$sorterStyles.removeClass('checked');
$selected.addClass('checked');
};
// render前先排序
Note.sortNotesToRender = function (notes) {
Note.sortNotes(notes);
};
Note.sortNotes = function (notes) {
if (isEmpty(notes)) {
return;
}
var sorterAndOrder = Note.getSorterAndOrder();
var sortBy = sorterAndOrder.sortBy;
var isAsc = sorterAndOrder.isAsc;
// 排序之
notes.sort(function(a, b) {
var t1 = a[sortBy];
var t2 = b[sortBy];
if (isAsc) {
if (t1 < t2) {
return -1;
} else if (t1 > t2) {
return 1;
}
} else {
if (t1 < t2) {
return 1;
} else if (t1 > t2) {
return -1;
}
}
return 0;
});
};
Note.getSorterAndOrder = function () {
var sortBy = "UpdatedTime";
var isAsc = false; // 默认是降序
var sorterType = localStorage.getItem('sorterType');
// console.log(sorterType);
Note.checkSorter(sorterType);
if (sorterType) {
switch(sorterType) {
case 'dateCreatedASC':
sortBy = 'CreatedTime';
isAsc = true;
break;
case 'dateCreatedDESC':
sortBy = 'CreatedTime';
isAsc = false;
break;
case 'dateUpdatedASC':
sortBy = 'UpdatedTime';
isAsc = true;
break;
case 'dateUpdatedDESC':
sortBy = 'UpdatedTime';
isAsc = false;
break;
case 'titleASC':
sortBy = 'Title';
isAsc = true;
break;
case 'titleDESC':
sortBy = 'Title';
isAsc = false;
break;
}
}
console.log({sortBy: sortBy, isAsc: isAsc});
return {sortBy: sortBy, isAsc: isAsc};
};
// 列表是
Note.listIsIn = function (isTag, isSearch, isShare) {
this._isTag = isTag;
this._isSearch = isSearch;
this._isShare = isShare;
};
// 这里如果notes过多>100个将会很慢!!, 使用setTimeout来分解 // 这里如果notes过多>100个将会很慢!!, 使用setTimeout来分解
Note.renderNotesC = 0; Note.renderNotesC = 0;
Note.renderNotes = function(notes, forNewNote, isShared) { Note.renderNotes = function(notes, forNewNote, isShared, hasSorted) {
var renderNotesC = ++Note.renderNotesC; var renderNotesC = ++Note.renderNotesC;
this.clearSeqForNew(); this.clearSeqForNew();
this.batch.reset(); this.batch.reset();
// 为了切换排序方式用
Note._everNotes = notes;
// 手机端不用 // 手机端不用
// slimScroll使得手机端滚动不流畅 // slimScroll使得手机端滚动不流畅
if(!LEA.isMobile && !Mobile.isMobile()) { if(!LEA.isMobile && !Mobile.isMobile()) {
@ -850,6 +1010,11 @@ Note.renderNotes = function(notes, forNewNote, isShared) {
var len = notes.length; var len = notes.length;
var c = Math.ceil(len/20); var c = Math.ceil(len/20);
// 重新排序
if (!hasSorted) {
Note.sortNotes(notes);
}
Note._renderNotes(notes, forNewNote, isShared, 1); Note._renderNotes(notes, forNewNote, isShared, 1);
// 先设置缓存 // 先设置缓存
@ -900,9 +1065,11 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
} else { } else {
tmp = tt(Note.itemTplNoImg, classes, i, note.NoteId, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc); tmp = tt(Note.itemTplNoImg, classes, i, note.NoteId, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc);
} }
if(!note.IsBlog) {
tmp = $(tmp); tmp = $(tmp);
tmp.find(".item-blog").hide(); if(!note.IsBlog) {
tmp.removeClass('item-b');
} else {
tmp.addClass('item-b');
} }
Note.noteItemListO.append(tmp); Note.noteItemListO.append(tmp);
@ -937,6 +1104,10 @@ Note.newNoteSeq = function () {
// isShare时fromUserId才有用 // isShare时fromUserId才有用
// 3.8 add isMarkdown // 3.8 add isMarkdown
Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) { Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
if (!notebookId) {
notebookId = $("#curNotebookForNewNote").attr('notebookId');
}
// 切换编辑器 // 切换编辑器
switchEditor(isMarkdown); switchEditor(isMarkdown);
Note.hideEditorMask(); Note.hideEditorMask();
@ -950,9 +1121,19 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
Note.batch.reset(); Note.batch.reset();
var note = {NoteId: getObjectId(), Title: "", Tags:[], Content:"", NotebookId: notebookId, IsNew: true, FromUserId: fromUserId, IsMarkdown: isMarkdown}; // 是新的 var note = {NoteId: getObjectId(),
Title: "", Tags:[], Content:"",
NotebookId: notebookId, IsNew: true, FromUserId: fromUserId,
IsMarkdown: isMarkdown,
UpdatedTime: new Date(),
CreatedTime: new Date()}; // 是新的
if (LEA.topInfo && LEA.topInfo.title) {
note.Title = LEA.topInfo.title;
}
// 添加到缓存中 // 添加到缓存中
Note.addNoteCache(note); Note.addNoteCache(note);
Note.clearCacheByNotebookId(notebookId);
// 清空附件数 // 清空附件数
Attach.clearNoteAttachNum(); Attach.clearNoteAttachNum();
@ -975,9 +1156,12 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
} }
// notebook是否是Blog // notebook是否是Blog
if(!notebook.IsBlog) {
newItem = $(newItem); newItem = $(newItem);
newItem.find(".item-blog").hide(); if(!notebook.IsBlog) {
newItem.removeClass('item-b');
}
else {
newItem.addClass('item-b');
} }
// 是否在当前notebook下, 不是则切换过去, 并得到该notebook下所有的notes, 追加到后面! // 是否在当前notebook下, 不是则切换过去, 并得到该notebook下所有的notes, 追加到后面!
@ -1261,6 +1445,10 @@ Note.searchNote = function() {
// 先取消上一个 // 先取消上一个
showLoading(); showLoading();
Notebook.showNoteAndEditorLoading(); Notebook.showNoteAndEditorLoading();
Note.listIsIn(false, true);
$("#tagSearch").hide();
Note.lastSearch = $.post("/note/searchNote", {key: val}, function(notes) { Note.lastSearch = $.post("/note/searchNote", {key: val}, function(notes) {
hideLoading(); hideLoading();
Notebook.hideNoteAndEditorLoading(); Notebook.hideNoteAndEditorLoading();
@ -1317,9 +1505,9 @@ Note._setBlog = function(target, isBlog) {
var noteId = noteIds[i]; var noteId = noteIds[i];
var $t = me.getTargetById(noteId); var $t = me.getTargetById(noteId);
if(isBlog) { if(isBlog) {
$t.find(".item-blog").show(); $t.addClass('item-b');
} else { } else {
$t.find(".item-blog").hide(); $t.removeClass('item-b');
} }
me.setNoteCache({NoteId: noteId, IsBlog: isBlog}, false); // 不清空NotesByNotebookId缓存 me.setNoteCache({NoteId: noteId, IsBlog: isBlog}, false); // 不清空NotesByNotebookId缓存
} }
@ -1742,6 +1930,7 @@ Note.initContextmenu = function() {
items.push("copy." + notebookTitle); items.push("copy." + notebookTitle);
} }
} }
// console.log(items);
// diable 这里 // diable 这里
menu.applyrule({ menu.applyrule({
@ -2450,7 +2639,6 @@ $(function() {
Note.curChangedSaveIt(true); Note.curChangedSaveIt(true);
}); });
// blog // blog
Note.$itemList.on("click", ".item-blog", function(e) { Note.$itemList.on("click", ".item-blog", function(e) {
e.preventDefault(); e.preventDefault();
@ -2511,6 +2699,16 @@ $(function() {
e.preventDefault(); e.preventDefault();
window.open(href); window.open(href);
}); });
var view = localStorage.getItem('viewStyle');
Note.toggleView(view);
// view 切换
$('.view-style').click(function (e) {
Note.toggleView(e);
});
$('.sorter-style').click(function (e) {
Note.setNotesSorter(e);
});
}); });
// 定时器启动 // 定时器启动

View File

@ -527,7 +527,7 @@ Notebook.changeNotebookNavForNewNote = function(notebookId, title) {
Notebook.changeNotebookNavForNewNote(notebookId, title); Notebook.changeNotebookNavForNewNote(notebookId, title);
} }
} }
} };
// 改变导航, 两处 // 改变导航, 两处
// 单击左侧, 单击新建下拉时调用 // 单击左侧, 单击新建下拉时调用
@ -544,7 +544,7 @@ Notebook.toggleToMyNav = function(userId, notebookId) {
// 搜索tag隐藏 // 搜索tag隐藏
$("#tagSearch").hide(); $("#tagSearch").hide();
} };
Notebook.changeNotebookNav = function(notebookId) { Notebook.changeNotebookNav = function(notebookId) {
Notebook.curNotebookId = notebookId; Notebook.curNotebookId = notebookId;
Notebook.toggleToMyNav(); Notebook.toggleToMyNav();
@ -615,7 +615,7 @@ Notebook.changeNotebook = function(notebookId, callback) {
if(callback) { if(callback) {
callback(cacheNotes); callback(cacheNotes);
} else { } else {
Note.renderNotesAndFirstOneContent(cacheNotes); Note.renderNotesAndFirstOneContent(cacheNotes, true);
} }
return; return;
} }
@ -628,7 +628,7 @@ Notebook.changeNotebook = function(notebookId, callback) {
if(callback) { if(callback) {
callback(cacheNotes); callback(cacheNotes);
} else { } else {
Note.renderNotesAndFirstOneContent(cacheNotes); Note.renderNotesAndFirstOneContent(cacheNotes, true);
} }
return; return;
} else { } else {
@ -653,7 +653,7 @@ Notebook.changeNotebook = function(notebookId, callback) {
if(callback) { if(callback) {
callback(cacheNotes); callback(cacheNotes);
} else { } else {
Note.renderNotesAndFirstOneContent(cacheNotes); Note.renderNotesAndFirstOneContent(cacheNotes, false);
} }
me.hideNoteAndEditorLoading(); me.hideNoteAndEditorLoading();
}); });
@ -728,19 +728,22 @@ Notebook.setNotebook2Blog = function(target) {
// 那么, 如果当前是该notebook下, 重新渲染之 // 那么, 如果当前是该notebook下, 重新渲染之
if(Notebook.curNotebookId == notebookId) { if(Notebook.curNotebookId == notebookId) {
if(isBlog) { if(isBlog) {
$("#noteList .item-blog").show(); $('.item').addClass('item-b');
} else { } else {
$("#noteList .item-blog").hide(); $('.item').removeClass('item-b');
} }
// 如果当前在所有笔记本下 // 如果当前在所有笔记本下
} else if(Notebook.curNotebookId == Notebook.allNotebookId){ } else if(Notebook.curNotebookId == Notebook.allNotebookId){
$("#noteItemList .item").each(function(){ $("#noteItemList .item").each(function(){
var noteId = $(this).attr("noteId"); var noteId = $(this).attr("noteId");
var note = Note.cache[noteId]; var note = Note.cache[noteId];
if(note.NotebookId == notebookId) { if(note.NotebookId == notebookId) {
if(isBlog) $(this).find(".item-blog").show(); if (isBlog) {
else $(this).find(".item-blog").hide(); $(this).addClass('item-b');
}
else {
$(this).removeClass('item-b');
}
} }
}); });
} }

View File

@ -1,6 +1,16 @@
// 主页渲染 // 主页渲染
//------------- //-------------
function sendLog (key, value) {
if (!key) {
return;
}
if (!value) {
value = '';
}
ajaxGet('/index/log', {key: key, value: value});
}
//---------------------- //----------------------
// 编辑器模式 // 编辑器模式
function editorMode() { function editorMode() {
@ -88,7 +98,7 @@ editorMode.prototype.normalMode = function() {
var $themeLink = $("#themeLink"); var $themeLink = $("#themeLink");
// 如果之前不是normal才换 // 如果之前不是normal才换
if(this.$themeLink.attr('href').indexOf('writting-overwrite.css') != -1) { if(this.$themeLink.attr('href').indexOf('writting-overwrite.css') != -1) {
this.$themeLink.attr("href", "/css/theme/" + theme); this.$themeLink.attr("href", LEA.sPath + "/css/theme/" + theme);
} }
$("#noteList").width(UserInfo.NoteListWidth); $("#noteList").width(UserInfo.NoteListWidth);
@ -103,7 +113,7 @@ editorMode.prototype.writtingMode = function() {
return; return;
} }
if(this.$themeLink.attr('href').indexOf('writting-overwrite.css') == -1) { if(this.$themeLink.attr('href').indexOf('writting-overwrite.css') == -1) {
this.$themeLink.attr("href", "/css/theme/writting-overwrite.css"); this.$themeLink.attr("href", LEA.sPath + "/css/theme/writting-overwrite.css");
} }
/* /*
@ -582,7 +592,7 @@ function initEditor() {
if (LEA.isLogout) { if (LEA.isLogout) {
return; return;
} }
Note.curChangedSaveIt(true); Note.curChangedSaveIt(true, null, {refresh: true});
} }
// 全局快捷键 // 全局快捷键
@ -594,7 +604,7 @@ function initEditor() {
if(ctrlOrMetaKey) { if(ctrlOrMetaKey) {
// 保存 // 保存
if (num == 83 ) { // ctrl + s or command + s if (num == 83 ) { // ctrl + s or command + s
Note.curChangedSaveIt(); Note.curChangedSaveIt(true, null, {ctrls: true});
e.preventDefault(); e.preventDefault();
return false; return false;
} }
@ -656,6 +666,11 @@ function scrollTo(self, tagName, text) {
} }
} }
function hideMask () {
$("#mainMask").html("");
$("#mainMask").hide(100);
}
//-------------- //--------------
// 调用之 // 调用之
// $(function() { // $(function() {
@ -722,7 +737,7 @@ function scrollTo(self, tagName, text) {
if (arr.length == 2) { if (arr.length == 2) {
id = arr[1]; id = arr[1];
} }
$("#themeLink").attr("href", "/css/theme/" + val + ".css?id=" + id); $("#themeLink").attr("href", LEA.sPath + "/css/theme/" + val + ".css?id=" + id);
ajaxPost("/user/updateTheme", {theme: val}, function(re) { ajaxPost("/user/updateTheme", {theme: val}, function(re) {
if(reIsOk(re)) { if(reIsOk(re)) {
UserInfo.Theme = val UserInfo.Theme = val
@ -812,18 +827,22 @@ function scrollTo(self, tagName, text) {
Resize.set3ColumnsWidth(UserInfo.NotebookWidth, UserInfo.NoteListWidth); Resize.set3ColumnsWidth(UserInfo.NotebookWidth, UserInfo.NoteListWidth);
Resize.setMdColumnWidth(UserInfo.MdEditorWidth); Resize.setMdColumnWidth(UserInfo.MdEditorWidth);
if (!Mobile.isMobile()) {
if (UserInfo.LeftIsMin) { if (UserInfo.LeftIsMin) {
minLeft(false); minLeft(false);
} }
else { else {
maxLeft(false); maxLeft(false);
} }
}
else {
maxLeft(false);
}
// end // end
// 开始时显示loading...... // 开始时显示loading......
// 隐藏mask // 隐藏mask
$("#mainMask").html(""); // hideMask();
$("#mainMask").hide(100);
// 4/25 防止dropdown太高 // 4/25 防止dropdown太高
// dropdown // dropdown
@ -1438,11 +1457,93 @@ LeaAce = {
} }
}; };
function initLeanoteIfrPlugin () {
// 如果在iframe下, 很可能是嵌入了leanote
if (self != window.parent) {
LEA.topInfo = {};
// 收到消息
window.addEventListener('message', function(e) {
console.log('child 收到消息: ')
console.log(e.data);
LEA.topInfo = e.data || {};
LEA.topInfo.got = true;
}, false);
if (window.parent.postMessage) {
window.parent.postMessage('leanote', '*');
}
}
}
// 通过src得到note
function getNoteBySrc(src, callback) {
ajaxGet('/note/getNoteAndContentBySrc', {src: src}, function (ret) {
if (ret && ret.Ok) {
var data = ret.Item;
if (data) {
var noteInfo = data.NoteInfo;
var contentInfo = data.NoteContentInfo;
for (var i in contentInfo) {
noteInfo[i] = contentInfo[i];
}
callback(noteInfo);
}
else {
callback();
}
}
else {
callback();
}
});
}
// 得到top的info's src
var _topInfoStart = (new Date()).getTime();
function getTopInfoSrc (callback) {
if (LEA.topInfo.got) {
return callback(LEA.topInfo.src);
}
else {
// 超过1000ms, 不行
if ((new Date()).getTime() - _topInfoStart > 2000) {
return callback();
}
setTimeout(function () {
getTopInfoSrc(callback);
}, 10);
}
}
// note.html调用 // note.html调用
// 实始化页面 // 实始化页面
function initPage() { function initPage() {
// 不要用$(function() {}) 因为要等到<script>都加载了才执行 initLeanoteIfrPlugin();
// $(function() { if (LEA.topInfo) {
getTopInfoSrc(function (src) {
if (src) {
getNoteBySrc (src, function (srcNote) {
_initPage(srcNote, true);
});
} else {
_initPage(false, true);
}
});
}
else {
_initPage();
}
}
function _initPage(srcNote, isTop) {
if (srcNote) {
curNoteId = srcNote.NoteId;
curNotebookId = srcNote.NotebookId;
noteContentJson = srcNote; // 当前笔记变成我的
}
else if(isTop) {
curNoteId = null;
}
Notebook.renderNotebooks(notebooks); Notebook.renderNotebooks(notebooks);
Share.renderShareNotebooks(sharedUserInfos, shareNotebooks); Share.renderShareNotebooks(sharedUserInfos, shareNotebooks);
@ -1453,12 +1554,40 @@ function initPage() {
// 初始打开的是我的笔记 // 初始打开的是我的笔记
} else { } else {
Note.setNoteCache(noteContentJson); Note.setNoteCache(noteContentJson);
// 判断srcNote是否在notes中
var isExists = false;
if (isTop && srcNote && notes) {
for (var i = 0; i < notes.length; ++i) {
var note = notes[i];
if (note.NoteId === srcNote.NoteId) {
isExists = true;
notes.splice(i, 1);
notes.unshift(srcNote);
break;
}
}
if (!isExists) {
notes.unshift(srcNote);
}
}
Note.renderNotes(notes); Note.renderNotes(notes);
if(curNoteId) { if(curNoteId) {
// 指定某个note时才target notebook, /note定位到最新 // 指定某个note时才target notebook, /note定位到最新
// ie10&+要setTimeout // ie10&+要setTimeout
setTimeout(function() { setTimeout(function() {
Note.changeNoteForPjax(curNoteId, true, curNotebookId); Note.changeNoteForPjax(curNoteId, true, curNotebookId);
if (isTop) {
Note.toggleWriteable();
setTimeout(function () {
Note.toggleWriteable();
}, 100);
// 如果是markdown
setTimeout(function () {
Note.toggleWriteable();
}, 1000);
}
}); });
if(!curNotebookId) { if(!curNotebookId) {
Notebook.selectNotebook($(tt('#notebook [notebookId="?"]', Notebook.allNotebookId))); Notebook.selectNotebook($(tt('#notebook [notebookId="?"]', Notebook.allNotebookId)));
@ -1478,5 +1607,24 @@ function initPage() {
initSlimScroll(); initSlimScroll();
LeaAce.handleEvent(); LeaAce.handleEvent();
// });
// 如果是插件, 则切换到编辑页, 并切换到写作模式
if (isTop) {
Mobile.toEditor();
// 如果没有, 则新建之
if (!srcNote) {
Note.newNote();
Note.toggleWriteable(true);
setTimeout(function () {
Note.toggleWriteable(true);
}, 100);
// 如果是markdown
setTimeout(function () {
Note.toggleWriteable(true);
}, 1000);
}
}
hideMask();
} }

View File

@ -208,7 +208,7 @@ Share.toggleToSharedNav = function(userId, notebookId) {
var self = this; var self = this;
// for list // for list
$("#curNotebookForListNote").html(Share.notebookCache[notebookId].Title + '(' + Share.sharedUserInfos[userId].Username + ")"); $("#curNotebookForListNote").html(Share.notebookCache[notebookId].Title + '(' + Share.sharedUserInfos[userId].Username + ")");
Note.listIsIn(false, false, true);
// for new // for new
// 如果该用户下有新建的note, 那么列出, 如果没有, 则列出我的笔记 // 如果该用户下有新建的note, 那么列出, 如果没有, 则列出我的笔记
var forNew = Share.userNavs[userId].forNew; var forNew = Share.userNavs[userId].forNew;

View File

@ -236,9 +236,11 @@ Tag.renderTagNav = function(tags) {
var text = Tag.mapEn2Cn[tag] || text; var text = Tag.mapEn2Cn[tag] || text;
} }
text = trimTitle(text); text = trimTitle(text);
if (text) {
var classes = Tag.classes[tag] || "label label-default"; var classes = Tag.classes[tag] || "label label-default";
$("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">?</span> <span class="tag-delete">X</span></li>', tag, classes, text)); $("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">?</span> <span class="tag-delete">X</span></li>', tag, classes, text));
} }
}
}; };
Tag.deleteTag = function(title) { Tag.deleteTag = function(title) {
@ -367,6 +369,7 @@ $(function() {
$("#tagSearch").html($li.html()).show(); $("#tagSearch").html($li.html()).show();
$("#tagSearch .tag-delete").remove(); $("#tagSearch .tag-delete").remove();
Note.listIsIn(true, false);
showLoading(); showLoading();
ajaxGet("/note/searchNoteByTags", {tags: [tag]}, function(notes) { ajaxGet("/note/searchNoteByTags", {tags: [tag]}, function(notes) {

File diff suppressed because one or more lines are too long