mirror of
https://github.com/silverstripe/silverstripe-reports
synced 2024-09-06 01:31:09 +02:00
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@104369 467b73ca-7a2a-4603-9d3b-597d59a354a9
77 lines
2.0 KiB
JavaScript
Executable File
77 lines
2.0 KiB
JavaScript
Executable File
/**
|
|
* File: CMSMain.Translatable.js
|
|
*/
|
|
(function($) {
|
|
$.entwine('ss', function($){
|
|
|
|
/**
|
|
* Class: .CMSMain #Form_LangForm
|
|
*
|
|
* Dropdown with languages above CMS tree, causing a redirect upon translation
|
|
*/
|
|
$('.CMSMain #Form_LangForm').entwine({
|
|
/**
|
|
* Constructor: onmatch
|
|
*/
|
|
onmatch: function() {
|
|
var self = this;
|
|
|
|
// monitor form loading for any locale changes
|
|
$('#Form_EditForm').bind('loadnewpage', function(e) {
|
|
var newLocale = $(this).find(':input[name=Locale]').val();
|
|
if(newLocale) self.val(newLocale);
|
|
});
|
|
|
|
// whenever a new value is selected, reload the whole CMS in the new locale
|
|
this.find(':input[name=Locale]').bind('change', function(e) {
|
|
var url = document.location.href;
|
|
url += (url.indexOf('?') != -1) ? '&' : '?';
|
|
// TODO Replace existing locale GET params
|
|
url += 'locale=' + $(e.target).val();
|
|
document.location = url;
|
|
return false;
|
|
});
|
|
|
|
this._super();
|
|
}
|
|
});
|
|
|
|
/**
|
|
* Class: .CMSMain .createTranslation
|
|
*
|
|
* Loads /admin/createtranslation, which will create the new record,
|
|
* and redirect to an edit form.
|
|
*
|
|
* Dropdown in "Translation" tab in CMS forms, with button to
|
|
* trigger translating the currently loaded record.
|
|
*
|
|
* Requires:
|
|
* jquery.metadata
|
|
*/
|
|
$('.CMSMain .createTranslation').entwine({
|
|
|
|
/**
|
|
* Constructor: onmatch
|
|
*/
|
|
onmatch: function() {
|
|
var self = this;
|
|
|
|
this.find(':input[name=action_createtranslation]').bind('click', function(e) {
|
|
var form = self.parents('form');
|
|
// redirect to new URL
|
|
// TODO This should really be a POST request
|
|
|
|
document.location.href = $('base').attr('href') +
|
|
jQuery(self).metadata().url +
|
|
'?ID=' + form.find(':input[name=ID]').val() +
|
|
'&newlang=' + self.find(':input[name=NewTransLang]').val() +
|
|
'&locale=' + form.find(':input[name=Locale]').val();
|
|
|
|
return false;
|
|
});
|
|
|
|
this._super();
|
|
}
|
|
});
|
|
});
|
|
}(jQuery)); |