This commit is contained in:
sw 2015-09-25 16:58:57 +08:00
commit b84ec1360a
17 changed files with 118 additions and 69 deletions

View File

@ -296,7 +296,12 @@ class ForumsController < ApplicationController
#检查forum的名字
def check_forum_name
forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false
forum_name_exist = true
if params[:forum_id]
forum_name_exist = Forum.where("name = '#{params[:forum_name]}' and id != #{params[:forum_id]}").count >= 1 ? true : false
else
forum_name_exist = Forum.where("name = '#{params[:forum_name]}' ").count >= 1 ? true : false
end
render :text => forum_name_exist
end

View File

@ -130,7 +130,7 @@ class UsersController < ApplicationController
when 'apply'
@message_alls = ForgeMessage.where("forge_message_type =? and user_id =?" , "AppliedProject", @user).order("created_at desc")
when 'homework'
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "HomeworkCommon", @user).order("created_at desc")
@message_alls = CourseMessage.where("course_message_type in ('HomeworkCommon','StudentWorksScore','JournalsForMessage') and user_id =?", @user).order("created_at desc")
when 'course_message'
@message_alls = CourseMessage.where("course_message_type =? and user_id =?", "Message", @user).order("created_at desc")
# when 'forge_message'

View File

@ -464,7 +464,7 @@ module UsersHelper
no_html = "message"
arr = details_to_strings(journal.details, no_html)
unless journal.notes.blank?
arr << "留言内容:" + journal.notes
arr << journal.notes
end
str = ''
arr.each { |item| str = str+item }

View File

@ -73,7 +73,7 @@ class Attachment < ActiveRecord::Base
cattr_accessor :thumbnails_storage_path
@@thumbnails_storage_path = File.join(Rails.root, "tmp", "thumbnails")
before_save :files_to_final_location,:act_as_course_activity,:act_as_forge_activity
before_save :files_to_final_location,:act_as_course_activity
after_create :office_conver, :be_user_score,:act_as_forge_activity
after_update :office_conver, :be_user_score
after_destroy :delete_from_disk,:down_user_score

View File

@ -3,7 +3,7 @@
<% if tag_name && tag_name == k%>
<a href="javascript:void(0);" class="files_tag_select"><%= k%>×<%= v%></a>
<% else%>
<span class="files_tag_icon"> <a href="javascript:void(0);" ondblclick="rename_tag($(this),'<%= k %>','',<%= 6 %>);"><%= k%>×<%= v%></a></span>
<span class="files_tag_icon"> <a ondblclick="rename_tag($(this),'<%= k %>','',<%= 6 %>);"><%= k%>×<%= v%></a></span>
<% end%>
<% end%>
<% end%>

View File

@ -9,10 +9,10 @@
<div id="error" style="display: none;color: red;">
</div>
<div>
<textarea type="text" id="forum_name" name="forum[name]" class="postCreateInput" placeholder="对应贴吧名称" ><%= @forum.name.html_safe%></textarea>
<textarea type="text" id="forum_name" name="forum[name]" maxlength="50" class="postCreateInput" placeholder="对应贴吧名称" ><%= @forum.name.html_safe%></textarea>
</div>
<div class="mt15">
<textarea type="text" id="forum_desc" name="forum[description]" class="postCreateInput" placeholder="对应贴吧描述" ><%= @forum.description.html_safe%></textarea>
<textarea type="text" id="forum_desc" name="forum[description]" maxlength="5000" class="postCreateInput" placeholder="对应贴吧描述" ><%= @forum.description.html_safe%></textarea>
</div>
<div class="mt10">
<div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit($(this));">确定</a></div>

View File

@ -10,7 +10,7 @@
<!--<a href="javascript:void(0);" class="f16 linkBlue">新手讨论吧</a>-->
<%= link_to forum.name, forum_path(forum),:class=>"f16 linkBlue" %>
</div>
<div class="postDes"><%= textAreailizable forum.description%></div>
<div class="postDes" style="word-break: break-all;word-wrap : break-word ;"><%= textAreailizable forum.description%></div>
<div class="postCreater">创建者:<a href="<%= user_path( forum.creator)%>" class="linkGrey2" target="_blank"><%= forum.creator.name %></a></div>
<div class="postDate">创建时间:<%= format_date(forum.created_at) %></div>
</div>

View File

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

View File

@ -1,23 +1,7 @@
<%= javascript_include_tag "/assets/kindeditor/kindeditor",'/assets/kindeditor/pasteimg' ,'new_user' %>
<script>
$(function(){
document.getElementById('forum_name').onkeydown = function()
{
var n = 0;
var str = this.value;
for (i = 0; i < str.length; i++) {
var leg = str.charCodeAt(i);//ASCII码
if (leg > 255) {
n += 2;
} else {
n += 1;
}
}
if(n >= 160)
event.returnValue = false;
}
})
function check_and_submit(doc){
$("#error").html('').hide();
@ -66,4 +50,29 @@
autoTextarea(textarea);
var textarea1 = document.getElementById('forum_desc');
autoTextarea(textarea1);
$(function(){
$('#forum_name').keypress(function(e)
{
var n = 0;
var str = this.value;
for (i = 0; i < str.length; i++) {
var leg = str.charCodeAt(i);//ASCII码
if (leg > 255) {
n += 2;
} else {
n += 1;
}
}
if(n >= 160 && e.keyCode != 8)
if(document.all)
{
e.returnValue = false;
}
else
{
e.preventDefault();
}
})
})
</script>

View File

@ -49,7 +49,7 @@
$("#reorder_popu").removeClass("sortArrowActiveD");
add_class("reorder_time");
});
document.getElementById('forum_name').onkeydown = function()
$('#forum_name').keypress( function(e)
{
var n = 0;
var str = this.value;
@ -61,9 +61,16 @@
n += 1;//英文,不多说了
}
}
if(n >= 160 && event.keyCode != 8)
event.returnValue = false;
}
if(n >= 160 && e.keyCode != 8)
if(document.all)
{
e.returnValue = false;
}
else
{
e.preventDefault();
}
})
});
function check_and_submit(doc){
$("#error").html('').hide();
@ -89,7 +96,7 @@
if( name != ""){
$.get(
'<%= check_forum_name_forums_path %>',
{"forum_name":name},
{"forum_name":encodeURIComponent(name)},
function(data){
if( data == 'true'){
@ -129,14 +136,14 @@
<div class="red fl mb10" id="error" style="display: none">error</div>
<%= form_tag({:controller => 'forums',:action=>'create',:format=>'js'},:method => 'post',:remote=>'true') do |f| %>
<div class="mt15">
<textarea type="text" name="forum[name]" id="forum_name" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" ></textarea>
<textarea type="text" name="forum[name]" id="forum_name" maxlength="80" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" ></textarea>
<script>
var textarea = document.getElementById('forum_name');
autoTextarea(textarea);
</script>
</div>
<div class="mt15">
<textarea type="text" name="forum[description]" id="forum_desc" class="postCreateInput" placeholder="输入贴吧描述"></textarea>
<textarea type="text" name="forum[description]" id="forum_desc" maxlength="5000" class="postCreateInput" placeholder="输入贴吧描述"></textarea>
<script>
var textarea1 = document.getElementById('forum_desc');
autoTextarea(textarea1);

View File

@ -92,14 +92,14 @@
<div id="error" class="red fl mb10" style="display: none">error</div>
<%= labelled_form_for(@memo, :url => forum_memos_path(@forum)) do |f| %>
<div>
<textarea type="text" name="memo[subject]" id="memo_subject" onblur="check_memo_name();" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子标题" ></textarea>
<textarea type="text" name="memo[subject]" id="memo_subject" maxlength="50" onblur="check_memo_name();" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子标题" ></textarea>
<script>
var textarea1 = document.getElementById('memo_subject');
autoTextarea(textarea1);
</script>
</div>
<div class="mt15">
<textarea type="text" name="memo[content]" id="memo_content" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子内容" /></textarea>
<textarea type="text" name="memo[content]" id="memo_content" maxlength="5000" onfocus="$('#error').hide();" onmouseover="this.style.borderColor='#d9d9d9'" class="postDetailInput" placeholder="输入帖子内容" /></textarea>
<script>
var textarea = document.getElementById('memo_content');
autoTextarea(textarea);

View File

@ -122,6 +122,12 @@
}
}
});
function del_confirm(){
if(confirm('您确定要删除么?')){
$("#del_link").click();
}
}
</script>
</head>
<body class="<%= h body_css_classes %>">
@ -143,7 +149,7 @@
<!--<div class="homepageEditProfile"><a href="javascript:void(0);" class="homepageEditProfileIcon"></a></div>-->
</div>
<div class="fl">
<div class="f16 fontBlue mb10"><a href="<%= forums_path+"/"+@forum.id.to_s%>" style="word-break: break-all; word-wrap:break-word;"><%= @forum.name%></a></div>
<div class="f16 fontBlue mb10" style="word-break: break-all; word-wrap:break-word;"><%= @forum.name%></div>
<div class="fontGrey2 mb8">吧主:<a href="<%= user_path(@forum.creator)%>" class="linkBlue"><%= @forum.creator.name%></a></div>
<div class="fontGrey3">回答:<a href="javascript:void(0);" class="linkOrange mr5" style="cursor: default"><%= @forum.memo_count %></a> 帖子:<a href="javascript:void(0);" class="linkOrange" style="cursor: default"><%=@forum.topic_count%></a></div>
</div>
@ -172,7 +178,8 @@
<span class="postEdit">
</span>
<a href="<%= edit_forum_path(@forum) %>" class="linkGrey3">编辑贴吧</a>
<a href="<%= forum_path(@forum)%>" data-method="delete" onclick="return confirm('您确定要删除么?');" class="fr linkGrey3">删除贴吧</a>
<a href="javascript:void(0);" data-method="delete" onclick="del_confirm();" class="fr linkGrey3">删除贴吧</a>
<a href="<%= forum_path(@forum)%>" data-method="delete" id="del_link" type="hidden"></a>
<span class="postDelete"></span>
<% end %>
</div>

View File

@ -1,11 +1,16 @@
<%= javascript_include_tag 'new_user'%>
<script>
$(function(){
limitStrsize('memo_subject',50);
limitStrsize('memo_content',5000);
});
function check_and_submit(){
if($("textarea[name='memo[subject]']").val().trim() != "" && $("textarea[name='memo[content]']").val().trim() != "" ){
if($("textarea[name='memo[subject]']").val().trim().length > 50 ){
$("#error").html('主题不能超过50个字符').show();
return;
}
if($("textarea[name='memo[content]']").val().trim().length > 5000 ){
$("#error").html('内容不能超过5000个字符').show();
return;
}
$("#edit_memo").submit();
}else if($("textarea[name='memo[subject]']").val().trim() == "" && $("textarea[name='memo[content]']").val().trim() != "" ){
$("#error").html("主题不能为空").show();
@ -19,7 +24,7 @@
</div>
<div class="postRightContainer" style="margin-top: 15px">
<%= labelled_form_for(@memo, :url => forum_memo_path(@memo.forum_id, @memo),:html=>{:id=>'edit_memo'}) do |f| %>
<div id="error" style="display: none">
<div id="error" style="color:red ;display: none">
</div>
<div>
@ -44,4 +49,10 @@
<div class="cl"></div>
</div>
<% end %>
</div>
</div>
<script>
$(function(){
limitStrsize('memo_subject',50);
limitStrsize('memo_content',5000);
});
</script>

View File

@ -56,7 +56,7 @@
<%= render :partial => "memos/praise_tread",:locals => {:obj => @memo,:show_flag => true,:user_id =>User.current.id,:horizontal => true}%>
</span>
<div class="cl"></div>
<div class="fl fontGrey3" class="memo-content">
<div class="memo-content" >
<%= @memo.content.html_safe%>
</div>
<div class="cl"></div>
@ -75,7 +75,9 @@
<div class="homepagePostReplyBannerCount">回复(<%=@reply_count %></div>
<div class="homepagePostReplyBannerTime"></div>
<div class="homepagePostReplyBannerMore">
<% 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>
<% end %>
</div>
</div>
<div class="" id="reply_div_<%= @memo.id %>">

View File

@ -397,25 +397,26 @@
<% end %>
<% if ma.course_message_type == "JournalsForMessage" %>
<% if ma.course_message.jour_type == 'Course' %>
<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="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="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>
</li>
<div style="display: none" class="message_title_red system_message_style">
<%= ma.course_message.notes.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% if params[:type] != 'homework' %>
<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="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="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to ma.course_message.notes.html_safe, course_feedback_path(:id => ma.course_id),
:class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover => "message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>
</li>
<div style="display: none" class="message_title_red system_message_style">
<%= ma.course_message.notes.html_safe %>
</div>
<li class="homepageNewsTime fl"><%= time_tag(ma.created_at).html_safe %> </li>
</ul>
<% end %>
<% else %>
<ul class="homepageNewsList fl">
<li class="homepageNewsPortrait fl">
@ -542,7 +543,7 @@
更新了问题状态:</span>
</li>
<li class="homepageNewsContent fl"><a href="javascript:void(0);" class="newsGrey">
<%= link_to get_issue_des_update(ma.forge_message).html_safe,
<%= link_to ma.forge_message.journalized.subject,
issue_path(:id => ma.forge_message.journalized_id), :class => "#{ma.viewed == 0 ? "newsBlack" : "newsGrey"}",
:onmouseover =>"message_titile_show($(this),event)",
:onmouseout => "message_titile_hide($(this))" %></a>

View File

@ -337,7 +337,7 @@ var autoTextarea = function (elem, extra, maxHeight) {
};
function limitStrsize(id,length){
document.getElementById(id).onkeydown = function()
$('#'+id).keypress(function(e)
{
var n = 0;
var str = this.value;
@ -350,9 +350,16 @@ function limitStrsize(id,length){
}
}
if(n >= length && event.keyCode !== 8)
event.returnValue = false;
}
if(n >= length && e.keyCode !== 8)
if(document.all)
{
e.returnValue = false;
}
else
{
e.preventDefault();
}
})
}
/////////////////////////////////////////////////////////////////////////////////////创建项目

View File

@ -555,7 +555,7 @@ a.homepageMenuText {color:#484848; font-size:16px; margin-left:20px;}
.homepageNewsContent {width:355px; max-width:365px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
.homepageSystenMessageContent {width:291px; max-width:291px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden;text-overflow:ellipsis;max-height: 49px; }
.homepageHomeworkContentWarn {width:110px; max-width:365px; margin-right:10px; font-size:12px; color:red; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
.homepageHomeworkContent {width:245px; max-width:365px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
.homepageHomeworkContent {width:235px; max-width:365px; margin-right:10px; font-size:12px; color:#4b4b4b; display:block; overflow:hidden; white-space: nowrap; text-overflow:ellipsis;max-height: 49px; }
.homepageNewsTime {width:75px; font-size:12px; color:#888888; display:block; text-align:right;}
a.homepageWhite {color:#ffffff;}