Fix site setting default-language changing effect

This commit is contained in:
Manson Wang 2013-12-02 12:15:42 +08:00
parent 8c4d6b972a
commit d1c532e8f4
1 changed files with 40 additions and 31 deletions

View File

@ -246,8 +246,33 @@
</fieldset>
<%end%>
<% content_for :page_specific_javascript do %>
<script type="text/javascript">
var locales = <%= @site.in_use_locales.to_json.html_safe %>;
$(".language-nav li a").click(function(){window.location.hash = $(this).attr("href")});
$(document).ready(function(){
// Disable default language if language detection enbaled
$("#site_enable_language_detection").change(function(){
if ( !$(this).parent().hasClass("disable") ){
$.each($( "input[name='site[default_locale]']" ),function(){
if ( !$(this).parent().hasClass("disable") ) $(this).parent().toggleClass('disable');
$(this).toggleClass('disable');
});
}
});
// Disable language detection if default language enbaled
$.each($( "input[name='site[default_locale]']" ),function(){
$(this).click(function(){
$("#site_enable_language_detection").parent().addClass('disable');
});
});
});
var locales = <%= @site.in_use_locales.to_json.html_safe %>;
$(document).ready(function(){
$( ".in_use_locales" ).each( function(){
$( this ).parent( "div.togglebox" ).addClass( "disabled" );
@ -256,36 +281,20 @@ var locales = <%= @site.in_use_locales.to_json.html_safe %>;
$( this ).parent( "div.togglebox" ).removeClass( "disabled" );
}
})
})
delete locales;
</script>
<script type="text/javascript">
$(".language-nav li a").click(function(){window.location.hash = $(this).attr("href")})
</script>>
<% content_for :page_specific_javascript do %>
<script>
$(document).ready(function(){
$(document).on('change', '.reset_default_locale', function(){
var control_group = $(this).closest(".control-group").parent().find(".control-group:eq(2)");
if ( $(this).is(":checked") ){
control_group.find(".togglebox").addClass("disabled");
control_group.find("input[type=radio]").removeAttr("checked");
}
});
});
</script>
<% end %>
<script type="text/javascript">
$(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();
}
});
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>