2015-09-21 09:59:41 +08:00
|
|
|
<%= javascript_include_tag 'new_user' %>
|
2015-09-22 17:18:10 +08:00
|
|
|
<%= stylesheet_link_tag 'public'%>
|
2015-09-18 17:44:16 +08:00
|
|
|
<script>
|
|
|
|
function add_class(id){
|
|
|
|
if($("#"+id).hasClass("sortArrowActiveD")){
|
|
|
|
$("#"+id).removeClass("sortArrowActiveD");
|
|
|
|
$("#"+id).addClass("sortArrowActiveU");
|
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: '<%= forums_path %>' + '.js?' + id + '=asc&page='+<%= @forums_pages.page%>
|
|
|
|
|
|
|
|
});
|
|
|
|
}else if($("#"+id).hasClass("sortArrowActiveU")){
|
|
|
|
$("#"+id).removeClass("sortArrowActiveU");
|
|
|
|
$("#"+id).addClass("sortArrowActiveD");
|
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: '<%= forums_path %>' + '.js?' + id + '=desc&page='+<%= @forums_pages.page%>
|
|
|
|
|
|
|
|
});
|
|
|
|
}else{
|
|
|
|
$("#"+id).addClass("sortArrowActiveD");
|
|
|
|
$.ajax({
|
|
|
|
type: 'GET',
|
|
|
|
url: '<%= forums_path %>' + '.js?' + id + '=desc&page='+<%= @forums_pages.page%>
|
|
|
|
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$(function() {
|
|
|
|
$("#complex").click(function(){
|
|
|
|
$("#reorder_popu").removeClass("sortArrowActiveU");
|
|
|
|
$("#reorder_popu").removeClass("sortArrowActiveD");
|
|
|
|
$("#reorder_time").removeClass("sortArrowActiveD");
|
|
|
|
$("#reorder_time").removeClass("sortArrowActiveU");
|
|
|
|
add_class("reorder_complex");
|
|
|
|
});
|
|
|
|
$("#popu").click(function () {
|
|
|
|
$("#reorder_complex").removeClass("sortArrowActiveD");
|
|
|
|
$("#reorder_complex").removeClass("sortArrowActiveU");
|
|
|
|
$("#reorder_time").removeClass("sortArrowActiveD");
|
|
|
|
$("#reorder_time").removeClass("sortArrowActiveU");
|
|
|
|
add_class("reorder_popu");
|
|
|
|
});
|
|
|
|
$("#time").click(function () {
|
|
|
|
$("#reorder_complex").removeClass("sortArrowActiveD");
|
|
|
|
$("#reorder_complex").removeClass("sortArrowActiveU");
|
|
|
|
$("#reorder_popu").removeClass("sortArrowActiveU");
|
|
|
|
$("#reorder_popu").removeClass("sortArrowActiveD");
|
|
|
|
add_class("reorder_time");
|
|
|
|
});
|
2015-09-23 09:11:29 +08:00
|
|
|
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) {//大于255的都是中文
|
|
|
|
n += 2;//如果是中文就是2个字节
|
|
|
|
} else {
|
|
|
|
n += 1;//英文,不多说了
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(n >= 160)
|
|
|
|
event.returnValue = false;
|
|
|
|
}
|
2015-09-18 17:44:16 +08:00
|
|
|
});
|
|
|
|
function check_and_submit(doc){
|
2015-09-19 13:43:59 +08:00
|
|
|
$("#error").html('').hide();
|
|
|
|
check_forum_name();
|
2015-09-23 09:31:49 +08:00
|
|
|
if( $("textarea[name='forum[name]']").val().trim() == "" && $("textarea[name='forum[description]']").val().trim() != "" ){
|
|
|
|
$("#error").html("名称不能为空").show();
|
2015-09-18 17:44:16 +08:00
|
|
|
return;
|
2015-09-23 09:31:49 +08:00
|
|
|
} else if( $("textarea[name='forum[description]']").val().trim() == "" && $("textarea[name='forum[name]']").val().trim() != "" ){
|
|
|
|
$("#error").html("描述不能为空").show();
|
|
|
|
return;
|
|
|
|
}else if($("textarea[name='forum[description]']").val().trim() == "" && $("textarea[name='forum[name]']").val().trim() == ""){
|
|
|
|
$("#error").html("名称和描述不能为空").show();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else{
|
2015-09-18 17:44:16 +08:00
|
|
|
doc.parent().parent().submit();
|
|
|
|
}
|
|
|
|
}
|
2015-09-19 12:49:25 +08:00
|
|
|
var check_pass = true;
|
2015-09-18 17:44:16 +08:00
|
|
|
function check_forum_name(){
|
2015-09-19 13:43:59 +08:00
|
|
|
check_pass = true;
|
2015-09-21 09:59:41 +08:00
|
|
|
name = $("textarea[name='forum[name]']").val().trim();
|
2015-09-18 17:44:16 +08:00
|
|
|
if( name != ""){
|
|
|
|
$.get(
|
|
|
|
'<%= check_forum_name_forums_path %>',
|
|
|
|
{"forum_name":name},
|
|
|
|
function(data){
|
2014-01-02 21:36:51 +08:00
|
|
|
|
2015-09-18 17:44:16 +08:00
|
|
|
if( data == 'true'){
|
|
|
|
$("#error").html("贴吧名称已经存在").show();
|
2015-09-19 12:49:25 +08:00
|
|
|
check_pass = false;
|
2015-09-18 17:44:16 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideError(){
|
|
|
|
$("#error").html("").hide();
|
|
|
|
}
|
2015-09-22 17:27:41 +08:00
|
|
|
|
|
|
|
function create_cancle(){
|
|
|
|
$('#error').hide();
|
|
|
|
$('#new_forum_div').slideToggle();
|
|
|
|
$('#create_btn').parent().slideToggle();
|
2015-09-23 09:11:29 +08:00
|
|
|
clear_form();
|
|
|
|
}
|
|
|
|
function clear_form(){
|
2015-09-22 17:27:41 +08:00
|
|
|
$("#forum_name").val('');
|
|
|
|
$("#forum_desc").val('');
|
|
|
|
}
|
2015-09-18 17:44:16 +08:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="homepageContentContainer mb10">
|
|
|
|
<div class="homepageContent">
|
|
|
|
<div class="postContainer">
|
|
|
|
<div id="new_forum_div" class="mb5" style="display: none">
|
|
|
|
<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">
|
2015-09-23 09:11:29 +08:00
|
|
|
<textarea type="text" name="forum[name]" id="forum_name" class="postCreateInput" onfocus="hideError();" onblur="check_forum_name();" placeholder="输入贴吧名称" ></textarea>
|
2015-09-21 09:59:41 +08:00
|
|
|
<script>
|
|
|
|
var textarea = document.getElementById('forum_name');
|
|
|
|
autoTextarea(textarea);
|
|
|
|
</script>
|
2015-09-18 17:44:16 +08:00
|
|
|
</div>
|
|
|
|
<div class="mt15">
|
2015-09-21 09:59:41 +08:00
|
|
|
<textarea type="text" name="forum[description]" id="forum_desc" class="postCreateInput" placeholder="输入贴吧描述"></textarea>
|
|
|
|
<script>
|
|
|
|
var textarea1 = document.getElementById('forum_desc');
|
|
|
|
autoTextarea(textarea1);
|
|
|
|
</script>
|
2015-09-18 17:44:16 +08:00
|
|
|
</div>
|
|
|
|
<div class="mt10">
|
|
|
|
<div class="fr"><a href="javascript:void(0);" class="submit_btn" onclick="check_and_submit($(this));">确定</a></div>
|
2015-09-22 17:27:41 +08:00
|
|
|
<div class="fr"><a href="javascript:void(0);" class="linkGrey2 mr10" onclick="create_cancle();">取消</a><span class="mr10 fontGrey">或</span></div>
|
2015-09-18 17:44:16 +08:00
|
|
|
<div class="cl"></div>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
</div>
|
2015-09-19 12:32:11 +08:00
|
|
|
<div class="postBanner" id="postBanner">
|
|
|
|
<%= render :partial => 'post_banner' ,:locals => {:order_type=>@type,:order_str=>@str}%>
|
|
|
|
<!--<div class="postSort" id="complex"><a href="javascript:void(0);" class="linkGrey2 fl">综合</a><a href="javascript:void(0);" id="reorder_complex" class="sortArrowActiveD"></a></div>-->
|
|
|
|
<!--<div class="postSort" id="popu"><a href="javascript:void(0);" class="linkGrey2 fl">人气</a><a href="javascript:void(0)" id="reorder_popu" ></a></div>-->
|
|
|
|
<!--<div class="postSort" id="time"><a href="javascript:void(0);" class="linkGrey2 fl">时间</a><a href="javascript:void(0)" id="reorder_time" ></a></div>-->
|
|
|
|
<!--<div class="creatPost"><a href="javascript:void(0);" id="create_btn" class="c_white db creatPostIcon bBlue" onclick="$('#error').hide();$('#new_forum_div').slideToggle();$(this).parent().slideToggle();">新建贴吧</a></div>-->
|
|
|
|
<!--<div class="cl"></div>-->
|
|
|
|
|
2015-09-18 17:44:16 +08:00
|
|
|
</div>
|
|
|
|
<div id="forum_list">
|
|
|
|
<%= render :partial => 'forum_list',:locals => {:forums=>@forums}%>
|
|
|
|
</div>
|
2015-09-22 17:18:10 +08:00
|
|
|
<ul class="wlist fr" id="pages" style="margin-top: 10px;">
|
2015-09-23 09:26:16 +08:00
|
|
|
<%= pagination_links_full @forums_pages, @forums_count ,:per_page_links => true,:remote =>true,:flag=>true%>
|
2015-09-22 17:18:10 +08:00
|
|
|
</ul>
|
2015-09-18 17:44:16 +08:00
|
|
|
<div class="cl"></div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|