Orbit/app/views/admin/attributes/edit.html.erb

163 lines
7.7 KiB
Plaintext
Raw Permalink Normal View History

2013-01-08 08:58:01 +00:00
<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t(:member_), :link_url => admin_site_site_info_path(@site), :icon => 'icons-group', :side_bar_content => 'admin/users_new_interface/side_bar'} %>
2013-01-08 08:58:01 +00:00
<% end %>
<%= form_for @attribute,:url => eval("admin_#{@attribute_type}_path(@attribute)") ,:class=> "form-horizontal" do |f| %>
<div class="site-map role-block">
<div class="map-block back">
2013-01-08 08:58:01 +00:00
<h4><span><%= t(eval(":#{@attribute_type}"))%></span></h4>
<div class="form-horizontal">
<div class="clear">
2013-02-20 03:12:08 +00:00
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:key) %></label>
<div class="controls">
<% if @attribute.new_record? %>
<%= f.text_field :key, :placeholder => t(:key) %>
<% else %>
<div><%= @attribute.key%></div>
<% end %>
</div>
</div>
<%= render :partial=>"shared/attribute_field/placeholder_block",:locals=>{:values=>@attribute.title_translations,:class_ext=>"pull-left",:label_ext=>t(:item_name),:field_name=>"#{@attribute_type}[title_translations]"}%>
2013-01-14 10:19:14 +00:00
2013-01-08 08:58:01 +00:00
<div class="control-group pull-left">
<label class="control-label" for="key"><%= t(:to_search) %></label>
<div class="controls">
<label class="radio inline">
<%= f.radio_button :to_search, true %>
Yes
</label>
<label class="radio inline">
<%= f.radio_button :to_search, false %>
No
</label>
</div>
</div>
</div>
</div>
</div>
2013-01-08 08:58:01 +00:00
<% if @attribute._type == "Info" %>
2012-12-05 12:32:28 +00:00
<div class="map-block back attributes">
2013-02-20 03:12:08 +00:00
<h4><span><%= @attribute.title+ t(:field)%></span></h4>
2012-12-05 12:32:28 +00:00
<div id="attribute_field_list">
<%= render :partial=>"shared/attribute_field/attribute_field",:collection=>@attribute.attribute_fields%>
</div>
</div>
2013-01-14 10:19:14 +00:00
<div class="add-attributes form-actions pagination-right">
<%= ( link_to content_tag(:i,t(:add_attribute_field),:class=>"icon-plus icon-white"),admin_info_add_attribute_field_path(@attribute),:class=>"btn btn-primary",:remote => true )%>
</div>
2013-01-08 08:58:01 +00:00
<% end %>
</div>
<div class="form-actions form-fixed pagination-right">
2013-01-18 03:09:38 +00:00
<%= f.submit t(:submit),:class=>"btn btn-primary"%>
2013-01-08 08:58:01 +00:00
<%= link_to t('cancel'), get_go_back, :class=>"btn" %>
</div>
<% end %>
<% content_for :page_specific_css do -%>
<%= stylesheet_link_tag "member" %>
<%= stylesheet_link_tag "site-map" %>
2011-12-23 10:34:21 +00:00
<% end %>
<% content_for :page_specific_javascript do -%>
2013-01-08 08:58:01 +00:00
<script>
2013-01-14 10:19:14 +00:00
var CloneTarget ;
2013-01-14 10:19:14 +00:00
var NewNode;
$(document).ready(function(){
function checkSwitch() {
$(".groups").addClass('disabled').has('.groups > .form-horizontal > div:not(.hide)').removeClass('disabled');
}
function checkMultipleInput() {
$(".multipleInput").each(function() {
$(this).find('.controls').length==1 ? $(this).addClass("plural") : $(this).removeClass("plural")
});
}
2013-01-14 10:19:14 +00:00
function removeInput(){
$(".removeInput").live('click',function (){
$(this).parents(".controls").remove();
checkMultipleInput();
return false;
});
}
checkSwitch();
checkMultipleInput();
removeInput();
2013-01-14 10:19:14 +00:00
$(".remove_attribute").live('click',function(){
$(this).siblings(".attribute_field_to_delete").val("true");
$(this).parents(".form-horizontal").fadeOut("slow", function () { $(this).hide(); });
});
$(".help-block a").live('click',function (){
CloneTarget = $(this).parents(".controls").prev(".multipleInput").find('.controls:last');
NewNode = CloneTarget.clone();
var index;
NewNode.find("input").each(function(k,v){
index = CloneTarget.parents("div.control-group").find(".list_count").val()
field_name = CloneTarget.parents("div.control-group").find(".field_name").val()
ori_str = $(v).attr("name").replace(field_name,"");
lang = ori_str.match(/\[\D*\]/);
new_field_name = (field_name+"[" + (parseInt(index)+1) + "]" + lang);
$(v).attr("name",new_field_name);
})
$(this).parents("div.control-group").find(".list_count").val(parseInt(index)+1)
$(this).parents(".controls").prev(".multipleInput").append(NewNode);
$(this).parents(".controls").prev(".multipleInput").find('.controls:last input').val("");
removeInput();
checkMultipleInput();
return false;
})
$(".status select").each(function (i) {
$(this).change(function () {
$(".status option:selected").eq(i).each(function () {
if($(this).attr("value")=="alumna") {
$(this).parents(".status").nextAll(".graduated").removeClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").removeAttr("disabled");
}else{
$(this).parents(".status").nextAll(".graduated").addClass("hide");
$(this).parents(".status").nextAll(".graduated").find("select").attr({disabled:''});
}
});
})
2013-01-14 10:19:14 +00:00
})
$('.onoff').live('click',function () {
if($(this).parents("h4").length==1) {
$(this).parents(".map-block").toggleClass("disabled");
$(this).parents(".map-block").find(".form-horizontal").toggleClass("hide");
if($(this).parents(".map-block").hasClass("disabled")){
$(this).text("OFF");
}else{
$(this).text("ON");
}
}
2013-01-14 10:19:14 +00:00
if($(this).parents("legend").length==1) {
$(this).toggleClass("disabled");
$(this).parents("legend").next("div").toggleClass("hide");
if($(this).parents("legend").next("div").hasClass("hide")){
$(this).text("OFF");
$(this).siblings(".attribute_field_disabled").val("true");
}else{
$(this).text("ON");
$(this).siblings(".attribute_field_disabled").val("false");
}
checkSwitch();
2013-01-08 08:58:01 +00:00
}
2013-01-14 10:19:14 +00:00
return false;
});
$(".dataType").change(function () {
$(this).parents("legend").next("div").find("div[class^='type']").addClass("hide");
$(this).parents("legend").next("div").find("."+$(this).find("option:selected").attr("ref")).removeClass("hide");
})
});
</script>
<% end -%>