orbit-4-2/app/views/admin/sites/preference.html.erb

325 lines
16 KiB
Plaintext
Raw Permalink Normal View History

<% content_for :side_bar do %>
<%= render :partial => 'layouts/side_bar', :locals => {:link_name => t('site.settings'), :link_url => admin_site_site_info_path(@site), :icon => 'icons-cog', :side_bar_content => 'admin/sites/side_bar'} %>
<% end %>
<head>
<%= stylesheet_link_tag "lib/wrap-nav"%>
<%= stylesheet_link_tag "lib/main-forms"%>
<%= stylesheet_link_tag "lib/fileupload"%>
<%= stylesheet_link_tag "lib/togglebox"%>
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
<%= javascript_include_tag 'lib/site_set' %>
</head>
<%= form_for @site, :url => admin_site_path(@site), :html => {:class => "form-horizontal main-forms"} do |f| %>
<fieldset>
<!-- Input Area -->
<div class="input-area">
<div class="nav-name"><strong><%= t('preferences.classification') %></strong></div>
<ul class="nav nav-pills language-nav">
<li class="active">
<a href="#sidebar-nav" data-toggle="tab"><%= t('preferences.sidebar_nav') %></a>
</li>
<li>
<a href="#system-email" data-toggle="tab"><%= t('preferences.system_email') %></a>
</li>
<li>
<a href="#openness" data-toggle="tab"><%= t('preferences.openness') %></a>
</li>
<li>
<a href="#language-set" data-toggle="tab"><%= t('preferences.language') %></a>
</li>
<li>
<a href="#orbitBar-them" data-toggle="tab"><%= t('preferences.orbitbar_theme') %></a>
</li>
</ul>
<div class="tab-content">
<!-- Sidebar Nav -->
<div id="sidebar-nav" class="tab-pane fade in active">
<div class="control-group">
<label class="control-label muted"><%= t("preferences.nav_enabled") %></label>
<div class="controls">
<input type="checkbox" class="toggle-check set-sidebar-state" data-disabled="true">
</div>
</div>
</div>
<!-- System Email -->
<%= f.fields_for :site_settings, @site['site_settings'] do |f| %>
<div id="system-email" class="tab-pane fade">
2014-03-07 07:15:52 +00:00
<div class="control-group">
<label class="control-label muted"><%= t 'mail.service_email' %></label>
<div class="controls">
<%= f.text_field :service_email, :value => (@site['site_settings']['service_email'] rescue nil), :class=>"input-large", :placeholder=>"Administrator Mail" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.reply_email' %></label>
<div class="controls">
<%= f.text_field :reply_email, :value => (@site['site_settings']['reply_email'] rescue nil), :class=>"input-large", :placeholder=>"Reply Mail" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.address' %></label>
<div class="controls">
<%= f.text_field :address, :value => (@site['site_settings']['address'] rescue nil), :class=>"input-large", :placeholder=>"Email Address" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.domain' %></label>
<div class="controls">
<%= f.text_field :domain, :value => (@site['site_settings']['domain'] rescue nil), :class=>"input-large", :placeholder=>"Domain" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.authentication' %></label>
<div class="controls">
<%= f.text_field :authentication, :value => (@site['site_settings']['authentication'] rescue nil), :class=>"input-large", :placeholder =>"Authentication" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.user_name' %></label>
<div class="controls">
<%= f.text_field :user_name, :value => (@site['site_settings']['user_name'] rescue nil), :class=>"input-large", :placeholder=>"User Name" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.password' %></label>
<div class="controls">
<%= f.password_field :password, :value => (@site['site_settings']['password'] rescue nil), :class=>"input-large", :placeholder=>"Password" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.port' %></label>
<div class="controls">
<%= f.text_field :port, :value => (@site['site_settings']['port'] rescue nil),:placeholder=>"Port", :class=>"input-mini" %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.tls' %></label>
<div class="controls">
<%= f.check_box :tls, :checked => (@site['site_settings']['tls'].eql?('1') rescue false),:class=>"toggle-check", :data=> { disabled: true } %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t 'mail.enable_starttls_auto' %></label>
<div class="controls">
<%= f.check_box 'enable_starttls_auto', :checked => (@site['site_settings']['enable_starttls_auto'].eql?('1') rescue false), :class=>"toggle-check", :data=> { disabled: true } %>
</div>
</div>
</div>
<% end %>
<!-- Openness -->
<div id="openness" class="tab-pane fade">
<div class="control-group">
<label class="control-label muted"><%= I18n.t('site.frontend_open')%></label>
<div class="controls">
<%= f.check_box :frontend_open , :class=>"toggle-check", :data=> { disabled: true } %>
<span class="help-block"><%= t("preferences.frontend_open") %></span>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= I18n.t('site.backend_openness_on') %></label>
<div class="controls">
<%= f.check_box :backend_openness_on , :class=>"toggle-check", :data=> { disabled: true } %>
<span class="help-block"><%= t("preferences.backend_open") %></span>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= I18n.t('site.enable_personal_desktop')%></label>
<div class="controls">
<%= f.check_box :desktop_closed , :class=>"toggle-check", :data=> { disabled: true } %>
</div>
</div>
</div>
<!-- Language -->
<div id="language-set" class="tab-pane fade">
<!-- <div class="control-group">
<label class="control-label muted">Enable User Language Detection</label>
<div class="controls">
<input type="checkbox" class="toggle-check" data-disabled="true">
</div>
</div> -->
<!-- Terms of Use -->
<div class="control-group">
<label class="control-label muted"><%= t('preferences.lang_detection') %>
</label>
<div class="controls">
<%= f.check_box :enable_language_detection, :class => "toggle-check reset_default_locale", data: {disabled: true} %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('preferences.lang_enabled') %></label>
<div class="controls">
<% @site_valid_locales.each do |valid_locale| %>
<%= check_box_tag "site[in_use_locales][]", valid_locale, @site.in_use_locales.include?(valid_locale), :class=>"toggle-check in_use_locales", :data => { :title => "#{I18nVariable.from_locale(valid_locale)}", disabled: true }, "data-deploy"=>"inline" %>
<% end %>
</div>
</div>
<div class="control-group">
<label class="control-label muted"><%= t('preferences.lang_default') %></label>
<div class="controls">
<% @site_in_use_locales.each do |locale| %>
<%= radio_button_tag "site[default_locale]", locale, @locale == locale ,:class=>"toggle-check", :data => { :title => "#{I18nVariable.from_locale(locale)}" }, "data-deploy"=>"inline", :checked => (@site.default_locale.eql?("#{locale}")) %>
<% end %>
</div>
</div>
</div>
<!-- OrbitBar Them -->
<div id="orbitBar-them" class="tab-pane fade">
<div class="control-group">
<label class="control-label muted">OrbitBar Logo <%= t('preferences.icon') %></label>
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left" style="background:black;">
<% if @site.default_image.file.present? %>
<%= image_tag( @site.default_image, :size=>"120x120") rescue ''%>
<% else %>
<%= image_tag "orbit-logo.png",:class => "pull-left upload-picture"%>
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<% if @site.default_image.file.present?%>
<span class="btn btn-file">
<%= f.file_field :default_image, :id => "input-upload", :class => 'fileupload-new', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %><%= t('preferences.change') %>
</span>
<%= f.check_box :remove_default_image %>
<%= t(:remove) %> OrbitBar Logo
<%else%>
<span class="btn btn-file">
<%= f.file_field :default_image, :id => "input-upload", :class => 'fileupload-new', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %><%= t('preferences.select_image') %>
</span>
<%end%>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
</div>
</div>
<div class="control-group">
<label class="control-label muted">Orbit <%= t('preferences.favicon') %></label>
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<div class="fileupload-new thumbnail pull-left">
<% if @site.favicon.file.present? %>
<%= image_tag( @site.favicon, :size=>"120x120") rescue ''%>
<% else %>
<%= image_tag "favicon.ico", :class => "pull-left upload-picture"%>
<% end %>
</div>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<% if @site.favicon.file.present?%>
<span class="btn btn-file">
<%= f.file_field :favicon, :id => "input-upload", :class => 'fileupload-new', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %><%= t('preferences.change') %>
</span>
<%= f.check_box :remove_favicon %>
<%= t(:remove) %> <%= t('preferences.favicon') %>
<%else%>
<span class="btn btn-file">
<%= f.file_field :favicon, :id => "input-upload", :class => 'fileupload-new', :onchange => "document.getElementById('fu').innerHTML = this.form.fu.value = this.value;" %><%= t('preferences.select_image') %>
</span>
<%end%>
<a href="#" class="btn fileupload-exists" data-dismiss="fileupload"><%= t(:cancel) %></a>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- Form Actions -->
<div class="form-actions" style="background: none;">
<%= f.submit t("submit"), :class => "btn btn-primary" %>
<%= f.submit t("cancel"), :class => "btn ", :type => 'reset' %>
</div>
</fieldset>
<%end%>
<% content_for :page_specific_javascript do %>
<%end%>
<script type="text/javascript">
$(".language-nav li a").click(function(){window.location.hash = $(this).attr("href")});
$(document).ready(function(){
var language_detection = $("#site_enable_language_detection");
var default_locale = $( "input[name='site[default_locale]']" );
$(language_detection).click(function(){
if ( !$(this).parent().hasClass("disable") ){
// Disable default language if language detection enbaled
$.each($(default_locale),function(){
if ( !$(this).parent().hasClass("disable") ){
$(this).parent().toggleClass('disable');
$(this).toggleClass('disable');
}
$(language_detection).val(1);
});
}else{
// Enable a default language when language detection is disabled
$(default_locale).first().click();
}
});
// Disable language detection if default language enbaled
$.each($(default_locale),function(){
$(this).change(function(){
if(!$(language_detection).parent().hasClass("disable")) {
$(language_detection).parent().toggleClass('disable');
$(language_detection).val(0);
}
});
});
});
var locales = <%= @site.in_use_locales.to_json.html_safe %>;
$(document).ready(function(){
$( ".in_use_locales" ).each( function(){
$( this ).parent( "div.togglebox" ).addClass( "disabled" );
var val = $( this ).val();
if( locales.filter(function(a){ return a == val }).length == 1){
$( this ).parent( "div.togglebox" ).removeClass( "disabled" );
}
})
});
delete locales;
$(function() {
$('a[data-toggle="tab"]').on('click', function (e) {
var tab = $(this).attr('href');
localStorage.setItem('lastTab', tab);
});
//go to the latest tab, if it exists:
var lastTab = localStorage.getItem('lastTab');
if (lastTab) {
$('a[href='+lastTab+']').click();
}
});
</script>