Merge branch 'szzh' of http://repository.trustie.net/xianbo/trustie2 into szzh
This commit is contained in:
commit
464fc461ea
1
Gemfile
1
Gemfile
|
@ -28,6 +28,7 @@ gem 'ruby-ole'
|
|||
gem 'rails_kindeditor',path:'lib/rails_kindeditor'
|
||||
#gem "rmagick", ">= 2.0.0"
|
||||
gem 'binding_of_caller'
|
||||
gem 'chinese_pinyin'
|
||||
|
||||
group :development do
|
||||
gem 'grape-swagger'
|
||||
|
|
|
@ -126,11 +126,13 @@ class MyController < ApplicationController
|
|||
end
|
||||
|
||||
@se = @user.extensions
|
||||
if params[:occupation].to_i.to_s == params[:occupation]
|
||||
@se.school_id = params[:occupation]
|
||||
else
|
||||
@se.occupation = params[:occupation]
|
||||
end
|
||||
# if params[:occupation].to_i.to_s == params[:occupation]
|
||||
# @se.school_id = params[:occupation]
|
||||
# else
|
||||
# @se.occupation = params[:occupation]
|
||||
# end
|
||||
@se.school_id = params[:occupation]
|
||||
|
||||
@se.gender = params[:gender]
|
||||
@se.location = params[:province] if params[:province]
|
||||
@se.location_city = params[:city] if params[:city]
|
||||
|
|
|
@ -105,4 +105,31 @@ class SchoolController < ApplicationController
|
|||
|
||||
render :text => options
|
||||
end
|
||||
|
||||
#根据学校名字或者拼音来查询
|
||||
def on_search
|
||||
condition = "#{params[:name].strip}".gsub(" ","")
|
||||
#将条件截断为汉字和拼音(全汉字 或者 全拼音 或者 汉字和拼音),
|
||||
#获取拼音的第一次出现的位置
|
||||
chinese = []
|
||||
pinyin = []
|
||||
condition.scan(/./).each_with_index do |char,index|
|
||||
if char =~ /[a-zA-Z0-9]/
|
||||
pinyin << char
|
||||
else
|
||||
chinese << char
|
||||
end
|
||||
end
|
||||
if(condition == '')
|
||||
@school = School.all
|
||||
else
|
||||
@school = School.where("name like '%#{chinese.join("")}%' and pinyin like '%#{pinyin.join("")}%'").all
|
||||
end
|
||||
|
||||
result = []
|
||||
# @school.each do |sc|
|
||||
# result << {:value=>sc.name,:data=>sc.id}
|
||||
# end
|
||||
render :json => @school.to_json
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
class School < ActiveRecord::Base
|
||||
attr_accessible :name, :province
|
||||
attr_accessible :name, :province,:pinyin
|
||||
has_many :courses
|
||||
|
||||
def to_s
|
||||
|
|
|
@ -11,10 +11,10 @@
|
|||
ul,li{ list-style-type:none}
|
||||
.cl{ clear:both; overflow:hidden; }
|
||||
a{ text-decoration:none; }
|
||||
a:hover{ }
|
||||
a:hover{}
|
||||
|
||||
.alert_box {width:488px;height:550px;position:fixed;z-index:1002;left:50%;top:40%;margin:-215px 0 0 -300px; background:#fff; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; box-shadow:0px 0px 8px #194a81; padding:5px; overflow:auto; }
|
||||
#popbox{width:488px;height:308px;}
|
||||
#popbox{width:488px;height:368px;}
|
||||
.alert .C{width:476px;height:296px;position:absolute;left:5px;top:5px; }
|
||||
.C_top{ margin-top:20px; width:368px; height:100px; background:#e9e9e9; padding:0px 60px; }
|
||||
.C_top h2{ color:#1c1d1d; font-size:24px; font-style:normal; font-weight:normal;}
|
||||
|
@ -22,12 +22,15 @@
|
|||
.C_form{ margin:20px 0 0 60px;}
|
||||
.C_form ul li{ font-size:14px; color:#3f3a39; line-height:30px; }
|
||||
.C_form ul li input{ margin-left:20px; border:0px; border:1px solid #e1e1e1; color:#898989; padding-left:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; padding: 0 !important; }
|
||||
.C_form ul li.mB5{ color:#898989; font-size:12px; padding-left:90px;}
|
||||
.C_form ul li.mB5{ color:#898989; font-size:12px; padding-left:97px;}
|
||||
.width190{ width:190px; height:26px; border-color:#e1e1e1;}
|
||||
.C_form a{ font-size:12px; color:#15bccf; float:left; display:block; height:40px; width:200px; margin-top:25px;}
|
||||
.C_form a:hover{ text-decoration:underline;}
|
||||
.C_form a.btn{ display:block; width:100px; height:36px; padding-top:4px; text-align: center; background:#15bccf; color:#fff; font-size:14px; margin:20px 20px 0 95px;}
|
||||
.C_form a.btn:hover{ background:#ff821d;}
|
||||
.C_form a.btn_join{ display:block; width:100px; height:36px; padding-top:4px; text-align: center; background:#269ac9; color:#fff; font-size:14px; margin:20px 20px 0 95px;}
|
||||
.C_form a.btn_join:hover{ background:#297fb8; text-decoration: none;}
|
||||
.C_form a.btn_cancel{ display:block; width:100px; height:36px; padding-top:4px; text-align: center; background:#c1c1c1; color:#fff; font-size:14px; margin:20px 20px 0 95px;}
|
||||
.C_form a.btn_cancel:hover{ background:#717171; text-decoration: none;}
|
||||
.IDType {border:1px solid #e1e1e1; outline: none; width: 65px; height: 25px;}
|
||||
</style>
|
||||
<script type="text/javascript">
|
||||
function submit_form(obj)
|
||||
|
@ -59,7 +62,7 @@
|
|||
<li>
|
||||
<input type="text" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<input type="password" style="display: none"/> <!--阻止表单自动填充 -->
|
||||
<span class="tips">课 程 ID:</span>
|
||||
<span class="tips" style="width: 72px; display: inline-block;">课 程 ID:</span>
|
||||
<input class=" width190" name="object_id" id="object_id" type="text" value="" >
|
||||
<input type="text" style="display: none"/>
|
||||
</li>
|
||||
|
@ -68,11 +71,19 @@
|
|||
<span class="tips">密 码:</span>
|
||||
<input class=" width190" type="password" name="course_password" id="course_password" value="" >
|
||||
</li>
|
||||
<li style="margin-top: 30px;">
|
||||
<span style="margin-right: 20px;">身 份:</span>
|
||||
<select class="IDType">
|
||||
<option>教师</option>
|
||||
<option>教辅</option>
|
||||
<option>学生</option>
|
||||
</select>
|
||||
</li>
|
||||
<li>
|
||||
<a href="javascript:" class="btn" style="margin-left: 50px;" onclick="submit_form(this);">
|
||||
<a href="javascript:" class="btn_join" style="margin-left: 50px;" onclick="submit_form(this);">
|
||||
<%= l(:label_new_join) %>
|
||||
</a>
|
||||
<a href="javascript:" class="btn" style="margin-left: 20px;" onclick="hideModal(this);">
|
||||
<a href="javascript:" class="btn_cancel" style="margin-left: 20px;" onclick="hideModal(this);">
|
||||
<%= l(:button_cancel)%>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
$('#ajax-modal').html('<%= escape_javascript(render :partial => 'join_private_course') %>');
|
||||
showModal('ajax-modal', '540px');
|
||||
$('#ajax-modal').css('height','330px');
|
||||
$('#ajax-modal').css('height','390px');
|
||||
//$('#ajax-modal').siblings().remove();
|
||||
$('#ajax-modal').siblings().hide();
|
||||
$('#ajax-modal').before("<span style='float: right;cursor:pointer;padding-left: 513px;'>" +
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<% if course && tag_list.empty? == false%>
|
||||
<% if course && tag_list && tag_list.empty? == false%>
|
||||
<span class="files_tag_icon" >
|
||||
<a title=""
|
||||
onclick="search_tag_attachment('<%= search_tag_attachment_course_files_path(course)%>','','<%= @q%>','<%= course.id%>');"
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<div class="mt5">
|
||||
<a target="hiddentab" href="http://wpa.qq.com/msgrd?v=1&uin=1554253403&site=qq&menu=yes" style="color: #15BCCF;">
|
||||
<a target="hiddentab" href="http://wpa.qq.com/msgrd?v=1&uin=1554253403&site=qq&menu=yes" style="color: #269ac9;">
|
||||
<%= l(:label_technical_support) %>白 羽</a>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -46,7 +46,7 @@
|
|||
</div>
|
||||
<div class="fl ml10">
|
||||
<p class="homepageImageName hidden db mb5">
|
||||
<%= @user.login %>
|
||||
<%= @user.realname %>
|
||||
</p>
|
||||
<% if (@user.user_extensions && (@user.user_extensions.identity != 2) ) %>
|
||||
<span class="<%= @user.user_extensions.gender == 1 ? 'homepageImageSexWomen' : 'homepageImageSexMan' %> "></span>
|
||||
|
|
|
@ -18,8 +18,8 @@
|
|||
<li>登录名 : <span style="color:red;">*</span></li>
|
||||
<li>邮箱 : <span style="color:red;">*</span></li>
|
||||
<li>身份 : </li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">姓氏 : <span style="color:red;">*</span></li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">名字 : <span style="color:red;">*</span></li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">姓(First Name) : <span style="color:red;">*</span></li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">名(Last Name) : <span style="color:red;">*</span></li>
|
||||
<li nhname="tag" nh_tag_2="true" style="display:none;">组织名 : <span style="color:red;">*</span></li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">性别 : </li>
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">工作单位 : </li>
|
||||
|
@ -72,21 +72,25 @@
|
|||
|
||||
<li nhname="tag" nh_tag_0="true" nh_tag_1="true" nh_tag_3="true" style="display:none;">
|
||||
<% if User.current.user_extensions.nil? %>
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" value=<%= l(:field_occupation_click) %> readonly>
|
||||
<input nhname="tag" autocomplete="off" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" >
|
||||
<input nhname="tag" nh_tag_3="true" id="occupation" name="occupation" style="display: none;" class="w210" type="text" value="" />
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" readonly/>
|
||||
<span id="hint" style="color: #7f7f7f;display: none">平台找到了<a id="school_num" href="javascript:void(0)" style="color: red" >0</a>个包含<a id="search_condition" href="javascript:void(0)">"国防"</a>的高校</span>
|
||||
<!--<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" readonly/>-->
|
||||
<% elsif User.current.user_extensions.identity == 3 || User.current.user_extensions.identity == 2 %>
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" value=<%= l(:field_occupation_click) %> readonly>
|
||||
<input nhname="tag" autocomplete="off" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" >
|
||||
<input nhname="tag" nh_tag_3="true" id="occupation" name="occupation" style="display: none;" class="w210" type="text" value="<%= @user.user_extensions.occupation %>" />
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" readonly/>
|
||||
<span id="hint" style="color: #7f7f7f;display: none">平台找到了<a id="school_num" href="javascript:void(0)" style="color: red" >0</a>个包含<a id="search_condition" href="javascript:void(0)">"国防"</a>的高校</span>
|
||||
<!--<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" readonly/>-->
|
||||
<% elsif User.current.user_extensions.school.nil? %>
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" value=<%= l(:field_occupation_click) %> readonly>
|
||||
<input nhname="tag" autocomplete="off" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" >
|
||||
<input nhname="tag" nh_tag_3="true" id="occupation" name="occupation" style="display: none;" class="w210" type="text" />
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" readonly/>
|
||||
<span id="hint" style="color: #7f7f7f;display: none">平台找到了<a id="school_num" href="javascript:void(0)" style="color: red" >0</a>个包含<a id="search_condition" href="javascript:void(0)">"国防"</a>的高校</span>
|
||||
<!--<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" readonly/>-->
|
||||
<% else %>
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" value="<%= User.current.user_extensions.school.province %>" readonly/>
|
||||
<input nhname="tag" autocomplete="off" nh_tag_0="true" nh_tag_1="true" id="province" name="province" style="display: none;width:130px;" class="w70" type="text" value="<%= User.current.user_extensions.school %>" />
|
||||
<input nhname="tag" nh_tag_3="true" id="occupation" name="occupation" type="text" style="display: none;" class="w210" value="<%= User.current.user_extensions.school.id %>"/>
|
||||
<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" value="<%= User.current.user_extensions.school.name %>" readonly="true" style="background-color: #E2E2E2;"/>
|
||||
<span id="hint" style="color: #7f7f7f;display: none" >平台找到了<a id="school_num" href="javascript:void(0)" style="color: red" >0</a>个包含<a id="search_condition" href="javascript:void(0)">"国防"</a>的高校</span>
|
||||
<!--<input nhname="tag" nh_tag_0="true" nh_tag_1="true" id="occupation_name" type="text" style="display: none;width:117px;" value="<%#= User.current.user_extensions.school.name %>" readonly="true" style="background-color: #E2E2E2;"/>-->
|
||||
<% end %>
|
||||
</li>
|
||||
|
||||
|
@ -180,7 +184,9 @@
|
|||
</div><!--users_setting end-->
|
||||
|
||||
</div>
|
||||
|
||||
<div id="search_school_result_list"
|
||||
style="width: 135px;line-height: 1.5;min-height:20px; max-height: 200px; height: auto!; !important;display: none;background: white;overflow: scroll;border: solid 1px #cccccc; overflow-x: hidden; overflow-y: auto;">
|
||||
</div>
|
||||
<div id="WOpenWindow">
|
||||
<a class="modal_close" href="#"></a>
|
||||
<h2 style="margin: 10px"><%= l(:lable_school_list)%></h2>
|
||||
|
@ -202,6 +208,7 @@
|
|||
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<%= stylesheet_link_tag 'nyan' %>
|
||||
|
@ -518,10 +525,77 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
$(function(){
|
||||
//学校
|
||||
$("#province").attr("href", "#WOpenWindow")
|
||||
$("#province").leanModal({top: 100, closeButton: ".modal_close"});
|
||||
function changeValue(value,data){
|
||||
//console.log(value+","+data)
|
||||
$("input[name='province']").val(value);
|
||||
$("input[name='occupation']").val(data);
|
||||
$("#search_school_result_list").hide();
|
||||
$("#hint").hide();
|
||||
}
|
||||
var lastSearchCondition = '';
|
||||
$(function() {
|
||||
//查询学校
|
||||
$("input[name='province']").on('input', function (e) {
|
||||
$("input[name='occupation']").val(''); //一旦有输入就清空id。
|
||||
if($(e.target).val().trim() == lastSearchCondition){
|
||||
return;
|
||||
}
|
||||
lastSearchCondition = $(e.target).val().trim();
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value,
|
||||
type: 'post',
|
||||
success: function (data) {
|
||||
if(data.lengh != 0) {
|
||||
var i = 0;
|
||||
$("#search_school_result_list").html('');
|
||||
for (; i < data.length; i++) {
|
||||
link = '<a onclick="window.changeValue(\'' + data[i].school.name + '\',\'' + data[i].school.id + '\')" href="javascript:void(0)">' + data[i].school.name + '</a><br/>';
|
||||
$("#search_school_result_list").append(link);
|
||||
}
|
||||
$("#search_school_result_list").css('left', $(e.target).offset().left);
|
||||
$("#search_school_result_list").css('top', $(e.target).offset().top + 28);
|
||||
$("#search_school_result_list").css("position", "absolute");
|
||||
$("#search_school_result_list").show();
|
||||
if($(e.target).val().trim() != '') {
|
||||
$("#hint").html('平台找到了' + data.length + '个包含"' + e.target.value + '"的高校');
|
||||
$("#hint").show();
|
||||
}else{
|
||||
$("#hint").hide();
|
||||
}
|
||||
}else{
|
||||
$("#hint").html('平台没有找到包含"'+e.target.value+'"的高校,创建该高校。');
|
||||
$("#hint").show();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$(document.body).click(function(e){
|
||||
if($(e.target).attr("id") != 'search_school_result_list')
|
||||
{
|
||||
$("#search_school_result_list").hide();
|
||||
$("#hint").hide();
|
||||
}
|
||||
})
|
||||
$("input[name='province']").on('focus', function (e) {
|
||||
$.ajax({
|
||||
url: '<%= url_for(:controller => 'school',:action => 'on_search') %>' + '?name=' + e.target.value,
|
||||
type: 'post',
|
||||
success: function (data) {
|
||||
var i = 0;
|
||||
$("#search_school_result_list").html('');
|
||||
for ( ;i<data.length;i++){
|
||||
link = '<a onclick="window.changeValue(\''+data[i].school.name+'\',\''+data[i].school.id+'\')" href="javascript:void(0)">' +data[i].school.name+'</a><br/>';
|
||||
$("#search_school_result_list").append(link);
|
||||
}
|
||||
$("#search_school_result_list").css('left',$(e.target).offset().left);
|
||||
$("#search_school_result_list").css('top',$(e.target).offset().top + 28);
|
||||
$("#search_school_result_list").css("position", "absolute");
|
||||
$("#search_school_result_list").show();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// $("#province").leanModal({top: 100, closeButton: ".modal_close"});
|
||||
|
||||
//地区
|
||||
var province = "<%= "#{province}" %>"
|
||||
|
@ -544,6 +618,9 @@
|
|||
$("#users_tb_2").click();
|
||||
<% end %>
|
||||
$('#my_account_form_link').click(function(){
|
||||
if( $("input[name='province']").val().trim() != '' && $("input[name='occupation']").val().trim() == ''){ //学校名字和id不对的话
|
||||
return;
|
||||
}
|
||||
$('#my_account_form_btn').click();
|
||||
});
|
||||
$('#my_password_form_link').click(function(){
|
||||
|
|
|
@ -879,6 +879,7 @@ RedmineApp::Application.routes.draw do
|
|||
post 'school/search_school/', :to => 'school#search_school'
|
||||
get 'school/search_school/', :to => 'school#search_school'
|
||||
|
||||
post 'school/on_search'
|
||||
######added by nie
|
||||
match 'tags/show_projects_tags'
|
||||
########### added by liuping
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AddColumnPinyinToSchools < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :schools, :pinyin, :string
|
||||
end
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
class TransferNameColumnValueToPinyinColumnValue < ActiveRecord::Migration
|
||||
def up
|
||||
School.all.each do |school|
|
||||
school.pinyin = Pinyin.t(school.name, splitter: '')
|
||||
school.save
|
||||
end
|
||||
end
|
||||
|
||||
def down
|
||||
end
|
||||
end
|
3438
db/schema.rb
3438
db/schema.rb
File diff suppressed because it is too large
Load Diff
|
@ -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
|
||||
@asset.asset_type = @dir
|
||||
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
|
||||
show_error(@asset.errors.full_messages)
|
||||
end
|
||||
|
|
|
@ -277,7 +277,10 @@ https://github.com/layerssss/paste.js
|
|||
if (!img["_paste_marked_" + timespan]) {
|
||||
cb(img.src);
|
||||
}
|
||||
_results.push($(img).remove());
|
||||
//firefox问题处理,因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
|
||||
if ($(img).attr('src').startsWith('data:image/')) {
|
||||
_results.push($(img).remove());
|
||||
};
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
@ -290,10 +293,9 @@ https://github.com/layerssss/paste.js
|
|||
|
||||
}).call(this);
|
||||
|
||||
function enablePasteImg(_editor) {
|
||||
var editor = _editor,
|
||||
KindEditor.plugin('paste', function(K) {
|
||||
var editor = this,
|
||||
name = 'paste';
|
||||
//这样貌似多编辑器就不会冲突了
|
||||
if(editor.edit == undefined || editor.edit.iframe == undefined){
|
||||
return;
|
||||
}
|
||||
|
@ -303,7 +305,7 @@ function enablePasteImg(_editor) {
|
|||
var nodeBody = contentWindow.document.getElementsByTagName('body')[0];
|
||||
console.log(nodeBody);
|
||||
$(nodeBody).pastableContenteditable();
|
||||
|
||||
|
||||
dataURItoBlob = function(dataURI) {
|
||||
// convert base64/URLEncoded data component to raw binary data held in a string
|
||||
var byteString;
|
||||
|
@ -329,7 +331,6 @@ function enablePasteImg(_editor) {
|
|||
console.log("dataURL: " + data.dataURL);
|
||||
console.log("width: " + data.width);
|
||||
console.log("height: " + data.height);
|
||||
console.log(data.blob);
|
||||
var blob = dataURItoBlob(data.dataURL);
|
||||
if (data.blob !== null) {
|
||||
var data = new FormData();
|
||||
|
@ -342,6 +343,7 @@ function enablePasteImg(_editor) {
|
|||
data: data,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
editor.exec('insertimage', JSON.parse(data).url);
|
||||
}
|
||||
});
|
||||
|
@ -349,37 +351,5 @@ function enablePasteImg(_editor) {
|
|||
|
||||
});
|
||||
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]) {
|
||||
cb(img.src);
|
||||
}
|
||||
_results.push($(img).remove());
|
||||
//firefox问题处理,因为采用了 pastableContenteditable 模式,故只需要删除默认的粘贴
|
||||
if ($(img).attr('src').startsWith('data:image/')) {
|
||||
_results.push($(img).remove());
|
||||
};
|
||||
}
|
||||
return _results;
|
||||
};
|
||||
|
@ -293,7 +296,6 @@ https://github.com/layerssss/paste.js
|
|||
KindEditor.plugin('paste', function(K) {
|
||||
var editor = this,
|
||||
name = 'paste';
|
||||
//这样貌似多编辑器就不会冲突了
|
||||
if(editor.edit == undefined || editor.edit.iframe == undefined){
|
||||
return;
|
||||
}
|
||||
|
@ -303,7 +305,7 @@ KindEditor.plugin('paste', function(K) {
|
|||
var nodeBody = contentWindow.document.getElementsByTagName('body')[0];
|
||||
console.log(nodeBody);
|
||||
$(nodeBody).pastableContenteditable();
|
||||
|
||||
|
||||
dataURItoBlob = function(dataURI) {
|
||||
// convert base64/URLEncoded data component to raw binary data held in a string
|
||||
var byteString;
|
||||
|
@ -329,7 +331,6 @@ KindEditor.plugin('paste', function(K) {
|
|||
console.log("dataURL: " + data.dataURL);
|
||||
console.log("width: " + data.width);
|
||||
console.log("height: " + data.height);
|
||||
console.log(data.blob);
|
||||
var blob = dataURItoBlob(data.dataURL);
|
||||
if (data.blob !== null) {
|
||||
var data = new FormData();
|
||||
|
@ -342,6 +343,7 @@ KindEditor.plugin('paste', function(K) {
|
|||
data: data,
|
||||
processData: false,
|
||||
success: function(data) {
|
||||
console.log(data);
|
||||
editor.exec('insertimage', JSON.parse(data).url);
|
||||
}
|
||||
});
|
||||
|
@ -349,37 +351,5 @@ KindEditor.plugin('paste', function(K) {
|
|||
|
||||
});
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
|
Binary file not shown.
Before Width: | Height: | Size: 2.8 KiB After Width: | Height: | Size: 944 B |
|
@ -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())){
|
||||
params.submit_btn.hide();
|
||||
this.resize("95%", null);
|
||||
}else if(edit.html().val().trim() != ""){
|
||||
}else if(this.edit.html().trim() != ""){
|
||||
params.submit_btn.show();
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ a.select_btn_select{ background:#64bddb; color:#fff;}
|
|||
.users_dis{display:block; }
|
||||
.users_undis{display:none;}
|
||||
.users_ctt{ font-size:14px; color:#666; margin-top:10px;}
|
||||
.setting_left{ width:85px; text-align:right; float:left;}
|
||||
.setting_left{ width:115px; text-align:right; float:left;}
|
||||
.setting_left li{ height:28px;line-height:28px;}
|
||||
.setting_right{width:500px; text-align:left; float:left; margin-left:8px;}
|
||||
.setting_right li{ height:28px;line-height:28px;}
|
||||
|
|
Loading…
Reference in New Issue