i18n the template attachments, fixes bug #11186

Also, rework some of the JS code according to jslint.
This commit is contained in:
Colin Kuskie 2009-11-09 13:28:53 -08:00
parent ce84be0498
commit 7b810ec227
4 changed files with 52 additions and 13 deletions

View file

@ -4,6 +4,7 @@
- fixed #11203: Manage groups in group: everyone added on save
- fixed #11101: 7.6.35-7.7 upgrade leaves packages
- fixed #11209: Form::HTMLArea uses invalid javascript identifier
- fixed #11186: Template Attachments i18n
7.8.4
- Fixed a compatibility problem between WRE and new Spectre code.

View file

@ -372,9 +372,12 @@ sub getEditForm {
);
my ($style, $url) = $self->session->quick(qw(style url));
$style->setScript($url->extras('yui/build/yahoo/yahoo-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui/build/json/json-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui/build/dom/dom-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui/build/yahoo/yahoo-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui/build/json/json-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui/build/dom/dom-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui/build/event/event-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui/build/connect/connect-min.js'), {type => 'text/javascript'});
$style->setScript($url->extras('yui-webgui/build/i18n/i18n.js'), {type => 'text/javascript'});
pop(@headers);
my $scriptUrl = $url->extras('templateAttachments.js');

View file

@ -379,6 +379,17 @@ Any scratch variables will be available in the template with this syntax:<br/>
message => q|Template in clipboard|,
lastUpdated => 0,
},
'Already attached!' => {
message => q|Already attached!|,
lastUpdated => 0,
},
'No url!' => {
message => q|No url!|,
lastUpdated => 0,
},
};
1;

View file

@ -1,6 +1,27 @@
// Really only used by the Template editor, but it doesn't belong in perl
// code. It's too long.
if ( typeof WebGUI == "undefined" ) {
WebGUI = {};
}
if ( typeof WebGUI.TemplateAttachments == "undefined" ) {
WebGUI.TemplateAttachments = {};
}
if ( typeof WebGUI.TemplateAttachments.i18n == "undefined" ) {
WebGUI.TemplateAttachments.i18n = new WebGUI.i18n( {
namespaces : {
'Asset_Template' : [
"attachment header remove",
"Already attached!",
"No url!"
]
},
onpreload : {
fn : function(){}
}
} );
}
var addClick = (function() {
var uniqueId = 1;
var count = 0;
@ -57,12 +78,15 @@ var addClick = (function() {
function nameFields(u) {
var id = uniqueId++;
var obj = urls[u];
if (!obj.index.name)
if (!obj.index.name) {
obj.index.name = 'attachmentIndex' + id;
if (!obj.type.name)
}
if (!obj.type.name) {
obj.type.name = 'attachmentType' + id;
if (!obj.url.name)
}
if (!obj.url.name) {
obj.url.name = 'attachmentUrl' + id;
}
}
// Make a function which will remove an attachment (remove the table row
@ -77,7 +101,7 @@ var addClick = (function() {
if (--count == 0) {
displayTable.style.display = 'none';
}
}
};
}
// Add a new attachment (proper table row, etc). Attachments that already
@ -85,7 +109,7 @@ var addClick = (function() {
// to the backend.
function add(d) {
if (urls[d.url]) {
alert('Already attached!');
alert(WebGUI.TemplateAttachments.i18n.get('Asset_Template','Already attached!'));
return;
}
@ -120,7 +144,7 @@ var addClick = (function() {
var oldValue = url.oldValue;
if (urls[newValue]) {
url.value = oldValue;
alert('Already attached!');
alert(WebGUI.TemplateAttachments.i18n.get('Asset_Template','Already attached!'));
}
else {
url.oldValue = newValue;
@ -134,7 +158,7 @@ var addClick = (function() {
var btn = document.createElement('input');
btn.type = 'button';
btn.value = 'Remove';
btn.value = WebGUI.TemplateAttachments.i18n.get('Asset_Template','attachment header remove');
btn.onclick = remover(d.url);
var tr = document.createElement('tr');
@ -149,7 +173,7 @@ var addClick = (function() {
tr : tr,
index : index,
type : type,
url : url,
url : url
};
nameFields(d.url);
@ -165,9 +189,9 @@ var addClick = (function() {
url: nodes.url.value
};
d.url = d.url.replace(/^\s+|\s+$/g, '')
d.url = d.url.replace(/^\s+|\s+$/g, '');
if (d.url == '') {
alert('No url!');
alert(WebGUI.TemplateAttachments.i18n.get('Asset_Template','No url!'));
return;
}
add(d);