mirror of
https://github.com/silverstripe/silverstripe-translatable
synced 2024-10-22 11:05:59 +02:00
Merge pull request #101 from tractorcow/master-querystring-fixes
BUG Cleaner handling of querystring arguments when selecting locale
This commit is contained in:
commit
ba31412fa8
@ -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
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user