BUG Cleaner handling of querystring arguments when selecting locale

This commit is contained in:
Damian Mooyman 2013-03-21 16:01:03 +13:00
parent 2dff101b45
commit ad791ca5d8
2 changed files with 14 additions and 5 deletions

View File

@ -40,7 +40,7 @@ class TranslatableCMSMainExtension extends Extension {
$req->param('Action'),
$req->param('ID'),
$req->param('OtherID'),
'?' . http_build_query($getVars)
($query = http_build_query($getVars)) ? "?$query" : null
));
}
}

View File

@ -36,10 +36,19 @@
this._super();
},
onchange: function(e) {
var url = $.path.addSearchParams(
document.location.href.replace(/locale=[^&]*/, ''),
{locale: $(e.target).val()}
);
// Get new locale code
locale = {locale: $(e.target).val()};
// Check existing url
search = /locale=[^&]*/;
url = document.location.href;
if(url.match(search)) {
// Replace locale code
url = url.replace(search, $.param(locale));
} else {
// Add locale code
url = $.path.addSearchParams(url, locale);
}
$('.cms-container').loadPanel(url);
return false;
}