项目留言提交JS问题修复

Branch_szzh
huang 10 years ago
parent 6a9cb0db5d
commit 55f8484654

@ -1,15 +1,15 @@
<style type="text/css"> <style type="text/css">
div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;} div.ke-toolbar{display:none;width:400px;border:none;background:none;padding:0px 0px;}
span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;} span.ke-toolbar-icon{line-height:26px;font-size:14px;padding-left:26px;}
span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )} span.ke-toolbar-icon-url{background-image:url( /images/public_icon.png )}
div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;} div.ke-toolbar .ke-outline{padding:0px 0px;line-height:26px;font-size:14px;}
span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;} span.ke-icon-emoticons{background-position:0px -671px;width:50px;height:26px;}
span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;} span.ke-icon-emoticons:hover{background-position:-79px -671px;width:50px;height:26px;}
div.ke-toolbar .ke-outline{border:none;} div.ke-toolbar .ke-outline{border:none;}
div.respond-form .reply_btn{margin-left:565px;margin-top:5px;} div.respond-form .reply_btn{margin-left:565px;margin-top:5px;}
div.recall_con{width:570px;} div.recall_con{width:570px;}
div.recall_con .reply_btn{margin-left:525px;margin-top:5px;} div.recall_con .reply_btn{margin-left:525px;margin-top:5px;}
</style> </style>
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %> <%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' %>
<div class="msg_box" id='leave-message' nhname='new_message' style="height:auto;"> <div class="msg_box" id='leave-message' nhname='new_message' style="height:auto;">
@ -22,18 +22,18 @@
<hr/> <hr/>
</div> </div>
<% else %> <% else %>
<%= form_for('new_form', :method => :post, :html => {:id => 'project_feedback_form', :multipart => true},
<%= form_for('new_form', :method => :post, :url => {:controller => 'words', :action => 'leave_project_message'}) do |f|%>
:url => {:controller => 'words', :action => 'leave_project_message'}) do |f|%> <%= f.text_area 'project_message', :rows => 3, :cols => 65,
<%= f.text_area 'project_message', :rows => 3, :cols => 65, :placeholder => "#{l(:label_welcome_my_respond)}",:nhname=>'new_message_textarea' %>
:placeholder => "#{l(:label_welcome_my_respond)}",:nhname=>'new_message_textarea' %> <p nhname="contentmsg"></p>
<p nhname="contentmsg"></p> <div class="fl mt10" style="padding-top:5px;" nhname="toolbar_container"></div>
<div class="fl mt10" style="padding-top:5px;" nhname="toolbar_container"></div> <%#= submit_tag l(:button_leave_meassge), :name => nil , :class => "blue_btn fr mt10 mb10" %>
<%= submit_tag l(:button_leave_meassge), :name => nil , :class => "blue_btn fr mt10 mb10" %> <%= link_to l(:button_leave_meassge), "javascript:void(0)", :onclick => 'submitProjectFeedback();', :onmouseover => 'submitFocus(this);', :class => 'blue_btn fr mt10 mb10' %>
<% end %> <% end %>
<% end %> <% end %>
<div class="cl"></div> <div class="cl"></div>
</div> </div>
<div id="history"> <div id="history">
<%= render :partial => 'history',:locals => { :journals => @jour, :state => false} %> <%= render :partial => 'history',:locals => { :journals => @jour, :state => false} %>
@ -42,47 +42,47 @@
<div style="display:none;"><a href="#" id="nhjump"></a></div> <div style="display:none;"><a href="#" id="nhjump"></a></div>
<script type="text/javascript"> <script type="text/javascript">
$(function(){ $(function(){
function init_editor(params){ function init_editor(params){
params.textarea.removeAttr('placeholder'); params.textarea.removeAttr('placeholder');
var editor = params.kindutil.create(params.textarea, { var editor = params.kindutil.create(params.textarea, {
resizeType : 1,minWidth:"1px",width:"100%",height:"150px", resizeType : 1,minWidth:"1px",width:"100%",height:"150px",
items:['emoticons'], items:['emoticons'],
afterChange:function(){//按键事件 afterChange:function(){//按键事件
nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea}); nh_check_field({content:this,contentmsg:params.contentmsg,textarea:params.textarea});
}, },
afterCreate:function(){ afterCreate:function(){
var toolbar = $("div[class='ke-toolbar']",params.div_form); var toolbar = $("div[class='ke-toolbar']",params.div_form);
$(".ke-outline>.ke-toolbar-icon",toolbar).append('表情'); $(".ke-outline>.ke-toolbar-icon",toolbar).append('表情');
params.toolbar_container.append(toolbar); params.toolbar_container.append(toolbar);
}
}).loadPlugin('paste');
return editor;
} }
}).loadPlugin('paste');
return editor;
}
function nh_check_field(params){ function nh_check_field(params){
var result=true; var result=true;
if(params.content!=undefined){ if(params.content!=undefined){
if(params.content.isEmpty()){ if(params.content.isEmpty()){
result=false; result=false;
} }
if(params.content.html()!=params.textarea.html() || params.issubmit==true){ if(params.content.html()!=params.textarea.html() || params.issubmit==true){
params.textarea.html(params.content.html()); params.textarea.html(params.content.html());
params.content.sync(); params.content.sync();
if(params.content.isEmpty()){ if(params.content.isEmpty()){
params.contentmsg.html('内容不能为空'); params.contentmsg.html('内容不能为空');
params.contentmsg.css({color:'#ff0000'}); params.contentmsg.css({color:'#ff0000'});
}else{ }else{
params.contentmsg.html('填写正确'); params.contentmsg.html('填写正确');
params.contentmsg.css({color:'#008000'}); params.contentmsg.css({color:'#008000'});
} }
params.contentmsg.show(); params.contentmsg.show();
}
}
return result;
} }
} function init_form(params){
return result;
}
function init_form(params){
// var flag = false; // var flag = false;
// if(params.form.attr('data-remote') != undefined ){ // if(params.form.attr('data-remote') != undefined ){
// flag = true // flag = true
@ -108,93 +108,93 @@
// return false; // return false;
// } // }
params.form.submit(function(){ params.form.submit(function(){
var flag = false; var flag = false;
if(params.form.attr('data-remote') != undefined ){ if(params.form.attr('data-remote') != undefined ){
flag = true flag = true
} }
var is_checked = nh_check_field({ var is_checked = nh_check_field({
issubmit:true, issubmit:true,
content:params.editor, content:params.editor,
contentmsg:params.contentmsg, contentmsg:params.contentmsg,
textarea:params.textarea textarea:params.textarea
}); });
if(is_checked){ if(is_checked){
if(flag){ if(flag){
return true; return true;
}else{ }else{
$(this)[0].submit(); $(this)[0].submit();
return false; return false;
} }
// return true; //这个涛哥的firefox不能提交 // return true; //这个涛哥的firefox不能提交
//$(this).trigger('submit'); //这个虽然能提交 但是他是个死循环 //$(this).trigger('submit'); //这个虽然能提交 但是他是个死循环
//$(this)[0].submit(); //用这个form的data-remote='true'没效果了 //$(this)[0].submit(); //用这个form的data-remote='true'没效果了
//肿么破阿 我滴个神 实在不行就用$.ajax()算了 //肿么破阿 我滴个神 实在不行就用$.ajax()算了
}
return false;
});
} }
return false; function nh_reset_form(params){
}); params.form[0].reset();
} params.textarea.empty();
function nh_reset_form(params){ if(params.editor != undefined){
params.form[0].reset(); params.editor.html(params.textarea.html());
params.textarea.empty(); }
if(params.editor != undefined){ params.contentmsg.hide();
params.editor.html(params.textarea.html());
}
params.contentmsg.hide();
}
KindEditor.ready(function(K){
$("a[nhname='reply_btn']").live('click',function(){
var params = {};
params.kindutil = K;
params.container = $(this).parent('div').parent('div');
params.div_form = $(">.respond-form",params.container);
params.form = $("form",params.div_form);
params.textarea = $("textarea[name='user_notes']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
if(params.textarea.data('init') == undefined){
params.editor = init_editor(params);
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
});
} }
params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea); KindEditor.ready(function(K){
setTimeout(function(){ $("a[nhname='reply_btn']").live('click',function(){
if(!params.div_form.is(':hidden')){ var params = {};
params.textarea.show(); params.kindutil = K;
params.textarea.focus(); params.container = $(this).parent('div').parent('div');
params.textarea.hide(); params.div_form = $(">.respond-form",params.container);
params.form = $("form",params.div_form);
params.textarea = $("textarea[name='user_notes']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
params.cancel_btn = $("input[nhname='cancel_btn']",params.div_form);
if(params.textarea.data('init') == undefined){
params.editor = init_editor(params);
init_form(params);
params.cancel_btn.click(function(){
nh_reset_form(params);
});
}
params.cancel_btn.click();
toggleAndSettingWordsVal(params.div_form, params.textarea);
setTimeout(function(){
if(!params.div_form.is(':hidden')){
params.textarea.show();
params.textarea.focus();
params.textarea.hide();
// $("#nhjump").attr('href','#'+params.div_form.attr('id')); // $("#nhjump").attr('href','#'+params.div_form.attr('id'));
// $("#nhjump")[0].click(); // $("#nhjump")[0].click();
} }
},300); },300);
params.textarea.data('init',1); params.textarea.data('init',1);
}); });
$("div[nhname='new_message']").each(function(){ $("div[nhname='new_message']").each(function(){
var params = {}; var params = {};
params.kindutil = K; params.kindutil = K;
params.div_form = $(this); params.div_form = $(this);
params.form = $("form",params.div_form); params.form = $("form",params.div_form);
if(params.form==undefined || params.form.length==0){ if(params.form==undefined || params.form.length==0){
return; return;
} }
params.textarea = $("textarea[nhname='new_message_textarea']",params.div_form); params.textarea = $("textarea[nhname='new_message_textarea']",params.div_form);
params.contentmsg = $("p[nhname='contentmsg']",params.div_form); params.contentmsg = $("p[nhname='contentmsg']",params.div_form);
params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form); params.toolbar_container = $("div[nhname='toolbar_container']",params.div_form);
if(params.textarea.data('init') == undefined){ if(params.textarea.data('init') == undefined){
params.editor = init_editor(params); params.editor = init_editor(params);
init_form(params); init_form(params);
// $("a[nhname='cancel_btn']",params.div_form).click(function(){ // $("a[nhname='cancel_btn']",params.div_form).click(function(){
// nh_reset_form(params); // nh_reset_form(params);
// }); // });
params.textarea.data('init',1); params.textarea.data('init',1);
} }
}); });
});
}); });
});
</script> </script>

@ -491,3 +491,8 @@ function judgeprojectname(){
} }
}); });
} }
//用户反馈
function submitProjectFeedback() {
$("#project_feedback_form").submit();
}
Loading…
Cancel
Save