v1.0 beta init
This commit is contained in:
1 parent
8ae438272b
commit
593d2c2965
225 files changed
+27217
-3675
No files matched your search
@@ -1,15 +1,61 @@
|
||||
// upload attachment
|
||||
// 依赖note
|
||||
var urlPrefix = window.location.protocol + "//" + window.location.host;
|
||||
var urlPrefix = UrlPrefix;
|
||||
define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
var initUploader = function() {
|
||||
var $msg = $('#attachUploadMsg');
|
||||
|
||||
$('#dropAttach .btn-choose-file').click(function() {
|
||||
// trigger to show file select
|
||||
// Helper function that formats the file sizes
|
||||
function formatFileSize(bytes) {
|
||||
if (typeof bytes !== 'number') {
|
||||
return '';
|
||||
}
|
||||
if (bytes >= 1000000000) {
|
||||
return (bytes / 1000000000).toFixed(2) + ' GB';
|
||||
}
|
||||
if (bytes >= 1000000) {
|
||||
return (bytes / 1000000).toFixed(2) + ' MB';
|
||||
}
|
||||
return (bytes / 1000).toFixed(2) + ' KB';
|
||||
}
|
||||
|
||||
function setDropStyle(dropzoneId, formId) {
|
||||
// drag css
|
||||
var dropZone = $(dropzoneId);
|
||||
$(formId).bind('dragover', function (e) {
|
||||
e.preventDefault();
|
||||
var timeout = window.dropZoneTimeoutAttach;
|
||||
if(timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
var found = false,
|
||||
node = e.target;
|
||||
do {
|
||||
if (node === dropZone[0]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
node = node.parentNode;
|
||||
} while (node != null);
|
||||
if (found) {
|
||||
dropZone.addClass('hover');
|
||||
} else {
|
||||
dropZone.removeClass('hover');
|
||||
}
|
||||
window.dropZoneTimeoutAttach = setTimeout(function () {
|
||||
window.dropZoneTimeoutAttach = null;
|
||||
dropZone.removeClass('in hover');
|
||||
}, 100);
|
||||
});
|
||||
}
|
||||
|
||||
setDropStyle("#dropAttach", "#uploadAttach");
|
||||
setDropStyle("#dropAvatar", "#uploadAvatar");
|
||||
|
||||
var initUploader = function() {
|
||||
$('.dropzone .btn-choose-file').click(function() {
|
||||
$(this).parent().find('input').click();
|
||||
});
|
||||
|
||||
var $msg = $('#attachUploadMsg');
|
||||
// Initialize the jQuery File Upload plugin
|
||||
$('#uploadAttach').fileupload({
|
||||
dataType: 'json',
|
||||
@@ -55,12 +101,10 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
jqXHR = data.submit();
|
||||
}, 10);
|
||||
},
|
||||
|
||||
/*
|
||||
progress: function (e, data) {
|
||||
},
|
||||
*/
|
||||
|
||||
done: function(e, data) {
|
||||
if (data.result.Ok == true) {
|
||||
data.context.html("");
|
||||
@@ -93,49 +137,73 @@ define('attachment_upload', ['jquery.ui.widget', 'fileupload'], function(){
|
||||
$("#uploadAttachMsg").scrollTop(1000);
|
||||
}
|
||||
});
|
||||
|
||||
// Helper function that formats the file sizes
|
||||
function formatFileSize(bytes) {
|
||||
if (typeof bytes !== 'number') {
|
||||
return '';
|
||||
}
|
||||
if (bytes >= 1000000000) {
|
||||
return (bytes / 1000000000).toFixed(2) + ' GB';
|
||||
}
|
||||
if (bytes >= 1000000) {
|
||||
return (bytes / 1000000).toFixed(2) + ' MB';
|
||||
}
|
||||
return (bytes / 1000).toFixed(2) + ' KB';
|
||||
}
|
||||
|
||||
// drag css
|
||||
var dropZone = $('#dropAttach');
|
||||
$("#uploadAttach").bind('dragover', function (e) {
|
||||
e.preventDefault();
|
||||
var timeout = window.dropZoneTimeoutAttach;
|
||||
if(timeout) {
|
||||
clearTimeout(timeout);
|
||||
}
|
||||
|
||||
var found = false,
|
||||
node = e.target;
|
||||
do {
|
||||
if (node === dropZone[0]) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
node = node.parentNode;
|
||||
} while (node != null);
|
||||
if (found) {
|
||||
dropZone.addClass('hover');
|
||||
} else {
|
||||
dropZone.removeClass('hover');
|
||||
}
|
||||
window.dropZoneTimeoutAttach = setTimeout(function () {
|
||||
window.dropZoneTimeoutAttach = null;
|
||||
dropZone.removeClass('in hover');
|
||||
}, 100);
|
||||
});
|
||||
//-------------------
|
||||
|
||||
var $msg2 = $('#avatarUploadMsg');
|
||||
$('#uploadAvatar').fileupload({
|
||||
dataType: 'json',
|
||||
dropZone: $('#dropAvatar'),
|
||||
add: function(e, data) {
|
||||
var tpl = $('<div class="alert alert-info"><img class="loader" src="/tinymce/plugins/leaui_image/public/images/ajax-loader.gif"> <a class="close" data-dismiss="alert">×</a></div>');
|
||||
|
||||
// Append the file name and file size
|
||||
tpl.append(data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small>');
|
||||
|
||||
// Add the HTML to the UL element
|
||||
$msg2.html(tpl);
|
||||
data.context = $msg2;
|
||||
|
||||
// 检查文件大小
|
||||
var size = data.files[0].size;
|
||||
if(typeof size == 'number' && size > 1024 * 1024) {
|
||||
tpl.find("img").remove();
|
||||
tpl.removeClass("alert-info").addClass("alert-danger");
|
||||
tpl.append(" Warning: File size is bigger than 1M");
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
tpl.remove();
|
||||
}
|
||||
})(tpl), 3000);
|
||||
return;
|
||||
}
|
||||
|
||||
// Automatically upload the file once it is added to the queue
|
||||
var jqXHR;
|
||||
setTimeout(function() {
|
||||
jqXHR = data.submit();
|
||||
}, 10);
|
||||
},
|
||||
done: function(e, data) {
|
||||
if (data.result.Ok == true) {
|
||||
data.context.html("");
|
||||
var re = data.result;
|
||||
$("#avatar").attr("src", UrlPrefix + "/" + re.Id);
|
||||
} else {
|
||||
var re = data.result;
|
||||
data.context.html("");
|
||||
var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');
|
||||
tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg);
|
||||
data.context.html(tpl);
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
tpl.remove();
|
||||
}
|
||||
})(tpl), 3000);
|
||||
}
|
||||
},
|
||||
fail: function(e, data) {
|
||||
data.context.html("");
|
||||
var tpl = $('<div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div>');
|
||||
tpl.append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown);
|
||||
data.context.html(tpl);
|
||||
setTimeout((function(tpl) {
|
||||
return function() {
|
||||
tpl.remove();
|
||||
}
|
||||
})(tpl), 3000);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
initUploader();
|
||||
|
||||
@@ -0,0 +1,207 @@
|
||||
// 返回是否是re.Ok == true
|
||||
function reIsOk(re) {
|
||||
return re && typeof re == "object" && re.Ok;
|
||||
}
|
||||
function showAlert(id, msg, type, id2Focus) {
|
||||
$(id).html(msg).removeClass("alert-danger").removeClass("alert-success").removeClass("alert-warning").addClass("alert-" + type).show();
|
||||
if(id2Focus) {
|
||||
$(id2Focus).focus();
|
||||
}
|
||||
}
|
||||
function hideAlert(id, timeout) {
|
||||
if(timeout) {
|
||||
setTimeout(function() {
|
||||
$(id).hide();
|
||||
}, timeout);
|
||||
} else {
|
||||
$(id).hide();
|
||||
}
|
||||
}
|
||||
function ajaxGet(url, param, func) {
|
||||
$.get(url, param, func);
|
||||
}
|
||||
function ajaxPost(url, param, func) {
|
||||
$.post(url, param, func);
|
||||
}
|
||||
function goLogin(){
|
||||
var loginUrl = urlPrefix + '/login?from=' + encodeURI(location.href);
|
||||
location.href = loginUrl;
|
||||
}
|
||||
function goRegister() {
|
||||
var registerUrl = urlPrefix + '/register?from=' + encodeURI(location.href);
|
||||
location.href = registerUrl;
|
||||
}
|
||||
function needLogin() {
|
||||
if(typeof visitUserInfo == "undefined" || !visitUserInfo || !visitUserInfo.UserId) {
|
||||
// 弹框之
|
||||
var loginUrl = urlPrefix + '/login?from=' + encodeURI(location.href);
|
||||
var registerUrl = urlPrefix + '/register?from=' + encodeURI(location.href);
|
||||
var modal = BootstrapDialog.show({
|
||||
title: "你还未登录",
|
||||
message: '<div class="needLogin" style="border:none"><a href="' + loginUrl + '">立即登录</a>, 发表评论.<br />没有帐号? <a href="' + registerUrl +'">立即注册</a>',
|
||||
nl2br: false
|
||||
});
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
function scrollToTarget(t, fixed) {
|
||||
if(!fixed) {
|
||||
fixed = 0;
|
||||
}
|
||||
var $t = $(t)
|
||||
var targetOffset = $t.offset().top + fixed;
|
||||
$('html,body').animate({scrollTop: targetOffset}, 300);
|
||||
}
|
||||
|
||||
var windowParam = 'width=700, height=580, top=180, left=320, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no';
|
||||
function getShareUrl(noteId) {
|
||||
return viewUrl + "/" + noteId;
|
||||
}
|
||||
function getShareTitle(title) {
|
||||
return encodeURI(title + " (来自leanote.com)");
|
||||
}
|
||||
function shareSinaWeibo(noteId, title, pic) {
|
||||
var url = "http://service.weibo.com/share/share.php?title=" + getShareTitle(title) + "&url=" + getShareUrl(noteId);
|
||||
window.open(url, 'Share', windowParam);
|
||||
}
|
||||
function shareTencentWeibo(noteId, title, pic) {
|
||||
var _appkey = '801542571';
|
||||
var url = "http://share.v.t.qq.com/index.php?c=share&a=index&appkey=" + _appkey +"&title=" + getShareTitle(title) + "&url=" + getShareUrl(noteId) +"&pic=" + pic;
|
||||
window.open(url, 'Share', windowParam);
|
||||
}
|
||||
function shareQQ(noteId, title, pic) {
|
||||
var url = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + getShareUrl(noteId) + '&title=' + title + '&pics=' + pic;
|
||||
window.open(url, 'Share', windowParam);
|
||||
}
|
||||
function shareRenRen(noteId, title, pic) {
|
||||
var url = 'http://widget.renren.com/dialog/share?resourceUrl=' + getShareUrl(noteId) + '&srcUrl=' + getShareUrl(noteId) + '&title=' + getShareTitle(title) + '&pic=' + pic;
|
||||
window.open(url, 'Share', windowParam);
|
||||
}
|
||||
|
||||
// https://twitter.com/intent/tweet?text=&pic=
|
||||
function shareTwitter(noteId, title, pic) {
|
||||
var url = 'https://twitter.com/intent/tweet?text=' + getShareTitle(title) + '&pic=' + pic;
|
||||
window.open(url, 'Share', windowParam);
|
||||
}
|
||||
// http://www.facebook.com/sharer.php?u=<?php the_permalink();?>&t=<?php the_title(); ?>”
|
||||
function shareFacebook(noteId, title, pic) {
|
||||
var url = ' http://www.facebook.com/sharer.php?t=' + getShareTitle(title) + '&pic=' + pic;
|
||||
window.open(url, 'Share', windowParam);
|
||||
}
|
||||
|
||||
//JavaScript函数:
|
||||
var minute = 1000 * 60;
|
||||
var hour = minute * 60;
|
||||
var day = hour * 24;
|
||||
var halfamonth = day * 15;
|
||||
var month = day * 30;
|
||||
// 2014-01-06T18:29:48.802+08:00
|
||||
|
||||
function goNowToDatetime(goNow) {
|
||||
if(!goNow) {
|
||||
return "";
|
||||
}
|
||||
return goNow.substr(0, 10) + " " + goNow.substr(11, 8);
|
||||
}
|
||||
function getDateDiff(dateTimeStamp){
|
||||
var now = new Date().getTime();
|
||||
var diffValue = now - dateTimeStamp;
|
||||
if(diffValue < 0){
|
||||
return "";
|
||||
}
|
||||
var monthC =diffValue/month;
|
||||
var weekC =diffValue/(7*day);
|
||||
var dayC =diffValue/day;
|
||||
var hourC =diffValue/hour;
|
||||
var minC =diffValue/minute;
|
||||
if(monthC>=1){
|
||||
result=parseInt(monthC) + getMsg("monthsAgo");
|
||||
}
|
||||
else if(weekC>=1){
|
||||
result=parseInt(weekC) + getMsg("weeksAgo");
|
||||
}
|
||||
else if(dayC>=1){
|
||||
result=parseInt(dayC) + getMsg("daysAgo");
|
||||
}
|
||||
else if(hourC>=1){
|
||||
result=parseInt(hourC) + getMsg("hoursAgo");
|
||||
}
|
||||
else if(minC>=1){
|
||||
result=parseInt(minC) + getMsg("minutesAgo");
|
||||
}else {
|
||||
result=getMsg("justNow");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function weixin() {
|
||||
var local=window.location.href;
|
||||
var title = $.trim($(".title").text());
|
||||
var desc = $.trim($("#desc").text());
|
||||
var imgUrl = $("#content img").eq(0).attr('src');
|
||||
window.shareData = {
|
||||
"imgUrl": imgUrl,
|
||||
"timeLineLink":local,
|
||||
"sendFriendLink": local,
|
||||
"weiboLink":local,
|
||||
"tTitle": title,
|
||||
"tContent": desc,
|
||||
"fTitle": title,
|
||||
"fContent": desc,
|
||||
"wContent": desc
|
||||
};
|
||||
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
|
||||
// 发送给好友
|
||||
WeixinJSBridge.on('menu:share:appmessage', function (argv) {
|
||||
WeixinJSBridge.invoke('sendAppMessage', {
|
||||
"img_url": window.shareData.imgUrl,
|
||||
"img_width": "200",
|
||||
"link": window.shareData.sendFriendLink,
|
||||
"desc": window.shareData.fContent,
|
||||
"title": window.shareData.fTitle
|
||||
}, function (res) {
|
||||
hs_guide('none');
|
||||
_report('send_msg', res.err_msg);
|
||||
})
|
||||
});
|
||||
|
||||
// 分享到朋友圈
|
||||
WeixinJSBridge.on('menu:share:timeline', function (argv) {
|
||||
WeixinJSBridge.invoke('shareTimeline', {
|
||||
"img_url": window.shareData.imgUrl,
|
||||
"img_width": "200",
|
||||
"link": window.shareData.timeLineLink,
|
||||
"desc": window.shareData.tContent,
|
||||
"title": window.shareData.tTitle
|
||||
}, function (res) {
|
||||
hs_guide('none');
|
||||
_report('timeline', res.err_msg);
|
||||
});
|
||||
});
|
||||
|
||||
// 分享到微博
|
||||
WeixinJSBridge.on('menu:share:weibo', function (argv) {
|
||||
WeixinJSBridge.invoke('shareWeibo', {
|
||||
"content": window.shareData.wContent,
|
||||
"url": window.shareData.weiboLink,
|
||||
}, function (res) {
|
||||
hs_guide('none');
|
||||
_report('weibo', res.err_msg);
|
||||
});
|
||||
});
|
||||
}, false);
|
||||
}
|
||||
|
||||
var LEA = {isMobile: false};
|
||||
function isMobile() {
|
||||
var u = navigator.userAgent;
|
||||
LEA.isMobile = false;
|
||||
LEA.isMobile = /Mobile|Android|iPhone/i.test(u);
|
||||
if(!LEA.isMobile && $(document).width() <= 600){
|
||||
LEA.isMobile = true
|
||||
}
|
||||
}
|
||||
$(function() {
|
||||
isMobile();
|
||||
});
|
||||
@@ -1,85 +0,0 @@
|
||||
function scrollTo(self, tagName, text) {
|
||||
var iframe = $("#content");
|
||||
var target = iframe.find(tagName + ":contains(" + text + ")");
|
||||
|
||||
// 找到是第几个
|
||||
// 在nav是第几个
|
||||
var navs = $('#blogNavContent [data-a="' + tagName + '-' + encodeURI(text) + '"]');
|
||||
var len = navs.size();
|
||||
for(var i = 0; i < len; ++i) {
|
||||
if(navs[i] == self) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (target.size() >= i+1) {
|
||||
target = target.eq(i);
|
||||
// 之前插入, 防止多行定位不准
|
||||
var top = target.offset().top;
|
||||
var nowTop = $(document).scrollTop();
|
||||
// 用$("body").scrllTop(10)没反应 firefox下
|
||||
$('html,body').animate({scrollTop: top}, 200);
|
||||
return;
|
||||
}
|
||||
}
|
||||
function genNav() {
|
||||
var $con = $("#content");
|
||||
var html = $con.html();
|
||||
// 构造一棵树
|
||||
// {"h1-title":{h2-title:{}}}
|
||||
var tree = [];//[{title: "xx", children:[{}]}, {title:"xx2"}];
|
||||
var hs = $con.find("h1,h2,h3,h4,h5,h6").toArray();
|
||||
var titles = '<ul>';
|
||||
for(var i = 0; i < hs.length; ++i) {
|
||||
var text = $(hs[i]).text();
|
||||
var tagName = hs[i].tagName.toLowerCase();
|
||||
// scrollTo在page.js中定义
|
||||
titles += '<li class="nav-' + tagName + '"><a data-a="' + tagName + '-' + encodeURI(text)+'" onclick="scrollTo(this, \'' + tagName + '\', \'' + text + '\')">' + text + '</a></li>';
|
||||
}
|
||||
titles += "</ul>";
|
||||
$("#blogNavContent").html(titles);
|
||||
if(!hs.length) {
|
||||
$("#blogNavContent").html(" 无");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function initNav() {
|
||||
var hasNav = genNav();
|
||||
if(!hasNav) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $title = $(".title");
|
||||
var titlePos = $title.offset();
|
||||
var top = titlePos.top + 10;// - $title.height();
|
||||
if(top < 0) {
|
||||
top = 10;
|
||||
}
|
||||
var left = $title.width() + titlePos.left - 100;
|
||||
$("#blogNav").css("top", top).css("left", left);
|
||||
$("#blogNav").show();
|
||||
|
||||
$("#blogNavNav").click(function() {
|
||||
var $o = $("#blogNavContent");
|
||||
if($o.is(":hidden")) {
|
||||
$o.show();
|
||||
} else {
|
||||
$o.hide();
|
||||
}
|
||||
});
|
||||
|
||||
var $d = $(document);
|
||||
function reNav() {
|
||||
var vtop = $d.scrollTop();
|
||||
if(vtop <= top) {
|
||||
$("#blogNav").css("top", top-vtop);
|
||||
} else {
|
||||
// 差距很磊了
|
||||
$("#blogNav").css("top", 10);
|
||||
}
|
||||
}
|
||||
reNav();
|
||||
$(window).scroll(reNav);
|
||||
}
|
||||
@@ -0,0 +1,509 @@
|
||||
function scrollTo(self, tagName, text) {
|
||||
var iframe = $("#content");
|
||||
var target = iframe.find(tagName + ":contains(" + text + ")");
|
||||
|
||||
// 找到是第几个
|
||||
// 在nav是第几个
|
||||
var navs = $('#blogNavContent [data-a="' + tagName + '-' + encodeURI(text) + '"]');
|
||||
var len = navs.size();
|
||||
for(var i = 0; i < len; ++i) {
|
||||
if(navs[i] == self) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (target.size() >= i+1) {
|
||||
target = target.eq(i);
|
||||
// 之前插入, 防止多行定位不准
|
||||
var top = target.offset().top;
|
||||
if(LEA.isMobile) {
|
||||
top -= 50;
|
||||
}
|
||||
var nowTop = $(document).scrollTop();
|
||||
// 用$("body").scrllTop(10)没反应 firefox下
|
||||
$('html,body').animate({scrollTop: top}, 200);
|
||||
return;
|
||||
}
|
||||
}
|
||||
function genNav() {
|
||||
var $con = $("#content");
|
||||
var html = $con.html();
|
||||
// 构造一棵树
|
||||
// {"h1-title":{h2-title:{}}}
|
||||
var tree = [];//[{title: "xx", children:[{}]}, {title:"xx2"}];
|
||||
var hs = $con.find("h1,h2,h3,h4,h5,h6").toArray();
|
||||
var titles = '<ul>';
|
||||
for(var i = 0; i < hs.length; ++i) {
|
||||
var text = $(hs[i]).text();
|
||||
var tagName = hs[i].tagName.toLowerCase();
|
||||
// scrollTo在page.js中定义
|
||||
titles += '<li class="nav-' + tagName + '"><a data-a="' + tagName + '-' + encodeURI(text)+'" onclick="scrollTo(this, \'' + tagName + '\', \'' + text + '\')">' + text + '</a></li>';
|
||||
}
|
||||
titles += "</ul>";
|
||||
$("#blogNavContent").html(titles);
|
||||
if(!hs.length) {
|
||||
$("#blogNavContent").html(getMsg("none"));
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function initNav() {
|
||||
var hasNav = genNav();
|
||||
if(!hasNav) {
|
||||
return;
|
||||
}
|
||||
|
||||
var $title = $(".title");
|
||||
var titlePos = $title.offset();
|
||||
var top = titlePos.top + 10;// - $title.height();
|
||||
// 手机下不要与标题在同一高度
|
||||
if(LEA.isMobile){
|
||||
top += 30;
|
||||
}
|
||||
if(top < 0) {
|
||||
top = 10;
|
||||
}
|
||||
|
||||
var left = $title.width() + titlePos.left - 100;
|
||||
$("#blogNav").css("top", top).css("left", left);
|
||||
$("#blogNav").show();
|
||||
|
||||
$("#blogNavNav").click(function() {
|
||||
var $o = $("#blogNavContent");
|
||||
if($o.is(":hidden")) {
|
||||
$o.show();
|
||||
} else {
|
||||
$o.hide();
|
||||
}
|
||||
});
|
||||
|
||||
var $d = $(document);
|
||||
function reNav() {
|
||||
var vtop = $d.scrollTop();
|
||||
if(vtop <= top) {
|
||||
$("#blogNav").css("top", top-vtop);
|
||||
} else {
|
||||
// 差距很磊了
|
||||
if(LEA.isMobile) {
|
||||
$("#blogNav").css("top", 50);
|
||||
} else {
|
||||
$("#blogNav").css("top", 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
reNav();
|
||||
$(window).scroll(reNav);
|
||||
}
|
||||
|
||||
var C = {
|
||||
info: null,
|
||||
noteId: noteId,
|
||||
preLikeNum: preLikeNum,
|
||||
commentNum: commentNum,
|
||||
likeBtnO: $("#likeBtn"),
|
||||
likeNumO: $("#likeNum"),
|
||||
tLikersO: $("#tLikers"),
|
||||
likersO: $("#likers"),
|
||||
tCommentsO: $("#tComments"),
|
||||
commentsO: $("#comments"),
|
||||
|
||||
commentBtnO: $("#commentBtn"),
|
||||
|
||||
commentsLoadingO: $(".comments-loading"),
|
||||
commentsMoreO: $(".comments-more"),
|
||||
|
||||
commentBoxO: $(".comment-box"),
|
||||
init: function() {
|
||||
var self = this;
|
||||
if(UserBlogInfo.CanComment && UserBlogInfo.CommentType != "disqus") {
|
||||
self.initLikeAndComments();
|
||||
} else {
|
||||
self.initLike();
|
||||
}
|
||||
self.initEvent();
|
||||
self.incReadNum();
|
||||
},
|
||||
incReadNum: function() {
|
||||
var self = this;
|
||||
if(!$.cookie(self.noteId)) {
|
||||
$.cookie(self.noteId, 1);
|
||||
ajaxGet(staticUrl + "/blog/incReadNum", {noteId: self.noteId});
|
||||
}
|
||||
},
|
||||
initLike: function() {
|
||||
var self = this;
|
||||
ajaxGet(staticUrl + "/blog/getLike", {noteId: self.noteId}, function(ret) {
|
||||
self.info = ret;
|
||||
self.toggleLikeBtnActive();
|
||||
self.renderLikers();
|
||||
});
|
||||
},
|
||||
initLikeAndComments: function() {
|
||||
var self = this;
|
||||
ajaxGet(staticUrl + "/blog/getLikeAndComments", {noteId: self.noteId}, function(ret) {
|
||||
self.info = ret;
|
||||
self.toggleLikeBtnActive();
|
||||
self.renderLikers();
|
||||
// 是否需要renderComments?
|
||||
self.info.commentUserInfo = self.info.commentUserInfo || {};
|
||||
// 为了防止第一条评论找不到用户信息情况
|
||||
if(visitUserInfo.UserId) {
|
||||
self.info.commentUserInfo[visitUserInfo.UserId] = visitUserInfo;
|
||||
}
|
||||
self.renderComments();
|
||||
|
||||
self.commentBoxO.removeClass("hide");
|
||||
self.commentsLoadingO.addClass("hide");
|
||||
if(self.info.pageInfo.TotalPage > self.info.pageInfo.CurPage) {
|
||||
self.commentsMoreO.removeClass("hide");
|
||||
self.initMoreComments();
|
||||
}
|
||||
});
|
||||
},
|
||||
initMoreComments: function() {
|
||||
var self = this;
|
||||
self.commentsMoreO.find("a").click(function(){
|
||||
if(self.info.pageInfo.TotalPage > self.info.pageInfo.CurPage) {
|
||||
self.commentsMoreO.addClass("hide");
|
||||
self.commentsLoadingO.removeClass("hide");
|
||||
ajaxGet(staticUrl + "/blog/listComments", {noteId: self.noteId, page: self.info.pageInfo.CurPage+1}, function(ret) {
|
||||
var pageInfo = ret.pageInfo;
|
||||
var comments = ret.comments;
|
||||
var commentUserInfo = ret.commentUserInfo;
|
||||
|
||||
$.extend(self.info.commentUserInfo, commentUserInfo);
|
||||
|
||||
// 渲染之
|
||||
for(var i in comments) {
|
||||
var comment = comments[i];
|
||||
comment = self.parseComment(comment);
|
||||
}
|
||||
var html = self.tCommentsO.render({comments: comments, visitUserInfo: visitUserInfo});
|
||||
self.commentsO.append(html);
|
||||
|
||||
self.info.pageInfo = pageInfo;
|
||||
|
||||
if(self.info.pageInfo.TotalPage > self.info.pageInfo.CurPage) {
|
||||
self.commentsMoreO.removeClass("hide");
|
||||
} else {
|
||||
self.commentsMoreO.addClass("hide");
|
||||
}
|
||||
|
||||
self.commentsLoadingO.addClass("hide");
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
addCommentRender: function(comment){
|
||||
var self = this;
|
||||
comment = self.parseComment(comment);
|
||||
var html = self.tCommentsO.render({blogUrl: blogUrl, comments: [comment], visitUserInfo: visitUserInfo});
|
||||
self.commentsO.prepend(html);
|
||||
var li = self.commentsO.find("li").eq(0);
|
||||
li.hide();
|
||||
li.show(500);
|
||||
li.addClass("item-highlight");
|
||||
setTimeout(function() {
|
||||
li.removeClass("item-highlight");
|
||||
}, 2000);
|
||||
},
|
||||
parseComment: function(comment) {
|
||||
var self = this;
|
||||
var authorUserId = UserInfo.UserId;
|
||||
commentUserInfo = self.info.commentUserInfo;
|
||||
comment.UserInfo = commentUserInfo[comment.UserId];
|
||||
// 是作者自己
|
||||
if(visitUserInfo.UserId == UserInfo.UserId) {
|
||||
comment.IsMyNote = true;
|
||||
}
|
||||
if(comment.UserId == authorUserId) {
|
||||
comment.IsAuthorComment = true;
|
||||
}
|
||||
if(comment.UserId == visitUserInfo.UserId) {
|
||||
comment.IsMyComment = true;
|
||||
}
|
||||
// 不是回复自己
|
||||
if(comment.ToUserId && comment.ToUserId != comment.UserId) {
|
||||
comment.ToUserInfo = commentUserInfo[comment.ToUserId];
|
||||
if(comment.ToUserInfo.UserId == UserInfo.UserId) {
|
||||
comment.ToUserIsAuthor = true;
|
||||
}
|
||||
}
|
||||
comment.PublishDate = getDateDiff(Date.parse(goNowToDatetime(comment.CreatedTime)));
|
||||
return comment;
|
||||
},
|
||||
// 渲染评论
|
||||
renderComments: function() {
|
||||
var self = this;
|
||||
var comments = self.info.comments || [];
|
||||
if(comments.length == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 整理数据
|
||||
// 回复谁, 是否是作者?
|
||||
// 回复日期, 几天前, 刚刚
|
||||
for(var i in comments) {
|
||||
var comment = comments[i];
|
||||
comment = self.parseComment(comment);
|
||||
}
|
||||
var html = self.tCommentsO.render({blogUrl: blogUrl, comments: comments, visitUserInfo: visitUserInfo});
|
||||
self.commentsO.html(html);
|
||||
},
|
||||
|
||||
// 重新渲染likers
|
||||
reRenderLikers: function(addMe) {
|
||||
var self = this;
|
||||
var likedUsers = self.info.likedUsers || [];
|
||||
for(var i = 0; i < likedUsers.length; ++i) {
|
||||
var user = likedUsers[i];
|
||||
if(user.UserId == visitUserInfo.UserId) {
|
||||
likedUsers.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(addMe) {
|
||||
likedUsers = [visitUserInfo].concat(likedUsers);
|
||||
self.info.likedUsers = likedUsers;
|
||||
}
|
||||
self.renderLikers();
|
||||
},
|
||||
renderLikers: function() {
|
||||
var self = this;
|
||||
var users = self.info.likedUsers || [];
|
||||
var html = self.tLikersO.render({blogUrl: blogUrl, users: users});
|
||||
self.likersO.html(html);
|
||||
},
|
||||
toggleLikeBtnActive: function() {
|
||||
var self = this;
|
||||
if(self.info.isILikeIt) {
|
||||
self.likeBtnO.addClass("active");
|
||||
} else {
|
||||
self.likeBtnO.removeClass("active");
|
||||
}
|
||||
},
|
||||
commentNumO: $("#commentNum"),
|
||||
bindCommentNum: function(fix) {
|
||||
var self = this;
|
||||
self.commentNum += fix;
|
||||
self.commentNumO.text(self.commentNum);
|
||||
},
|
||||
initEvent: function() {
|
||||
var self = this;
|
||||
|
||||
// like or not
|
||||
self.likeBtnO.click(function() {
|
||||
if(!visitUserInfo.UserId) {
|
||||
needLogin();
|
||||
return;
|
||||
}
|
||||
ajaxPost(staticUrl + "/blog/likeBlog", {noteId: self.noteId}, function(ret) {
|
||||
if(ret.Ok) {
|
||||
// like
|
||||
if(ret.Item) {
|
||||
var num = self.preLikeNum+1;
|
||||
} else {
|
||||
var num = self.preLikeNum-1;
|
||||
}
|
||||
self.preLikeNum = num >= 0 ? num : 0;
|
||||
self.likeNumO.text(self.preLikeNum);
|
||||
self.info.isILikeIt = ret.Item;
|
||||
self.toggleLikeBtnActive();
|
||||
|
||||
// 重新render likers
|
||||
// 我是否在列表中
|
||||
self.reRenderLikers(ret.Item);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 显示回复回复
|
||||
$("#comments").on("click", ".comment-reply", function() {
|
||||
var form = $(this).closest("li").find("form");
|
||||
if(form.is(":hidden")) {
|
||||
form.show();
|
||||
form.find("textarea").focus();
|
||||
} else {
|
||||
form.hide();
|
||||
}
|
||||
});
|
||||
$("#comments").on("click", ".reply-cancel", function() {
|
||||
$(this).closest("form").hide();
|
||||
});
|
||||
|
||||
// 回复
|
||||
$(".comment-box").on("click", ".reply-comment-btn", function(e) {
|
||||
e.preventDefault();
|
||||
var commentId = $(this).data("comment-id");
|
||||
var $form = $(this).closest("form");
|
||||
var $content = $form.find("textarea");
|
||||
var content = $.trim($content.val());
|
||||
if(!content) {
|
||||
$content.focus();
|
||||
return;
|
||||
}
|
||||
var t = $(this);
|
||||
t.button("loading");
|
||||
var data = {noteId: self.noteId, toCommentId: commentId, content: content};
|
||||
ajaxPost(staticUrl + "/blog/comment", data, function(ret) {
|
||||
t.button("reset");
|
||||
$content.val("");
|
||||
self.bindCommentNum(1);
|
||||
if(commentId) {
|
||||
$form.hide();
|
||||
}
|
||||
|
||||
if(commentId) {
|
||||
scrollToTarget("#comments", -200);
|
||||
}
|
||||
|
||||
// 添加一个
|
||||
self.addCommentRender(ret.Item);
|
||||
});
|
||||
});
|
||||
|
||||
// 删除
|
||||
$(".comment-box").on("click", ".comment-trash", function(e) {
|
||||
var commentId = $(this).parent().data("comment-id");
|
||||
var t = this;
|
||||
BootstrapDialog.confirm(getMsg("confirmDeleteComment"), function(yes) {
|
||||
if(yes) {
|
||||
ajaxPost(staticUrl + "/blog/deleteComment", {noteId: self.noteId, commentId: commentId}, function(ret) {
|
||||
if(ret.Ok) {
|
||||
var li = $(t).closest("li");
|
||||
li.hide(500); // remove();
|
||||
setTimeout(function() {
|
||||
li.remove();
|
||||
}, 300);
|
||||
|
||||
self.bindCommentNum(-1);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 点zan
|
||||
$(".comment-box").on("click", ".comment-like", function(e) {
|
||||
var commentId = $(this).parent().data("comment-id");
|
||||
var t = this;
|
||||
|
||||
ajaxPost(staticUrl + "/blog/likeComment", {commentId: commentId}, function(re) {
|
||||
if(re.Ok) {
|
||||
var ret = re.Item;
|
||||
if(ret.Num <= 0) {
|
||||
$(t).parent().find(".like-num").addClass("hide");
|
||||
} else {
|
||||
$(t).parent().find(".like-num").removeClass("hide");
|
||||
$(t).parent().find(".like-num-i").text(ret.Num)
|
||||
}
|
||||
if(ret.IsILikeIt) {
|
||||
$(t).find(".like-text").text(getMsg("unlike"));
|
||||
} else {
|
||||
$(t).find(".like-text").text(getMsg('like'));
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 举报
|
||||
function report(commentId, noteId, title) {
|
||||
var form = $("#reportMsg").html();
|
||||
var body;
|
||||
var input;
|
||||
var isOver = false;
|
||||
var modal = BootstrapDialog.show({
|
||||
title: title,
|
||||
message: form,
|
||||
nl2br: false,
|
||||
buttons: [{
|
||||
label: getMsg("cancel"),
|
||||
action: function(dialog) {
|
||||
dialog.close();
|
||||
}
|
||||
}, {
|
||||
label: getMsg("confirm"),
|
||||
cssClass: 'btn-primary',
|
||||
action: function(dialog) {
|
||||
if(isOver) {
|
||||
dialog.close();
|
||||
}
|
||||
var val = body.find("input[type='radio']:checked").val();
|
||||
if(!val) {
|
||||
var val = body.find(".input-container input").val();
|
||||
}
|
||||
if(!val) {
|
||||
body.find(".footnote").html(getMsg("chooseReason"));
|
||||
return;
|
||||
}
|
||||
ajaxPost(staticUrl + "/blog/report", {commentId: commentId, noteId: noteId, reason: val}, function(re) {
|
||||
isOver = true;
|
||||
if(reIsOk(re)) {
|
||||
body.html(getMsg("reportSuccess"));
|
||||
} else {
|
||||
body.html(getMsg("error"));
|
||||
}
|
||||
setTimeout(function() {
|
||||
dialog.close();
|
||||
}, 3000);
|
||||
});
|
||||
}
|
||||
}]
|
||||
});
|
||||
body = modal.getModalBody();
|
||||
input = body.find(".input-container");
|
||||
body.find("input[type='radio']").click(function(){
|
||||
if(!$(this).val()) {
|
||||
input.show();
|
||||
input.find("input").focus();
|
||||
} else {
|
||||
input.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".comment-box").on("click", ".comment-report", function() {
|
||||
if(needLogin()) {
|
||||
return;
|
||||
}
|
||||
var commentId = $(this).parent().data("comment-id");
|
||||
report(commentId, self.noteId, getMsg("reportComment?"));
|
||||
});
|
||||
$("#reportBtn").click(function() {
|
||||
if(needLogin()) {
|
||||
return;
|
||||
}
|
||||
report("", self.noteId, getMsg("reportBlog?"));
|
||||
});
|
||||
|
||||
self.initShare();
|
||||
},
|
||||
weixinQRCodeO: $("#weixinQRCode"),
|
||||
initShare: function() {
|
||||
var self = this;
|
||||
$(".btn-weixin").click(function() {
|
||||
if(!self.weixinQRCodeO.html()) {
|
||||
self.weixinQRCodeO.qrcode(viewUrl + "/" + self.noteId);
|
||||
}
|
||||
BootstrapDialog.show({
|
||||
title: getMsg('scanQRCode'),
|
||||
message: self.weixinQRCodeO
|
||||
});
|
||||
});
|
||||
|
||||
$(".btn-share").click(function() {
|
||||
var $this = $(this);
|
||||
var map = {"btn-weibo": shareSinaWeibo, "tencent-weibo": shareTencentWeibo, "qq": shareQQ, "renren": shareRenRen};
|
||||
for(var i in map) {
|
||||
if($this.hasClass(i)) {
|
||||
map[i](self.noteId, document.title);
|
||||
break;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
C.init();
|
||||
});
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
Note.curNoteId="";Note.interval="";Note.itemIsBlog='<div class="item-blog"><i class="fa fa-bold" title="blog"></i></div><div class="item-setting"><i class="fa fa-cog" title="setting"></i></div>';Note.itemTplNoImg='<div href="#" class="item ?" noteId="?">';Note.itemTplNoImg+=Note.itemIsBlog+'<div class="item-desc" style="right: 0;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';Note.itemTpl='<div href="#" class="item ?" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>';Note.itemTpl+=Note.itemIsBlog+'<div class="item-desc" style=""><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';Note.newItemTpl='<div href="#" class="item item-active ?" fromUserId="?" noteId="?">';Note.newItemTpl+=Note.itemIsBlog+'<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></div>';Note.noteItemListO=$("#noteItemList");Note.cacheByNotebookId={all:{}};Note.notebookIds={};Note.isReadOnly=false;Note.intervalTime=6e5;Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始...");changedNote=Note.curChangedSaveIt(false)},Note.intervalTime)};Note.stopInterval=function(){clearInterval(Note.interval);setTimeout(function(){Note.startInterval()},Note.intervalTime)};Note.addNoteCache=function(note){Note.cache[note.NoteId]=note;Note.clearCacheByNotebookId(note.NotebookId)};Note.setNoteCache=function(content,clear){if(!Note.cache[content.NoteId]){Note.cache[content.NoteId]=content}else{$.extend(Note.cache[content.NoteId],content)}if(clear==undefined){clear=true}if(clear){Note.clearCacheByNotebookId(content.NotebookId)}};Note.getCurNote=function(){var self=this;if(self.curNoteId==""){return null}return self.cache[self.curNoteId]};Note.getNote=function(noteId){var self=this;return self.cache[noteId]};Note.clearCacheByNotebookId=function(notebookId){if(notebookId){Note.cacheByNotebookId[notebookId]={};Note.cacheByNotebookId["all"]={};Note.notebookIds[notebookId]=true}};Note.notebookHasNotes=function(notebookId){var notes=Note.getNotesByNotebookId(notebookId);return!isEmpty(notes)};Note.getNotesByNotebookId=function(notebookId,sortBy,isAsc){if(!sortBy){sortBy="UpdatedTime"}if(isAsc=="undefined"){isAsc=false}if(!notebookId){notebookId="all"}if(!Note.cacheByNotebookId[notebookId]){return[]}if(Note.cacheByNotebookId[notebookId][sortBy]){return Note.cacheByNotebookId[notebookId][sortBy]}else{}var notes=[];var sortBys=[];for(var i in Note.cache){if(!i){continue}var note=Note.cache[i];if(note.IsTrash||note.IsShared){continue}if(notebookId=="all"||note.NotebookId==notebookId){notes.push(note)}}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.cacheByNotebookId[notebookId][sortBy]=notes;return notes};Note.renderNotesAndFirstOneContent=function(ret){if(!isArray(ret)){return}Note.renderNotes(ret);if(!isEmpty(ret[0])){Note.changeNote(ret[0].NoteId)}else{}};Note.curHasChanged=function(force){if(force==undefined){force=true}var cacheNote=Note.cache[Note.curNoteId]||{};var title=$("#noteTitle").val();var tags=Tag.getTags();var contents=getEditorContent(cacheNote.IsMarkdown);var content,preview;var contentText;if(isArray(contents)){content=contents[0];preview=contents[1];contentText=content;if(content&&previewIsEmpty(preview)){preview=Converter.makeHtml(content)}if(!content){preview=""}cacheNote.Preview=preview}else{content=contents;try{contentText=$(content).text()}catch(e){}}var hasChanged={hasChanged:false,IsNew:cacheNote.IsNew,IsMarkdown:cacheNote.IsMarkdown,FromUserId:cacheNote.FromUserId,NoteId:cacheNote.NoteId,NotebookId:cacheNote.NotebookId};if(hasChanged.IsNew){$.extend(hasChanged,cacheNote)}if(cacheNote.Title!=title){hasChanged.hasChanged=true;hasChanged.Title=title;if(!hasChanged.Title){}}if(!arrayEqual(cacheNote.Tags,tags)){hasChanged.hasChanged=true;hasChanged.Tags=tags}if(force&&cacheNote.Content!=content||!force&&$(cacheNote.Content).text()!=contentText){hasChanged.hasChanged=true;hasChanged.Content=content;var c=preview||content;hasChanged.Desc=Note.genDesc(c);hasChanged.ImgSrc=Note.getImgSrc(c);hasChanged.Abstract=Note.genAbstract(c)}else{log("text相同");log(cacheNote.Content==content)}hasChanged["UserId"]=cacheNote["UserId"]||"";return hasChanged};Note.genDesc=function(content){if(!content){return""}var token="ALEALE";content=content.replace(/<\/p>/g,token);content=content.replace(/<\/div>/g,token);content=Line truncated
|
||||
Note.curNoteId="";Note.interval="";Note.itemIsBlog='<div class="item-blog"><i class="fa fa-bold" title="blog"></i></div><div class="item-setting"><i class="fa fa-cog" title="setting"></i></div>';Note.itemTplNoImg='<li href="#" class="item ?" noteId="?">';Note.itemTplNoImg+=Note.itemIsBlog+'<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';Note.itemTpl='<li href="#" class="item ? item-image" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>';Note.itemTpl+=Note.itemIsBlog+'<div class="item-desc" style=""><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';Note.newItemTpl='<li href="#" class="item item-active ?" fromUserId="?" noteId="?">';Note.newItemTpl+=Note.itemIsBlog+'<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></li>';Note.noteItemListO=$("#noteItemList");Note.cacheByNotebookId={all:{}};Note.notebookIds={};Note.isReadOnly=false;Note.intervalTime=6e5;Note.startInterval=function(){Note.interval=setInterval(function(){log("自动保存开始...");changedNote=Note.curChangedSaveIt(false)},Note.intervalTime)};Note.stopInterval=function(){clearInterval(Note.interval);setTimeout(function(){Note.startInterval()},Note.intervalTime)};Note.addNoteCache=function(note){Note.cache[note.NoteId]=note;Note.clearCacheByNotebookId(note.NotebookId)};Note.setNoteCache=function(content,clear){if(!Note.cache[content.NoteId]){Note.cache[content.NoteId]=content}else{$.extend(Note.cache[content.NoteId],content)}if(clear==undefined){clear=true}if(clear){Note.clearCacheByNotebookId(content.NotebookId)}};Note.getCurNote=function(){var self=this;if(self.curNoteId==""){return null}return self.cache[self.curNoteId]};Note.getNote=function(noteId){var self=this;return self.cache[noteId]};Note.clearCacheByNotebookId=function(notebookId){if(notebookId){Note.cacheByNotebookId[notebookId]={};Note.cacheByNotebookId["all"]={};Note.notebookIds[notebookId]=true}};Note.notebookHasNotes=function(notebookId){var notes=Note.getNotesByNotebookId(notebookId);return!isEmpty(notes)};Note.getNotesByNotebookId=function(notebookId,sortBy,isAsc){if(!sortBy){sortBy="UpdatedTime"}if(isAsc=="undefined"){isAsc=false}if(!notebookId){notebookId="all"}if(!Note.cacheByNotebookId[notebookId]){return[]}if(Note.cacheByNotebookId[notebookId][sortBy]){return Note.cacheByNotebookId[notebookId][sortBy]}else{}var notes=[];var sortBys=[];for(var i in Note.cache){if(!i){continue}var note=Note.cache[i];if(note.IsTrash||note.IsShared){continue}if(notebookId=="all"||note.NotebookId==notebookId){notes.push(note)}}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.cacheByNotebookId[notebookId][sortBy]=notes;return notes};Note.renderNotesAndFirstOneContent=function(ret){if(!isArray(ret)){return}Note.renderNotes(ret);if(!isEmpty(ret[0])){Note.changeNote(ret[0].NoteId)}else{}};Note.curHasChanged=function(force){if(force==undefined){force=true}var cacheNote=Note.cache[Note.curNoteId]||{};var title=$("#noteTitle").val();var tags=Tag.getTags();var contents=getEditorContent(cacheNote.IsMarkdown);var content,preview;var contentText;if(isArray(contents)){content=contents[0];preview=contents[1];contentText=content;if(content&&previewIsEmpty(preview)&&Converter){preview=Converter.makeHtml(content)}if(!content){preview=""}cacheNote.Preview=preview}else{content=contents;try{contentText=$(content).text()}catch(e){}}var hasChanged={hasChanged:false,IsNew:cacheNote.IsNew,IsMarkdown:cacheNote.IsMarkdown,FromUserId:cacheNote.FromUserId,NoteId:cacheNote.NoteId,NotebookId:cacheNote.NotebookId};if(hasChanged.IsNew){$.extend(hasChanged,cacheNote)}if(cacheNote.Title!=title){hasChanged.hasChanged=true;hasChanged.Title=title;if(!hasChanged.Title){}}if(!arrayEqual(cacheNote.Tags,tags)){hasChanged.hasChanged=true;hasChanged.Tags=tags}if(force&&cacheNote.Content!=content||!force&&$(cacheNote.Content).text()!=contentText){hasChanged.hasChanged=true;hasChanged.Content=content;var c=preview||content;hasChanged.Desc=Note.genDesc(c);hasChanged.ImgSrc=Note.getImgSrc(c);hasChanged.Abstract=Note.genAbstract(c)}else{log("text相同");log(cacheNote.Content==content)}hasChanged["UserId"]=cacheNote["UserId"]||"";return hasChanged};Note.genDesc=function(content){if(!content){return""}content=content.replace(/<br \/>/g," <br />");content=content.replace(/<\/p>/g," </p>");content=content.replace(/<\/div>/g," </div>");conLine truncated
|
||||
+132
-60
@@ -13,15 +13,16 @@ Note.interval = ""; // 定时器
|
||||
|
||||
Note.itemIsBlog = '<div class="item-blog"><i class="fa fa-bold" title="blog"></i></div><div class="item-setting"><i class="fa fa-cog" title="setting"></i></div>';
|
||||
// for render
|
||||
Note.itemTplNoImg = '<div href="#" class="item ?" noteId="?">'
|
||||
Note.itemTplNoImg += Note.itemIsBlog +'<div class="item-desc" style="right: 0;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';
|
||||
Note.itemTplNoImg = '<li href="#" class="item ?" noteId="?">'
|
||||
Note.itemTplNoImg += Note.itemIsBlog +'<div class="item-desc"><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
|
||||
Note.itemTpl = '<div href="#" class="item ?" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>'
|
||||
Note.itemTpl +=Note.itemIsBlog + '<div class="item-desc" style=""><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span> <br /><span class="desc">?</span></p></div></div>';
|
||||
// 有image
|
||||
Note.itemTpl = '<li href="#" class="item ? item-image" noteId="?"><div class="item-thumb" style=""><img src="?"/></div>'
|
||||
Note.itemTpl +=Note.itemIsBlog + '<div class="item-desc" style=""><p class="item-title">?</p><p class="item-info"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span></p><p class="desc">?</p></div></li>';
|
||||
|
||||
// for new
|
||||
Note.newItemTpl = '<div href="#" class="item item-active ?" fromUserId="?" noteId="?">'
|
||||
Note.newItemTpl += Note.itemIsBlog + '<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></div>';
|
||||
Note.newItemTpl = '<li href="#" class="item item-active ?" fromUserId="?" noteId="?">'
|
||||
Note.newItemTpl += Note.itemIsBlog + '<div class="item-desc" style="right: 0px;"><p class="item-title">?</p><p class="item-text"><i class="fa fa-book"></i> <span class="note-notebook">?</span> <i class="fa fa-calendar"></i> <span class="updated-time">?</span><br /><span class="desc">?</span></p></div></li>';
|
||||
|
||||
Note.noteItemListO = $("#noteItemList");
|
||||
|
||||
@@ -205,7 +206,7 @@ Note.curHasChanged = function(force) {
|
||||
preview = contents[1];
|
||||
contentText = content;
|
||||
// preview可能没来得到及解析
|
||||
if (content && previewIsEmpty(preview)) {
|
||||
if (content && previewIsEmpty(preview) && Converter) {
|
||||
preview = Converter.makeHtml(content);
|
||||
}
|
||||
if(!content) {
|
||||
@@ -276,6 +277,7 @@ Note.genDesc = function(content) {
|
||||
}
|
||||
|
||||
// 将</div>, </p>替换成\n
|
||||
/*
|
||||
var token = "ALEALE";
|
||||
content = content.replace(/<\/p>/g, token);
|
||||
content = content.replace(/<\/div>/g, token);
|
||||
@@ -291,6 +293,19 @@ Note.genDesc = function(content) {
|
||||
content = trimLeft(content, "<br />");
|
||||
content = trimLeft(content, "</p>");
|
||||
content = trimLeft(content, "</div>");
|
||||
*/
|
||||
|
||||
// 留空格
|
||||
content = content.replace(/<br \/>/g," <br />");
|
||||
content = content.replace(/<\/p>/g," </p>");
|
||||
content = content.replace(/<\/div>/g," </div>");
|
||||
|
||||
// 避免其它的<img 之类的不完全
|
||||
content = $("<div></div>").html(content).text();
|
||||
|
||||
// pre下text()会将< => < > => >
|
||||
content = content.replace(/</g, "<");
|
||||
content = content.replace(/>/g, ">");
|
||||
|
||||
if(content.length < 300) {
|
||||
return content;
|
||||
@@ -401,7 +416,16 @@ Note.selectTarget = function(target) {
|
||||
// 可能改变的是share note
|
||||
// 1. 保存之前的note
|
||||
// 2. ajax得到现在的note
|
||||
Note.showContentLoading = function() {
|
||||
$("#noteMaskForLoading").css("z-index", 99999);
|
||||
}
|
||||
Note.hideContentLoading = function() {
|
||||
$("#noteMaskForLoading").css("z-index", -1);
|
||||
}
|
||||
Note.contentAjax = null;
|
||||
Note.contentAjaxSeq = 1;
|
||||
Note.changeNote = function(selectNoteId, isShare, needSaveChanged) {
|
||||
var self = this;
|
||||
// -1 停止定时器
|
||||
Note.stopInterval();
|
||||
|
||||
@@ -433,30 +457,35 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged) {
|
||||
}
|
||||
var hasPerm = !isShare || Share.hasUpdatePerm(selectNoteId); // 不是共享, 或者是共享但有权限
|
||||
|
||||
// 不是手机浏览器且有权限
|
||||
if(!LEA.isMobile && hasPerm) {
|
||||
// 有权限
|
||||
if(hasPerm) {
|
||||
Note.hideReadOnly();
|
||||
Note.renderNote(cacheNote);
|
||||
|
||||
// 这里要切换编辑器
|
||||
switchEditor(cacheNote.IsMarkdown)
|
||||
|
||||
} else {
|
||||
Note.renderNoteReadOnly(cacheNote);
|
||||
}
|
||||
|
||||
Attach.renderNoteAttachNum(selectNoteId, true);
|
||||
|
||||
Note.contentAjaxSeq++;
|
||||
var seq = Note.contentAjaxSeq;
|
||||
function setContent(ret) {
|
||||
Note.contentAjax = null;
|
||||
if(seq != Note.contentAjaxSeq) {
|
||||
return;
|
||||
}
|
||||
Note.setNoteCache(ret, false);
|
||||
// 把其它信息也带上
|
||||
ret = Note.cache[selectNoteId]
|
||||
if(!LEA.isMobile && hasPerm) {
|
||||
if(hasPerm) {
|
||||
Note.renderNoteContent(ret);
|
||||
} else {
|
||||
Note.renderNoteContentReadOnly(ret);
|
||||
}
|
||||
hideLoading();
|
||||
self.hideContentLoading();
|
||||
}
|
||||
|
||||
if(cacheNote.Content) {
|
||||
@@ -471,9 +500,11 @@ Note.changeNote = function(selectNoteId, isShare, needSaveChanged) {
|
||||
param.sharedUserId = cacheNote.UserId // 谁的笔记
|
||||
}
|
||||
|
||||
// 这里loading
|
||||
showLoading();
|
||||
ajaxGet(url, param, setContent);
|
||||
self.showContentLoading();
|
||||
if(Note.contentAjax != null) {
|
||||
Note.contentAjax.abort();
|
||||
}
|
||||
note.contentAjax = ajaxGet(url, param, setContent);
|
||||
}
|
||||
|
||||
// 渲染
|
||||
@@ -494,18 +525,19 @@ Note.renderChangedNote = function(changedNote) {
|
||||
if(changedNote.Desc) {
|
||||
$leftNoteNav.find(".desc").html(changedNote.Desc);
|
||||
}
|
||||
if(changedNote.ImgSrc && !LEA.isMobile) {
|
||||
if(changedNote.ImgSrc) {
|
||||
$thumb = $leftNoteNav.find(".item-thumb");
|
||||
// 有可能之前没有图片
|
||||
if($thumb.length > 0) {
|
||||
$thumb.find("img").attr("src", changedNote.ImgSrc);
|
||||
} else {
|
||||
$leftNoteNav.append(tt('<div class="item-thumb" style=""><img src="?"></div>', changedNote.ImgSrc));
|
||||
$leftNoteNav.addClass("item-image");
|
||||
}
|
||||
$leftNoteNav.find(".item-desc").removeAttr("style");
|
||||
} else if(changedNote.ImgSrc == "") {
|
||||
$leftNoteNav.find(".item-thumb").remove(); // 以前有, 现在没有了
|
||||
$leftNoteNav.find(".item-desc").css("right", 0);
|
||||
$leftNoteNav.removeClass("item-image");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -579,7 +611,7 @@ Note.renderNoteContent = function(content) {
|
||||
*/
|
||||
|
||||
Note.showEditorMask = function() {
|
||||
$("#editorMask").css("z-index", 10);
|
||||
$("#editorMask").css("z-index", 10).show();
|
||||
// 要判断是否是垃圾筒
|
||||
if(Notebook.curNotebookIsTrashOrAll()) {
|
||||
$("#editorMaskBtns").hide();
|
||||
@@ -590,7 +622,7 @@ Note.showEditorMask = function() {
|
||||
}
|
||||
}
|
||||
Note.hideEditorMask = function() {
|
||||
$("#editorMask").css("z-index", -10);
|
||||
$("#editorMask").css("z-index", -10).hide();
|
||||
}
|
||||
|
||||
// 这里如果notes过多>100个将会很慢!!, 使用setTimeout来分解
|
||||
@@ -598,7 +630,11 @@ Note.renderNotesC = 0;
|
||||
Note.renderNotes = function(notes, forNewNote, isShared) {
|
||||
var renderNotesC = ++Note.renderNotesC;
|
||||
|
||||
$("#noteItemList").slimScroll({ scrollTo: '0px', height: "100%", onlyScrollBar: true});
|
||||
// 手机端不用
|
||||
// slimScroll使得手机端滚动不流畅
|
||||
if(!LEA.isMobile && !Mobile.isMobile()) {
|
||||
$("#noteItemList").slimScroll({ scrollTo: '0px', height: "100%", onlyScrollBar: true});
|
||||
}
|
||||
|
||||
if(!notes || typeof notes != "object" || notes.length <= 0) {
|
||||
// 如果没有, 那么是不是应该hide editor?
|
||||
@@ -661,7 +697,7 @@ Note._renderNotes = function(notes, forNewNote, isShared, tang) { // 第几趟
|
||||
}
|
||||
var note = notes[i];
|
||||
var tmp;
|
||||
if(note.ImgSrc && !LEA.isMobile) {
|
||||
if(note.ImgSrc) {
|
||||
tmp = tt(Note.itemTpl, classes, note.NoteId, note.ImgSrc, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc);
|
||||
} else {
|
||||
tmp = tt(Note.itemTplNoImg, classes, note.NoteId, note.Title, Notebook.getNotebookTitle(note.NotebookId), goNowToDatetime(note.UpdatedTime), note.Desc);
|
||||
@@ -763,6 +799,9 @@ Note.newNote = function(notebookId, isShare, fromUserId, isMarkdown) {
|
||||
Note.renderNote(note);
|
||||
Note.renderNoteContent(note);
|
||||
Note.curNoteId = note.NoteId;
|
||||
|
||||
// 更新数量
|
||||
Notebook.incrNotebookNumberNotes(notebookId)
|
||||
}
|
||||
|
||||
// 保存note ctrl + s
|
||||
@@ -822,6 +861,9 @@ Note.deleteNote = function(target, contextmenuItem, isShared) {
|
||||
var url = "/note/deleteNote"
|
||||
if(note.IsTrash) {
|
||||
url = "/note/deleteTrash";
|
||||
} else {
|
||||
// 减少数量
|
||||
Notebook.minusNotebookNumberNotes(note.NotebookId);
|
||||
}
|
||||
|
||||
ajaxGet(url, {noteId: noteId, userId: note.UserId, isShared: isShared}, function(ret) {
|
||||
@@ -843,6 +885,7 @@ Note.deleteNote = function(target, contextmenuItem, isShared) {
|
||||
showMsg("删除失败!", 2000);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
// 显示共享信息
|
||||
@@ -854,7 +897,7 @@ Note.listNoteShareUserInfo = function(target) {
|
||||
// 共享笔记
|
||||
Note.shareNote = function(target) {
|
||||
var title = $(target).find(".item-title").text();
|
||||
showDialog("dialogShareNote", {title: "分享笔记给好友-" + title});
|
||||
showDialog("dialogShareNote", {title: getMsg("shareToFriends") + "-" + title});
|
||||
|
||||
setTimeout(function() {
|
||||
$("#friendsEmail").focus();
|
||||
@@ -870,15 +913,15 @@ Note.listNoteContentHistories = function() {
|
||||
$("#leanoteDialog #modalTitle").html(getMsg("history"));
|
||||
$content = $("#leanoteDialog .modal-body");
|
||||
$content.html("");
|
||||
$("#leanoteDialog .modal-footer").html('<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>');
|
||||
$("#leanoteDialog .modal-footer").html('<button type="button" class="btn btn-default" data-dismiss="modal">' + getMsg("close") + '</button>');
|
||||
options = {}
|
||||
options.show = true;
|
||||
$("#leanoteDialog").modal(options);
|
||||
|
||||
ajaxGet("noteContentHistory/listHistories", {noteId: Note.curNoteId}, function(re) {
|
||||
if(!isArray(re)) {$content.html("无历史记录"); return}
|
||||
if(!isArray(re)) {$content.html(getMsg("noHistories")); return}
|
||||
// 组装成一个tab
|
||||
var str = 'leanote会保存笔记的最近10份历史记录. <div id="historyList"><table class="table table-hover">';
|
||||
var str = "<p>" + getMsg("historiesNum") + '</p><div id="historyList"><table class="table table-hover">';
|
||||
note = Note.cache[Note.curNoteId];
|
||||
var s = "div"
|
||||
if(note.IsMarkdown) {
|
||||
@@ -887,7 +930,7 @@ Note.listNoteContentHistories = function() {
|
||||
for (i in re) {
|
||||
var content = re[i]
|
||||
content.Ab = Note.genAbstract(content.Content, 200);
|
||||
str += tt('<tr><td seq="?"><? class="each-content">?</?> <div class="btns">时间: <span class="label label-default">?</span> <button class="btn btn-default all">展开</button> <button class="btn btn-primary back">还原</button></div></td></tr>', i, s, content.Ab, s, goNowToDatetime(content.UpdatedTime))
|
||||
str += tt('<tr><td seq="?">#?<? class="each-content">?</?> <div class="btns">' + getMsg("datetime") + ': <span class="label label-default">?</span> <button class="btn btn-default all">' + getMsg("unfold") + '</button> <button class="btn btn-primary back">' + getMsg('restoreFromThisVersion') + '</button></div></td></tr>', i, (+i+1), s, content.Ab, s, goNowToDatetime(content.UpdatedTime))
|
||||
}
|
||||
str += "</table></div>";
|
||||
$content.html(str);
|
||||
@@ -895,12 +938,15 @@ Note.listNoteContentHistories = function() {
|
||||
$p = $(this).parent().parent();
|
||||
var seq = $p.attr("seq");
|
||||
var $c = $p.find(".each-content");
|
||||
if($(this).text() == "展开") {
|
||||
$(this).text("折叠")
|
||||
$c.html(re[seq].Content);
|
||||
var info = re[seq];
|
||||
if(!info.unfold) { // 默认是折叠的
|
||||
$(this).text(getMsg("fold")); // 折叠
|
||||
$c.html(info.Content);
|
||||
info.unfold = true;
|
||||
} else {
|
||||
$(this).text("展开")
|
||||
$c.html(re[seq].Ab);
|
||||
$(this).text(getMsg("unfold")); // 展开
|
||||
$c.html(info.Ab);
|
||||
info.unfold = false
|
||||
}
|
||||
});
|
||||
|
||||
@@ -908,7 +954,7 @@ Note.listNoteContentHistories = function() {
|
||||
$("#historyList .back").click(function() {
|
||||
$p = $(this).parent().parent();
|
||||
var seq = $p.attr("seq");
|
||||
if(confirm("确定要从该版还原? 还原前leanote会备份当前版本到历史记录中.")) {
|
||||
if(confirm(getMsg("confirmBackup"))) {
|
||||
// 保存当前版本
|
||||
Note.curChangedSaveIt();
|
||||
// 设置之
|
||||
@@ -925,20 +971,36 @@ Note.listNoteContentHistories = function() {
|
||||
// 长微博
|
||||
Note.html2Image = function(target) {
|
||||
var noteId = $(target).attr("noteId");
|
||||
showDialog("html2ImageDialog", {title: "发送长微博", postShow: function() {
|
||||
showDialog("html2ImageDialog", {title: "分享到社区", postShow: function() {
|
||||
ajaxGet("/note/html2Image", {noteId: noteId}, function(ret) {
|
||||
if (typeof ret == "object" && ret.Ok) {
|
||||
$("#leanoteDialog .weibo span").html("生成成功, 右键图片保存到本地.")
|
||||
$("#leanoteDialog .weibo img").attr("src", ret.Id);
|
||||
$("#leanoteDialog .sendWeiboBtn").removeClass("disabled");
|
||||
$("#leanoteDialog .weibo img").attr("src", ret.Id + "?" + ((new Date()).getTime()));
|
||||
$("#leanoteDialog .btn-share").removeClass("disabled");
|
||||
var note = Note.cache[noteId];
|
||||
var pic = UrlPrefix + ret.Id;
|
||||
var title = encodeURI(note.Title + " (" + UserInfo.Username + "分享. 来自leanote.com)");
|
||||
var windowParam = 'width=700, height=580, top=180, left=320, toolbar=no, menubar=no, scrollbars=no, location=yes, resizable=no, status=no';
|
||||
$("#leanoteDialog .sendWeiboBtn").click(function() {
|
||||
var title = Note.cache[noteId].Title;
|
||||
var url = "http://service.weibo.com/share/share.php?title=" + title + " (" + UserInfo.Username + "分享. 来自leanote.com)";
|
||||
url += "&pic=" + UrlPrefix + ret.Id;
|
||||
window.open(url, "_blank");
|
||||
var url = "http://service.weibo.com/share/share.php?title=" + title;
|
||||
url += "&pic=" + pic;
|
||||
window.open(url, '分享到新浪微博', windowParam);
|
||||
});
|
||||
$("#leanoteDialog .sendTxWeiboBtn").click(function() {
|
||||
var _appkey = '801542571';
|
||||
var url = "http://share.v.t.qq.com/index.php?c=share&a=index&appkey=" + _appkey +"&title=" + title +"&url=&pic=" + pic
|
||||
window.open(url, '分享到腾讯微博', windowParam);
|
||||
});
|
||||
$("#leanoteDialog .sendQQBtn").click(function() {
|
||||
var url = 'http://sns.qzone.qq.com/cgi-bin/qzshare/cgi_qzshare_onekey?url=' + UrlPrefix + '&title=' + title + '&pics=' + pic;
|
||||
window.open(url, '分享QQ空间', windowParam);
|
||||
});
|
||||
$("#leanoteDialog .sendRRBtn").click(function() {
|
||||
var url = 'http://widget.renren.com/dialog/share?resourceUrl=' + UrlPrefix + '&srcUrl=' + UrlPrefix + '&title=' + title + '&pic=' + pic;
|
||||
window.open(url, '分享人人网', windowParam);
|
||||
});
|
||||
} else {
|
||||
$("#leanoteDialog .weibo span").html("对不起, 我们出错了!")
|
||||
$("#leanoteDialog .weibo").html("对不起, 我们出错了!")
|
||||
}
|
||||
});
|
||||
}});
|
||||
@@ -1109,6 +1171,13 @@ Note.moveNote = function(target, data) {
|
||||
if(!note.IsTrash && note.NotebookId == notebookId) {
|
||||
return;
|
||||
}
|
||||
|
||||
// 修改数量
|
||||
Notebook.incrNotebookNumberNotes(notebookId);
|
||||
if(!note.IsTrash) {
|
||||
Notebook.minusNotebookNumberNotes(note.NotebookId);
|
||||
}
|
||||
|
||||
ajaxGet("/note/moveNote", {noteId: noteId, notebookId: notebookId}, function(ret) {
|
||||
if(ret && ret.NoteId) {
|
||||
if(note.IsTrash) {
|
||||
@@ -1168,6 +1237,9 @@ Note.copyNote = function(target, data, isShared) {
|
||||
Note.setNoteCache(ret)
|
||||
}
|
||||
});
|
||||
|
||||
// 增加数量
|
||||
Notebook.incrNotebookNumberNotes(notebookId)
|
||||
}
|
||||
|
||||
// 这里速度不慢, 很快
|
||||
@@ -1218,24 +1290,24 @@ Note.initContextmenu = function() {
|
||||
// context menu
|
||||
//---------------------
|
||||
var noteListMenu = {
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: [
|
||||
{ text: "分享给好友", alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Note.listNoteShareUserInfo},
|
||||
{ text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Note.listNoteShareUserInfo},
|
||||
{ type: "splitLine" },
|
||||
{ text: "公开为博客", alias: 'set2Blog', icon: "", action: Note.setNote2Blog },
|
||||
{ text: "取消公开为博客", alias: 'unset2Blog', icon: "", action: Note.setNote2Blog },
|
||||
{ text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Note.setNote2Blog },
|
||||
{ text: getMsg("cancelPublic"), alias: 'unset2Blog', faIcon: "fa-undo", action: Note.setNote2Blog },
|
||||
//{ type: "splitLine" },
|
||||
//{ text: "分享到社区", alias: 'html2Image', icon: "", action: Note.html2Image},
|
||||
{ type: "splitLine" },
|
||||
// { text: "发送长微博", alias: 'html2Image', icon: "", action: Note.html2Image , width: 150, type: "group", items:[{text: "a"}]},
|
||||
// { type: "splitLine" },
|
||||
{ text: "删除", icon: "", faIcon: "fa-trash-o", action: Note.deleteNote },
|
||||
{ text: "移动", alias: "move", icon: "",
|
||||
{ text: getMsg("delete"), icon: "", faIcon: "fa-trash-o", action: Note.deleteNote },
|
||||
{ text: getMsg("move"), alias: "move", faIcon: "fa-arrow-right",
|
||||
type: "group",
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: notebooksMove
|
||||
},
|
||||
{ text: "复制", alias: "copy", icon: "",
|
||||
{ text: getMsg("copy"), alias: "copy", icon:"", faIcon: "fa-copy",
|
||||
type: "group",
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: notebooksCopy
|
||||
}
|
||||
],
|
||||
@@ -1446,6 +1518,8 @@ var Attach = {
|
||||
self._renderAttachs(self.loadedNoteAttachs[noteId]);
|
||||
return;
|
||||
}
|
||||
// 显示loading
|
||||
self.attachListO.html('<li class="loading"><img src="/images/loading-24.gif"/></li>');
|
||||
// ajax获取noteAttachs
|
||||
ajaxGet("/attach/getAttachs", {noteId: noteId}, function(ret) {
|
||||
var list = [];
|
||||
@@ -1501,22 +1575,20 @@ $(function() {
|
||||
//-----------------
|
||||
// for list nav
|
||||
$("#noteItemList").on("click", ".item", function(event) {
|
||||
log(event);
|
||||
event.stopPropagation();
|
||||
// 找到上级.item
|
||||
var parent = findParents(this, ".item");
|
||||
if(!parent) {
|
||||
return;
|
||||
}
|
||||
var noteId = $(this).attr("noteId");
|
||||
|
||||
// 手机端处理
|
||||
Mobile.changeNote(noteId);
|
||||
|
||||
var noteId = parent.attr("noteId");
|
||||
if(!noteId) {
|
||||
return;
|
||||
}
|
||||
// 当前的和所选的是一个, 不改变
|
||||
if(Note.curNoteId == noteId) {
|
||||
return;
|
||||
if(Note.curNoteId != noteId) {
|
||||
Note.changeNote(noteId);
|
||||
}
|
||||
Note.changeNote(noteId);
|
||||
});
|
||||
|
||||
//------------------
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
Notebook.curNotebookId="";Notebook.cache={};Notebook.notebooks=[];Notebook.notebookNavForListNote="";Notebook.notebookNavForNewNote="";Notebook.setCache=function(notebook){var notebookId=notebook.NotebookId;if(!notebookId){return}if(!Notebook.cache[notebookId]){Notebook.cache[notebookId]={}}$.extend(Notebook.cache[notebookId],notebook)};Notebook.getCurNotebookId=function(){return Notebook.curNotebookId};Notebook.getNotebook=function(notebookId){return Notebook.cache[notebookId]};Notebook.getNotebookTitle=function(notebookId){var notebook=Notebook.cache[notebookId];if(notebook){return notebook.Title}else{return"未知"}};Notebook.getTreeSetting=function(isSearch,isShare){var noSearch=!isSearch;var self=this;function addDiyDom(treeId,treeNode){var spaceWidth=5;var switchObj=$("#"+treeId+" #"+treeNode.tId+"_switch"),icoObj=$("#"+treeId+" #"+treeNode.tId+"_ico");switchObj.remove();icoObj.before(switchObj);if(!isShare){if(!Notebook.isAllNotebookId(treeNode.NotebookId)&&!Notebook.isTrashNotebookId(treeNode.NotebookId)){icoObj.after($('<span class="fa notebook-setting" title="setting"></span>'))}}else{if(!Share.isDefaultNotebookId(treeNode.NotebookId)){icoObj.after($('<span class="fa notebook-setting" title="setting"></span>'))}}if(treeNode.level>1){var spaceStr="<span style='display: inline-block;width:"+spaceWidth*treeNode.level+"px'></span>";switchObj.before(spaceStr)}}function beforeDrag(treeId,treeNodes){for(var i=0,l=treeNodes.length;i<l;i++){if(treeNodes[i].drag===false){return false}}return true}function beforeDrop(treeId,treeNodes,targetNode,moveType){return targetNode?targetNode.drop!==false:true}function onDrop(e,treeId,treeNodes,targetNode,moveType){var treeNode=treeNodes[0];if(!targetNode){return}var parentNode;var treeObj=self.tree;var ajaxData={curNotebookId:treeNode.NotebookId};if(moveType=="inner"){parentNode=targetNode}else{parentNode=targetNode.getParentNode()}if(!parentNode){var nodes=treeObj.getNodes()}else{ajaxData.parentNotebookId=parentNode.NotebookId;var nextLevel=parentNode.level+1;function filter(node){return node.level==nextLevel}var nodes=treeObj.getNodesByFilter(filter,false,parentNode)}ajaxData.siblings=[];for(var i in nodes){var notebookId=nodes[i].NotebookId;if(!Notebook.isAllNotebookId(notebookId)&&!Notebook.isTrashNotebookId(notebookId)){ajaxData.siblings.push(notebookId)}}ajaxPost("/notebook/dragNotebooks",{data:JSON.stringify(ajaxData)});setTimeout(function(){Notebook.changeNav()},100)}if(!isShare){var onClick=function(e,treeId,treeNode){var notebookId=treeNode.NotebookId;Notebook.changeNotebook(notebookId)};var onDblClick=function(e){var notebookId=$(e.target).attr("notebookId");if(!Notebook.isAllNotebookId(notebookId)&&!Notebook.isTrashNotebookId(notebookId)){self.updateNotebookTitle(e.target)}}}else{var onClick=function(e,treeId,treeNode){var notebookId=treeNode.NotebookId;var fromUserId=$(e.target).closest(".friend-notebooks").attr("fromUserId");Share.changeNotebook(fromUserId,notebookId)};var onDblClick=null}var setting={view:{showLine:false,showIcon:false,selectedMulti:false,dblClickExpand:false,addDiyDom:addDiyDom},data:{key:{name:"Title",children:"Subs"}},edit:{enable:true,showRemoveBtn:false,showRenameBtn:false,drag:{isMove:noSearch,prev:noSearch,inner:noSearch,next:noSearch}},callback:{beforeDrag:beforeDrag,beforeDrop:beforeDrop,onDrop:onDrop,onClick:onClick,onDblClick:onDblClick,beforeRename:function(treeId,treeNode,newName,isCancel){if(newName==""){if(treeNode.IsNew){self.tree.removeNode(treeNode);return true}return false}if(treeNode.Title==newName){return true}if(treeNode.IsNew){var parentNode=treeNode.getParentNode();var parentNotebookId=parentNode?parentNode.NotebookId:"";self.doAddNotebook(treeNode.NotebookId,newName,parentNotebookId)}else{self.doUpdateNotebookTitle(treeNode.NotebookId,newName)}return true}}};if(isSearch){}return setting};Notebook.allNotebookId="0";Notebook.trashNotebookId="-1";Notebook.curNotebookIsTrashOrAll=function(){return Notebook.curNotebookId==Notebook.trashNotebookId||Notebook.curNotebookId==Notebook.allNotebookId};Notebook.renderNotebooks=function(notebooks){var self=this;if(!notebooks||typeof notebooks!="object"||notebooks.length<0){notebooks=[]}notebooks=[{NotebookId:Notebook.allNotebookId,Title:getMsg("all"),drop:false,drag:false}].concat(notebooks);notebooks.push({NotebookId:Notebook.trashNotebookId,Title:getMsg("trash"),drop:false,drag:false});Notebook.notebooks=notebooks;self.tree=$.fn.zTree.init($("#notebookList"),self.getTreeSetting(),notebooks);var $notebookList=$("#notebookList");$notebookList.hover(function(){if(!$(this).hasClass("showIcon")){$(this).addClass("showIcon")}},function(){$(this).removeClass("showIcon")});if(!isEmpty(notebooks)){Notebook.curNotebookId=notebooks[0].NotebookId;self.cacheAllNotebooks(notebooks)}Notebook.renderNav();Notebook.changeNotebookNavForNewNote(notebooks[0].NotebookId)};Notebook.cacheAllNotebooks=function(notebooks){var self=this;for(var i in notebooks){var notebook=notebooks[i];Notebook.cacLine truncated
|
||||
Notebook.curNotebookId="";Notebook.cache={};Notebook.notebooks=[];Notebook.notebookNavForListNote="";Notebook.notebookNavForNewNote="";Notebook.setCache=function(notebook){var notebookId=notebook.NotebookId;if(!notebookId){return}if(!Notebook.cache[notebookId]){Notebook.cache[notebookId]={}}$.extend(Notebook.cache[notebookId],notebook)};Notebook.getCurNotebookId=function(){return Notebook.curNotebookId};Notebook._updateNotebookNumberNotes=function(notebookId,n){var self=this;var notebook=self.getNotebook(notebookId);if(!notebook){return}notebook.NumberNotes+=n;if(notebook.NumberNotes<0){notebook.NumberNotes=0}$("#numberNotes_"+notebookId).html(notebook.NumberNotes)};Notebook.incrNotebookNumberNotes=function(notebookId){var self=this;self._updateNotebookNumberNotes(notebookId,1)};Notebook.minusNotebookNumberNotes=function(notebookId){var self=this;self._updateNotebookNumberNotes(notebookId,-1)};Notebook.getNotebook=function(notebookId){return Notebook.cache[notebookId]};Notebook.getNotebookTitle=function(notebookId){var notebook=Notebook.cache[notebookId];if(notebook){return notebook.Title}else{return"未知"}};Notebook.getTreeSetting=function(isSearch,isShare){var noSearch=!isSearch;var self=this;function addDiyDom(treeId,treeNode){var spaceWidth=5;var switchObj=$("#"+treeId+" #"+treeNode.tId+"_switch"),icoObj=$("#"+treeId+" #"+treeNode.tId+"_ico");switchObj.remove();icoObj.before(switchObj);if(!isShare){if(!Notebook.isAllNotebookId(treeNode.NotebookId)&&!Notebook.isTrashNotebookId(treeNode.NotebookId)){icoObj.after($('<span class="notebook-number-notes" id="numberNotes_'+treeNode.NotebookId+'">'+(treeNode.NumberNotes||0)+"</span>"));icoObj.after($('<span class="fa notebook-setting" title="setting"></span>'))}}else{if(!Share.isDefaultNotebookId(treeNode.NotebookId)){icoObj.after($('<span class="fa notebook-setting" title="setting"></span>'))}}if(treeNode.level>1){var spaceStr="<span style='display: inline-block;width:"+spaceWidth*treeNode.level+"px'></span>";switchObj.before(spaceStr)}}function beforeDrag(treeId,treeNodes){for(var i=0,l=treeNodes.length;i<l;i++){if(treeNodes[i].drag===false){return false}}return true}function beforeDrop(treeId,treeNodes,targetNode,moveType){return targetNode?targetNode.drop!==false:true}function onDrop(e,treeId,treeNodes,targetNode,moveType){var treeNode=treeNodes[0];if(!targetNode){return}var parentNode;var treeObj=self.tree;var ajaxData={curNotebookId:treeNode.NotebookId};if(moveType=="inner"){parentNode=targetNode}else{parentNode=targetNode.getParentNode()}if(!parentNode){var nodes=treeObj.getNodes()}else{ajaxData.parentNotebookId=parentNode.NotebookId;var nextLevel=parentNode.level+1;function filter(node){return node.level==nextLevel}var nodes=treeObj.getNodesByFilter(filter,false,parentNode)}ajaxData.siblings=[];for(var i in nodes){var notebookId=nodes[i].NotebookId;if(!Notebook.isAllNotebookId(notebookId)&&!Notebook.isTrashNotebookId(notebookId)){ajaxData.siblings.push(notebookId)}}ajaxPost("/notebook/dragNotebooks",{data:JSON.stringify(ajaxData)});setTimeout(function(){Notebook.changeNav()},100)}if(!isShare){var onClick=function(e,treeId,treeNode){var notebookId=treeNode.NotebookId;Notebook.changeNotebook(notebookId)};var onDblClick=function(e){var notebookId=$(e.target).attr("notebookId");if(!Notebook.isAllNotebookId(notebookId)&&!Notebook.isTrashNotebookId(notebookId)){self.updateNotebookTitle(e.target)}}}else{var onClick=function(e,treeId,treeNode){var notebookId=treeNode.NotebookId;var fromUserId=$(e.target).closest(".friend-notebooks").attr("fromUserId");Share.changeNotebook(fromUserId,notebookId)};var onDblClick=null}var setting={view:{showLine:false,showIcon:false,selectedMulti:false,dblClickExpand:false,addDiyDom:addDiyDom},data:{key:{name:"Title",children:"Subs"}},edit:{enable:true,showRemoveBtn:false,showRenameBtn:false,drag:{isMove:noSearch,prev:noSearch,inner:noSearch,next:noSearch}},callback:{beforeDrag:beforeDrag,beforeDrop:beforeDrop,onDrop:onDrop,onClick:onClick,onDblClick:onDblClick,beforeRename:function(treeId,treeNode,newName,isCancel){if(newName==""){if(treeNode.IsNew){self.tree.removeNode(treeNode);return true}return false}if(treeNode.Title==newName){return true}if(treeNode.IsNew){var parentNode=treeNode.getParentNode();var parentNotebookId=parentNode?parentNode.NotebookId:"";self.doAddNotebook(treeNode.NotebookId,newName,parentNotebookId)}else{self.doUpdateNotebookTitle(treeNode.NotebookId,newName)}return true}}};if(isSearch){}return setting};Notebook.allNotebookId="0";Notebook.trashNotebookId="-1";Notebook.curNotebookIsTrashOrAll=function(){return Notebook.curNotebookId==Notebook.trashNotebookId||Notebook.curNotebookId==Notebook.allNotebookId};Notebook.renderNotebooks=function(notebooks){var self=this;if(!notebooks||typeof notebooks!="object"||notebooks.length<0){notebooks=[]}notebooks=[{NotebookId:Notebook.allNotebookId,Title:getMsg("all"),drop:false,drag:false}].concat(notebooks);notebooks.push({NotebookId:Notebook.trashNotebookId,Title:getMLine truncated
|
||||
+39
-13
@@ -21,6 +21,30 @@ Notebook.getCurNotebookId = function() {
|
||||
return Notebook.curNotebookId;
|
||||
};
|
||||
|
||||
// 笔记本的笔记数量更新
|
||||
Notebook._updateNotebookNumberNotes = function(notebookId, n) {
|
||||
var self = this;
|
||||
var notebook = self.getNotebook(notebookId);
|
||||
if(!notebook) {
|
||||
return;
|
||||
}
|
||||
notebook.NumberNotes += n;
|
||||
if(notebook.NumberNotes < 0) {
|
||||
notebook.NumberNotes = 0;
|
||||
}
|
||||
$("#numberNotes_" + notebookId).html(notebook.NumberNotes);
|
||||
};
|
||||
// addNote, copyNote, moveNote
|
||||
Notebook.incrNotebookNumberNotes = function(notebookId) {
|
||||
var self = this;
|
||||
self._updateNotebookNumberNotes(notebookId, 1);
|
||||
};
|
||||
// moteNote, deleteNote
|
||||
Notebook.minusNotebookNumberNotes = function(notebookId) {
|
||||
var self = this;
|
||||
self._updateNotebookNumberNotes(notebookId, -1);
|
||||
};
|
||||
|
||||
// 得到notebook标题, 给note显示其notebook标题用
|
||||
// called by Note
|
||||
Notebook.getNotebook = function(notebookId) {
|
||||
@@ -58,6 +82,7 @@ Notebook.getTreeSetting = function(isSearch, isShare){
|
||||
icoObj.before(switchObj);
|
||||
if(!isShare) {
|
||||
if(!Notebook.isAllNotebookId(treeNode.NotebookId) && !Notebook.isTrashNotebookId(treeNode.NotebookId)) {
|
||||
icoObj.after($('<span class="notebook-number-notes" id="numberNotes_' + treeNode.NotebookId + '">' + (treeNode.NumberNotes || 0) + '</span>'));
|
||||
icoObj.after($('<span class="fa notebook-setting" title="setting"></span>'));
|
||||
}
|
||||
} else {
|
||||
@@ -772,16 +797,16 @@ $(function() {
|
||||
//-------------------
|
||||
// 右键菜单
|
||||
var notebookListMenu = {
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: [
|
||||
{ text: "分享给好友", alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo},
|
||||
{ text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo},
|
||||
{ type: "splitLine" },
|
||||
{ text: "公开为博客", alias: 'set2Blog', icon: "", action: Notebook.setNotebook2Blog },
|
||||
{ text: "取消公开为博客", alias: 'unset2Blog', icon: "", action: Notebook.setNotebook2Blog }, // Unset
|
||||
{ text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Notebook.setNotebook2Blog },
|
||||
{ text: getMsg("cancelPublic"), alias: 'unset2Blog',faIcon: "fa-undo", action: Notebook.setNotebook2Blog }, // Unset
|
||||
{ type: "splitLine" },
|
||||
{ text: "添加子笔记本", icon: "", action: Notebook.addChildNotebook },
|
||||
{ text: "重命名", icon: "", action: Notebook.updateNotebookTitle },
|
||||
{ text: "删除", icon: "", alias: 'delete', faIcon: "fa-trash-o", action: Notebook.deleteNotebook }
|
||||
{ text: getMsg("addChildNotebook"), faIcon: "fa-sitemap", action: Notebook.addChildNotebook },
|
||||
{ text: getMsg("rename"), faIcon: "fa-pencil", action: Notebook.updateNotebookTitle },
|
||||
{ text: getMsg("delete"), icon: "", alias: 'delete', faIcon: "fa-trash-o", action: Notebook.deleteNotebook }
|
||||
],
|
||||
onShow: applyrule,
|
||||
onContextMenu: beforeContextMenu,
|
||||
@@ -789,16 +814,17 @@ $(function() {
|
||||
children: "li a"
|
||||
}
|
||||
|
||||
// for search
|
||||
var notebookListMenu2 = {
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: [
|
||||
{ text: "分享给好友", alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo},
|
||||
{ text: getMsg("shareToFriends"), alias: 'shareToFriends', icon: "", faIcon: "fa-share-square-o", action: Notebook.listNotebookShareUserInfo},
|
||||
{ type: "splitLine" },
|
||||
{ text: "公开为博客", alias: 'set2Blog', icon: "", action: Notebook.setNotebook2Blog },
|
||||
{ text: "取消公开为博客", alias: 'unset2Blog', icon: "", action: Notebook.setNotebook2Blog }, // Unset
|
||||
{ text: getMsg("publicAsBlog"), alias: 'set2Blog', faIcon: "fa-bold", action: Notebook.setNotebook2Blog },
|
||||
{ text: getMsg("cancelPublic"), alias: 'unset2Blog',faIcon: "fa-undo", action: Notebook.setNotebook2Blog }, // Unset
|
||||
{ type: "splitLine" },
|
||||
{ text: "重命名", icon: "", action: Notebook.updateNotebookTitle },
|
||||
{ text: "删除", icon: "", alias: 'delete', faIcon: "fa-trash-o", action: Notebook.deleteNotebook }
|
||||
{ text: getMsg("rename"), icon: "", action: Notebook.updateNotebookTitle },
|
||||
{ text: getMsg("delete"), icon: "", alias: 'delete', faIcon: "fa-trash-o", action: Notebook.deleteNotebook }
|
||||
],
|
||||
onShow: applyrule,
|
||||
onContextMenu: beforeContextMenu,
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
var em=new editorMode;var lineMove=false;var target=null;function stopResize3Columns(){if(lineMove){ajaxGet("/user/updateColumnWidth",{notebookWidth:UserInfo.NotebookWidth,noteListWidth:UserInfo.NoteListWidth},function(){})}lineMove=false;$(".noteSplit").css("background","none")}function resize3ColumnsEnd(notebookWidth,noteListWidth){if(notebookWidth<150||noteListWidth<100){}var noteWidth=$("body").width()-notebookWidth-noteListWidth;if(noteWidth<400){}$("#leftNotebook").width(notebookWidth);$("#notebookSplitter").css("left",notebookWidth);$("#noteAndEditor").css("left",notebookWidth);$("#noteList").width(noteListWidth);$("#noteSplitter").css("left",noteListWidth);$("#note").css("left",noteListWidth);UserInfo.NotebookWidth=notebookWidth;UserInfo.NoteListWidth=noteListWidth}function resize3Columns(event,isFromeIfr){if(isFromeIfr){event.clientX+=$("body").width()-$("#note").width()}var notebookWidth,noteListWidth;if(lineMove==true){if(target=="notebookSplitter"){notebookWidth=event.clientX;noteListWidth=$("#noteList").width();resize3ColumnsEnd(notebookWidth,noteListWidth)}else{notebookWidth=$("#leftNotebook").width();noteListWidth=event.clientX-notebookWidth;resize3ColumnsEnd(notebookWidth,noteListWidth)}resizeEditor()}}$(function(){$(".noteSplit").bind("mousedown",function(event){event.preventDefault();lineMove=true;$(this).css("background-color","#ccc");target=$(this).attr("id");$("#noteMask").css("z-index",99999)});$("body").bind("mouseup",function(event){stopResize3Columns();$("#noteMask").css("z-index",-1)});$("body").bind("mousemove",function(event){if(lineMove){event.preventDefault();resize3Columns(event)}});$("#moreBtn").click(function(){saveBookmark();var height=$("#mceToolbar").height();if(height<$("#popularToolbar").height()){$("#mceToolbar").height($("#popularToolbar").height());$(this).find("i").removeClass("fa-angle-down").addClass("fa-angle-up")}else{$("#mceToolbar").height(height/2);$(this).find("i").removeClass("fa-angle-up").addClass("fa-angle-down")}resizeEditor();restoreBookmark()});$(window).resize(function(){resizeEditor()});$(".folderHeader").click(function(){var body=$(this).next();var p=$(this).parent();if(!body.is(":hidden")){$(".folderNote").removeClass("opened").addClass("closed");p.removeClass("opened").addClass("closed");$(this).find(".fa-angle-down").removeClass("fa-angle-down").addClass("fa-angle-right")}else{$(".folderNote").removeClass("opened").addClass("closed");p.removeClass("closed").addClass("opened");$(this).find(".fa-angle-right").removeClass("fa-angle-right").addClass("fa-angle-down")}});tinymce.init({setup:function(ed){ed.on("keydown",Note.saveNote);ed.on("keydown",function(e){var num=e.which?e.which:e.keyCode;if(num==9){if(!e.shiftKey){var node=ed.selection.getNode();if(node.nodeName=="PRE"){ed.execCommand("mceInsertRawHTML",false," ")}else{ed.execCommand("mceInsertRawHTML",false," ")}}else{}e.preventDefault();e.stopPropagation();return false}});ed.on("click",function(e){$("body").trigger("click")});ed.on("click",function(){log(ed.selection.getNode())})},convert_urls:true,relative_urls:false,remove_script_host:false,selector:"#editorContent",content_css:["css/bootstrap.css","css/editor/editor.css"].concat(em.getWritingCss()),skin:"custom",language:LEA.locale,plugins:["autolink link leaui_image lists charmap hr","paste","searchreplace leanote_nav leanote_code tabfocus","table directionality textcolor codemirror"],toolbar1:"formatselect | forecolor backcolor | bold italic underline strikethrough | leaui_image | leanote_code | bullist numlist | alignleft aligncenter alignright alignjustify",toolbar2:"outdent indent blockquote | link unlink | table | hr removeformat | subscript superscript |searchreplace | code | pastetext | fontselect fontsizeselect",menubar:false,toolbar_items_size:"small",statusbar:false,url_converter:false,font_formats:"Arial=arial,helvetica,sans-serif;"+"Arial Black=arial black,avant garde;"+"Times New Roman=times new roman,times;"+"Courier New=courier new,courier;"+"Tahoma=tahoma,arial,helvetica,sans-serif;"+"Verdana=verdana,geneva;"+"宋体=SimSun;"+"新宋体=NSimSun;"+"黑体=SimHei;"+"微软雅黑=Microsoft YaHei",block_formats:"Header 1=h1;Header 2=h2;Header 3=h3; Header 4=h4;Pre=pre;Paragraph=p",codemirror:{indentOnInit:true,path:"CodeMirror",config:{lineNumbers:true},jsFiles:[]},paste_data_images:true});window.onbeforeunload=function(e){Note.curChangedSaveIt()};$("body").on("keydown",Note.saveNote)});var random=1;function scrollTo(self,tagName,text){var iframe=$("#editorContent_ifr").contents();var target=iframe.find(tagName+":contains("+text+")");random++;var navs=$('#leanoteNavContent [data-a="'+tagName+"-"+encodeURI(text)+'"]');var len=navs.size();for(var i=0;i<len;++i){if(navs[i]==self){break}}if(target.size()>=i+1){target=target.eq(i);var top=target.offset().top;var nowTop=iframe.scrollTop();var d=200;for(var i=0;i<d;i++){setTimeout(function(top){return function(){iframe.scrollTop(top)}}(nowTop+1*i*(top-nowTop)/Line truncated
|
||||
function editorMode(){this.writingHash="#writing";this.normalHash="#normal";this.isWritingMode=location.hash==this.writingHash;this.toggleA=null}editorMode.prototype.toggleAText=function(isWriting){var self=this;setTimeout(function(){toggleA=$("#toggleEditorMode a");if(isWriting){toggleA.attr("href",self.normalHash).text(getMsg("normalMode"))}else{toggleA.attr("href",self.writingHash).text(getMsg("writingMode"))}},0)};editorMode.prototype.isWriting=function(hash){return hash==this.writingHash};editorMode.prototype.init=function(){this.changeMode(this.isWritingMode);var self=this;$("#toggleEditorMode").click(function(){saveBookmark();var $a=$(this).find("a");var isWriting=self.isWriting($a.attr("href"));self.changeMode(isWriting);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(){setTimeout(function(){resizeEditor()},10);setTimeout(function(){resizeEditor()},20);setTimeout(function(){resizeEditor()},500)};editorMode.prototype.normalMode=function(){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");this.resizeEditor();$("#noteList").width(UserInfo.NoteListWidth);$("#note").css("left",UserInfo.NoteListWidth)};editorMode.prototype.writtingMode=function(){$("#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()});$("#mceToolbar").css("height","40px");this.resizeEditor();$("#noteList").width(250);$("#note").css("left",0)};editorMode.prototype.getWritingCss=function(){if(this.isWritingMode){return["css/editor/editor-writting-mode.css"]}return[]};var em=new editorMode;var Resize={lineMove:false,mdLineMove:false,target:null,leftNotebook:$("#leftNotebook"),notebookSplitter:$("#notebookSplitter"),noteList:$("#noteList"),noteAndEditor:$("#noteAndEditor"),noteSplitter:$("#noteSplitter"),note:$("#note"),body:$("body"),leftColumn:$("#left-column"),rightColumn:$("#right-column"),mdSplitter:$("#mdSplitter"),init:function(){var self=this;self.initEvent()},initEvent:function(){var self=this;$(".noteSplit").bind("mousedown",function(event){event.preventDefault();self.lineMove=true;$(this).css("background-color","#ccc");self.target=$(this).attr("id");$("#noteMask").css("z-index",99999)});self.mdSplitter.bind("mousedown",function(event){event.preventDefault();self.mdLineMove=true;$(this).css("background-color","#ccc")});self.body.bind("mousemove",function(event){if(self.lineMove){event.preventDefault();self.resize3Columns(event)}else if(self.mdLineMove){event.preventDefault();self.resizeMdColumns(event)}});self.body.bind("mouseup",function(event){self.stopResize();$("#noteMask").css("z-index",-1)})},stopResize:function(){var self=this;if(self.lineMove||self.mdLineMove){ajaxGet("/user/updateColumnWidth",{mdEditorWidth:UserInfo.MdEditorWidth,notebookWidth:UserInfo.NotebookWidth,noteListWidth:UserInfo.NoteListWidth},function(){})}self.lineMove=false;self.mdLineMove=false;$(".noteSplit").css("background","none");self.mdSplitter.css("background","none")},set3ColumnsWidth:function(notebookWidth,noteListWidth){var self=this;if(notebookWidth<150||noteListWidth<100){return}var noteWidth=self.body.width()-notebookWidth-noteListWidth;if(noteWidth<400){return}self.leftNotebook.width(notebookWidth);self.notebookSplitter.css("left",notebookWidth);self.noteAndEditor.css("left",notebookWidth);self.noteList.width(noteListWidth);self.noteSplitter.css("left",noteListWidth);self.note.css("left",noteListWidth);UserInfo.NotebookWidth=notebookWidth;UserInfo.NoteListWidth=noteListWidth},resize3Columns:function(event,isFromeIfr){var self=this;if(isFromeIfr){event.clientX+=self.body.width()-self.note.width()}var notebookWidth,noteListWidth;if(self.lineMove){if(self.target=="notebookSplitter"){notebookWidth=event.clientX;noteListWidth=self.noteList.width();self.set3ColumnsWidth(notebookWidth,noteListWidth)}else{notebookWidth=self.leftNotebook.width();noteListWidth=event.clientX-notebookWidth;self.set3ColumnsWidth(notebookWidth,noteListWidth)}resizeEditor()}},resizeMdColumns:function(event){var self=this;if(self.mdLineMove){var mdEditorWidth=event.clientX-self.leftNotebook.width()-self.noteLisLine truncated
|
||||
+671
-724
File diff suppressed because it is too large.
Load diff
Vendored
+1
-1
@@ -1 +1 @@
|
||||
Share.defaultNotebookId="share0";Share.defaultNotebookTitle="Default Share";Share.sharedUserInfos={};Share.userNavs={};Share.notebookCache={};Share.cache={};Share.dialogIsNote=true;Share.setCache=function(note){if(!note||!note.NoteId){return}Share.cache[note.NoteId]=note};Share.getNotebooksForNew=function(userId,notebooks){var self=this;var navForNewNote="";var len=notebooks.length;for(var i=0;i<len;++i){var notebook=notebooks[i];notebook.IsShared=true;notebook.UserId=userId;self.notebookCache[notebook.NotebookId]=notebook;Notebook.cache[notebook.NotebookId]=notebook;var classes="";var subs=false;if(!isEmpty(notebook.Subs)){log(11);log(notebook.Subs);var subs=self.getNotebooksForNew(userId,notebook.Subs);if(subs){classes="dropdown-submenu"}}var eachForNew="";if(notebook.Perm){var eachForNew=tt('<li role="presentation" class="clearfix ?" userId="?" notebookId="?"><div class="new-note-left pull-left" title="为该笔记本新建笔记" href="#">?</div><div title="为该笔记本新建markdown笔记" class="new-note-right pull-left">M</div>',classes,userId,notebook.NotebookId,notebook.Title);if(subs){eachForNew+="<ul class='dropdown-menu'>";eachForNew+=subs;eachForNew+="</ul>"}eachForNew+="</li>"}navForNewNote+=eachForNew}return navForNewNote};Share.trees={};Share.renderShareNotebooks=function(sharedUserInfos,shareNotebooks){var self=Share;if(isEmpty(sharedUserInfos)){return}if(!shareNotebooks||typeof shareNotebooks!="object"||shareNotebooks.length<0){shareNotebooks={}}var $shareNotebooks=$("#shareNotebooks");for(var i in sharedUserInfos){var userInfo=sharedUserInfos[i];var userNotebooksPre=shareNotebooks[userInfo.UserId]||[];userNotebooks=[{NotebookId:self.defaultNotebookId,Title:Share.defaultNotebookTitle}].concat(userNotebooksPre);self.notebookCache[self.defaultNotebookId]=userNotebooks[0];var username=userInfo.Username||userInfo.Email;userInfo.Username=username;Share.sharedUserInfos[userInfo.UserId]=userInfo;var userId=userInfo.UserId;var header=tt('<li class="each-user"><div class="friend-header" fromUserId="?"><i class="fa fa-angle-down"></i><span>?</span> <span class="fa notebook-setting" title="setting"></span> </div>',userInfo.UserId,username);var friendId="friendContainer_"+userId;var body='<ul class="friend-notebooks ztree" id="'+friendId+'" fromUserId="'+userId+'"></ul>';$shareNotebooks.append(header+body+"</li>");self.trees[userId]=$.fn.zTree.init($("#"+friendId),Notebook.getTreeSetting(true,true),userNotebooks);self.userNavs[userId]={forNew:self.getNotebooksForNew(userId,userNotebooksPre)};log(self.userNavs)}$(".friend-notebooks").hover(function(){if(!$(this).hasClass("showIcon")){$(this).addClass("showIcon")}},function(){$(this).removeClass("showIcon")});$(".friend-header i").click(function(){var $this=$(this);var $tree=$(this).parent().next();if($tree.is(":hidden")){$tree.slideDown("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-down")}else{$tree.slideUp("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-right")}});var shareNotebookMenu={width:150,items:[{text:"删除共享笔记本",icon:"",faIcon:"fa-trash-o",action:Share.deleteShareNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#shareNotebooks",children:".notebook-item"};function applyrule(menu){return}function beforeContextMenu(){var notebookId=$(this).attr("notebookId");return!Share.isDefaultNotebookId(notebookId)}var menuNotebooks=$("#shareNotebooks").contextmenu(shareNotebookMenu);var shareUserMenu={width:150,items:[{text:"删除所有共享",icon:"",faIcon:"fa-trash-o",action:Share.deleteUserShareNoteAndNotebook}],parent:"#shareNotebooks",children:".friend-header"};var menuUser=$("#shareNotebooks").contextmenu(shareUserMenu);$(".friend-header").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuUser.showMenu(e,$p)});$("#shareNotebooks .notebook-item").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuNotebooks.showMenu(e,$p)})};Share.isDefaultNotebookId=function(notebookId){return Share.defaultNotebookId==notebookId};Share.toggleToSharedNav=function(userId,notebookId){var self=this;$("#curNotebookForListNote").html(Share.notebookCache[notebookId].Title+"("+Share.sharedUserInfos[userId].Username+")");var forNew=Share.userNavs[userId].forNew;if(forNew){$("#notebookNavForNewSharedNote").html(forNew);var curNotebookId="";var curNotebookTitle="";if(Share.notebookCache[notebookId].Perm){curNotebookId=notebookId;curNotebookTitle=Share.notebookCache[notebookId].Title}else{var $f=$("#notebookNavForNewSharedNote li").eq(0);curNotebookId=$f.attr("notebookId");curNotebookTitle=$f.find(".new-note-left").text()}$("#curNotebookForNewSharedNote").html(curNotebookTitle+"("+Share.sharedUserInfos[userId].Username+")");$("#curNotebookForNewSharedNote").attr("notebookId",curNotebookId);$("#curNotebookForNewSharedNote").attr("userId",userId);$("#newSharedNote").showLine truncated
|
||||
Share.defaultNotebookId="share0";Share.defaultNotebookTitle=getMsg("defaulthhare");Share.sharedUserInfos={};Share.userNavs={};Share.notebookCache={};Share.cache={};Share.dialogIsNote=true;Share.setCache=function(note){if(!note||!note.NoteId){return}Share.cache[note.NoteId]=note};Share.getNotebooksForNew=function(userId,notebooks){var self=this;var navForNewNote="";var len=notebooks.length;for(var i=0;i<len;++i){var notebook=notebooks[i];notebook.IsShared=true;notebook.UserId=userId;self.notebookCache[notebook.NotebookId]=notebook;Notebook.cache[notebook.NotebookId]=notebook;var classes="";var subs=false;if(!isEmpty(notebook.Subs)){log(11);log(notebook.Subs);var subs=self.getNotebooksForNew(userId,notebook.Subs);if(subs){classes="dropdown-submenu"}}var eachForNew="";if(notebook.Perm){var eachForNew=tt('<li role="presentation" class="clearfix ?" userId="?" notebookId="?"><div class="new-note-left pull-left" title="为该笔记本新建笔记" href="#">?</div><div title="为该笔记本新建markdown笔记" class="new-note-right pull-left">M</div>',classes,userId,notebook.NotebookId,notebook.Title);if(subs){eachForNew+="<ul class='dropdown-menu'>";eachForNew+=subs;eachForNew+="</ul>"}eachForNew+="</li>"}navForNewNote+=eachForNew}return navForNewNote};Share.trees={};Share.renderShareNotebooks=function(sharedUserInfos,shareNotebooks){var self=Share;if(isEmpty(sharedUserInfos)){return}if(!shareNotebooks||typeof shareNotebooks!="object"||shareNotebooks.length<0){shareNotebooks={}}var $shareNotebooks=$("#shareNotebooks");for(var i in sharedUserInfos){var userInfo=sharedUserInfos[i];var userNotebooksPre=shareNotebooks[userInfo.UserId]||[];userNotebooks=[{NotebookId:self.defaultNotebookId,Title:Share.defaultNotebookTitle}].concat(userNotebooksPre);self.notebookCache[self.defaultNotebookId]=userNotebooks[0];var username=userInfo.Username||userInfo.Email;userInfo.Username=username;Share.sharedUserInfos[userInfo.UserId]=userInfo;var userId=userInfo.UserId;var header=tt('<li class="each-user"><div class="friend-header" fromUserId="?"><i class="fa fa-angle-down"></i><span>?</span> <span class="fa notebook-setting" title="setting"></span> </div>',userInfo.UserId,username);var friendId="friendContainer_"+userId;var body='<ul class="friend-notebooks ztree" id="'+friendId+'" fromUserId="'+userId+'"></ul>';$shareNotebooks.append(header+body+"</li>");self.trees[userId]=$.fn.zTree.init($("#"+friendId),Notebook.getTreeSetting(true,true),userNotebooks);self.userNavs[userId]={forNew:self.getNotebooksForNew(userId,userNotebooksPre)};log(self.userNavs)}$(".friend-notebooks").hover(function(){if(!$(this).hasClass("showIcon")){$(this).addClass("showIcon")}},function(){$(this).removeClass("showIcon")});$(".friend-header i").click(function(){var $this=$(this);var $tree=$(this).parent().next();if($tree.is(":hidden")){$tree.slideDown("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-down")}else{$tree.slideUp("fast");$this.removeClass("fa-angle-right fa-angle-down").addClass("fa-angle-right")}});var shareNotebookMenu={width:180,items:[{text:getMsg("deleteSharedNotebook"),icon:"",faIcon:"fa-trash-o",action:Share.deleteShareNotebook}],onShow:applyrule,onContextMenu:beforeContextMenu,parent:"#shareNotebooks",children:".notebook-item"};function applyrule(menu){return}function beforeContextMenu(){var notebookId=$(this).attr("notebookId");return!Share.isDefaultNotebookId(notebookId)}var menuNotebooks=$("#shareNotebooks").contextmenu(shareNotebookMenu);var shareUserMenu={width:180,items:[{text:getMsg("deleteAllShared"),icon:"",faIcon:"fa-trash-o",action:Share.deleteUserShareNoteAndNotebook}],parent:"#shareNotebooks",children:".friend-header"};var menuUser=$("#shareNotebooks").contextmenu(shareUserMenu);$(".friend-header").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuUser.showMenu(e,$p)});$("#shareNotebooks .notebook-item").on("click",".notebook-setting",function(e){e.preventDefault();e.stopPropagation();var $p=$(this).parent();menuNotebooks.showMenu(e,$p)})};Share.isDefaultNotebookId=function(notebookId){return Share.defaultNotebookId==notebookId};Share.toggleToSharedNav=function(userId,notebookId){var self=this;$("#curNotebookForListNote").html(Share.notebookCache[notebookId].Title+"("+Share.sharedUserInfos[userId].Username+")");var forNew=Share.userNavs[userId].forNew;if(forNew){$("#notebookNavForNewSharedNote").html(forNew);var curNotebookId="";var curNotebookTitle="";if(Share.notebookCache[notebookId].Perm){curNotebookId=notebookId;curNotebookTitle=Share.notebookCache[notebookId].Title}else{var $f=$("#notebookNavForNewSharedNote li").eq(0);curNotebookId=$f.attr("notebookId");curNotebookTitle=$f.find(".new-note-left").text()}$("#curNotebookForNewSharedNote").html(curNotebookTitle+"("+Share.sharedUserInfos[userId].Username+")");$("#curNotebookForNewSharedNote").attr("notebookId",curNotebookId);$("#curNotebookForNewSharedNote").attr("userId",userId);$("#nLine truncated
|
||||
+26
-26
@@ -4,7 +4,7 @@
|
||||
|
||||
// 默认共享notebook id
|
||||
Share.defaultNotebookId = "share0";
|
||||
Share.defaultNotebookTitle = "Default Share";
|
||||
Share.defaultNotebookTitle = getMsg("defaulthhare");
|
||||
Share.sharedUserInfos = {}; // userId => {}
|
||||
|
||||
// 在render时就创建, 以后复用之
|
||||
@@ -147,9 +147,9 @@ Share.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
|
||||
// contextmenu shareNotebooks
|
||||
// 删除共享笔记本
|
||||
var shareNotebookMenu = {
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: [
|
||||
{ text: "删除共享笔记本", icon: "", faIcon: "fa-trash-o", action: Share.deleteShareNotebook }
|
||||
{ text: getMsg("deleteSharedNotebook"), icon: "", faIcon: "fa-trash-o", action: Share.deleteShareNotebook }
|
||||
],
|
||||
onShow: applyrule,
|
||||
onContextMenu: beforeContextMenu,
|
||||
@@ -172,9 +172,9 @@ Share.renderShareNotebooks = function(sharedUserInfos, shareNotebooks) {
|
||||
// contextmenu shareNotebooks
|
||||
// 删除某用户所有的
|
||||
var shareUserMenu = {
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: [
|
||||
{ text: "删除所有共享", icon: "", faIcon: "fa-trash-o", action: Share.deleteUserShareNoteAndNotebook }
|
||||
{ text: getMsg("deleteAllShared"), icon: "", faIcon: "fa-trash-o", action: Share.deleteUserShareNoteAndNotebook }
|
||||
],
|
||||
parent: "#shareNotebooks",
|
||||
children: ".friend-header",
|
||||
@@ -367,15 +367,15 @@ Share.initContextmenu = function(notebooksCopy) {
|
||||
// context menu
|
||||
//---------------------
|
||||
var noteListMenu = {
|
||||
width: 170,
|
||||
width: 180,
|
||||
items: [
|
||||
{ text: "复制到我的笔记本", alias: "copy", icon: "",
|
||||
{ text: getMsg("copyToMyNotebook"), alias: "copy", faIcon: "fa-copy",
|
||||
type: "group",
|
||||
width: 150,
|
||||
width: 180,
|
||||
items: notebooksCopy
|
||||
},
|
||||
{ type: "splitLine" },
|
||||
{ text: "删除", alias: "delete", icon: "", faIcon: "fa-trash-o", action: Share.deleteSharedNote }
|
||||
{ text: getMsg("delete"), alias: "delete", icon: "", faIcon: "fa-trash-o", action: Share.deleteSharedNote }
|
||||
],
|
||||
onShow: applyrule,
|
||||
parent: "#noteItemList",
|
||||
@@ -447,10 +447,10 @@ $(function() {
|
||||
var perm = $(this).attr("perm");
|
||||
var noteOrNotebookId = $(this).attr("noteOrNotebookId");
|
||||
var toUserId = $(this).attr("toUserId");
|
||||
var toHtml = "可编辑";
|
||||
var toHtml = getMsg("writable");
|
||||
var toPerm = "1";
|
||||
if(perm == "1") {
|
||||
toHtml = "只读";
|
||||
toHtml = getMsg("readOnly");
|
||||
toPerm = "0";
|
||||
}
|
||||
var url = "/share/UpdateShareNotebookPerm";
|
||||
@@ -494,11 +494,11 @@ $(function() {
|
||||
var seq = 1;
|
||||
$("#leanoteDialogRemote").on("click", "#addShareNotebookBtn", function() {
|
||||
seq++;
|
||||
var tpl = '<tr id="tr' + seq + '"><td>#</td><td><input id="friendsEmail" type="text" class="form-control" style="width: 200px" placeholder="好友邮箱"/></td>';
|
||||
tpl += '<td><label for="readPerm' + seq + '"><input type="radio" name="perm' + seq + '" checked="checked" value="0" id="readPerm' + seq + '"> 只读</label>';
|
||||
tpl += ' <label for="writePerm' + seq + '"><input type="radio" name="perm' + seq + '" value="1" id="writePerm' + seq + '"> 可编辑</label></td>';
|
||||
tpl += '<td><button class="btn btn-success" onclick="addShareNoteOrNotebook(' + seq + ')">分享</button>';
|
||||
tpl += ' <button class="btn btn-warning" onclick="deleteShareNoteOrNotebook(' + seq + ')">删除</button>';
|
||||
var tpl = '<tr id="tr' + seq + '"><td>#</td><td><input id="friendsEmail" type="text" class="form-control" style="width: 200px" placeholder="' + getMsg('friendEmail') + '"/></td>';
|
||||
tpl += '<td><label for="readPerm' + seq + '"><input type="radio" name="perm' + seq + '" checked="checked" value="0" id="readPerm' + seq + '"> ' + getMsg('readOnly') + '</label>';
|
||||
tpl += ' <label for="writePerm' + seq + '"><input type="radio" name="perm' + seq + '" value="1" id="writePerm' + seq + '"> ' + getMsg('writable') + '</label></td>';
|
||||
tpl += '<td><button class="btn btn-success" onclick="addShareNoteOrNotebook(' + seq + ')">' + getMsg('share') + '</button>';
|
||||
tpl += ' <button class="btn btn-warning" onclick="deleteShareNoteOrNotebook(' + seq + ')">' + getMsg("delete") + '</button>';
|
||||
tpl += "</td></tr>";
|
||||
$("#shareNotebookTable tbody").prepend(tpl);
|
||||
|
||||
@@ -511,11 +511,11 @@ $(function() {
|
||||
var content = $("#emailContent").val();
|
||||
var toEmail = $("#toEmail").val();
|
||||
if(!content) {
|
||||
showAlert("#registerEmailMsg", "邮件内容不能为空", "danger");
|
||||
showAlert("#registerEmailMsg", getMsg("emailBodyRequired"), "danger");
|
||||
return;
|
||||
}
|
||||
post("/user/sendRegisterEmail", {content: content, toEmail: toEmail}, function(ret) {
|
||||
showAlert("#registerEmailMsg", "发送成功!", "success");
|
||||
showAlert("#registerEmailMsg", getMsg("sendSuccess"), "success");
|
||||
hideDialog2("#sendRegisterEmailDialog", 1000);
|
||||
}, this);
|
||||
});
|
||||
@@ -526,7 +526,7 @@ function addShareNoteOrNotebook(trSeq) {
|
||||
var trId = "#tr" + trSeq;
|
||||
var id = Share.dialogNoteOrNotebookId;
|
||||
|
||||
var emails = isEmailFromInput(trId + " #friendsEmail", "#shareMsg", "请输入好友邮箱");
|
||||
var emails = isEmailFromInput(trId + " #friendsEmail", "#shareMsg", getMsg("inputFriendEmail"));
|
||||
if(!emails) {
|
||||
return;
|
||||
}
|
||||
@@ -548,18 +548,18 @@ function addShareNoteOrNotebook(trSeq) {
|
||||
if(ret.Ok) {
|
||||
var tpl = tt('<td>?</td>', '#');
|
||||
tpl += tt('<td>?</td>', emails);
|
||||
tpl += tt('<td><a href="#" noteOrNotebookId="?" perm="?" toUserId="?" title="点击改变权限" class="btn btn-default change-perm">?</a></td>', id, perm, ret.Id, !perm || perm == '0' ? "只读" : "可编辑");
|
||||
tpl += tt('<td><a href="#" noteOrNotebookId="?" toUserId="?" class="btn btn-warning delete-share">删除</a></td>', id, ret.Id);
|
||||
tpl += tt('<td><a href="#" noteOrNotebookId="?" perm="?" toUserId="?" title="' + getMsg("clickToChangePermission") + '" class="btn btn-default change-perm">?</a></td>', id, perm, ret.Id, !perm || perm == '0' ? getMsg("readOnly") : getMsg("writable"));
|
||||
tpl += tt('<td><a href="#" noteOrNotebookId="?" toUserId="?" class="btn btn-warning delete-share">' + getMsg("delete") +'</a></td>', id, ret.Id);
|
||||
$(trId).html(tpl);
|
||||
} else {
|
||||
var shareUrl = 'http://leanote/register?from=' + UserInfo.Username;
|
||||
showAlert("#shareMsg", "该用户还没有注册, 复制邀请链接发送给Ta一起来体验leanote, 邀请链接: " + shareUrl + ' <a id="shareCopy" data-clipboard-target="copyDiv">点击复制</a> <span id="copyStatus"></span> <br /> 或者发送邀请邮件给Ta, <a href="#" onclick="sendRegisterEmail(\'' + emails + '\')">点击发送', "warning");
|
||||
var shareUrl = UrlPrefix + '/register?from=' + UserInfo.Username;
|
||||
showAlert("#shareMsg", getMsg('friendNotExits', [getMsg("app"), shareUrl]) + ' <a id="shareCopy" data-clipboard-target="copyDiv">' + getMsg("clickToCopy") + '</a> <span id="copyStatus"></span> <br /> ' + getMsg("sendInviteEmailToYourFriend") + ', <a href="#" onclick="sendRegisterEmail(\'' + emails + '\')">' + getMsg("send"), "warning");
|
||||
$("#copyDiv").text(shareUrl);
|
||||
initCopy("shareCopy", function(args) {
|
||||
if(args.text) {
|
||||
showMsg2("#copyStatus", "复制成功", 1000);
|
||||
showMsg2("#copyStatus", getMsg("copySuccess"), 1000);
|
||||
} else {
|
||||
showMsg2("#copyStatus", "对不起, 复制失败, 请自行复制", 1000);
|
||||
showMsg2("#copyStatus", getMsg("copyFailed"), 1000);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -570,7 +570,7 @@ function addShareNoteOrNotebook(trSeq) {
|
||||
// 发送邀请邮件
|
||||
function sendRegisterEmail(email) {
|
||||
showDialog2("#sendRegisterEmailDialog", {postShow: function() {
|
||||
$("#emailContent").val("Hi, 我是" + UserInfo.Username + ", leanote非常好用, 快来注册吧!");
|
||||
$("#emailContent").val(getMsg("inviteEmailBody", [UserInfo.Username, getMsg("app")]));
|
||||
setTimeout(function() {
|
||||
$("#emailContent").focus();
|
||||
}, 500);
|
||||
|
||||
Vendored
+1
-1
@@ -1 +1 @@
|
||||
Tag.classes={"蓝色":"label label-blue","红色":"label label-red","绿色":"label label-green","黄色":"label label-yellow",blue:"label label-blue",red:"label label-red",green:"label label-green",yellow:"label label-yellow"};Tag.mapCn2En={"蓝色":"blue","红色":"red","绿色":"green","黄色":"yellow"};Tag.mapEn2Cn={blue:"蓝色",red:"红色",green:"绿色",yellow:"黄色"};Tag.t=$("#tags");Tag.getTags=function(){var tags=[];Tag.t.children().each(function(){var text=$(this).text();text=text.substring(0,text.length-1);text=Tag.mapCn2En[text]||text;tags.push(text)});return tags};Tag.clearTags=function(){Tag.t.html("")};Tag.renderTags=function(tags){Tag.t.html("");if(isEmpty(tags)){return}for(var i=0;i<tags.length;++i){var tag=tags[i];Tag.appendTag(tag)}};function revertTagStatus(){$("#addTagTrigger").show();$("#addTagInput").hide()}function hideTagList(event){$("#tagDropdown").removeClass("open");if(event){event.stopPropagation()}}function showTagList(event){$("#tagDropdown").addClass("open");if(event){event.stopPropagation()}}Tag.renderReadOnlyTags=function(tags){$("#noteReadTags").html("");if(isEmpty(tags)){$("#noteReadTags").html("无标签")}var i=true;function getNextDefaultClasses(){if(i){return"label label-default";i=false}else{i=true;return"label label-info"}}for(var i in tags){var text=tags[i];text=Tag.mapEn2Cn[text]||text;var classes=Tag.classes[text];if(!classes){classes=getNextDefaultClasses()}tag=tt('<span class="?">?</span>',classes,text);$("#noteReadTags").append(tag)}};Tag.appendTag=function(tag){var isColor=false;var classes,text;if(typeof tag=="object"){classes=tag.classes;text=tag.text;if(!text){return}}else{tag=$.trim(tag);text=tag;if(!text){return}var classes=Tag.classes[text];if(classes){isColor=true}else{classes="label label-default"}}text=Tag.mapEn2Cn[text]||text;tag=tt('<span class="?">?<i title="删除">X</i></span>',classes,text);$("#tags").children().each(function(){if(isColor){var tagHtml=$("<div></div>").append($(this).clone()).html();if(tagHtml==tag){$(this).remove()}}else if(text+"X"==$(this).text()){$(this).remove()}});$("#tags").append(tag);hideTagList();if(!isColor){reRenderTags()}};function reRenderTags(){var defautClasses=["label label-default","label label-info"];var i=0;$("#tags").children().each(function(){var thisClasses=$(this).attr("class");if(thisClasses=="label label-default"||thisClasses=="label label-info"){$(this).removeClass(thisClasses).addClass(defautClasses[i%2]);i++}})}Tag.renderTagNav=function(tags){tags=tags||[];for(var i in tags){var tag=tags[i];if(tag=="red"||tag=="blue"||tag=="yellow"||tag=="green"){continue}var text=Tag.mapEn2Cn[tag]||tag;var classes=Tag.classes[tag]||"label label-default";$("#tagNav").append(tt('<li><a> <span class="?">?</span></li>',classes,text))}};$(function(){$("#addTagTrigger").click(function(){$(this).hide();$("#addTagInput").show().focus().val("")});$("#addTagInput").click(function(event){showTagList(event)});$("#addTagInput").blur(function(){var val=$(this).val();if(val){Tag.appendTag(val,true)}return;$("#addTagTrigger").show();$("#addTagInput").hide()});$("#addTagInput").keydown(function(e){if(e.keyCode==13){hideTagList();if($("#addTagInput").val()){$(this).trigger("blur");$("#addTagTrigger").trigger("click")}else{$(this).trigger("blur")}}});$("#tagColor li").click(function(event){var a;if($(this).attr("role")){a=$(this).find("span")}else{a=$(this)}Tag.appendTag({classes:a.attr("class"),text:a.text()})});$("#tags").on("click","i",function(){$(this).parent().remove();reRenderTags()});function searchTag(){var tag=$.trim($(this).text());tag=Tag.mapCn2En[tag]||tag;Note.curChangedSaveIt();Note.clearAll();$("#tagSearch").html($(this).html()).show();showLoading();ajaxGet("/note/searchNoteByTags",{tags:[tag]},function(notes){hideLoading();if(notes){Note.renderNotes(notes);if(!isEmpty(notes)){Note.changeNote(notes[0].NoteId)}}})}$("#myTag .folderBody").on("click","li",searchTag);$("#minTagNav").on("click","li",searchTag)});
|
||||
Tag.classes={"蓝色":"label label-blue","红色":"label label-red","绿色":"label label-green","黄色":"label label-yellow",blue:"label label-blue",red:"label label-red",green:"label label-green",yellow:"label label-yellow"};Tag.mapCn2En={"蓝色":"blue","红色":"red","绿色":"green","黄色":"yellow"};Tag.mapEn2Cn={blue:"蓝色",red:"红色",green:"绿色",yellow:"黄色"};Tag.t=$("#tags");Tag.getTags=function(){var tags=[];Tag.t.children().each(function(){var text=$(this).text();text=text.substring(0,text.length-1);text=Tag.mapCn2En[text]||text;tags.push(text)});return tags};Tag.clearTags=function(){Tag.t.html("")};Tag.renderTags=function(tags){Tag.t.html("");if(isEmpty(tags)){return}for(var i=0;i<tags.length;++i){var tag=tags[i];Tag.appendTag(tag)}};function revertTagStatus(){$("#addTagTrigger").show();$("#addTagInput").hide()}function hideTagList(event){$("#tagDropdown").removeClass("open");if(event){event.stopPropagation()}}function showTagList(event){$("#tagDropdown").addClass("open");if(event){event.stopPropagation()}}Tag.renderReadOnlyTags=function(tags){$("#noteReadTags").html("");if(isEmpty(tags)){$("#noteReadTags").html(getMsg("noTag"))}var i=true;function getNextDefaultClasses(){if(i){return"label label-default";i=false}else{i=true;return"label label-info"}}for(var i in tags){var text=tags[i];text=Tag.mapEn2Cn[text]||text;var classes=Tag.classes[text];if(!classes){classes=getNextDefaultClasses()}tag=tt('<span class="?">?</span>',classes,text);$("#noteReadTags").append(tag)}};Tag.appendTag=function(tag){var isColor=false;var classes,text;if(typeof tag=="object"){classes=tag.classes;text=tag.text;if(!text){return}}else{tag=$.trim(tag);text=tag;if(!text){return}var classes=Tag.classes[text];if(classes){isColor=true}else{classes="label label-default"}}if(LEA.locale=="zh"){text=Tag.mapEn2Cn[text]||text}tag=tt('<span class="?">?<i title="'+getMsg("delete")+'">X</i></span>',classes,text);$("#tags").children().each(function(){if(isColor){var tagHtml=$("<div></div>").append($(this).clone()).html();if(tagHtml==tag){$(this).remove()}}else if(text+"X"==$(this).text()){$(this).remove()}});$("#tags").append(tag);hideTagList();if(!isColor){reRenderTags()}};function reRenderTags(){var defautClasses=["label label-default","label label-info"];var i=0;$("#tags").children().each(function(){var thisClasses=$(this).attr("class");if(thisClasses=="label label-default"||thisClasses=="label label-info"){$(this).removeClass(thisClasses).addClass(defautClasses[i%2]);i++}})}Tag.renderTagNav=function(tags){tags=tags||[];for(var i in tags){var tag=tags[i];if(tag=="red"||tag=="blue"||tag=="yellow"||tag=="green"){continue}var text=Tag.mapEn2Cn[tag]||tag;var classes=Tag.classes[tag]||"label label-default";$("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">?</span></li>',text,classes,text))}};$(function(){$("#addTagTrigger").click(function(){$(this).hide();$("#addTagInput").show().focus().val("")});$("#addTagInput").click(function(event){showTagList(event)});$("#addTagInput").blur(function(){var val=$(this).val();if(val){Tag.appendTag(val,true)}return;$("#addTagTrigger").show();$("#addTagInput").hide()});$("#addTagInput").keydown(function(e){if(e.keyCode==13){hideTagList();if($("#addTagInput").val()){$(this).trigger("blur");$("#addTagTrigger").trigger("click")}else{$(this).trigger("blur")}}});$("#tagColor li").click(function(event){var a;if($(this).attr("role")){a=$(this).find("span")}else{a=$(this)}Tag.appendTag({classes:a.attr("class"),text:a.text()})});$("#tags").on("click","i",function(){$(this).parent().remove();reRenderTags()});function searchTag(){var tag=$.trim($(this).data("tag"));Note.curChangedSaveIt();Note.clearAll();$("#tagSearch").html($(this).html()).show();showLoading();ajaxGet("/note/searchNoteByTags",{tags:[tag]},function(notes){hideLoading();if(notes){Note.renderNotes(notes);if(!isEmpty(notes)){Note.changeNote(notes[0].NoteId)}}})}$("#myTag .folderBody").on("click","li",searchTag);$("#minTagNav").on("click","li",searchTag)});
|
||||
@@ -19,7 +19,6 @@ Tag.mapCn2En = {
|
||||
"红色": "red",
|
||||
"绿色": "green",
|
||||
"黄色": "yellow",
|
||||
|
||||
}
|
||||
Tag.mapEn2Cn = {
|
||||
"blue": "蓝色",
|
||||
@@ -88,7 +87,7 @@ Tag.renderReadOnlyTags = function(tags) {
|
||||
// 先清空
|
||||
$("#noteReadTags").html("");
|
||||
if(isEmpty(tags)) {
|
||||
$("#noteReadTags").html("无标签");
|
||||
$("#noteReadTags").html(getMsg("noTag"));
|
||||
}
|
||||
|
||||
var i = true;
|
||||
@@ -142,8 +141,10 @@ Tag.appendTag = function(tag) {
|
||||
}
|
||||
}
|
||||
|
||||
text = Tag.mapEn2Cn[text] || text;
|
||||
tag = tt('<span class="?">?<i title="删除">X</i></span>', classes, text);
|
||||
if(LEA.locale == "zh") {
|
||||
text = Tag.mapEn2Cn[text] || text;
|
||||
}
|
||||
tag = tt('<span class="?">?<i title="' + getMsg("delete") + '">X</i></span>', classes, text);
|
||||
|
||||
// 避免重复
|
||||
$("#tags").children().each(function() {
|
||||
@@ -193,7 +194,7 @@ Tag.renderTagNav = function(tags) {
|
||||
}
|
||||
var text = Tag.mapEn2Cn[tag] || tag;
|
||||
var classes = Tag.classes[tag] || "label label-default";
|
||||
$("#tagNav").append(tt('<li><a> <span class="?">?</span></li>', classes, text));
|
||||
$("#tagNav").append(tt('<li data-tag="?"><a> <span class="?">?</span></li>', text, classes, text));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,8 +267,8 @@ $(function() {
|
||||
//-------------
|
||||
// nav 标签搜索
|
||||
function searchTag() {
|
||||
var tag = $.trim($(this).text());
|
||||
tag = Tag.mapCn2En[tag] || tag;
|
||||
var tag = $.trim($(this).data("tag"));
|
||||
// tag = Tag.mapCn2En[tag] || tag;
|
||||
|
||||
// 学习changeNotebook
|
||||
|
||||
|
||||
Reference in new issue
Block a user