Tim 10 years ago
commit 58c8851a99

@ -756,7 +756,7 @@ class ApplicationController < ActionController::Base
# Returns a string that can be used as filename value in Content-Disposition header # Returns a string that can be used as filename value in Content-Disposition header
def filename_for_content_disposition(name) def filename_for_content_disposition(name)
request.env['HTTP_USER_AGENT'] =~ %r{MSIE} ? ERB::Util.url_encode(name) : name request.env['HTTP_USER_AGENT'] =~ %r{MSIE|Trident} ? ERB::Util.url_encode(name) : name
end end
def api_request? def api_request?

@ -133,8 +133,9 @@ class StudentWorkController < ApplicationController
format.js format.js
format.html format.html
format.xls { format.xls {
filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls"
send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present", send_data(homework_to_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_homework_list)}.xls") :filename => filename_for_content_disposition(filename))
} }
end end
end end
@ -386,8 +387,9 @@ class StudentWorkController < ApplicationController
end end
respond_to do |format| respond_to do |format|
format.xls { format.xls {
filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_absence_list)}.xls"
send_data(absence_penalty_list_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present", send_data(absence_penalty_list_xls(@stundet_works), :type => "text/excel;charset=utf-8; header=present",
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_absence_list)}.xls") :filename => filename_for_content_disposition(filename))
} }
end end
end end
@ -396,8 +398,9 @@ class StudentWorkController < ApplicationController
def evaluation_list def evaluation_list
respond_to do |format| respond_to do |format|
format.xls { format.xls {
filename = "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_evaluation_list)}.xls"
send_data(evaluation_list_xls(@homework.student_works), :type => "text/excel;charset=utf-8; header=present", send_data(evaluation_list_xls(@homework.student_works), :type => "text/excel;charset=utf-8; header=present",
:filename => "#{@course.teacher.lastname.to_s + @course.teacher.firstname}_#{@course.name}_#{@course.time.to_s + @course.term}_#{@homework.name}#{l(:excel_evaluation_list)}.xls") :filename => filename_for_content_disposition(filename))
} }
end end
end end

@ -94,7 +94,7 @@
$('#reply_content_<%= activity.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false}); $('#reply_content_<%= activity.id %> a').colorbox({rel:'nofollow', close: "关闭", returnFocus: false});
}); });
</script> </script>
<% if activity %> <% if activity && activity.course_act%>
<% act = activity.course_act %> <% act = activity.course_act %>
<% case activity.course_act_type.to_s %> <% case activity.course_act_type.to_s %>
<% when 'HomeworkCommon' %> <% when 'HomeworkCommon' %>

@ -234,9 +234,10 @@
//第二种是改变某个tag名称。其他所有的资源如果拥有这个tag。那么对应的tag名也要改掉。 //第二种是改变某个tag名称。其他所有的资源如果拥有这个tag。那么对应的tag名也要改掉。
//目前这两种依据 的来源就是 是否 传了参数 id。如果有id。就指定了资源id就是第一种情况。如果没有id。就是第二种情况 //目前这两种依据 的来源就是 是否 传了参数 id。如果有id。就指定了资源id就是第一种情况。如果没有id。就是第二种情况
function rename_tag(domEle,name,id,type){ function rename_tag(domEle,name,id,type){
if(String(id) != '' || '<%=User.current.allowed_to?(:as_teacher,@course)%>' == 'true' ) { //如果有id 或者是老师就都能编辑否则没有id不是老师就不能编辑
isdb = true; //这是双击 isdb = true; //这是双击
//clearTimeout(clickFunction); //clearTimeout(clickFunction);
if(domEle.children().get(0) != undefined ){ //已经是编辑框的情况下不要动 if (domEle.children().get(0) != undefined) { //已经是编辑框的情况下不要动
return; return;
} }
tagNameHtml = domEle.parent().html() tagNameHtml = domEle.parent().html()
@ -245,11 +246,12 @@
ele = domEle; ele = domEle;
tagId = id; tagId = id;
taggableType = type; taggableType = type;
width = parseInt(domEle.css('width').replace('px','')) >=100 ? parseInt(domEle.css('width').replace('px','')) : 100 width = parseInt(domEle.css('width').replace('px', '')) >= 100 ? parseInt(domEle.css('width').replace('px', '')) : 100
domEle.html('<input name="" id="renameTagName" maxlength="<%=Setting.tags_max_length%>" minlength="<%= Setting.tags_min_length%>" style="width:'+width +'px;" value="'+name+'"/>'); domEle.html('<input name="" id="renameTagName" maxlength="<%=Setting.tags_max_length%>" minlength="<%= Setting.tags_min_length%>" style="width:' + width + 'px;" value="' + name + '"/>');
domEle.parent().css("border","1px solid #ffffff"); domEle.parent().css("border", "1px solid #ffffff");
$("#renameTagName").focus(); $("#renameTagName").focus();
} }
}
//监听所有的单击事件 //监听所有的单击事件
$(function(){ $(function(){
$("#renameTagName").live("blur",function(){ $("#renameTagName").live("blur",function(){

@ -1,6 +1,6 @@
<% forum.tag_list.each do |tag|%> <% forum.reload.tag_list.each do |tag|%>
<span class="postlabel mr10"> <span class="postlabel mr10">
<a href="javascript:void(0);" ondblclick="rename_tag($(this),<%= tag %>,<%= forum.id%>,5);" style="cursor: default" class="fontGrey2 mr5"><%= tag %></a> <a title="双击可编辑" ondblclick="rename_tag($(this),'<%= tag %>',<%= forum.id%>,5);" style="cursor: pointer" class="fontGrey2 mr5"><%= tag %></a>
<%if forum.creator.id == User.current.id%> <%if forum.creator.id == User.current.id%>
<a href="javascript:void(0);" class="fontGrey2" onclick="delete_forum_tag($(this));">×</a> <a href="javascript:void(0);" class="fontGrey2" onclick="delete_forum_tag($(this));">×</a>
<% end %> <% end %>

@ -76,10 +76,10 @@
$("#error").html("主题 过长(最长为 50 个字符)").show(); $("#error").html("主题 过长(最长为 50 个字符)").show();
return false; return false;
} }
if(memo_content.html().trim().length > 5000){ // if(memo_content.html().trim().length > 5000){
$("#error").html("内容 过长(最长为 5000 个字符)").show(); // $("#error").html("内容 过长(最长为 5000 个字符)").show();
return false; // return false;
} // }
return true; return true;
} }

@ -98,12 +98,7 @@
domEle.parent().css("border","1px solid #ffffff"); domEle.parent().css("border","1px solid #ffffff");
$("#renameTagName").focus(); $("#renameTagName").focus();
} }
//监听所有的单击事件 $("#renameTagName").live('blur',function(){
$(document).click(function(e){
node = document.elementFromPoint(e.clientX, e.clientY);
if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了
return;
}
if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态 if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态 if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态
ele.parent().css("border",""); ele.parent().css("border","");
@ -122,6 +117,30 @@
} }
} }
}); });
//监听所有的单击事件
// $(document).click(function(e){
// node = document.elementFromPoint(e.clientX, e.clientY);
// if(node.tagName == "INPUT"){ //如果是输入框的聚焦,那么就不要进行下去了
// return;
// }
// if($("#renameTagName")[0] != undefined ){//存在renameTagName,则处于编辑状态
// if($("#renameTagName").val().trim() == tagName){ //如果值一样,则恢复原来的状态
// ele.parent().css("border","");
// ele.parent().html(tagNameHtml);
//
// }else{ //否则就要更新tag名称了
// if(confirm("是否将标签改为 "+ $("#renameTagName").val().trim())){
// $.post(
// '<%#= update_tag_name_path %>',
// {"taggableId": taggableId, "taggableType": taggableType, "tagName": tagName, "renameName": $("#renameTagName").val().trim()}
// )
// }else{
// ele.parent().css("border","");
// ele.parent().html(tagNameHtml);
// }
// }
// }
// });
function del_forum_confirm(){ function del_forum_confirm(){
if(confirm('您确定要删除么?')){ if(confirm('您确定要删除么?')){

@ -7,10 +7,10 @@
$("#error").html('主题不能超过50个字符').show(); $("#error").html('主题不能超过50个字符').show();
return; return;
} }
if(memo_content.html().trim().length > 5000 ){ // if(memo_content.html().trim().length > 5000 ){
$("#error").html('内容不能超过5000个字符').show(); // $("#error").html('内容不能超过5000个字符').show();
return; // return;
} // }
memo_content.sync(); memo_content.sync();
$("#edit_memo").submit(); $("#edit_memo").submit();
}else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.html().trim() != "" ){ }else if($("textarea[name='memo[subject]']").val().trim() == "" && memo_content.html().trim() != "" ){

@ -86,15 +86,15 @@
<div class="homepagePostReplyBanner"> <div class="homepagePostReplyBanner">
<div class="homepagePostReplyBannerCount">回复(<%=@reply_count %></div> <div class="homepagePostReplyBannerCount">回复(<%=@reply_count %></div>
<div class="homepagePostReplyBannerTime"></div> <div class="homepagePostReplyBannerTime"></div>
<div class="homepagePostReplyBannerMore"> <!--<div class="homepagePostReplyBannerMore">-->
<% if @reply_count > 2%> <!--<%# if @reply_count > 2%>-->
<a href="javascript:void(0);" class="replyGrey" id="reply_btn_<%= @memo.id%>" onclick="expand_reply('#reply_div_<%= @memo.id %>','#reply_btn_<%= @memo.id%>')" data-count="<%= @reply_count %>" data-init="0" >点击展开更多回复</a> <!--<a# href="javascript:void(0);" class="replyGrey" id="reply_btn_<%#= @memo.id%>" onclick="expand_reply('#reply_div_<%#= @memo.id %>','#reply_btn_<%#= @memo.id%>')" data-count="<%= @reply_count %>" data-init="0" >点击展开更多回复</a>-->
<% end %> <!--<%# end %>-->
</div> <!--</div>-->
</div> </div>
<div class="" id="reply_div_<%= @memo.id %>"> <div class="" id="reply_div_<%= @memo.id %>">
<% @replies.each_with_index do |reply,i| %> <% @replies.each_with_index do |reply,i| %>
<div class="homepagePostReplyContainer" style="display: <%= i >= 2 ? 'none':''%>"> <div class="homepagePostReplyContainer" >
<div class="homepagePostReplyPortrait"> <div class="homepagePostReplyPortrait">
<%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %> <%= link_to image_tag(url_to_avatar(reply.author), :width => 33,:height => 33), user_path(reply.author) %>
</div> </div>

@ -21,6 +21,19 @@
"<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>"); "<a href='javascript:' onclick='clickCanel();'><img src='/images/bid/close.png' width='26px' height='26px' /></a></span>");
$('#ajax-modal').parent().css("top","30%").css("left","20%").css("position","fixed"); $('#ajax-modal').parent().css("top","30%").css("left","20%").css("position","fixed");
} }
// 点击 checkbox选中引用的资源的时候保存该资源的id到session里去
function store_seleted_resource(dom){
if(dom.attr('checked') == 'checked' ){
$.get(
'<%= store_selected_resource_user_path(User.current) %>'+'?save=y&res_id='+dom.val()
)
}else {
$.get(
'<%= store_selected_resource_user_path(User.current) %>'+'?save=n&res_id='+dom.val()
)
}
}
</script> </script>
<div class="homepageRightBanner mb10"> <div class="homepageRightBanner mb10">

@ -84,7 +84,9 @@
<% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %> <% if ma.course_message_type == "HomeworkCommon" && ma.status == 1 %>
<ul class="homepageNewsList fl"> <ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li> <li class="homepageNewsPortrait fl"><a href="javascript:void(0);"><%=link_to image_tag(url_to_avatar(ma.course_message.user), :width => "30", :height => "30"), user_path(ma.course_message.user) %></a></li>
<li class="homepageNewsPubType fl"><%=link_to ma.course_message.user, user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher" %><span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布的作业:</span></li> <li class="homepageNewsPubType fl"><%=link_to ma.course_message.user.lastname + ma.course_message.user.firstname + '老师',
user_path(ma.course_message.user), :class => "newsBlue homepageNewsPublisher", :title => "#{ma.course_message.user.lastname + ma.course_message.user.firstname}老师" %>
<span class="<%= ma.viewed == 0 ? "homepageNewsTypeNotRead fl":"homepageNewsType fl" %>">发布的作业:</span></li>
<li class="homepageHomeworkContent fl"> <li class="homepageHomeworkContent fl">
<%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id), <%= link_to ma.course_message.name, student_work_index_path(:homework => ma.course_message.id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}", :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",

@ -10,7 +10,6 @@
// 点击 checkbox选中引用的资源的时候保存该资源的id到session里去 // 点击 checkbox选中引用的资源的时候保存该资源的id到session里去
function store_seleted_resource(dom){ function store_seleted_resource(dom){
console.log(dom.attr('checked'))
if(dom.attr('checked') == 'checked' ){ if(dom.attr('checked') == 'checked' ){
$.get( $.get(
'<%= store_selected_resource_user_path %>'+'?save=y&res_id='+dom.val() '<%= store_selected_resource_user_path %>'+'?save=y&res_id='+dom.val()

@ -11,7 +11,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20150917022239) do ActiveRecord::Schema.define(:version => 20150930011457) do
create_table "activities", :force => true do |t| create_table "activities", :force => true do |t|
t.integer "act_id", :null => false t.integer "act_id", :null => false
@ -497,26 +497,23 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
add_index "documents", ["created_on"], :name => "index_documents_on_created_on" add_index "documents", ["created_on"], :name => "index_documents_on_created_on"
add_index "documents", ["project_id"], :name => "documents_project_id" add_index "documents", ["project_id"], :name => "documents_project_id"
create_table "dts", :primary_key => "Num", :force => true do |t| create_table "dts", :force => true do |t|
t.string "Defect", :limit => 50 t.string "IPLineCode"
t.string "Category", :limit => 50
t.string "File"
t.string "Method"
t.string "Module", :limit => 20
t.string "Variable", :limit => 50
t.integer "StartLine"
t.integer "IPLine"
t.string "IPLineCode", :limit => 200
t.string "Judge", :limit => 15
t.integer "Review", :limit => 1
t.string "Description" t.string "Description"
t.text "PreConditions", :limit => 2147483647 t.string "Num"
t.text "TraceInfo", :limit => 2147483647 t.string "Variable"
t.text "Code", :limit => 2147483647 t.string "TraceInfo"
t.string "Method"
t.string "File"
t.string "IPLine"
t.string "Review"
t.string "Category"
t.string "Defect"
t.string "PreConditions"
t.string "StartLine"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at", :null => false
t.datetime "updated_at" t.datetime "updated_at", :null => false
t.integer "id", :null => false
end end
create_table "enabled_modules", :force => true do |t| create_table "enabled_modules", :force => true do |t|
@ -575,6 +572,8 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.integer "viewed" t.integer "viewed"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.string "secret_key"
t.integer "status"
end end
create_table "forums", :force => true do |t| create_table "forums", :force => true do |t|
@ -783,16 +782,6 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id" add_index "journal_details", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_details_copy", :force => true do |t|
t.integer "journal_id", :default => 0, :null => false
t.string "property", :limit => 30, :default => "", :null => false
t.string "prop_key", :limit => 30, :default => "", :null => false
t.text "old_value"
t.text "value"
end
add_index "journal_details_copy", ["journal_id"], :name => "journal_details_journal_id"
create_table "journal_replies", :id => false, :force => true do |t| create_table "journal_replies", :id => false, :force => true do |t|
t.integer "journal_id" t.integer "journal_id"
t.integer "user_id" t.integer "user_id"
@ -911,6 +900,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.datetime "updated_on", :null => false t.datetime "updated_on", :null => false
t.boolean "locked", :default => false t.boolean "locked", :default => false
t.integer "sticky", :default => 0 t.integer "sticky", :default => 0
t.integer "reply_id"
end end
add_index "messages", ["author_id"], :name => "index_messages_on_author_id" add_index "messages", ["author_id"], :name => "index_messages_on_author_id"
@ -1318,9 +1308,9 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
create_table "student_work_tests", :force => true do |t| create_table "student_work_tests", :force => true do |t|
t.integer "student_work_id" t.integer "student_work_id"
t.integer "status"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "status", :default => 9
t.text "results" t.text "results"
t.text "src" t.text "src"
end end
@ -1376,6 +1366,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.text "description" t.text "description"
t.string "subject"
end end
create_table "taggings", :force => true do |t| create_table "taggings", :force => true do |t|
@ -1567,6 +1558,7 @@ ActiveRecord::Schema.define(:version => 20150917022239) do
t.string "identity_url" t.string "identity_url"
t.string "mail_notification", :default => "", :null => false t.string "mail_notification", :default => "", :null => false
t.string "salt", :limit => 64 t.string "salt", :limit => 64
t.integer "gid"
end end
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id" add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"

@ -13,7 +13,7 @@ class Kindeditor::AssetsController < ApplicationController
logger.warn '========= Warning: the owner_id is 0, "delete uploaded files automatically" will not work. =========' if defined?(logger) && @asset.owner_id == 0 logger.warn '========= Warning: the owner_id is 0, "delete uploaded files automatically" will not work. =========' if defined?(logger) && @asset.owner_id == 0
@asset.asset_type = @dir @asset.asset_type = @dir
if @asset.save if @asset.save
render :text => ({:error => 0, :url => "http://"+Setting.host_name + "/" + @asset.asset.url,:asset_id => @asset.id}.to_json) render :text => ({:error => 0, :url => @asset.asset.url,:asset_id => @asset.id}.to_json)
else else
show_error(@asset.errors.full_messages) show_error(@asset.errors.full_messages)
end end

@ -277,7 +277,10 @@ https://github.com/layerssss/paste.js
if (!img["_paste_marked_" + timespan]) { if (!img["_paste_marked_" + timespan]) {
cb(img.src); cb(img.src);
} }
//firefox问题处理因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
if ($(img).attr('src').startsWith('data:image/')) {
_results.push($(img).remove()); _results.push($(img).remove());
};
} }
return _results; return _results;
}; };
@ -290,10 +293,9 @@ https://github.com/layerssss/paste.js
}).call(this); }).call(this);
function enablePasteImg(_editor) { KindEditor.plugin('paste', function(K) {
var editor = _editor, var editor = this,
name = 'paste'; name = 'paste';
//这样貌似多编辑器就不会冲突了
if(editor.edit == undefined || editor.edit.iframe == undefined){ if(editor.edit == undefined || editor.edit.iframe == undefined){
return; return;
} }
@ -329,7 +331,6 @@ function enablePasteImg(_editor) {
console.log("dataURL: " + data.dataURL); console.log("dataURL: " + data.dataURL);
console.log("width: " + data.width); console.log("width: " + data.width);
console.log("height: " + data.height); console.log("height: " + data.height);
console.log(data.blob);
var blob = dataURItoBlob(data.dataURL); var blob = dataURItoBlob(data.dataURL);
if (data.blob !== null) { if (data.blob !== null) {
var data = new FormData(); var data = new FormData();
@ -342,6 +343,7 @@ function enablePasteImg(_editor) {
data: data, data: data,
processData: false, processData: false,
success: function(data) { success: function(data) {
console.log(data);
editor.exec('insertimage', JSON.parse(data).url); editor.exec('insertimage', JSON.parse(data).url);
} }
}); });
@ -349,37 +351,5 @@ function enablePasteImg(_editor) {
}); });
return; return;
contentWindow.document.getElementsByTagName('body')[0].onpaste = function(event) {
// use event.originalEvent.clipboard for newer chrome versions });
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
console.log(JSON.stringify(items)); // will give you the mime types
// find pasted image among pasted items
var blob = null;
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf("image") === 0) {
blob = items[i].getAsFile();
}
}
// load image if there is a pasted image
if (blob !== null) {
var reader = new FileReader();
reader.onload = function(event) {
console.log(event.target.result); // data url!
var data = new FormData();
data.append("imgFile", blob, "imageFilename.png");
console.log(blob);
$.ajax({
url: '/kindeditor/upload?dir=image',
contentType: false,
type: 'POST',
data: data,
processData: false,
success: function(data) {
editor.exec('insertimage', JSON.parse(data).url);
}
});
};
reader.readAsDataURL(blob);
}
}
};

@ -277,7 +277,10 @@ https://github.com/layerssss/paste.js
if (!img["_paste_marked_" + timespan]) { if (!img["_paste_marked_" + timespan]) {
cb(img.src); cb(img.src);
} }
//firefox问题处理因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
if ($(img).attr('src').startsWith('data:image/')) {
_results.push($(img).remove()); _results.push($(img).remove());
};
} }
return _results; return _results;
}; };
@ -293,7 +296,6 @@ https://github.com/layerssss/paste.js
KindEditor.plugin('paste', function(K) { KindEditor.plugin('paste', function(K) {
var editor = this, var editor = this,
name = 'paste'; name = 'paste';
//这样貌似多编辑器就不会冲突了
if(editor.edit == undefined || editor.edit.iframe == undefined){ if(editor.edit == undefined || editor.edit.iframe == undefined){
return; return;
} }
@ -329,7 +331,6 @@ KindEditor.plugin('paste', function(K) {
console.log("dataURL: " + data.dataURL); console.log("dataURL: " + data.dataURL);
console.log("width: " + data.width); console.log("width: " + data.width);
console.log("height: " + data.height); console.log("height: " + data.height);
console.log(data.blob);
var blob = dataURItoBlob(data.dataURL); var blob = dataURItoBlob(data.dataURL);
if (data.blob !== null) { if (data.blob !== null) {
var data = new FormData(); var data = new FormData();
@ -342,6 +343,7 @@ KindEditor.plugin('paste', function(K) {
data: data, data: data,
processData: false, processData: false,
success: function(data) { success: function(data) {
console.log(data);
editor.exec('insertimage', JSON.parse(data).url); editor.exec('insertimage', JSON.parse(data).url);
} }
}); });
@ -349,37 +351,5 @@ KindEditor.plugin('paste', function(K) {
}); });
return; return;
contentWindow.document.getElementsByTagName('body')[0].onpaste = function(event) {
// use event.originalEvent.clipboard for newer chrome versions
var items = (event.clipboardData || event.originalEvent.clipboardData).items;
console.log(JSON.stringify(items)); // will give you the mime types
// find pasted image among pasted items
var blob = null;
for (var i = 0; i < items.length; i++) {
if (items[i].type.indexOf("image") === 0) {
blob = items[i].getAsFile();
}
}
// load image if there is a pasted image
if (blob !== null) {
var reader = new FileReader();
reader.onload = function(event) {
console.log(event.target.result); // data url!
var data = new FormData();
data.append("imgFile", blob, "imageFilename.png");
console.log(blob);
$.ajax({
url: '/kindeditor/upload?dir=image',
contentType: false,
type: 'POST',
data: data,
processData: false,
success: function(data) {
editor.exec('insertimage', JSON.parse(data).url);
}
});
};
reader.readAsDataURL(blob);
}
}
}); });

@ -26,7 +26,7 @@ function init_editor(params){
if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())){ if(/^\s*<\w*\s*\w*\=\"\w*\"\s*\w*\=\"\w*\:\s*\#\d*\;\s*\w*\-\w*\:\s*\w*\;\"\>[\u4e00-\u9fa5]*<\/\w*\>\s*$/.test(this.edit.html())){
params.submit_btn.hide(); params.submit_btn.hide();
this.resize("95%", null); this.resize("95%", null);
}else if(edit.html().val().trim() != ""){ }else if(this.edit.html().trim() != ""){
params.submit_btn.show(); params.submit_btn.show();
} }

@ -724,6 +724,10 @@ div.actions input[type="text"] {
word-wrap: break-word; word-wrap: break-word;
} }
.memo-content li {
list-style-type: decimal;
}
.memo-timestamp { .memo-timestamp {
position: absolute; position: absolute;
bottom: 0px; bottom: 0px;

Loading…
Cancel
Save