Fixed locale issues for main menu (will work once lang files are updated)

git-svn-id: http://svg-edit.googlecode.com/svn/trunk@1218 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
Alexis Deveria
2010-01-14 16:05:05 +00:00
parent d360c991cd
commit b835da83ea
3 changed files with 19 additions and 6 deletions

View File

@@ -44,9 +44,9 @@ var put_locale = function(svgCanvas, given_param){
if(data.title) if(data.title)
elem.title = data.title; elem.title = data.title;
if(data.textContent) { if(data.textContent) {
// Only replace text nodes, not elements // Only replace non-empty text nodes, not elements
$.each(elem.childNodes, function(j, node) { $.each(elem.childNodes, function(j, node) {
if(node.nodeType == 3) { if(node.nodeType == 3 && $.trim(node.textContent)) {
node.textContent = data.textContent; node.textContent = data.textContent;
} }
}); });

View File

@@ -87,7 +87,7 @@ script type="text/javascript" src="locale/locale.min.js"></script-->
<ul> <ul>
<li id="tool_clear"> <li id="tool_clear">
<div></div> <div></div>
<label>New Image [N]</label> New Image [N]
</li> </li>
<li id="tool_open" style="display:none;"> <li id="tool_open" style="display:none;">

View File

@@ -2199,7 +2199,10 @@ function svg_edit_setup() {
if(opts.sel && !opts.hidekey) { if(opts.sel && !opts.hidekey) {
var new_title = btn.attr('title').split('[')[0] + '[' + keyval + ']'; var new_title = btn.attr('title').split('[')[0] + '[' + keyval + ']';
key_assocs[keyval] = opts.sel; key_assocs[keyval] = opts.sel;
btn.attr('title', new_title); // Disregard for menu items
if(!btn.parents('#main_menu').length) {
btn.attr('title', new_title);
}
} }
} }
}); });
@@ -2215,8 +2218,14 @@ function svg_edit_setup() {
}, },
setTitles: function() { setTitles: function() {
$.each(key_assocs, function(keyval, sel) { $.each(key_assocs, function(keyval, sel) {
var menu = ($(sel).parents('#main_menu').length);
$(sel).each(function() { $(sel).each(function() {
var t = this.title.split(' [')[0]; if(menu) {
var t = $(this).text().split(' [')[0];
} else {
var t = this.title.split(' [')[0];
}
var key_str = ''; var key_str = '';
// Shift+Up // Shift+Up
$.each(keyval.split('/'), function(i, key) { $.each(keyval.split('/'), function(i, key) {
@@ -2227,7 +2236,11 @@ function svg_edit_setup() {
} }
key_str += (i?'/':'') + mod + (uiStrings['key_'+key] || key); key_str += (i?'/':'') + mod + (uiStrings['key_'+key] || key);
}); });
this.title = t +' ['+key_str+']'; if(menu) {
this.lastChild.textContent = t +' ['+key_str+']';
} else {
this.title = t +' ['+key_str+']';
}
}); });
}); });
} }