This commit is contained in:
life
2015-03-31 14:27:26 +08:00
parent 9515f1e58f
commit decf580ed3
585 changed files with 8128 additions and 9023 deletions

View File

@ -1,230 +0,0 @@
// for editor.
// drag image to editor
// Copyright leaui
var urlPrefix = UrlPrefix; // window.location.protocol + "//" + window.location.host;
define('leaui_image', ['jquery.ui.widget', 'fileupload'], function(){
// 当url改变时, 得到图片的大小
function getImageSize(url, callback) {
var img = document.createElement('img');
function done(width, height) {
img.parentNode.removeChild(img);
callback({width: width, height: height});
}
img.onload = function() {
done(img.clientWidth, img.clientHeight);
};
img.onerror = function() {
done();
};
img.src = url;
var style = img.style;
style.visibility = 'hidden';
style.position = 'fixed';
style.bottom = style.left = 0;
style.width = style.height = 'auto';
document.body.appendChild(img);
}
var i = 1;
function insertImage(data) {
var editor = tinymce.activeEditor;
var dom = editor.dom;
var renderImage = function(data2) {
// 这里, 如果图片宽度过大, 这里设置成500px
var d = {};
var imgElm;
// 先显示loading...
d.id = '__mcenew' + (i++);
d.src = "http://leanote.com/images/loading-24.gif";
imgElm = dom.createHTML('img', d);
tinymce.activeEditor.insertContent(imgElm);
imgElm = dom.get(d.id);
function callback (wh) {
if(wh && wh.width) {
if(wh.width > 600) {
wh.width = 600;
}
data2.width = wh.width;
}
dom.setAttrib(imgElm, 'src', data2.src);
dom.setAttrib(imgElm, 'width', data2.width);
if(data2.title) {
dom.setAttrib(imgElm, 'title', data2.title);
}
dom.setAttrib(imgElm, 'id', null);
};
getImageSize(data.src, callback);
}
//-------------
// outputImage?fileId=123232323
var fileId = "";
fileIds = data.src.split("fileId=")
if(fileIds.length == 2 && fileIds[1].length == "53aecf8a8a039a43c8036282".length) {
fileId = fileIds[1];
}
if(fileId) {
// 得到fileId, 如果这个笔记不是我的, 那么肯定是协作的笔记, 那么需要将图片copy给原note owner
var curNote = Note.getCurNote();
if(curNote && curNote.UserId != UserInfo.UserId) {
(function(data) {
ajaxPost("/file/copyImage", {userId: UserInfo.UserId, fileId: fileId, toUserId: curNote.UserId}, function(re) {
if(reIsOk(re) && re.Id) {
var urlPrefix = window.location.protocol + "//" + window.location.host;
data.src = urlPrefix + "/file/outputImage?fileId=" + re.Id;
}
renderImage(data);
});
})(data);
} else {
renderImage(data);
}
} else {
renderImage(data);
}
}
var initUploader = function() {
var ul = $('#upload ul');
$('#drop a').click(function() {
// trigger to show file select
$(this).parent().find('input').click();
});
// Initialize the jQuery File Upload plugin
$('#upload').fileupload({
dataType: 'json',
acceptFileTypes: /(\.|\/)(gif|jpg|jpeg|png|jpe)$/i,
maxFileSize: 210000,
// This element will accept file drag/drop uploading
dropZone: $('#drop'),
formData: function(form) {
return [{name: 'albumId', value: ""}]
},
// This function is called when a file is added to the queue;
// either via the browse button, or via drag/drop:
add: function(e, data) {
var tpl = $('<li><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></li>');
// Append the file name and file size
tpl.find('div').append(data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small>');
// Add the HTML to the UL element
data.context = tpl.appendTo(ul);
// data.form[0].action += "&album_id=" + $("#albumsForUpload").val();
// Automatically upload the file once it is added to the queue
var jqXHR = data.submit();
},
done: function(e, data) {
if (data.result.Ok == true) {
data.context.remove();
// life
var data2 = {src: urlPrefix + "/file/outputImage?fileId=" + data.result.Id}
insertImage(data2);
} else {
data.context.empty();
var tpl = $('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');
tpl.find('div').append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.result.Msg);
data.context.append(tpl);
setTimeout((function(tpl) {
return function() {
tpl.remove();
}
})(tpl), 2000);
}
$("#uploadMsg").scrollTop(1000);
},
fail: function(e, data) {
data.context.empty();
var tpl = $('<li><div class="alert alert-danger"><a class="close" data-dismiss="alert">×</a></div></li>');
tpl.find('div').append('<b>Error:</b> ' + data.files[0].name + ' <small>[<i>' + formatFileSize(data.files[0].size) + '</i>]</small> ' + data.errorThrown);
data.context.append(tpl);
setTimeout((function(tpl) {
return function() {
tpl.remove();
}
})(tpl), 2000);
$("#uploadMsg").scrollTop(1000);
}
});
// Prevent the default action when a file is dropped on the window
$(document).on('drop dragover', function(e) {
e.preventDefault();
});
// 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 showUpload() {
$("#upload").css("z-index", 12);
var top = +$("#mceToolbar").css("height").slice(0, -2); // px
$("#upload").css("top", top - 8);
$("#upload").show();
}
function hideUpload() {
$("#upload").css("z-index", 0).css("top", "auto").hide();
}
// drag css
$(document).bind('dragover', function (e) {
var dropZone = $('#drop'),
timeout = window.dropZoneTimeout;
if (!timeout) {
dropZone.addClass('in');
showUpload();
} else {
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.dropZoneTimeout = setTimeout(function () {
window.dropZoneTimeout = null;
dropZone.removeClass('in hover');
hideUpload();
}, 100);
});
}
initUploader();
});

View File

@ -117,4 +117,4 @@
writeScripts();
})(this);
// $hash: 190286403c2f41db4f7f5e13ca9a2158
// $hash: eead586884e827fb28480c335ab9d3fc

View File

@ -114,4 +114,4 @@
writeScripts();
})(this);
// $hash: 0dea0ce031907f908bd45feb13483a36
// $hash: 69eeaf44413967796526c27a57f9e5c3

File diff suppressed because one or more lines are too long

View File

@ -116,4 +116,4 @@
writeScripts();
})(this);
// $hash: 03d011b56beb69dc9e64484e888e2704
// $hash: cc4206b9f467adfd42760ee5a6c3606f

View File

@ -1831,7 +1831,7 @@ define("tinymce/tableplugin/Plugin", [
function insertTable(cols, rows) {
var y, x, html;
html = '<table><tbody>';
html = '<table style="width: 100%"><tbody>';
for (y = 0; y < rows; y++) {
html += '<tr>';

File diff suppressed because one or more lines are too long

View File

@ -210,4 +210,4 @@
writeScripts();
})(this);
// $hash: 130cd5accbf13f2c03f8ce625aec1f19
// $hash: 11a55fa37d4eb591eeccc37e9f5b9d00

File diff suppressed because one or more lines are too long

View File

@ -209,4 +209,4 @@
writeScripts();
})(this);
// $hash: 7ac9215dd1d6bfa06c35a80c1eebfc6b
// $hash: c7c1f3d9261e2b8bbf291b977dfec921

View File

@ -1,86 +0,0 @@
----------------
Editor.js
line 659:
title: self.editorManager.translate(
"leanote编辑器"
),
----------------
Editor.js
line 1701:
content = args.content;
// 这里修改高度
// life-height
// iframe父的高度是屏幕的高度, 定死. 而其内容包含title+iframe的高度, 很高
// 所以滑动会是title+iframe一起滑.
// iframe的高度肯定是内容的高度度
resizeEditor();
// alert($("#content").height())
// alert($("#content").height() + " " + $("#content_ifr").height())
$("#content_ifr").attr("src", "#1"); // 不做这样, scroll不启作用
// $("#content_ifr").width($("#content").width()-50);
---------------------
DOMUtils.js
// life /public/会去掉/
/*
if (s.url_converter) {
v = s.url_converter.call(s.url_converter_scope || t, v, n, e);
}
*/
---------------------
--------------------
EditorCommands.js
line 479
修改mceInsertRawHTML
--------------------
---------------
Editor.js
添加insertRawContent, 为了paste.js插件复制代码
insertRawContent: function(content) {
this.execCommand('mceInsertRawHTML', false, content);
}
---------------
---------------
paste/classes/Clipbord.js
修改pasteText()与pasteHtml()
---------------
themes/modern/theme.js
---------------------
-----------
fix bug
使用full.min.js时url没有tinymce后缀
EditorManage.js
line 110
-----------
-------------------------------------
jquery.filedrop.js
当filename很中文,英文, 空格时有问题. 到服务器上的数据有问题(filename)
builder += 'Content-Disposition: form-data; name="'+opts.paramname+'"';
// 当filename很中文,英文, 空格时有问题
// 得到ext
var pos = filename.lastIndexOf(".");
var seconds = (new Date()).getTime();
var filename2 = "leanote_" + seconds;
if(pos != -1) {
var ext = filename.substr(pos)
filename2 += ext;
}
builder += '; filename="' + filename2 + '"';
builder += crlf;
-------------------------------------
// 使用tab键
http://www.tinymce.com/wiki.php/Plugin3x:nonbreaking
http://stackoverflow.com/questions/13543220/tiny-mce-how-to-allow-people-to-indent