2009-11-21 03:38:05 +01:00
|
|
|
(function($) {
|
2009-11-21 04:19:59 +01:00
|
|
|
$.concrete('ss', function($){
|
2009-11-21 03:38:05 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
|
|
|
* @class Dropdown with languages above CMS tree, causing a redirect upon translation
|
|
|
|
* @name ss.CMSMain.LangSelector
|
|
|
|
*/
|
|
|
|
$('.CMSMain #Form_LangForm').concrete(/** @lends ss.CMSMain.LangSelector */{
|
2009-11-21 03:38:05 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:44 +01:00
|
|
|
// 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);
|
|
|
|
});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:44 +01:00
|
|
|
// whenever a new value is selected, reload the whole CMS in the new locale
|
2009-11-21 04:16:00 +01:00
|
|
|
this.find(':input[name=Locale]').bind('change', function(e) {
|
2009-11-21 04:16:11 +01:00
|
|
|
var url = document.location.href;
|
|
|
|
url += (url.indexOf('?') != -1) ? '&' : '?';
|
|
|
|
// TODO Replace existing locale GET params
|
|
|
|
url += 'locale=' + $(e.target).val();
|
|
|
|
document.location = url;
|
2009-11-21 03:38:05 +01:00
|
|
|
return false;
|
|
|
|
});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
|
|
|
this._super();
|
2009-11-21 03:38:05 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 03:38:05 +01:00
|
|
|
|
2009-11-21 04:19:59 +01:00
|
|
|
/**
|
|
|
|
* 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(/** @lends ss.CMSMain.createtranslation */{
|
2009-11-21 03:38:05 +01:00
|
|
|
onmatch: function() {
|
|
|
|
var self = this;
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:05 +01:00
|
|
|
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
|
2009-11-21 04:19:59 +01:00
|
|
|
|
2009-11-21 03:38:05 +01:00
|
|
|
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;
|
|
|
|
});
|
2009-11-21 04:19:59 +01:00
|
|
|
|
|
|
|
this._super();
|
2009-11-21 03:38:05 +01:00
|
|
|
}
|
2009-11-21 04:19:59 +01:00
|
|
|
});
|
2009-11-21 03:38:05 +01:00
|
|
|
});
|
|
|
|
}(jQuery));
|