1.组织配置中,输入组织名字、子栏目域名目录后,自动变成小写字母;2.将所有子域名及域名目录改成小写;3.组织配置中,修改子栏目时,如果没有点确定,输入框的内容保持不变。

This commit is contained in:
ouyangxuhua 2016-03-22 13:51:19 +08:00
parent 4fa1288411
commit 675b1ad403
4 changed files with 49 additions and 13 deletions

View File

@ -11,7 +11,7 @@ class OrgSubfieldsController < ApplicationController
sql = "select subfield_subdomain_dirs.* from subfield_subdomain_dirs, org_subfields where subfield_subdomain_dirs.org_subfield_id = org_subfields.id "+
"and org_subfields.organization_id=#{@organization.id} and subfield_subdomain_dirs.name='#{params[:sub_dir]}'"
if SubfieldSubdomainDir.find_by_sql(sql).count == 0
SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir])
SubfieldSubdomainDir.create(:org_subfield_id => @subfield.id, :name => params[:sub_dir].downcase)
end
end
@subfield.update_attributes(:field_type => params[:field_type])

View File

@ -54,7 +54,7 @@
</div>
<% end %>
<div id="sub_dir_edit_<%= field.id %>" style="display:none;">
<input type="text" name="name" onblur="update_sub_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>','<%= field.id %>',$(this).val());" value="<%= field.subfield_subdomain_dir.nil? ? '': field.subfield_subdomain_dir.name %>" style="width:70px;"/>
<input type="text" name="name" onfocus="observe_input_to_lowercase($(this));" onblur="update_sub_dir('#sub_dir_show_<%= field.id %>','#sub_dir_edit_<%= field.id %>','<%= field.id %>',$(this).val().toLowerCase());" value="<%= field.subfield_subdomain_dir.nil? ? '': field.subfield_subdomain_dir.name %>" style="width:70px;"/>
</div>
</li>
<%#= link_to "隐藏", hide_org_subfield_organizations_path(field), :method => 'post', :remote => true, :id => "hide_#{field.id}", :class => "linkBlue fr mr5" %>
@ -85,6 +85,9 @@
url: "/org_subfields/" + field_id + "?name=" + input_value,
type: 'put'
});
else{
$(edit_id).children("input").val($(show_id).html().trim());
}
}
$(show_id).show();
$(edit_id).hide();
@ -109,6 +112,9 @@
url: "/org_subfields/" + field_id + "/update_sub_dir?sub_dir_name=" + input_value,
type: 'put'
});
else{
$(edit_id).children("input").val($(show_id).html().trim());
}
}
$(show_id).show();
$(edit_id).hide();
@ -134,6 +140,9 @@
type: 'put'
});
}
else{
$(edit_id).children("input").val($(show_id).html().trim());
}
}
else
{

View File

@ -57,7 +57,7 @@
<div style="margin-left: 80px " id="check_desc_hint"></div>
<div class="orgRow mb10"><span class="ml10">组织URL</span>
<div class="w607 fr">http//
<input type="text" name="organization[domain]" id="domain" value="<%= domain.nil? ? '' : domain.subname %>" class="orgUrlInput" />
<input type="text" name="organization[domain]" id="domain" value="<%= domain.nil? ? '' : domain.subname %>" class="orgUrlInput" onfocus="observe_input_to_lowercase($(this));" />
.trustie.net<a href="javascript:void(0);" class="linkBlue ml15" style="text-decoration:underline;" onclick="apply_subdomain(<%= @organization.id %>,$('#domain').val());">申请</a>
<% record = OrgMessage.where("organization_id=? and message_type='ApplySubdomain'", @organization.id).order("updated_at desc").first %>
<% if domain.present? and record.present? and record.content == domain.subname %>
@ -129,9 +129,9 @@
<div class="mb5">
<p class="fontGrey3"><span class="fb">域名目录</span>用户自定义url可选</p>
<% if domain %>
<span class="fl"><%= domain.subname %>.trustie.net/</span><input id="sub_dir" class="fl personalUrl ml3" type="text" name="sub_dir">
<span class="fl"><%= domain.subname %>.trustie.net/</span><input id="sub_dir" class="fl personalUrl ml3" type="text" name="sub_dir" onfocus="observe_input_to_lowercase($(this));">
<% else %>
<span class="fl">您还没有子域名,请先在左侧信息栏申请子域名</span>
<span class="fl" style="width:195px;">您还没有子域名,请先在左侧信息栏申请子域名</span>
<% end %>
<div class="cl"></div>
</div>
@ -195,12 +195,25 @@
}
}
// $(document).ready(function(){
// if ( $("#is_public").attr("checked") != true){
// alert($(this).attr("checked"));
// $("#allow_download").attr("checked", false);
// $("#allow_download").attr("disabled", true);
// $("#allow_down_hint").html("");
// }
// });
//输入子域名或者二级目录,自动将输入换成小写
function observe_input_to_lowercase(id){
$(id).each(function(){
var $this = $(this);
var old_input = $this.val();
var check=function(){
var val = $this.val();
if ( old_input != val){
$this.val(val.toLowerCase());
old_input = val.toLowerCase();
}
};
var reset = function() {
if (timer) {
clearInterval(timer);
}
};
var timer = setInterval(check, 300);
$this.bind('blur', reset);
});
}
</script>

View File

@ -0,0 +1,14 @@
class ChangeDomainNameToLowercase < ActiveRecord::Migration
def up
Secdomain.all.each do |domain|
domain.update_attribute(:subname, domain.subname.downcase)
end
SubfieldSubdomainDir.all.each do |dir|
dir.update_attribute(:name, dir.name.downcase)
end
end
def down
end
end