commit
850a7c937f
@ -1,3 +1,3 @@
|
|||||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
|
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/course_news', :locals => {:activity => @news,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
|
||||||
|
|
||||||
init_KindEditor_data('<%= @user_activity_id%>',"","85%");
|
init_activity_KindEditor_data('<%= @user_activity_id%>',"","85%");
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
|
$("#user_activity_<%= @user_activity_id%>").replaceWith("<%= escape_javascript(render :partial => 'users/project_issue', :locals => {:activity => @issue,:user_activity_id =>@user_activity_id,:first_user_activity =>@first_user_activity,:page => @page}) %>");
|
||||||
|
|
||||||
init_KindEditor_data(<%= @user_activity_id%>,"","85%");
|
init_activity_KindEditor_data(<%= @user_activity_id%>,"","85%");
|
@ -0,0 +1,144 @@
|
|||||||
|
/**
|
||||||
|
* Created by Alan on 2015/9/18.
|
||||||
|
*/
|
||||||
|
function init_editor(params){
|
||||||
|
// var minHeight; //最小高度
|
||||||
|
var id = arguments[1] ? arguments[1] : undefined;
|
||||||
|
var paramsHeight = params.height; //设定的高度
|
||||||
|
var paramsWidth = params.width == undefined ? "100%" : params.width;
|
||||||
|
|
||||||
|
var editor = params.kindutil.create(params.textarea, {
|
||||||
|
resizeType : 1,minWidth:"1px",width:"95%",
|
||||||
|
height:"30px",// == undefined ? "30px":paramsHeight+"px",
|
||||||
|
minHeight:"30px",// == undefined ? "30px":paramsHeight+"px",
|
||||||
|
items:['emoticons'],
|
||||||
|
afterChange:function(){//按键事件
|
||||||
|
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
|
||||||
|
var edit = this.edit;
|
||||||
|
var body = edit.doc.body;
|
||||||
|
edit.iframe.height(paramsHeight);
|
||||||
|
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight) + (paramsHeight == undefined ? 30:paramsHeight), paramsHeight));
|
||||||
|
},
|
||||||
|
afterCreate:function(){
|
||||||
|
params.submit_btn.css("display","none");
|
||||||
|
var toolbar = $("div[class='ke-toolbar']",params.div_form);
|
||||||
|
toolbar.css('width',24);
|
||||||
|
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
|
||||||
|
params.toolbar_container.append(toolbar);
|
||||||
|
params.toolbar_container.style.display = 'none';
|
||||||
|
//init
|
||||||
|
var edit = this.edit;
|
||||||
|
var body = edit.doc.body;
|
||||||
|
edit.iframe[0].scroll = 'no';
|
||||||
|
body.style.overflowY = 'hidden';
|
||||||
|
//reset height
|
||||||
|
var edit = this.edit;
|
||||||
|
var body = edit.doc.body;
|
||||||
|
paramsHeight = paramsHeight == undefined ? params.kindutil.removeUnit(this.height) : paramsHeight;
|
||||||
|
edit.iframe.height(paramsHeight);
|
||||||
|
this.resize(null, Math.max((params.kindutil.IE ? body.scrollHeight : body.offsetHeight)+ (paramsHeight == undefined ? 30:paramsHeight) , paramsHeight));
|
||||||
|
|
||||||
|
},
|
||||||
|
afterFocus:function(){
|
||||||
|
$('#reply_image_' + id).removeClass('imageFuzzy');
|
||||||
|
//edit.iframe.width(paramsWidth);
|
||||||
|
this.resize(paramsWidth, null);
|
||||||
|
params.submit_btn.css('display','inline-block');
|
||||||
|
},
|
||||||
|
|
||||||
|
afterBlur:function(){
|
||||||
|
$('#reply_image_' + id).addClass('imageFuzzy');
|
||||||
|
this.resize("95%", null);
|
||||||
|
params.submit_btn.css("display","none");
|
||||||
|
}
|
||||||
|
}).loadPlugin('paste');
|
||||||
|
return editor;
|
||||||
|
}
|
||||||
|
|
||||||
|
function nh_check_field(params){
|
||||||
|
var result=true;
|
||||||
|
if(params.content!=undefined){
|
||||||
|
if(params.content.isEmpty()){
|
||||||
|
result=false;
|
||||||
|
}
|
||||||
|
if(params.content.html()!=params.textarea.html() || params.issubmit==true){
|
||||||
|
params.textarea.html(params.content.html());
|
||||||
|
params.content.sync();
|
||||||
|
if(params.content.isEmpty()){
|
||||||
|
params.contentmsg.html('内容不能为空');
|
||||||
|
params.contentmsg.css({color:'#ff0000'});
|
||||||
|
}else{
|
||||||
|
params.contentmsg.html('填写正确');
|
||||||
|
params.contentmsg.css({color:'#008000'});
|
||||||
|
}
|
||||||
|
params.contentmsg.show();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
function init_form(params){
|
||||||
|
params.form.submit(function(){
|
||||||
|
var flag = false;
|
||||||
|
if(params.form.attr('data-remote') != undefined ){
|
||||||
|
flag = true
|
||||||
|
}
|
||||||
|
var is_checked = nh_check_field({
|
||||||
|
issubmit:true,
|
||||||
|
content:params.editor,
|
||||||
|
contentmsg:params.contentmsg,
|
||||||
|
textarea:params.textarea
|
||||||
|
});
|
||||||
|
if(is_checked){
|
||||||
|
if(flag){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
$(this)[0].submit();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
function nh_reset_form(params){
|
||||||
|
params.form[0].reset();
|
||||||
|
params.textarea.empty();
|
||||||
|
if(params.editor != undefined){
|
||||||
|
params.editor.html(params.textarea.html());
|
||||||
|
}
|
||||||
|
params.contentmsg.hide();
|
||||||
|
}
|
||||||
|
//第二个参数是高度,可以传,可以不传
|
||||||
|
function init_activity_KindEditor_data(id){
|
||||||
|
var height = arguments[1] ? arguments[1] : undefined;
|
||||||
|
var width = arguments[2] ? arguments[2] : undefined;
|
||||||
|
KindEditor.ready(function (K) {
|
||||||
|
$("div[nhname='new_message_" + id + "']").each(function () {
|
||||||
|
var params = {};
|
||||||
|
params.kindutil = K;
|
||||||
|
params.div_form = $(this);
|
||||||
|
params.form = $("form", params.div_form);
|
||||||
|
if (params.form == undefined || params.form.length == 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
params.textarea = $("textarea[nhname='new_message_textarea_" + id + "']", params.div_form);
|
||||||
|
params.contentmsg = $("p[nhname='contentmsg_" + id + "']", params.div_form);
|
||||||
|
params.toolbar_container = $("div[nhname='toolbar_container_" + id + "']", params.div_form);
|
||||||
|
params.cancel_btn = $("#new_message_cancel_btn_" + id);
|
||||||
|
params.submit_btn = $("#new_message_submit_btn_" + id);
|
||||||
|
params.height = height;
|
||||||
|
params.width = width;
|
||||||
|
if (params.textarea.data('init') == undefined) {
|
||||||
|
params.editor = init_editor(params, id);
|
||||||
|
init_form(params);
|
||||||
|
params.cancel_btn.click(function () {
|
||||||
|
nh_reset_form(params);
|
||||||
|
});
|
||||||
|
params.submit_btn.click(function () {
|
||||||
|
params.form.submit();
|
||||||
|
});
|
||||||
|
params.textarea.data('init', 1);
|
||||||
|
$(this).show();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
Loading…
Reference in new issue