Merge pull request #101 from tractorcow/master-querystring-fixes

BUG Cleaner handling of querystring arguments when selecting locale
This commit is contained in:
Ingo Schommer 2013-04-11 00:56:46 -07:00
commit ba31412fa8
2 changed files with 14 additions and 5 deletions

View File

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

View File

@ -36,10 +36,19 @@
this._super(); this._super();
}, },
onchange: function(e) { onchange: function(e) {
var url = $.path.addSearchParams( // Get new locale code
document.location.href.replace(/locale=[^&]*/, ''), locale = {locale: $(e.target).val()};
{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); $('.cms-container').loadPanel(url);
return false; return false;
} }