增加编辑器

Signed-off-by: alan <547533434@qq.com>
This commit is contained in:
alan 2015-05-20 17:38:40 +08:00
parent ab9d74f364
commit 4a588506a4
6 changed files with 76 additions and 28 deletions

View File

@ -2,17 +2,17 @@
<% if topic.project %>
<%#= board_breadcrumb(@message) %>
<!--<h3><%#= avatar(@topic.author, :size => "24") %><span style = "width:100%;word-break:break-all;word-wrap: break-word;"><%#=h @topic.subject %></span></h3>-->
<div class="talk_new ml15">
<div class="talk_new ml15" name='containerxxoo'>
<ul>
<%= form_for topic, { :as => :message,
:url => {:controller => 'messages',:action => 'edit', :is_board => 'true',:id => topic.id, :board_id => topic.board_id},
:html => {:multipart => true,
:html => {:multipart => true, :name=>'message-form',
:id => 'message-form' + topic.id.to_s,
:method => :post}
} do |f| %>
<%= render :partial => 'form_project',
:locals => {:f => f, :replying => !topic.parent.nil?, :topic => topic} %>
<a href="javascript:void(0)" onclick="submitProjectsBoard('<%= topic.id%>');" class="blue_btn fl c_white" ><%= l(:button_submit)%></a>
<a href="javascript:void(0)" name='submitbtn' class="blue_btn fl c_white" ><%= l(:button_submit)%></a>
<a href="javascript:void(0)" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" class="blue_btn grey_btn fl c_white"><%= l(:button_cancel) %></a>
<%#= link_to l(:button_cancel), board_message_url(topic.board, topic.root, :r => (topic.parent_id && topic.id)), :class => "blue_btn grey_btn fl c_white" %>
</ul>

View File

@ -48,24 +48,10 @@
</li>
<li>
<div id="message_quote" class="wiki" style="width: 100%;word-break: break-all;word-wrap: break-word;"></div>
<script>
var id = <%= f.object.id %>
var editor = new Array();
KindEditor.ready(function(K) {
editor[id] = K.create('textarea[name="content"]', {
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
width:"100%",
items : [
'emoticons']
});
});
</script>
<% unless replying %>
<label class="fl ml3" ><span class="c_red">*</span>&nbsp;<%= l(:field_description) %>&nbsp;</label>
<% end %>
<%= text_area :quote,:quote,:style => 'display:none' %>
<%= f.text_area :quote,:quote,:style => 'display:none' %>
<div class="content">
<% if replying%>

View File

@ -1,10 +1,10 @@
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form'} do |f| %>
<%= form_for @message, :url =>{:controller=>'messages',:action => 'new', :board_id => @board.id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message-form', :name=>'message-form'} do |f| %>
<%= render :partial => 'form_project', :locals => {:f => f, :topic => @message} %>
<li>
<a href="javascript:void(0)" onclick="show_newtalk();" class="grey_btn fr ml10"><%= l(:button_cancel) %></a>
<a href="#" onclick="submitProjectsBoard('<%= @message.id %>')" class="blue_btn fr " style="margin-left: 55px"><%= l(:button_submit)%></a>
<a href="javascript:;" name="submitbtn" class="blue_btn fr " style="margin-left: 55px"><%= l(:button_submit)%></a>
<div class="cl"></div>
</li>
<% end %>

View File

@ -22,7 +22,7 @@
<!-- 发布新帖部分 -->
<div class="cl"></div>
<div class=" talklist_box" >
<div class="talk_new ml15 mb10" id="about_newtalk" style="display:<%= !@flag.nil? && @flag=='true' ? 'block' : 'none' %>;">
<div class="talk_new ml15 mb10" name="containerxxoo" id="about_newtalk" style="display:<%= !@flag.nil? && @flag=='true' ? 'block' : 'none' %>;">
<ul>
<%= render :partial => 'project_new_topic' %>
</ul>
@ -41,6 +41,7 @@
<p class="talkmain_tit fl fb break_word">&nbsp;&nbsp;<%= h(topic.subject) %></p>
<% if topic.editable_by?(User.current) %>
<a href="javascript:void(0)" onclick="show_newtalk1('#about_newtalk<%= topic.id%>');" style="color: #426e9a;float: right;
margin-right: 10px;"><%= l(:button_edit) %></a>
<% end %>
@ -81,7 +82,7 @@
<%= l(:label_activity_time)%>&nbsp;&nbsp;<%= format_time topic.created_on %>
</div>
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => 'message_content',:class => ' c_dblue fr' %>
<%= toggle_link l(:button_reply), "reply" + topic.id.to_s, :focus => "about_newtalk#{topic.id}",:class => ' c_dblue fr' %>
<div class="cl"></div>
@ -98,12 +99,12 @@
<% if !topic.locked? && authorize_for('messages', 'reply') %>
<em class="talkWrapArrow"></em>
<div class="cl"></div>
<div class="talkConIpt ml15 mb10" style="display: none" id="reply<%= topic.id %>">
<%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s} do |f| %>
<div class="talkConIpt ml15 mb10" style="display: none" name="containerxxoo" id="reply<%= topic.id %>">
<%= form_for reply, :as => :reply, :url => {:controller=>'messages',:action => 'reply', :id => topic.id, :board_id => topic.board_id, :is_board => 'true'}, :html => {:multipart => true, :id => 'message_form' + topic.id.to_s, :name=>'message-form'} do |f| %>
<%= render :partial => 'form_project', :locals => {:f => f, :replying => true} %>
<%= toggle_link l(:button_cancel), "reply" + topic.id.to_s, :focus => 'message_content',:class => 'grey_btn fr ml10' %>
<a href="#" onclick="$('#message_form<%= topic.id%>').submit();" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a>
<a href="javascript:(0)" name="submitbtn" class="blue_btn fr " style=""><%= l(:label_memo_create)%></a>
<% end %>
@ -142,6 +143,16 @@
:title => l(:button_delete),
:class => ' c_dblue fr'
) if message.course_destroyable_by?(User.current) %>
<%= link_to(
l(:button_quote),
{:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:class => ' c_dblue fr',
:style => 'margin-right: 10px;',
:remote => true,
:method => 'get',
:onclick => "$('#reply#{topic.id}').slideToggle(); return false;",
:focus => "about_newtalk#{topic.id}",
:title => l(:button_quote)) if !topic.locked? && authorize_for('messages', 'reply') %>
</div>
<div class="cl"></div>
@ -169,8 +180,18 @@
:method => :post,
:data => {:confirm => l(:text_are_you_sure)},
:title => l(:button_delete),
:class => ' c_dblue fr'
) if message.course_destroyable_by?(User.current) %>
<%= link_to(
l(:button_quote),
{:controller => 'messages', :action => 'quote', :id => message.id, :board_id => message.board_id, :is_board => 'true'},
:remote => true,
:method => 'get',
:focus => "about_newtalk#{topic.id}",
:class => ' c_dblue fr',
:style => 'margin-right: 10px;',
:title => l(:button_quote)) if !topic.locked? && authorize_for('messages', 'reply') %>
</div>
<div class="cl"></div>
@ -216,4 +237,34 @@
}
}
</script>
<script type="text/javascript">
//submitProjectsBoard()
KindEditor.ready(function(K){
$("div[name='containerxxoo']").each(function(){
var container=$(this);
var textarea= $("textarea[name='content']",container);
var editor = K.create(textarea, {
resizeType : 1,
allowPreviewEmoticons : false,
allowImageUpload : false,
width:"89%",
items : ['emoticons']
});
$("a[name='submitbtn']",container).click(function(){
textarea[0].value = editor.html();
var id = textarea[0].id.toString().substr(15);
if(this.parentNode.name == 'message-form') {
this.parentNode.submit();
}
else
this.parentNode.parentNode.submit();
});
});
});
</script>

View File

@ -51,11 +51,17 @@ var getParam = function(name){
function show_newtalk()
{
$("#about_newtalk").toggle();
}
function show_newtalk1(id)
{
$(id).toggle();
}

View File

@ -161,10 +161,15 @@ function regexSubject(id) {
}
return false;
}
function regexContent(id) {
editor[id].sync();
function regexContent(){
}
function regexContentxx(id) {
var contentid = "#message_content" + id;
var message = "#message_content_span"+ id;
var ps=document.getElementById('message_content' + id).previousElementSibling.children[1].children[0];
alert(ps);
document.getElementById('message_content' + id).value = ps.value;
var content = $.trim($(contentid).val());
alert(content);
if (content.length == 0) {
@ -188,7 +193,7 @@ function submitProjectsBoard(id) {
if (regexSubject(id) && regexContent(id)) {
$(formid).submit();
$(formid).submit();
}
}
// 提交新闻