-var setFocus = function(e, field) {
+self.setFocus = function(field) {
//Y.log(e.type + ":" + e.keyCode + ': ' + field);
// if there is nofield, do nothing
if (Y.one('#' + field)) {
@@ -96,7 +96,7 @@
var setNextFocus = function(e, field) {
- setFocus(e,field);
+ self.setFocus(field);
// stopPropagation() and preventDefault()
e.halt();
};
@@ -106,8 +106,8 @@
// Original singular test is focused first to make sure
// it is visible when scrolling up
- setFocus(e, original);
- setFocus(e, field);
+ self.setFocus(original);
+ self.setFocus(field);
// stopPropagation() and preventDefault()
e.halt();
};
@@ -116,7 +116,6 @@
var copyOriginalTextOne = function(from_id, to_id, select_id) {
var from = Y.one('#' + from_id);
var to = Y.one('#' + to_id);
-
// The replacement regex strips all tags from the html.
to.set('value', unescapeHTML( from.get('innerHTML').replace(/<\/?[^>]+>/gi, "")));
@@ -182,7 +181,13 @@
*/
self.initializeKeyBindings = function(e) {
- var fields = tabindex_chain.split(' ');
+ if (translations_order.length < 1) {
+ // If no translations fiels are displayed on the page
+ // don't initialize the translations order
+ return;
+ }
+
+ var fields = translations_order.split(' ');
// The last field is Save & Continue button
fields.push('save_and_continue_button');
@@ -192,7 +197,7 @@
var html_parts = fields[key].split('_');
var original_stem = html_parts[0] + '_' + html_parts[1];
- var translation_stem = original_stem + '_' + html_parts[2];
+ var translation_stem = fields[key].replace(/_translation_(\d)+_new/,"");
var select_widget = ( translation_stem + '_' + html_parts[3] + '_' + html_parts[4] + '_new_select');
Thanks for the review!
Here is the latest diff.
=== modified file 'lib/canonical/ launchpad/ javascript/ translations/ pofile. js' launchpad/ javascript/ translations/ pofile. js 2009-12-21 11:36:04 +0000 launchpad/ javascript/ translations/ pofile. js 2009-12-22 07:44:31 +0000
--- lib/canonical/
+++ lib/canonical/
@@ -86,7 +86,7 @@
};
-var setFocus = function(e, field) {
+self.setFocus = function(field) {
//Y.log(e.type + ":" + e.keyCode + ': ' + field);
// if there is nofield, do nothing
if (Y.one('#' + field)) {
@@ -96,7 +96,7 @@
var setNextFocus = function(e, field) { field);
- setFocus(e,field);
+ self.setFocus(
// stopPropagation() and preventDefault()
e.halt();
};
@@ -106,8 +106,8 @@
// Original singular test is focused first to make sure original) ; field); set('value' , unescapeHTML(
from. get('innerHTML' ).replace( /<\/?[^ >]+>/gi, ""))); eKeyBindings = function(e) {
// it is visible when scrolling up
- setFocus(e, original);
- setFocus(e, field);
+ self.setFocus(
+ self.setFocus(
// stopPropagation() and preventDefault()
e.halt();
};
@@ -116,7 +116,6 @@
var copyOriginalTextOne = function(from_id, to_id, select_id) {
var from = Y.one('#' + from_id);
var to = Y.one('#' + to_id);
-
// The replacement regex strips all tags from the html.
to.
@@ -182,7 +181,13 @@
*/
self.initializ
- var fields = tabindex_ chain.split( ' '); order.length < 1) { order.split( ' '); push('save_ and_continue_ button' );
+ if (translations_
+ // If no translations fiels are displayed on the page
+ // don't initialize the translations order
+ return;
+ }
+
+ var fields = translations_
// The last field is Save & Continue button
fields.
@@ -192,7 +197,7 @@
var html_parts = fields[ key].split( '_'); key].replace( /_translation_ (\d)+_new/ ,"");
translati on_stem + '_' + html_parts[3] + '_' +
html_ parts[4] + '_new_select');
var original_stem = html_parts[0] + '_' + html_parts[1];
- var translation_stem = original_stem + '_' + html_parts[2];
+ var translation_stem = fields[
var select_widget = (
=== modified file 'lib/lp/ translations/ browser/ pofile. py' translations/ browser/ pofile. py 2009-12-20 11:12:16 +0000 translations/ browser/ pofile. py 2009-12-22 06:16:13 +0000
first_ field = first_message. translation_ dictionaries[ 0] 'html_id_ translation' ]
--- lib/lp/
+++ lib/lp/
@@ -935,17 +935,17 @@
return first_field[
except IndexError:
- return False
+ return ""
@property chain(self) : order(self) : nmessage_ views:
for dictionary in message. translation_ dictionaries:
dictionary[ 'html_id_ translation' ] + '_new')
- def tabindex_
+ def translations_
try:
- tabindex = []
+ order = []
for message in self.translatio
- tabindex.append(
+ order.append(
- return ' '.join(tabindex)
+ return ' '.join(order)
except IndexError:
return ""
=== modified file 'lib/lp/ translations/ browser/ translationmess age.py' translations/ browser/ translationmess age.py 2009-12-20 11:12:16 +0000 translations/ browser/ translationmess age.py 2009-12-22 06:17:04 +0000
first_ field = first_message. translation_ dictionaries[ 0] 'html_id_ translation' ]
--- lib/lp/
+++ lib/lp/
@@ -836,16 +836,16 @@
return first_field[
except IndexError:
- return False
+ return ""
@property chain(self) : order(self) :
message = self.translatio nmessage_ view translation_ dictionaries: append( dictionary[ 'html_id_ translation' ] + '_new') dictionary[ 'html_id_ translation' ] + '_new')
- def tabindex_
+ def translations_
try:
- tabindex = []
+ order = []
for dictionary in message.
- tabindex.
- return ' '.join(tabindex)
+ order.append(
+ return ' '.join(order)
except IndexError:
return ""
=== modified file 'lib/lp/ translations/ templates/ currenttranslat ionmessage- translate- one.pt' translations/ templates/ currenttranslat ionmessage- translate- one.pt 2009-12-21 10:50:26 +0000 translations/ templates/ currenttranslat ionmessage- translate- one.pt 2009-12-22 06:19:00 +0000
'${view/ html_id} _singular' ,
'${view/ html_id_ singular} _new'); ;
selectWidget( '${view/ html_id_ singular} _new_select' , event);; tal:form- writeable>
--- lib/lp/
+++ lib/lp/
@@ -48,7 +48,7 @@
- return false;;
+ return false;;
"><img alt="Copy text" title="Copy text" src="/@@/copy" /></a>
</
</td>
=== modified file 'lib/lp/ translations/ templates/ pofile- translate. pt' translations/ templates/ pofile- translate. pt 2009-12-20 10:57:20 +0000 translations/ templates/ pofile- translate. pt 2009-12-22 07:30:06 +0000
Y.on( 'domready' , Y.lp.pofile. initializeKeyBi ndings) ;
Y.on( 'domready' , Y.lp.pofile. updateNotificat ionBox) ;
Y.on( 'domready' , function(e) { field). focus() ; setFocus( autofocus_ field);
--- lib/lp/
+++ lib/lp/
@@ -25,7 +25,7 @@
- Y.one('#' + autofocus_
+ Y.lp.pofile.
});
});
</script>
=== modified file 'lib/lp/ translations/ templates/ translations- macros. pt' translations/ templates/ translations- macros. pt 2009-12-20 10:57:20 +0000 translations/ templates/ translations- macros. pt 2009-12-22 06:17:44 +0000
--- lib/lp/
+++ lib/lp/
@@ -131,11 +131,10 @@
<metal: pofile- js-footer define- macro=" pofile- js-footer" > javascript" "view/autofocus _html_id"
tal:content= " autofocus_ html_id} _new'; tabindex_ chain}' ; translations_ order}' ; plural_ forms}; pofile- js-footer>
<script type="text/
- tal:condition=
structure string:<!--
var autofocus_field = '${view/
- var tabindex_chain = '${view/
+ var translations_order = '${view/
var plural_forms = ${context/
// -->" />
</metal: