v1.0 beta init

This commit is contained in:
life
2014-10-22 16:20:45 +08:00
parent 8ae438272b
commit 593d2c2965
225 changed files with 27217 additions and 3675 deletions
app
messages
public
admin
css
images
js
mdeditor
tinymce

File diff suppressed because one or more lines are too long

@ -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("&nbsp; 无");
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);
}

509
public/js/app/blog/view.js Normal file

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

File diff suppressed because one or more lines are too long

@ -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()会将&lt; => < &gt; => >
content = content.replace(/</g, "&lt;");
content = content.replace(/>/g, "&gt;");
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);
});
//------------------

File diff suppressed because one or more lines are too long

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

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

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

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

1
public/js/bootstrap-dialog.min.js vendored Normal file

File diff suppressed because one or more lines are too long

111
public/js/bootstrap-hover-dropdown.js vendored Normal file

@ -0,0 +1,111 @@
/**
* @preserve
* Project: Bootstrap Hover Dropdown
* Author: Cameron Spear
* Version: v2.0.11
* Contributors: Mattia Larentis
* Dependencies: Bootstrap's Dropdown plugin, jQuery
* Description: A simple plugin to enable Bootstrap dropdowns to active on hover and provide a nice user experience.
* License: MIT
* Homepage: http://cameronspear.com/blog/bootstrap-dropdown-on-hover-plugin/
*/
;(function ($, window, undefined) {
// outside the scope of the jQuery plugin to
// keep track of all dropdowns
var $allDropdowns = $();
// if instantlyCloseOthers is true, then it will instantly
// shut other nav items when a new one is hovered over
$.fn.dropdownHover = function (options) {
// don't do anything if touch is supported
// (plugin causes some issues on mobile)
if('ontouchstart' in document) return this; // don't want to affect chaining
// the element we really care about
// is the dropdown-toggle's parent
$allDropdowns = $allDropdowns.add(this.parent());
return this.each(function () {
var $this = $(this),
$parent = $this.parent(),
defaults = {
delay: 500,
instantlyCloseOthers: true
},
data = {
delay: $(this).data('delay'),
instantlyCloseOthers: $(this).data('close-others')
},
showEvent = 'show.bs.dropdown',
hideEvent = 'hide.bs.dropdown',
// shownEvent = 'shown.bs.dropdown',
// hiddenEvent = 'hidden.bs.dropdown',
settings = $.extend(true, {}, defaults, options, data),
timeout;
$parent.hover(function (event) {
// so a neighbor can't open the dropdown
if(!$parent.hasClass('open') && !$this.is(event.target)) {
// stop this event, stop executing any code
// in this callback but continue to propagate
return true;
}
openDropdown(event);
}, function () {
timeout = window.setTimeout(function () {
$parent.removeClass('open');
$this.trigger(hideEvent);
}, settings.delay);
});
// this helps with button groups!
$this.hover(function (event) {
/*
// life
// this helps prevent a double event from firing.
// see https://github.com/CWSpear/bootstrap-hover-dropdown/issues/55
if(!$parent.hasClass('open') && !$parent.is(event.target)) {
// stop this event, stop executing any code
// in this callback but continue to propagate
return true;
}
*/
openDropdown(event);
});
// handle submenus
$parent.find('.dropdown-submenu').each(function (){
var $this = $(this);
var subTimeout;
$this.hover(function () {
window.clearTimeout(subTimeout);
$this.children('.dropdown-menu').show();
// always close submenu siblings instantly
$this.siblings().children('.dropdown-menu').hide();
}, function () {
var $submenu = $this.children('.dropdown-menu');
subTimeout = window.setTimeout(function () {
$submenu.hide();
}, settings.delay);
});
});
function openDropdown(event) {
$allDropdowns.find(':focus').blur();
if(settings.instantlyCloseOthers === true)
$allDropdowns.removeClass('open');
window.clearTimeout(timeout);
$parent.addClass('open');
$this.trigger(showEvent);
}
});
};
$(document).ready(function () {
// apply dropdownHover to all elements with the data-hover="dropdown" attribute
$('[data-hover="dropdown"]').dropdownHover({delay: 100});
});
})(jQuery, this);

File diff suppressed because one or more lines are too long

@ -17,6 +17,7 @@ var Note = {
var Tag = {};
var Notebook = {};
var Share = {};
var Mobile = {}; // 手机端处理
// markdown
var Converter;
@ -184,7 +185,7 @@ function _ajax(type, url, param, successFunc, failureFunc, async) {
} else {
async = false;
}
$.ajax({
return $.ajax({
type: type,
url: url,
data: param,
@ -209,7 +210,7 @@ function _ajax(type, url, param, successFunc, failureFunc, async) {
* @returns
*/
function ajaxGet(url, param, successFunc, failureFunc, async) {
_ajax("GET", url, param, successFunc, failureFunc, async);
return _ajax("GET", url, param, successFunc, failureFunc, async);
}
/**
@ -322,8 +323,8 @@ function setEditorContent(content, isMarkdown, preview) {
}
if(!isMarkdown) {
$("#editorContent").html(content);
var editor = tinymce.activeEditor;
if(editor) {
if(typeof tinymce != "undefined" && tinymce.activeEditor) {
var editor = tinymce.activeEditor;
editor.setContent(content);
editor.undoManager.clear(); // 4-7修复BUG
} else {
@ -480,8 +481,14 @@ function showDialogRemote(url, data) {
$("#leanoteDialogRemote").modal({remote: url});
}
function hideDialogRemote() {
$("#leanoteDialogRemote").modal('hide');
function hideDialogRemote(timeout) {
if(timeout) {
setTimeout(function() {
$("#leanoteDialogRemote").modal('hide');
}, timeout);
} else {
$("#leanoteDialogRemote").modal('hide');
}
}
//---------------
// notify
@ -651,12 +658,11 @@ function hideAlert(id, timeout) {
function post(url, param, func, btnId) {
var btnPreText;
if(btnId) {
btnPreText = $(btnId).html();
$(btnId).html("正在处理").addClass("disabled");
$(btnId).button("loading"); // html("正在处理").addClass("disabled");
}
ajaxPost(url, param, function(ret) {
if(btnPreText) {
$(btnId).html(btnPreText).removeClass("disabled");
if(btnId) {
$(btnId).button("reset");
}
if (typeof ret == "object") {
if(typeof func == "function") {
@ -684,9 +690,9 @@ function isEmailFromInput(inputId, msgId, selfBlankMsg, selfInvalidMsg) {
}
}
if(!val) {
msg(msgId, selfBlankMsg || "请输入邮箱");
msg(msgId, selfBlankMsg || getMsg("inputEmail"));
} else if(!isEmail(val)) {
msg(msgId, selfInvalidMsg || "请输入正确的邮箱");
msg(msgId, selfInvalidMsg || getMsg("errorEmail"));
} else {
return val;
}
@ -716,7 +722,7 @@ function hideLoading() {
// 注销, 先清空cookie
function logout() {
$.removeCookie("LEANOTE_SESSION");
location.href = "/logout?id=1";
location.href = UrlPrefix + "/logout?id=1";
}
// 得到图片width, height, callback(ret); ret = {width:11, height:33}
@ -849,15 +855,295 @@ function restoreBookmark() {
}
// 是否是手机浏览器
var u = navigator.userAgent;
LEA.isMobile = /Mobile|Android|iPhone/i.test(u);
// var u = navigator.userAgent;
// LEA.isMobile = /Mobile|Android|iPhone/i.test(u);
// LEA.isMobile = u.indexOf('Android')>-1 || u.indexOf('Linux')>-1;
// LEA.isMobile = false;
//if($("body").width() < 600) {
// location.href = "/mobile/index";
//}
// 国际化 i18n
function getMsg(key) {
return MSG[key] || key;
}
// 表单验证
var vd = {
isInt: function(o) {
var intPattern=/^0$|^[1-9]\d*$/; //整数的正则表达式
result=intPattern.test(o);
return result;
},
isNumeric: function(o) {
return $.isNumeric(o);
},
isFloat: function(floatValue){
var floatPattern=/^0(\.\d+)?$|^[1-9]\d*(\.\d+)?$/; //小数的正则表达式
result=floatPattern.test(floatValue);
return result;
},
isEmail: function(emailValue){
var emailPattern=/^[^@.]+@([^@.]+\.)+[^@.]+$/; //邮箱的正则表达式
result=emailPattern.test(emailValue);
return result;
},
isBlank: function(o) {
return !$.trim(o);
},
has_special_chars: function(o) {
return /['"#$%&\^<>\?*]/.test(o);
},
// life
// 动态验证
// rules = {max: function() {}};
// <input data-rules='[{rule: 'requried', msg:"请填写标题"}]' data-msg_target="#msg"/>
init: function(form, rule_funcs) {
var get_val = function(target) {
if(target.is(":checkbox")) {
var name = target.attr('name');
var val = $('input[name="' + name + '"]:checked').length;
return val;
} else if(target.is(":radio")) {
} else {
return target.val();
}
}
var default_rule_funcs = {
// 必须输入
required: function(target) {
return get_val(target);
},
// 最少
min: function(target, rule) {
var val = get_val(target);
if(val === "" && !is_required(target)) {
return true;
}
if(val < rule.data) {
return false;
}
return true;
},
minLength: function(target, rule) {
var val = get_val(target);
if(val === "" && !is_required(target)) {
return true;
}
if(val.length < rule.data) {
return false;
}
return true;
},
email: function(target, rule) {
var val = get_val(target);
if(val === "" && !is_required(target)) {
return true;
}
return isEmail(val);
},
noSpecialChars: function(target) {
var val = get_val(target);
if(!val) {
return true;
}
if(/[^0-9a-zzA-Z_\-]/.test(val)) {
return false;
}
return true;
},
password: function(target, rule) {
var val = get_val(target);
if(val === "" && !is_required(target)) {
return true;
}
return val.length >= 6
},
equalTo: function(target, rule) {
var val = get_val(target);
if(val === "" && !is_required(target)) {
return true;
}
return $(rule.data).val() == val;
}
}
rule_funcs = rule_funcs || {};
rule_funcs = $.extend(default_rule_funcs, rule_funcs);
var rules = {}; // name对应的
var msg_targets = {};
// 是否是必须输入的
function is_required(target) {
var name = get_name(target);
var rules = get_rules(target, name);
var required_rule = rules[0];
if(required_rule['rule'] == "required") {
return true;
}
return false;
}
// 先根据msg_target_name, 再根据name
function get_rules(target, name) {
if(!rules[name]) {
rules[name] = eval("(" + target.data("rules") + ")");
}
return rules[name];
}
// 以name为索引, 如果多个input name一样, 但希望有不同的msg怎么办?
// 添加data-u_name=""
function get_msg_target(target, name) {
if(!msg_targets[name]) {
var t = target.data("msg_target");
if(!t) {
// 在其父下append一个
var msg_o = $('<div class="help-block alert alert-warning" style="display: block;"></div>');
target.parent().append(msg_o);
msg_targets[name] = msg_o;
} else {
msg_targets[name] = $(t);
}
}
return msg_targets[name];
}
function hide_msg(target, name) {
var msgT = get_msg_target(target, name);
// 之前是正确信息, 那么不隐藏
if(!msgT.hasClass("alert-success")) {
msgT.hide();
}
}
function show_msg(target, name, msg, msgData) {
var t = get_msg_target(target, name);
t.html(getMsg(msg, msgData)).removeClass("hide alert-success").addClass("alert-danger").show();
}
// 验证前修改
function pre_fix(target) {
var fix_name = target.data("pre_fix");
if(!fix_name) {
return;
}
switch(fix_name) {
case 'int': int_fix(target);
break;
case 'price': price_fix(target);
break;
case 'decimal': decimal_fix(target);
break;
}
}
// 验证各个rule
// 正确返回true
function apply_rules(target, name) {
var rules = get_rules(target, name);
// 是否有前置fix data-pre_fix
pre_fix(target);
if(!rules) {
return true;
}
for(var i = 0; i < rules.length; ++i) {
var rule = rules[i];
var rule_func_name = rule.rule;
var msg = rule.msg;
var msgData = rule.msgData;
if(!rule_funcs[rule_func_name](target, rule)) {
show_msg(target, name, msg, msgData);
return false;
}
}
hide_msg(target, name);
// 这里, 如果都正确, 是否有sufix验证其它的
var post_rule = target.data('post_rule');
if(post_rule) {
setTimeout(function() {
var post_target = $(post_rule);
apply_rules(post_target, get_name(post_target));
},0);
}
return true;
}
function focus_func(e) {
var target = $(e.target);
var name = get_name(target);
// 验证如果有错误, 先隐藏
hide_msg(target, name);
// key up的时候pre_fix
pre_fix(target);
}
function unfocus_func(e) {
var target = $(e.target);
var name = get_name(target);
// 验证各个rule
apply_rules(target, name);
}
// u_name是唯一名, msg, rule的索引
function get_name(target) {
return target.data('u_name') || target.attr("name") || target.attr("id");
}
var $allElems = $(form).find('[data-rules]');
var $form = $(form);
$form.on({
keyup: function(e) {
if(e.keyCode != 13) { // 不是enter
focus_func(e)
}
},
blur: unfocus_func,
}, 'input[type="text"], input[type="password"]');
$form.on({
change: function(e) {
if($(this).val()) {
focus_func(e);
} else {
unfocus_func(e);
}
}
}, 'select');
$form.on({
change: function(e) {
unfocus_func(e);
}
}, 'input[type="checkbox"]');
// 验证所有的
this.valid = function() {
var $ts = $allElems;
var is_valid = true;
for(var i = 0; i < $ts.length; ++i) {
var target = $ts.eq(i);
var name = get_name(target);
// 验证各个rule
if(!apply_rules(target, name)) {
is_valid = false;
target.focus();
return false
} else {
}
}
return is_valid;
}
// 验证某一元素(s)
// .num-in, #life
this.validElement = function(targets) {
var targets = $(targets);
var ok = true;
for(var i = 0; i < targets.length; ++i) {
var target = targets.eq(i);
var name = get_name(target);
// 验证各个rule
if(!apply_rules(target, name)) {
ok = false;
}
}
return ok;
}
}
};

File diff suppressed because one or more lines are too long

@ -7,7 +7,7 @@ LEA.cmroot = 1;
option = $.extend({ alias: cmroot, width: 150 }, option);
var ruleName = null, target = null,
groups = {}, mitems = {}, actions = {}, showGroups = [],
itemTpl = '<div class="b-m-$[type]" unselectable="on"><div class="clearfix"><div class="b-m-icon pull-left"><i class="fa $[faIcon]"></i>$[imgIcon]</div><div class="pull-left"><span class="c-text" unselectable="on">$[text]</span></div></div></div>';
itemTpl = '<div class="b-m-$[type]" unselectable="on"><div class="clearfix cm-item"><div class="b-m-icon pull-left"><i class="fa $[faIcon]"></i>$[imgIcon]</div><div class="pull-left cm-text"><span class="c-text" unselectable="on">$[text]</span></div></div></div>';
itemNoIconTpl = "<div class='b-m-$[type]' unselectable=on><nobr unselectable=on><span align='absmiddle'></span><span class='c-text' unselectable=on>$[text]</span></nobr></div>";
var gTemplet = $("<div/>").addClass("b-m-mpanel").attr("unselectable", "on").css("display", "none");
var iTemplet = $("<div/>").addClass("b-m-item").attr("unselectable", "on");

822
public/js/fastclick.js Normal file

@ -0,0 +1,822 @@
/**
* @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
*
* @version 1.0.3
* @codingstandard ftlabs-jsv2
* @copyright The Financial Times Limited [All Rights Reserved]
* @license MIT License (see LICENSE.txt)
*/
/*jslint browser:true, node:true*/
/*global define, Event, Node*/
/**
* Instantiate fast-clicking listeners on the specified layer.
*
* @constructor
* @param {Element} layer The layer to listen on
* @param {Object} options The options to override the defaults
*/
function FastClick(layer, options) {
'use strict';
var oldOnClick;
options = options || {};
/**
* Whether a click is currently being tracked.
*
* @type boolean
*/
this.trackingClick = false;
/**
* Timestamp for when click tracking started.
*
* @type number
*/
this.trackingClickStart = 0;
/**
* The element being tracked for a click.
*
* @type EventTarget
*/
this.targetElement = null;
/**
* X-coordinate of touch start event.
*
* @type number
*/
this.touchStartX = 0;
/**
* Y-coordinate of touch start event.
*
* @type number
*/
this.touchStartY = 0;
/**
* ID of the last touch, retrieved from Touch.identifier.
*
* @type number
*/
this.lastTouchIdentifier = 0;
/**
* Touchmove boundary, beyond which a click will be cancelled.
*
* @type number
*/
this.touchBoundary = options.touchBoundary || 10;
/**
* The FastClick layer.
*
* @type Element
*/
this.layer = layer;
/**
* The minimum time between tap(touchstart and touchend) events
*
* @type number
*/
this.tapDelay = options.tapDelay || 200;
if (FastClick.notNeeded(layer)) {
return;
}
// Some old versions of Android don't have Function.prototype.bind
function bind(method, context) {
return function() { return method.apply(context, arguments); };
}
var methods = ['onMouse', 'onClick', 'onTouchStart', 'onTouchMove', 'onTouchEnd', 'onTouchCancel'];
var context = this;
for (var i = 0, l = methods.length; i < l; i++) {
context[methods[i]] = bind(context[methods[i]], context);
}
// Set up event handlers as required
if (deviceIsAndroid) {
layer.addEventListener('mouseover', this.onMouse, true);
layer.addEventListener('mousedown', this.onMouse, true);
layer.addEventListener('mouseup', this.onMouse, true);
}
layer.addEventListener('click', this.onClick, true);
layer.addEventListener('touchstart', this.onTouchStart, false);
layer.addEventListener('touchmove', this.onTouchMove, false);
layer.addEventListener('touchend', this.onTouchEnd, false);
layer.addEventListener('touchcancel', this.onTouchCancel, false);
// Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
// which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
// layer when they are cancelled.
if (!Event.prototype.stopImmediatePropagation) {
layer.removeEventListener = function(type, callback, capture) {
var rmv = Node.prototype.removeEventListener;
if (type === 'click') {
rmv.call(layer, type, callback.hijacked || callback, capture);
} else {
rmv.call(layer, type, callback, capture);
}
};
layer.addEventListener = function(type, callback, capture) {
var adv = Node.prototype.addEventListener;
if (type === 'click') {
adv.call(layer, type, callback.hijacked || (callback.hijacked = function(event) {
if (!event.propagationStopped) {
callback(event);
}
}), capture);
} else {
adv.call(layer, type, callback, capture);
}
};
}
// If a handler is already declared in the element's onclick attribute, it will be fired before
// FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
// adding it as listener.
if (typeof layer.onclick === 'function') {
// Android browser on at least 3.2 requires a new reference to the function in layer.onclick
// - the old one won't work if passed to addEventListener directly.
oldOnClick = layer.onclick;
layer.addEventListener('click', function(event) {
oldOnClick(event);
}, false);
layer.onclick = null;
}
}
/**
* Android requires exceptions.
*
* @type boolean
*/
var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0;
/**
* iOS requires exceptions.
*
* @type boolean
*/
var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent);
/**
* iOS 4 requires an exception for select elements.
*
* @type boolean
*/
var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent);
/**
* iOS 6.0(+?) requires the target element to be manually derived
*
* @type boolean
*/
var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS ([6-9]|\d{2})_\d/).test(navigator.userAgent);
/**
* BlackBerry requires exceptions.
*
* @type boolean
*/
var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0;
/**
* Determine whether a given element requires a native click.
*
* @param {EventTarget|Element} target Target DOM element
* @returns {boolean} Returns true if the element needs a native click
*/
FastClick.prototype.needsClick = function(target) {
'use strict';
switch (target.nodeName.toLowerCase()) {
// Don't send a synthetic click to disabled inputs (issue #62)
case 'button':
case 'select':
case 'textarea':
if (target.disabled) {
return true;
}
break;
case 'input':
// File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
if ((deviceIsIOS && target.type === 'file') || target.disabled) {
return true;
}
break;
case 'label':
case 'video':
return true;
}
return (/\bneedsclick\b/).test(target.className);
};
/**
* Determine whether a given element requires a call to focus to simulate click into element.
*
* @param {EventTarget|Element} target Target DOM element
* @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
*/
FastClick.prototype.needsFocus = function(target) {
'use strict';
switch (target.nodeName.toLowerCase()) {
case 'textarea':
return true;
case 'select':
return !deviceIsAndroid;
case 'input':
switch (target.type) {
case 'button':
case 'checkbox':
case 'file':
case 'image':
case 'radio':
case 'submit':
return false;
}
// No point in attempting to focus disabled inputs
return !target.disabled && !target.readOnly;
default:
return (/\bneedsfocus\b/).test(target.className);
}
};
/**
* Send a click event to the specified element.
*
* @param {EventTarget|Element} targetElement
* @param {Event} event
*/
FastClick.prototype.sendClick = function(targetElement, event) {
'use strict';
var clickEvent, touch;
// On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
if (document.activeElement && document.activeElement !== targetElement) {
document.activeElement.blur();
// $("#editorContent_ifr").blur();
}
touch = event.changedTouches[0];
// Synthesise a click event, with an extra attribute so it can be tracked
clickEvent = document.createEvent('MouseEvents');
clickEvent.initMouseEvent(this.determineEventType(targetElement), true, true, window, 1, touch.screenX, touch.screenY, touch.clientX, touch.clientY, false, false, false, false, 0, null);
clickEvent.forwardedTouchEvent = true;
targetElement.dispatchEvent(clickEvent);
};
FastClick.prototype.determineEventType = function(targetElement) {
'use strict';
//Issue #159: Android Chrome Select Box does not open with a synthetic click event
if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
return 'mousedown';
}
return 'click';
};
/**
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.focus = function(targetElement) {
'use strict';
var length;
// Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
if (deviceIsIOS && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time') {
length = targetElement.value.length;
targetElement.setSelectionRange(length, length);
} else {
targetElement.focus();
}
};
/**
* Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
*
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.updateScrollParent = function(targetElement) {
'use strict';
var scrollParent, parentElement;
scrollParent = targetElement.fastClickScrollParent;
// Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
// target element was moved to another parent.
if (!scrollParent || !scrollParent.contains(targetElement)) {
parentElement = targetElement;
do {
if (parentElement.scrollHeight > parentElement.offsetHeight) {
scrollParent = parentElement;
targetElement.fastClickScrollParent = parentElement;
break;
}
parentElement = parentElement.parentElement;
} while (parentElement);
}
// Always update the scroll top tracker if possible.
if (scrollParent) {
scrollParent.fastClickLastScrollTop = scrollParent.scrollTop;
}
};
/**
* @param {EventTarget} targetElement
* @returns {Element|EventTarget}
*/
FastClick.prototype.getTargetElementFromEventTarget = function(eventTarget) {
'use strict';
// On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
if (eventTarget.nodeType === Node.TEXT_NODE) {
return eventTarget.parentNode;
}
return eventTarget;
};
/**
* On touch start, record the position and scroll offset.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchStart = function(event) {
'use strict';
var targetElement, touch, selection;
// Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
if (event.targetTouches.length > 1) {
return true;
}
targetElement = this.getTargetElementFromEventTarget(event.target);
touch = event.targetTouches[0];
if (deviceIsIOS) {
// Only trusted events will deselect text on iOS (issue #49)
selection = window.getSelection();
if (selection.rangeCount && !selection.isCollapsed) {
return true;
}
if (!deviceIsIOS4) {
// Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
// when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
// with the same identifier as the touch event that previously triggered the click that triggered the alert.
// Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
// immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
// Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
// which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
// random integers, it's safe to to continue if the identifier is 0 here.
if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
event.preventDefault();
return false;
}
this.lastTouchIdentifier = touch.identifier;
// If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
// 1) the user does a fling scroll on the scrollable layer
// 2) the user stops the fling scroll with another tap
// then the event.target of the last 'touchend' event will be the element that was under the user's finger
// when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
// is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
this.updateScrollParent(targetElement);
}
}
this.trackingClick = true;
this.trackingClickStart = event.timeStamp;
this.targetElement = targetElement;
this.touchStartX = touch.pageX;
this.touchStartY = touch.pageY;
// Prevent phantom clicks on fast double-tap (issue #36)
if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
event.preventDefault();
}
return true;
};
/**
* Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.touchHasMoved = function(event) {
'use strict';
var touch = event.changedTouches[0], boundary = this.touchBoundary;
if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
return true;
}
return false;
};
/**
* Update the last position.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchMove = function(event) {
'use strict';
if (!this.trackingClick) {
return true;
}
// If the touch has moved, cancel the click tracking
if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
this.trackingClick = false;
this.targetElement = null;
}
return true;
};
/**
* Attempt to find the labelled control for the given label element.
*
* @param {EventTarget|HTMLLabelElement} labelElement
* @returns {Element|null}
*/
FastClick.prototype.findControl = function(labelElement) {
'use strict';
// Fast path for newer browsers supporting the HTML5 control attribute
if (labelElement.control !== undefined) {
return labelElement.control;
}
// All browsers under test that support touch events also support the HTML5 htmlFor attribute
if (labelElement.htmlFor) {
return document.getElementById(labelElement.htmlFor);
}
// If no for attribute exists, attempt to retrieve the first labellable descendant element
// the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
return labelElement.querySelector('button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea');
};
/**
* On touch end, determine whether to send a click event at once.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onTouchEnd = function(event) {
'use strict';
var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement;
if (!this.trackingClick) {
return true;
}
// Prevent phantom clicks on fast double-tap (issue #36)
if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
this.cancelNextClick = true;
return true;
}
// Reset to prevent wrong click cancel on input (issue #156).
this.cancelNextClick = false;
this.lastClickTime = event.timeStamp;
trackingClickStart = this.trackingClickStart;
this.trackingClick = false;
this.trackingClickStart = 0;
// On some iOS devices, the targetElement supplied with the event is invalid if the layer
// is performing a transition or scroll, and has to be re-detected manually. Note that
// for this to function correctly, it must be called *after* the event target is checked!
// See issue #57; also filed as rdar://13048589 .
if (deviceIsIOSWithBadTarget) {
touch = event.changedTouches[0];
// In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) || targetElement;
targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent;
}
targetTagName = targetElement.tagName.toLowerCase();
if (targetTagName === 'label') {
forElement = this.findControl(targetElement);
if (forElement) {
this.focus(targetElement);
if (deviceIsAndroid) {
return false;
}
targetElement = forElement;
}
} else if (this.needsFocus(targetElement)) {
// Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
// Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
if ((event.timeStamp - trackingClickStart) > 100 || (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
this.targetElement = null;
return false;
}
this.focus(targetElement);
this.sendClick(targetElement, event);
// Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
// Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
if (!deviceIsIOS || targetTagName !== 'select') {
this.targetElement = null;
event.preventDefault();
}
return false;
}
if (deviceIsIOS && !deviceIsIOS4) {
// Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
// and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
scrollParent = targetElement.fastClickScrollParent;
if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
return true;
}
}
// Prevent the actual click from going though - unless the target node is marked as requiring
// real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
if (!this.needsClick(targetElement)) {
event.preventDefault();
this.sendClick(targetElement, event);
}
return false;
};
/**
* On touch cancel, stop tracking the click.
*
* @returns {void}
*/
FastClick.prototype.onTouchCancel = function() {
'use strict';
this.trackingClick = false;
this.targetElement = null;
};
/**
* Determine mouse events which should be permitted.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onMouse = function(event) {
'use strict';
// If a target element was never set (because a touch event was never fired) allow the event
if (!this.targetElement) {
return true;
}
if (event.forwardedTouchEvent) {
return true;
}
// Programmatically generated events targeting a specific element should be permitted
if (!event.cancelable) {
return true;
}
// Derive and check the target element to see whether the mouse event needs to be permitted;
// unless explicitly enabled, prevent non-touch click events from triggering actions,
// to prevent ghost/doubleclicks.
if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
// Prevent any user-added listeners declared on FastClick element from being fired.
if (event.stopImmediatePropagation) {
event.stopImmediatePropagation();
} else {
// Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
event.propagationStopped = true;
}
// Cancel the event
event.stopPropagation();
event.preventDefault();
return false;
}
// If the mouse event is permitted, return true for the action to go through.
return true;
};
/**
* On actual clicks, determine whether this is a touch-generated click, a click action occurring
* naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
* an actual click which should be permitted.
*
* @param {Event} event
* @returns {boolean}
*/
FastClick.prototype.onClick = function(event) {
'use strict';
var permitted;
// It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
if (this.trackingClick) {
this.targetElement = null;
this.trackingClick = false;
return true;
}
// Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
if (event.target.type === 'submit' && event.detail === 0) {
return true;
}
permitted = this.onMouse(event);
// Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
if (!permitted) {
this.targetElement = null;
}
// If clicks are permitted, return true for the action to go through.
return permitted;
};
/**
* Remove all FastClick's event listeners.
*
* @returns {void}
*/
FastClick.prototype.destroy = function() {
'use strict';
var layer = this.layer;
if (deviceIsAndroid) {
layer.removeEventListener('mouseover', this.onMouse, true);
layer.removeEventListener('mousedown', this.onMouse, true);
layer.removeEventListener('mouseup', this.onMouse, true);
}
layer.removeEventListener('click', this.onClick, true);
layer.removeEventListener('touchstart', this.onTouchStart, false);
layer.removeEventListener('touchmove', this.onTouchMove, false);
layer.removeEventListener('touchend', this.onTouchEnd, false);
layer.removeEventListener('touchcancel', this.onTouchCancel, false);
};
/**
* Check whether FastClick is needed.
*
* @param {Element} layer The layer to listen on
*/
FastClick.notNeeded = function(layer) {
'use strict';
var metaViewport;
var chromeVersion;
var blackberryVersion;
// Devices that don't support touch don't need FastClick
if (typeof window.ontouchstart === 'undefined') {
return true;
}
// Chrome version - zero for other browsers
chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) || [,0])[1];
if (chromeVersion) {
if (deviceIsAndroid) {
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport) {
// Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
return true;
}
// Chrome 32 and above with width=device-width or less don't need FastClick
if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
return true;
}
}
// Chrome desktop doesn't need FastClick (issue #15)
} else {
return true;
}
}
if (deviceIsBlackBerry10) {
blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/);
// BlackBerry 10.3+ does not require Fastclick library.
// https://github.com/ftlabs/fastclick/issues/251
if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
metaViewport = document.querySelector('meta[name=viewport]');
if (metaViewport) {
// user-scalable=no eliminates click delay.
if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
return true;
}
// width=device-width (or less than device-width) eliminates click delay.
if (document.documentElement.scrollWidth <= window.outerWidth) {
return true;
}
}
}
}
// IE10 with -ms-touch-action: none, which disables double-tap-to-zoom (issue #97)
if (layer.style.msTouchAction === 'none') {
return true;
}
return false;
};
/**
* Factory method for creating a FastClick object
*
* @param {Element} layer The layer to listen on
* @param {Object} options The options to override the defaults
*/
FastClick.attach = function(layer, options) {
'use strict';
return new FastClick(layer, options);
};
if (typeof define == 'function' && typeof define.amd == 'object' && define.amd) {
// AMD. Register as an anonymous module.
define(function() {
'use strict';
return FastClick;
});
} else if (typeof module !== 'undefined' && module.exports) {
module.exports = FastClick.attach;
module.exports.FastClick = FastClick;
} else {
window.FastClick = FastClick;
}

16
public/js/i18n/blog.en.js Normal file

@ -0,0 +1,16 @@
var MSG = {"a":"a","aboutMe":"About me","author":"Author","baseInfoSet":"Base info","blog":"Blog","blogClass":"Classification","blogDesc":"Description","blogLogo":"Logo","blogLogoTips":"Upload image to replace blog title","blogName":"Title","blogNav":"Blog nav","blogNavs":"Navs","blogSet":"Set blog","cancel":"Cancel","chooseReason":"请选择举报理由","comment":"Comment","commentSet":"Comment","commentSys":"leanote use \u003ca href=\"http://disqus.com\" target=\"_blank\"\u003eDisqus\u003c/a\u003e as comment system","comments":"Comments","community":"Community","confirm":"Confirm","confirmDeleteComment":"Are you sure?","createdTime":"Created at","daysAgo":"days ago","delete":"Delete","disqusHelp":"Please input your Disqus Id or use \"leanote\"","elegant":"Elegant","error":"Error","fullBlog":"Full blog","home":"Home","hoursAgo":"hours ago","justNow":"Just now","latestPosts":"Latest posts","like":"Like","minutesAgo":"minutes ago","monthsAgo":"months ago","moreShare":"More","navFixed":"Nav fixed at left side","needHelp":"Need help?","noBlog":"No blog","noTag":"No tag","none":"None","openComment":"Open comment?","other":"Other","qqZone":"QQ Zone","quickLinks":"Quick links","renren":"Renren","reply":"Reply","report":"Report","reportBlog?":"举报该博客?","reportComment?":"举报该评论?","reportReason":"Reason","reportReason1":"不友善内容","reportReason2":"广告等垃圾信息","reportReason3":"违法违规内容","reportReason4":"不宜公开讨论的政治内容","reportSuccess":"举报成功, 我们处理后会通知作者, 感谢您的监督","saveSuccess":"Save success","scanQRCode":"Open weichat and scan the QR code","signIn":"Sign In","signUp":"Sign Up","sinaWeibo":"Weibo","submitComment":"Submit","tencentWeibo":"Tencent Weibo","theme":"Theme","themeSet":"Theme","unlike":"Unlike","updatedTime":"Updated at","viewers":"Viewers","weeksAgo":"weeks ago","weixin":"Weichat"};
function getMsg(key, data) {
var msg = MSG[key]
if(msg) {
if(data) {
if(!isArray(data)) {
data = [data];
}
for(var i = 0; i < data.length; ++i) {
msg = msg.replace("%s", data[i]);
}
}
return msg;
}
return key;
}

16
public/js/i18n/blog.zh.js Normal file

@ -0,0 +1,16 @@
var MSG = {"a":"a","aboutMe":"关于我","author":"作者","baseInfoSet":"基本设置","blog":"博客","blogClass":"分类","blogDesc":"博客描述","blogLogo":"博客Logo","blogLogoTips":"上传logo将显示logo(替代博客标题)","blogName":"博客标题","blogNav":"导航","blogNavs":"导航","blogSet":"博客设置","cancel":"取消","chooseReason":"请选择举报理由","comment":"评论","commentSet":"评论设置","commentSys":"leanote 使用 \u003ca href=\"http://disqus.com\" target=\"_blank\"\u003eDisqus\u003c/a\u003e 作为评论系统","comments":"条评论","community":"社区","confirm":"确认","confirmDeleteComment":"确定删除该评论?","createdTime":"创建","daysAgo":"天前","delete":"删除","disqusHelp":"请填写您申请的Disqus唯一url前缀. 建议您申请Disqus帐号, 这样可以自己管理评论. 或使用leanote的默认Disqus Id. ","elegant":"大气","error":"错误","fullBlog":"全文","home":"主页","hoursAgo":"个小时前","justNow":"刚刚","latestPosts":"最近发表","like":"赞","minutesAgo":"分钟前","monthsAgo":"个月前","moreShare":"更多分享","navFixed":"导航左侧固定","needHelp":"需要帮助?","noBlog":"无博客","noTag":"无","none":"无","openComment":"开启评论?","other":"其它","qqZone":"QQ空间","quickLinks":"快速链接","renren":"人人网","reply":"回复","report":"举报","reportBlog?":"举报该博客?","reportComment?":"举报该评论?","reportReason":"举报理由","reportReason1":"不友善内容","reportReason2":"广告等垃圾信息","reportReason3":"违法违规内容","reportReason4":"不宜公开讨论的政治内容","reportSuccess":"举报成功, 我们处理后会通知作者, 感谢您的监督","saveSuccess":"保存成功","scanQRCode":"打开微信扫一扫二维码","signIn":"登录","signUp":"注册","sinaWeibo":"新浪微博","submitComment":"发表评论","tencentWeibo":"腾讯微博","theme":"主题","themeSet":"主题设置","unlike":"取消赞","updatedTime":"更新","viewers":"人读过","weeksAgo":"周前","weixin":"微信"};
function getMsg(key, data) {
var msg = MSG[key]
if(msg) {
if(data) {
if(!isArray(data)) {
data = [data];
}
for(var i = 0; i < data.length; ++i) {
msg = msg.replace("%s", data[i]);
}
}
return msg;
}
return key;
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

@ -1 +1 @@
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery"],factory)}else{factory(jQuery)}})(function($){var pluses=/\+/g;function encode(s){return config.raw?s:encodeURIComponent(s)}function decode(s){return config.raw?s:decodeURIComponent(s)}function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value))}function parseCookieValue(s){if(s.indexOf('"')===0){s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}try{s=decodeURIComponent(s.replace(pluses," "));return config.json?JSON.parse(s):s}catch(e){}}function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value}var config=$.cookie=function(key,value,options){if(value!==undefined&&!$.isFunction(value)){options=$.extend({},config.defaults,options);if(typeof options.expires==="number"){var days=options.expires,t=options.expires=new Date;t.setTime(+t+days*864e5)}return document.cookie=[encode(key),"=",stringifyCookieValue(value),options.expires?"; expires="+options.expires.toUTCString():"",options.path?"; path="+options.path:"",options.domain?"; domain="+options.domain:"",options.secure?"; secure":""].join("")}var result=key?undefined:{};var cookies=document.cookie?document.cookie.split("; "):[];for(var i=0,l=cookies.length;i<l;i++){var parts=cookies[i].split("=");var name=decode(parts.shift());var cookie=parts.join("=");if(key&&key===name){result=read(cookie,value);break}if(!key&&(cookie=read(cookie))!==undefined){result[name]=cookie}}return result};config.defaults={};$.removeCookie=function(key,options){if($.cookie(key)===undefined){return false}$.cookie(key,"",$.extend({},options,{expires:-1}));return!$.cookie(key)}});
(function(factory){factory(jQuery)})(function($){var pluses=/\+/g;function encode(s){return config.raw?s:encodeURIComponent(s)}function decode(s){return config.raw?s:decodeURIComponent(s)}function stringifyCookieValue(value){return encode(config.json?JSON.stringify(value):String(value))}function parseCookieValue(s){if(s.indexOf('"')===0){s=s.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")}try{s=decodeURIComponent(s.replace(pluses," "));return config.json?JSON.parse(s):s}catch(e){}}function read(s,converter){var value=config.raw?s:parseCookieValue(s);return $.isFunction(converter)?converter(value):value}var config=$.cookie=function(key,value,options){if(value!==undefined&&!$.isFunction(value)){options=$.extend({},config.defaults,options);if(typeof options.expires==="number"){var days=options.expires,t=options.expires=new Date;t.setTime(+t+days*864e5)}return document.cookie=[encode(key),"=",stringifyCookieValue(value),options.expires?"; expires="+options.expires.toUTCString():"",options.path?"; path="+options.path:"",options.domain?"; domain="+options.domain:"",options.secure?"; secure":""].join("")}var result=key?undefined:{};var cookies=document.cookie?document.cookie.split("; "):[];for(var i=0,l=cookies.length;i<l;i++){var parts=cookies[i].split("=");var name=decode(parts.shift());var cookie=parts.join("=");if(key&&key===name){result=read(cookie,value);break}if(!key&&(cookie=read(cookie))!==undefined){result[name]=cookie}}return result};config.defaults={};$.removeCookie=function(key,options){if($.cookie(key)===undefined){return false}$.cookie(key,"",$.extend({},options,{expires:-1}));return!$.cookie(key)}});

@ -6,13 +6,8 @@
* Released under the MIT license
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as anonymous module.
define(['jquery'], factory);
} else {
// Browser globals.
factory(jQuery);
}
// Browser globals.
factory(jQuery);
}(function ($) {
var pluses = /\+/g;

10
public/js/jquery.mobile-1.4.4.min.js vendored Normal file

File diff suppressed because one or more lines are too long

28
public/js/jquery.qrcode.min.js vendored Normal file

@ -0,0 +1,28 @@
(function(r){r.fn.qrcode=function(h){var s;function u(a){this.mode=s;this.data=a}function o(a,c){this.typeNumber=a;this.errorCorrectLevel=c;this.modules=null;this.moduleCount=0;this.dataCache=null;this.dataList=[]}function q(a,c){if(void 0==a.length)throw Error(a.length+"/"+c);for(var d=0;d<a.length&&0==a[d];)d++;this.num=Array(a.length-d+c);for(var b=0;b<a.length-d;b++)this.num[b]=a[b+d]}function p(a,c){this.totalCount=a;this.dataCount=c}function t(){this.buffer=[];this.length=0}u.prototype={getLength:function(){return this.data.length},
write:function(a){for(var c=0;c<this.data.length;c++)a.put(this.data.charCodeAt(c),8)}};o.prototype={addData:function(a){this.dataList.push(new u(a));this.dataCache=null},isDark:function(a,c){if(0>a||this.moduleCount<=a||0>c||this.moduleCount<=c)throw Error(a+","+c);return this.modules[a][c]},getModuleCount:function(){return this.moduleCount},make:function(){if(1>this.typeNumber){for(var a=1,a=1;40>a;a++){for(var c=p.getRSBlocks(a,this.errorCorrectLevel),d=new t,b=0,e=0;e<c.length;e++)b+=c[e].dataCount;
for(e=0;e<this.dataList.length;e++)c=this.dataList[e],d.put(c.mode,4),d.put(c.getLength(),j.getLengthInBits(c.mode,a)),c.write(d);if(d.getLengthInBits()<=8*b)break}this.typeNumber=a}this.makeImpl(!1,this.getBestMaskPattern())},makeImpl:function(a,c){this.moduleCount=4*this.typeNumber+17;this.modules=Array(this.moduleCount);for(var d=0;d<this.moduleCount;d++){this.modules[d]=Array(this.moduleCount);for(var b=0;b<this.moduleCount;b++)this.modules[d][b]=null}this.setupPositionProbePattern(0,0);this.setupPositionProbePattern(this.moduleCount-
7,0);this.setupPositionProbePattern(0,this.moduleCount-7);this.setupPositionAdjustPattern();this.setupTimingPattern();this.setupTypeInfo(a,c);7<=this.typeNumber&&this.setupTypeNumber(a);null==this.dataCache&&(this.dataCache=o.createData(this.typeNumber,this.errorCorrectLevel,this.dataList));this.mapData(this.dataCache,c)},setupPositionProbePattern:function(a,c){for(var d=-1;7>=d;d++)if(!(-1>=a+d||this.moduleCount<=a+d))for(var b=-1;7>=b;b++)-1>=c+b||this.moduleCount<=c+b||(this.modules[a+d][c+b]=
0<=d&&6>=d&&(0==b||6==b)||0<=b&&6>=b&&(0==d||6==d)||2<=d&&4>=d&&2<=b&&4>=b?!0:!1)},getBestMaskPattern:function(){for(var a=0,c=0,d=0;8>d;d++){this.makeImpl(!0,d);var b=j.getLostPoint(this);if(0==d||a>b)a=b,c=d}return c},createMovieClip:function(a,c,d){a=a.createEmptyMovieClip(c,d);this.make();for(c=0;c<this.modules.length;c++)for(var d=1*c,b=0;b<this.modules[c].length;b++){var e=1*b;this.modules[c][b]&&(a.beginFill(0,100),a.moveTo(e,d),a.lineTo(e+1,d),a.lineTo(e+1,d+1),a.lineTo(e,d+1),a.endFill())}return a},
setupTimingPattern:function(){for(var a=8;a<this.moduleCount-8;a++)null==this.modules[a][6]&&(this.modules[a][6]=0==a%2);for(a=8;a<this.moduleCount-8;a++)null==this.modules[6][a]&&(this.modules[6][a]=0==a%2)},setupPositionAdjustPattern:function(){for(var a=j.getPatternPosition(this.typeNumber),c=0;c<a.length;c++)for(var d=0;d<a.length;d++){var b=a[c],e=a[d];if(null==this.modules[b][e])for(var f=-2;2>=f;f++)for(var i=-2;2>=i;i++)this.modules[b+f][e+i]=-2==f||2==f||-2==i||2==i||0==f&&0==i?!0:!1}},setupTypeNumber:function(a){for(var c=
j.getBCHTypeNumber(this.typeNumber),d=0;18>d;d++){var b=!a&&1==(c>>d&1);this.modules[Math.floor(d/3)][d%3+this.moduleCount-8-3]=b}for(d=0;18>d;d++)b=!a&&1==(c>>d&1),this.modules[d%3+this.moduleCount-8-3][Math.floor(d/3)]=b},setupTypeInfo:function(a,c){for(var d=j.getBCHTypeInfo(this.errorCorrectLevel<<3|c),b=0;15>b;b++){var e=!a&&1==(d>>b&1);6>b?this.modules[b][8]=e:8>b?this.modules[b+1][8]=e:this.modules[this.moduleCount-15+b][8]=e}for(b=0;15>b;b++)e=!a&&1==(d>>b&1),8>b?this.modules[8][this.moduleCount-
b-1]=e:9>b?this.modules[8][15-b-1+1]=e:this.modules[8][15-b-1]=e;this.modules[this.moduleCount-8][8]=!a},mapData:function(a,c){for(var d=-1,b=this.moduleCount-1,e=7,f=0,i=this.moduleCount-1;0<i;i-=2)for(6==i&&i--;;){for(var g=0;2>g;g++)if(null==this.modules[b][i-g]){var n=!1;f<a.length&&(n=1==(a[f]>>>e&1));j.getMask(c,b,i-g)&&(n=!n);this.modules[b][i-g]=n;e--; -1==e&&(f++,e=7)}b+=d;if(0>b||this.moduleCount<=b){b-=d;d=-d;break}}}};o.PAD0=236;o.PAD1=17;o.createData=function(a,c,d){for(var c=p.getRSBlocks(a,
c),b=new t,e=0;e<d.length;e++){var f=d[e];b.put(f.mode,4);b.put(f.getLength(),j.getLengthInBits(f.mode,a));f.write(b)}for(e=a=0;e<c.length;e++)a+=c[e].dataCount;if(b.getLengthInBits()>8*a)throw Error("code length overflow. ("+b.getLengthInBits()+">"+8*a+")");for(b.getLengthInBits()+4<=8*a&&b.put(0,4);0!=b.getLengthInBits()%8;)b.putBit(!1);for(;!(b.getLengthInBits()>=8*a);){b.put(o.PAD0,8);if(b.getLengthInBits()>=8*a)break;b.put(o.PAD1,8)}return o.createBytes(b,c)};o.createBytes=function(a,c){for(var d=
0,b=0,e=0,f=Array(c.length),i=Array(c.length),g=0;g<c.length;g++){var n=c[g].dataCount,h=c[g].totalCount-n,b=Math.max(b,n),e=Math.max(e,h);f[g]=Array(n);for(var k=0;k<f[g].length;k++)f[g][k]=255&a.buffer[k+d];d+=n;k=j.getErrorCorrectPolynomial(h);n=(new q(f[g],k.getLength()-1)).mod(k);i[g]=Array(k.getLength()-1);for(k=0;k<i[g].length;k++)h=k+n.getLength()-i[g].length,i[g][k]=0<=h?n.get(h):0}for(k=g=0;k<c.length;k++)g+=c[k].totalCount;d=Array(g);for(k=n=0;k<b;k++)for(g=0;g<c.length;g++)k<f[g].length&&
(d[n++]=f[g][k]);for(k=0;k<e;k++)for(g=0;g<c.length;g++)k<i[g].length&&(d[n++]=i[g][k]);return d};s=4;for(var j={PATTERN_POSITION_TABLE:[[],[6,18],[6,22],[6,26],[6,30],[6,34],[6,22,38],[6,24,42],[6,26,46],[6,28,50],[6,30,54],[6,32,58],[6,34,62],[6,26,46,66],[6,26,48,70],[6,26,50,74],[6,30,54,78],[6,30,56,82],[6,30,58,86],[6,34,62,90],[6,28,50,72,94],[6,26,50,74,98],[6,30,54,78,102],[6,28,54,80,106],[6,32,58,84,110],[6,30,58,86,114],[6,34,62,90,118],[6,26,50,74,98,122],[6,30,54,78,102,126],[6,26,52,
78,104,130],[6,30,56,82,108,134],[6,34,60,86,112,138],[6,30,58,86,114,142],[6,34,62,90,118,146],[6,30,54,78,102,126,150],[6,24,50,76,102,128,154],[6,28,54,80,106,132,158],[6,32,58,84,110,136,162],[6,26,54,82,110,138,166],[6,30,58,86,114,142,170]],G15:1335,G18:7973,G15_MASK:21522,getBCHTypeInfo:function(a){for(var c=a<<10;0<=j.getBCHDigit(c)-j.getBCHDigit(j.G15);)c^=j.G15<<j.getBCHDigit(c)-j.getBCHDigit(j.G15);return(a<<10|c)^j.G15_MASK},getBCHTypeNumber:function(a){for(var c=a<<12;0<=j.getBCHDigit(c)-
j.getBCHDigit(j.G18);)c^=j.G18<<j.getBCHDigit(c)-j.getBCHDigit(j.G18);return a<<12|c},getBCHDigit:function(a){for(var c=0;0!=a;)c++,a>>>=1;return c},getPatternPosition:function(a){return j.PATTERN_POSITION_TABLE[a-1]},getMask:function(a,c,d){switch(a){case 0:return 0==(c+d)%2;case 1:return 0==c%2;case 2:return 0==d%3;case 3:return 0==(c+d)%3;case 4:return 0==(Math.floor(c/2)+Math.floor(d/3))%2;case 5:return 0==c*d%2+c*d%3;case 6:return 0==(c*d%2+c*d%3)%2;case 7:return 0==(c*d%3+(c+d)%2)%2;default:throw Error("bad maskPattern:"+
a);}},getErrorCorrectPolynomial:function(a){for(var c=new q([1],0),d=0;d<a;d++)c=c.multiply(new q([1,l.gexp(d)],0));return c},getLengthInBits:function(a,c){if(1<=c&&10>c)switch(a){case 1:return 10;case 2:return 9;case s:return 8;case 8:return 8;default:throw Error("mode:"+a);}else if(27>c)switch(a){case 1:return 12;case 2:return 11;case s:return 16;case 8:return 10;default:throw Error("mode:"+a);}else if(41>c)switch(a){case 1:return 14;case 2:return 13;case s:return 16;case 8:return 12;default:throw Error("mode:"+
a);}else throw Error("type:"+c);},getLostPoint:function(a){for(var c=a.getModuleCount(),d=0,b=0;b<c;b++)for(var e=0;e<c;e++){for(var f=0,i=a.isDark(b,e),g=-1;1>=g;g++)if(!(0>b+g||c<=b+g))for(var h=-1;1>=h;h++)0>e+h||c<=e+h||0==g&&0==h||i==a.isDark(b+g,e+h)&&f++;5<f&&(d+=3+f-5)}for(b=0;b<c-1;b++)for(e=0;e<c-1;e++)if(f=0,a.isDark(b,e)&&f++,a.isDark(b+1,e)&&f++,a.isDark(b,e+1)&&f++,a.isDark(b+1,e+1)&&f++,0==f||4==f)d+=3;for(b=0;b<c;b++)for(e=0;e<c-6;e++)a.isDark(b,e)&&!a.isDark(b,e+1)&&a.isDark(b,e+
2)&&a.isDark(b,e+3)&&a.isDark(b,e+4)&&!a.isDark(b,e+5)&&a.isDark(b,e+6)&&(d+=40);for(e=0;e<c;e++)for(b=0;b<c-6;b++)a.isDark(b,e)&&!a.isDark(b+1,e)&&a.isDark(b+2,e)&&a.isDark(b+3,e)&&a.isDark(b+4,e)&&!a.isDark(b+5,e)&&a.isDark(b+6,e)&&(d+=40);for(e=f=0;e<c;e++)for(b=0;b<c;b++)a.isDark(b,e)&&f++;a=Math.abs(100*f/c/c-50)/5;return d+10*a}},l={glog:function(a){if(1>a)throw Error("glog("+a+")");return l.LOG_TABLE[a]},gexp:function(a){for(;0>a;)a+=255;for(;256<=a;)a-=255;return l.EXP_TABLE[a]},EXP_TABLE:Array(256),
LOG_TABLE:Array(256)},m=0;8>m;m++)l.EXP_TABLE[m]=1<<m;for(m=8;256>m;m++)l.EXP_TABLE[m]=l.EXP_TABLE[m-4]^l.EXP_TABLE[m-5]^l.EXP_TABLE[m-6]^l.EXP_TABLE[m-8];for(m=0;255>m;m++)l.LOG_TABLE[l.EXP_TABLE[m]]=m;q.prototype={get:function(a){return this.num[a]},getLength:function(){return this.num.length},multiply:function(a){for(var c=Array(this.getLength()+a.getLength()-1),d=0;d<this.getLength();d++)for(var b=0;b<a.getLength();b++)c[d+b]^=l.gexp(l.glog(this.get(d))+l.glog(a.get(b)));return new q(c,0)},mod:function(a){if(0>
this.getLength()-a.getLength())return this;for(var c=l.glog(this.get(0))-l.glog(a.get(0)),d=Array(this.getLength()),b=0;b<this.getLength();b++)d[b]=this.get(b);for(b=0;b<a.getLength();b++)d[b]^=l.gexp(l.glog(a.get(b))+c);return(new q(d,0)).mod(a)}};p.RS_BLOCK_TABLE=[[1,26,19],[1,26,16],[1,26,13],[1,26,9],[1,44,34],[1,44,28],[1,44,22],[1,44,16],[1,70,55],[1,70,44],[2,35,17],[2,35,13],[1,100,80],[2,50,32],[2,50,24],[4,25,9],[1,134,108],[2,67,43],[2,33,15,2,34,16],[2,33,11,2,34,12],[2,86,68],[4,43,27],
[4,43,19],[4,43,15],[2,98,78],[4,49,31],[2,32,14,4,33,15],[4,39,13,1,40,14],[2,121,97],[2,60,38,2,61,39],[4,40,18,2,41,19],[4,40,14,2,41,15],[2,146,116],[3,58,36,2,59,37],[4,36,16,4,37,17],[4,36,12,4,37,13],[2,86,68,2,87,69],[4,69,43,1,70,44],[6,43,19,2,44,20],[6,43,15,2,44,16],[4,101,81],[1,80,50,4,81,51],[4,50,22,4,51,23],[3,36,12,8,37,13],[2,116,92,2,117,93],[6,58,36,2,59,37],[4,46,20,6,47,21],[7,42,14,4,43,15],[4,133,107],[8,59,37,1,60,38],[8,44,20,4,45,21],[12,33,11,4,34,12],[3,145,115,1,146,
116],[4,64,40,5,65,41],[11,36,16,5,37,17],[11,36,12,5,37,13],[5,109,87,1,110,88],[5,65,41,5,66,42],[5,54,24,7,55,25],[11,36,12],[5,122,98,1,123,99],[7,73,45,3,74,46],[15,43,19,2,44,20],[3,45,15,13,46,16],[1,135,107,5,136,108],[10,74,46,1,75,47],[1,50,22,15,51,23],[2,42,14,17,43,15],[5,150,120,1,151,121],[9,69,43,4,70,44],[17,50,22,1,51,23],[2,42,14,19,43,15],[3,141,113,4,142,114],[3,70,44,11,71,45],[17,47,21,4,48,22],[9,39,13,16,40,14],[3,135,107,5,136,108],[3,67,41,13,68,42],[15,54,24,5,55,25],[15,
43,15,10,44,16],[4,144,116,4,145,117],[17,68,42],[17,50,22,6,51,23],[19,46,16,6,47,17],[2,139,111,7,140,112],[17,74,46],[7,54,24,16,55,25],[34,37,13],[4,151,121,5,152,122],[4,75,47,14,76,48],[11,54,24,14,55,25],[16,45,15,14,46,16],[6,147,117,4,148,118],[6,73,45,14,74,46],[11,54,24,16,55,25],[30,46,16,2,47,17],[8,132,106,4,133,107],[8,75,47,13,76,48],[7,54,24,22,55,25],[22,45,15,13,46,16],[10,142,114,2,143,115],[19,74,46,4,75,47],[28,50,22,6,51,23],[33,46,16,4,47,17],[8,152,122,4,153,123],[22,73,45,
3,74,46],[8,53,23,26,54,24],[12,45,15,28,46,16],[3,147,117,10,148,118],[3,73,45,23,74,46],[4,54,24,31,55,25],[11,45,15,31,46,16],[7,146,116,7,147,117],[21,73,45,7,74,46],[1,53,23,37,54,24],[19,45,15,26,46,16],[5,145,115,10,146,116],[19,75,47,10,76,48],[15,54,24,25,55,25],[23,45,15,25,46,16],[13,145,115,3,146,116],[2,74,46,29,75,47],[42,54,24,1,55,25],[23,45,15,28,46,16],[17,145,115],[10,74,46,23,75,47],[10,54,24,35,55,25],[19,45,15,35,46,16],[17,145,115,1,146,116],[14,74,46,21,75,47],[29,54,24,19,
55,25],[11,45,15,46,46,16],[13,145,115,6,146,116],[14,74,46,23,75,47],[44,54,24,7,55,25],[59,46,16,1,47,17],[12,151,121,7,152,122],[12,75,47,26,76,48],[39,54,24,14,55,25],[22,45,15,41,46,16],[6,151,121,14,152,122],[6,75,47,34,76,48],[46,54,24,10,55,25],[2,45,15,64,46,16],[17,152,122,4,153,123],[29,74,46,14,75,47],[49,54,24,10,55,25],[24,45,15,46,46,16],[4,152,122,18,153,123],[13,74,46,32,75,47],[48,54,24,14,55,25],[42,45,15,32,46,16],[20,147,117,4,148,118],[40,75,47,7,76,48],[43,54,24,22,55,25],[10,
45,15,67,46,16],[19,148,118,6,149,119],[18,75,47,31,76,48],[34,54,24,34,55,25],[20,45,15,61,46,16]];p.getRSBlocks=function(a,c){var d=p.getRsBlockTable(a,c);if(void 0==d)throw Error("bad rs block @ typeNumber:"+a+"/errorCorrectLevel:"+c);for(var b=d.length/3,e=[],f=0;f<b;f++)for(var h=d[3*f+0],g=d[3*f+1],j=d[3*f+2],l=0;l<h;l++)e.push(new p(g,j));return e};p.getRsBlockTable=function(a,c){switch(c){case 1:return p.RS_BLOCK_TABLE[4*(a-1)+0];case 0:return p.RS_BLOCK_TABLE[4*(a-1)+1];case 3:return p.RS_BLOCK_TABLE[4*
(a-1)+2];case 2:return p.RS_BLOCK_TABLE[4*(a-1)+3]}};t.prototype={get:function(a){return 1==(this.buffer[Math.floor(a/8)]>>>7-a%8&1)},put:function(a,c){for(var d=0;d<c;d++)this.putBit(1==(a>>>c-d-1&1))},getLengthInBits:function(){return this.length},putBit:function(a){var c=Math.floor(this.length/8);this.buffer.length<=c&&this.buffer.push(0);a&&(this.buffer[c]|=128>>>this.length%8);this.length++}};"string"===typeof h&&(h={text:h});h=r.extend({},{render:"canvas",width:256,height:256,typeNumber:-1,
correctLevel:2,background:"#ffffff",foreground:"#000000"},h);return this.each(function(){var a;if("canvas"==h.render){a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();var c=document.createElement("canvas");c.width=h.width;c.height=h.height;for(var d=c.getContext("2d"),b=h.width/a.getModuleCount(),e=h.height/a.getModuleCount(),f=0;f<a.getModuleCount();f++)for(var i=0;i<a.getModuleCount();i++){d.fillStyle=a.isDark(f,i)?h.foreground:h.background;var g=Math.ceil((i+1)*b)-Math.floor(i*b),
j=Math.ceil((f+1)*b)-Math.floor(f*b);d.fillRect(Math.round(i*b),Math.round(f*e),g,j)}}else{a=new o(h.typeNumber,h.correctLevel);a.addData(h.text);a.make();c=r("<table></table>").css("width",h.width+"px").css("height",h.height+"px").css("border","0px").css("border-collapse","collapse").css("background-color",h.background);d=h.width/a.getModuleCount();b=h.height/a.getModuleCount();for(e=0;e<a.getModuleCount();e++){f=r("<tr></tr>").css("height",b+"px").appendTo(c);for(i=0;i<a.getModuleCount();i++)r("<td></td>").css("width",
d+"px").css("background-color",a.isDark(e,i)?h.foreground:h.background).appendTo(f)}}a=c;jQuery(a).appendTo(this)})}})(jQuery);

1626
public/js/jsrender.js Normal file

File diff suppressed because it is too large Load Diff

1
public/js/main-min.js vendored Normal file

@ -0,0 +1 @@
require.config({baseUrl:"/public",paths:{tinymce:"tinymce/tinymce","jquery.slimscroll":"js/jQuery-slimScroll-1.3.0/jquery.slimscroll",contextmenu:"js/contextmenu/jquery.contextmenu","jquery.cookie":"js/jquery-cookie",page:"js/app/page",note:"js/app/note",notebook:"js/app/notebook",tag:"js/app/tag",share:"js/app/share",objectId:"js/object_id-min",ZeroClipboard:"js/ZeroClipboard/ZeroClipboard-min",bootstrap:"js/bootstrap-min",leanote:"js/main",leaui_image:"tinymce/plugins/leaui_image/public/js/for_editor",attachment_upload:"js/app/attachment_upload","jquery.ui.widget":"tinymce/plugins/leaui_image/public/js/jquery.ui.widget",fileupload:"/tinymce/plugins/leaui_image/public/js/jquery.fileupload","iframe-transport":"/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport","Markdown.Converter":"mdeditor/editor/pagedown/Markdown.Converter-min","Markdown.Sanitizer":"mdeditor/editor/pagedown/Markdown.Sanitizer-min","Markdown.Editor":"mdeditor/editor/pagedown/Markdown.Editor","Markdown.zh":"mdeditor/editor/pagedown/local/Markdown.local.zh-min","Markdown.en":"mdeditor/editor/pagedown/local/Markdown.local.en-min","Markdown.Extra":"mdeditor/editor/Markdown.Extra-min",underscore:"mdeditor/editor/underscore-min",scrollLink:"mdeditor/editor/scrollLink",mathJax:"mdeditor/editor/mathJax","jquery.waitforimages":"mdeditor/editor/jquery.waitforimages-min",pretty:"mdeditor/editor/google-code-prettify/prettify",mdeditor:"mdeditor/editor/mdeditor","jquery.mobile":"js/jquery.mobile-1.4.4.min",fastclick:"js/fastclick"},shim:{page:{deps:["tinymce"]},fileupload:{deps:["jquery.ui.widget","iframe-transport"]},"Markdown.Sanitizer":{deps:["Markdown.Converter"]},"Markdown.Editor":{deps:["Markdown.Converter"]},"Markdown.Extra":{deps:["Markdown.Editor"]},"Markdown.zh":{deps:["Markdown.Editor"]},"Markdown.en":{deps:["Markdown.Editor"]}}});require(["mdeditor"],function(mdeditor){});require(["leaui_image"],function(leaui_image){});require(["attachment_upload"],function(attachment_upload){});require(["attachment_upload"],function(attachment_upload){});if(Mobile.isMobile()){require(["fastclick"],function(){})}

105
public/js/main.js Normal file

@ -0,0 +1,105 @@
require.config({
baseUrl: '/public',
paths: {
// 'jquery': 'js/jquery-1.9.0.min',
// base editor
'tinymce': 'tinymce/tinymce',
'jquery.slimscroll': 'js/jQuery-slimScroll-1.3.0/jquery.slimscroll',
'contextmenu': 'js/contextmenu/jquery.contextmenu',
'jquery.cookie': 'js/jquery-cookie',
'page': 'js/app/page',
'note': 'js/app/note',
'notebook': 'js/app/notebook',
'tag': 'js/app/tag',
'share': 'js/app/share',
'objectId': 'js/object_id-min',
'ZeroClipboard': 'js/ZeroClipboard/ZeroClipboard-min',
'bootstrap': 'js/bootstrap-min',
'leanote': 'js/main',
// ajax upload image/attach
'leaui_image': 'tinymce/plugins/leaui_image/public/js/for_editor',
'attachment_upload': 'js/app/attachment_upload',
'jquery.ui.widget': 'tinymce/plugins/leaui_image/public/js/jquery.ui.widget',
'fileupload': '/tinymce/plugins/leaui_image/public/js/jquery.fileupload',
'iframe-transport': '/tinymce/plugins/leaui_image/public/js/jquery.iframe-transport',
// mdeditor
'Markdown.Converter': 'mdeditor/editor/pagedown/Markdown.Converter-min',
'Markdown.Sanitizer': 'mdeditor/editor/pagedown/Markdown.Sanitizer-min',
'Markdown.Editor': 'mdeditor/editor/pagedown/Markdown.Editor',
'Markdown.zh': 'mdeditor/editor/pagedown/local/Markdown.local.zh-min',
'Markdown.en': 'mdeditor/editor/pagedown/local/Markdown.local.en-min',
'Markdown.Extra': 'mdeditor/editor/Markdown.Extra-min',
'underscore': 'mdeditor/editor/underscore-min',
'scrollLink': 'mdeditor/editor/scrollLink',
'mathJax': 'mdeditor/editor/mathJax',
'jquery.waitforimages': 'mdeditor/editor/jquery.waitforimages-min',
'pretty': 'mdeditor/editor/google-code-prettify/prettify',
'mdeditor': 'mdeditor/editor/mdeditor',
'jquery.mobile': 'js/jquery.mobile-1.4.4.min',
'fastclick': 'js/fastclick'
},
shim: {
'page': {deps: ['tinymce']},
'fileupload': {deps: ['jquery.ui.widget', 'iframe-transport']},
'Markdown.Sanitizer': {deps: ['Markdown.Converter']},
'Markdown.Editor': {deps: ['Markdown.Converter']},
'Markdown.Extra': {deps: ['Markdown.Editor']},
'Markdown.zh': {deps: ['Markdown.Editor']},
'Markdown.en': {deps: ['Markdown.Editor']}
}
});
/*
// leanote, 这里使用requireJs很慢, 不用
define('leanote', ['tinymce', 'page'], function(){
});
require(['jquery.slimscroll', 'contextmenu', 'jquery.cookie',
'note', 'notebook', 'share', 'tag', 'objectId', 'ZeroClipboard', 'bootstrap'], function() {
// 没有执行
Notebook.renderNotebooks(notebooks);
Share.renderShareNotebooks(sharedUserInfos, shareNotebooks);
Note.renderNotes(notes);
if(!isEmpty(notes)) {
Note.changeNote(notes[0].NoteId);
}
Note.setNoteCache(noteContentJson);
Note.renderNoteContent(noteContentJson)
Tag.renderTagNav(tagsJson);
// init notebook后才调用
require(['page'], function() {
initSlimScroll();
});
});
*/
require(['mdeditor'], function(mdeditor) {});
require(['leaui_image'], function(leaui_image) {});
require(['attachment_upload'], function(attachment_upload) {});
require(['attachment_upload'], function(attachment_upload) {});
if(Mobile.isMobile()) {
// 不能要, 要了样式会有问题, 会增加一些class(也会减少之前的class)
// fastclick会focus
require(['fastclick'], function() {
/*
FastClick.attach($("#noteItemList").get(0));
FastClick.attach($("#leftNotebook").get(0));
FastClick.attach($("#switcher").get(0));
*/
});
/*
$("#noteItemList,#leftSwitcher").on("touchend", function(e) {
$(this).trigger("click");
e.stopPropagation();
});
*/
}