silverstripe-cms/javascript/CMSMain.Translatable.js
Ingo Schommer 48068e1f75 MINOR Syntax in CMSMain.Translatable.js
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/trunk@92647 467b73ca-7a2a-4603-9d3b-597d59a354a9
2009-11-21 02:38:12 +00:00

50 lines
1.4 KiB
JavaScript
Executable File

(function($) {
/**
* @class Dropdown with languages above CMS tree, causing a redirect upon translation
* @name ss.CMSMain.LangSelector
*/
$('.CMSMain #LangSelector').concrete('ss', function($){
return/** @lends ss.CMSMain.LangSelector */{
onmatch: function() {
var self = this;
this.bind('change', function(e) {
document.location = 'admin/?locale=' + $(e.target).val();
return false;
});
}
}
});
/**
* Loads /admin/createtranslation, which will create the new record,
* and redirect to an edit form.
*
* @class Dropdown in "Translation" tab in CMS forms, with button to
* trigger translating the currently loaded record.
* @name ss.CMSMain.createtranslation
* @requires jquery.metadata
*/
$('.CMSMain .createTranslation').concrete('ss', function($){
return/** @lends ss.CMSMain.createtranslation */{
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;
});
}
}
});
}(jQuery));