Hi,
> Hi Adi,
>
> This is a good improvement. I ran into an annoying problem running the tests.
> The tests use the combined javascript file, but "make jsbuild" was not getting
> run automatically. I also noticed that translationmessage-translate.pt and
> pofile-translate.pt load pofile.js directly, when the <script> tag really
> should be added to lib/lp/app/templates/base-layout-macros.pt next to all
> the other js files in the ${lp_js} directory.
I have moved the pofile.js inclusing in base-layout-macros.pt.
> Since I was confused by some of your changes that I don't think were
> necessary, I'm marking this
> needs-fixing
Thanks for the review
[snip]
> > var notice = Y.one('.important-notice-container');
> >+ if (!notice) {
>
>
> Since Y.one() is expected to return null when the element is not found,
> the preferred if-statement is:
> if (notice !== null)
Thanks for this remark.
I have changed the if statement to explicitly test agains null.
Same for the other cases.
[snip]
> >+ LPS.use('lp.pofile', function(Y) {
> > Y.on('domready', Y.lp.pofile.setupSuggestionDismissal);
> >- Y.on('domready', Y.lp.pofile.updateNotificationBox);
> >+ });
> >+
> >+ LPS.use('lp.pofile', function(Y) {
>
>
> Why are you calling LPS.use('lp.pofile', ...) repeatedly? This
> should have no effect unless there is something seriously wrong with
> lp.pofile.
I moved them back in the same sandbox.
I split independent functions in different sandboxes so that the failure of one function to not affect the others.
self.updateNotificationBox = function(e) {
var notice = Y.one('.important-notice-container');
- if (!notice) {
+ if (notice == null) {
// We have no notice container on this page, this is why there is
// nothing more to be done by this function.
return;
@@ -71,7 +71,7 @@
// Check the cookie to see if the user has already dismissed
// the notification box for this session.
var already_seen = Y.Cookie.get(dismiss_notice_cookie, Boolean);
- if (already_seen) {
+ if (already_seen !== null) {
notice.setStyle('display', 'none');
}
@@ -79,7 +79,7 @@ '.important-notice-cancel-button');
// Cancel button starts out hidden. If user has JavaScript,
// then we want to show it.
- if (!cancel_button) {
+ if (cancel_button == null) {
// No cancel button was found to attach the action.
return;
}
@@ -94,7 +94,7 @@
self.setFocus = function(field) {
// if there is nofield, do nothing
- if (Y.one('#' + field)) {
+ if (Y.one('#' + field) !== null) {
Y.one('#' + field).focus();
}
};
@@ -151,7 +151,7 @@ original_singular, translation_singular, singular_select);
// Copy plural text if needed
- if (Y.one('#' + translation_plural + '1')) {
+ if (Y.one('#' + translation_plural + '1') !== null) { copyOriginalTextPlural( original_plural, translation_plural, plural_forms);
}
@@ -162,7 +162,7 @@
var selectWidgetByID = function(widget) {
var node = Y.one('#' + widget);
- if (node) {
+ if (node !== null) { node.set('checked', true);
}
};
@@ -170,7 +170,7 @@
var toggleWidget = function(widget) {
var node = Y.one('#' + widget);
- if (node) {
+ if (node !== null) {
if (node.get('checked')) { node.set('checked', false);
} else {
@@ -196,48 +196,48 @@
var initializeGlobalKeyBindings = function(fields) {
- Y.get('document').on("keyup", function(e) {
+ Y.get('document').on("keyup", function(e) {
// Shift+Alt+s - Save form
- if (e.shiftKey && e.altKey && e.keyCode == 83) {
- Y.one('#save_and_continue_button').invoke('click');
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 83) {
+ Y.one('#save_and_continue_button').invoke('click');
+ }
// Shift+Alt+f - Go to search field
- if (e.shiftKey && e.altKey && e.keyCode == 70) {
- self.setFocus('search_box');
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 70) {
+ self.setFocus('search_box');
+ }
// Shift+Alt+b - Go to first translation field
- if (e.shiftKey && e.altKey && e.keyCode == 66) {
- self.setFocus(fields[0]);
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 66) {
+ self.setFocus(fields[0]);
+ }
// Shift+Alt+n - Go to next page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 78) {
- link = Y.one('#batchnav_next');
- if (link){
- window.location.assign(link.get('href'));
- }
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 78) {
+ link = Y.one('#batchnav_next');
+ if (link !== null){
+ window.location.assign(link.get('href'));
+ }
+ }
// Shift+Alt+p - Go to previous page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 80) {
- link = Y.one('#batchnav_previous');
- if (link){
- window.location.assign(link.get('href'));
- }
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 80) {
+ link = Y.one('#batchnav_previous');
+ if (link !== null){
+ window.location.assign(link.get('href'));
+ }
+ }
// Shift+Alt+a - Go to first page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 65) {
- link = Y.one('#batchnav_first');
- if (link){
- window.location.assign(link.get('href'));
- }
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 65) {
+ link = Y.one('#batchnav_first');
+ if (link !== null){
+ window.location.assign(link.get('href'));
+ }
+ }
// Shift+Alt+l - Go to last page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 76) {
- link = Y.one('#batchnav_last');
- if (link){
- window.location.assign(link.get('href'));
- }
- }
- });
+ if (e.shiftKey && e.altKey && e.keyCode == 76) {
+ link = Y.one('#batchnav_last');
+ if (link !== null){
+ window.location.assign(link.get('href'));
+ }
+ }
+ });
};
Hi, age-translate. pt and app/templates/ base-layout- macros. pt next to all
> Hi Adi,
>
> This is a good improvement. I ran into an annoying problem running the tests.
> The tests use the combined javascript file, but "make jsbuild" was not getting
> run automatically. I also noticed that translationmess
> pofile-translate.pt load pofile.js directly, when the <script> tag really
> should be added to lib/lp/
> the other js files in the ${lp_js} directory.
I have moved the pofile.js inclusing in base-layout- macros. pt.
> Since I was confused by some of your changes that I don't think were
> necessary, I'm marking this
> needs-fixing
Thanks for the review
[snip]
> > var notice = Y.one(' .important- notice- container' );
> >+ if (!notice) {
>
>
> Since Y.one() is expected to return null when the element is not found,
> the preferred if-statement is:
> if (notice !== null)
Thanks for this remark.
I have changed the if statement to explicitly test agains null.
Same for the other cases.
[snip] 'lp.pofile' , function(Y) { setupSuggestion Dismissal) ; updateNotificat ionBox) ; 'lp.pofile' , function(Y) { 'lp.pofile' , ...) repeatedly? This
> >+ LPS.use(
> > Y.on('domready', Y.lp.pofile.
> >- Y.on('domready', Y.lp.pofile.
> >+ });
> >+
> >+ LPS.use(
>
>
> Why are you calling LPS.use(
> should have no effect unless there is something seriously wrong with
> lp.pofile.
I moved them back in the same sandbox.
I split independent functions in different sandboxes so that the failure of one function to not affect the others.
Here is the latest diff:
=== modified file 'lib/canonical/ launchpad/ javascript/ translations/ pofile. js' launchpad/ javascript/ translations/ pofile. js 2010-03-17 13:11:23 +0000 launchpad/ javascript/ translations/ pofile. js 2010-03-17 22:18:24 +0000
--- lib/canonical/
+++ lib/canonical/
@@ -59,7 +59,7 @@
self.updateNot ificationBox = function(e) { .important- notice- container' ); get(dismiss_ notice_ cookie, Boolean); setStyle( 'display' , 'none');
var notice = Y.one('
- if (!notice) {
+ if (notice == null) {
// We have no notice container on this page, this is why there is
// nothing more to be done by this function.
return;
@@ -71,7 +71,7 @@
// Check the cookie to see if the user has already dismissed
// the notification box for this session.
var already_seen = Y.Cookie.
- if (already_seen) {
+ if (already_seen !== null) {
notice.
}
@@ -79,7 +79,7 @@
'.important- notice- cancel- button' );
// Cancel button starts out hidden. If user has JavaScript,
// then we want to show it.
- if (!cancel_button) {
+ if (cancel_button == null) {
// No cancel button was found to attach the action.
return;
}
@@ -94,7 +94,7 @@
self.setFocus = function(field) {
original_ singular, translation_ singular, singular_select);
// if there is nofield, do nothing
- if (Y.one('#' + field)) {
+ if (Y.one('#' + field) !== null) {
Y.one('#' + field).focus();
}
};
@@ -151,7 +151,7 @@
// Copy plural text if needed
copyOriginalT extPlural(
original_ plural, translation_plural, plural_forms);
- if (Y.one('#' + translation_plural + '1')) {
+ if (Y.one('#' + translation_plural + '1') !== null) {
}
@@ -162,7 +162,7 @@
var selectWidgetByID = function(widget) {
node. set('checked' , true);
var node = Y.one('#' + widget);
- if (node) {
+ if (node !== null) {
}
};
@@ -170,7 +170,7 @@
var toggleWidget = function(widget) { 'checked' )) {
node. set('checked' , false);
var node = Y.one('#' + widget);
- if (node) {
+ if (node !== null) {
if (node.get(
} else {
@@ -196,48 +196,48 @@
var initializeGloba lKeyBindings = function(fields) {
- Y.get(' document' ).on("keyup" , function(e) { document' ).on("keyup" , function(e) { #save_and_ continue_ button' ).invoke( 'click' ); #save_and_ continue_ button' ).invoke( 'click' ); 'search_ box'); 'search_ box'); fields[ 0]); fields[ 0]); #batchnav_ next'); location. assign( link.get( 'href') ); #batchnav_ next'); location. assign( link.get( 'href') ); #batchnav_ previous' ); location. assign( link.get( 'href') ); #batchnav_ previous' ); location. assign( link.get( 'href') ); #batchnav_ first') ; location. assign( link.get( 'href') ); #batchnav_ first') ; location. assign( link.get( 'href') ); #batchnav_ last'); location. assign( link.get( 'href') ); #batchnav_ last'); location. assign( link.get( 'href') );
+ Y.get('
// Shift+Alt+s - Save form
- if (e.shiftKey && e.altKey && e.keyCode == 83) {
- Y.one('
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 83) {
+ Y.one('
+ }
// Shift+Alt+f - Go to search field
- if (e.shiftKey && e.altKey && e.keyCode == 70) {
- self.setFocus(
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 70) {
+ self.setFocus(
+ }
// Shift+Alt+b - Go to first translation field
- if (e.shiftKey && e.altKey && e.keyCode == 66) {
- self.setFocus(
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 66) {
+ self.setFocus(
+ }
// Shift+Alt+n - Go to next page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 78) {
- link = Y.one('
- if (link){
- window.
- }
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 78) {
+ link = Y.one('
+ if (link !== null){
+ window.
+ }
+ }
// Shift+Alt+p - Go to previous page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 80) {
- link = Y.one('
- if (link){
- window.
- }
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 80) {
+ link = Y.one('
+ if (link !== null){
+ window.
+ }
+ }
// Shift+Alt+a - Go to first page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 65) {
- link = Y.one('
- if (link){
- window.
- }
- }
+ if (e.shiftKey && e.altKey && e.keyCode == 65) {
+ link = Y.one('
+ if (link !== null){
+ window.
+ }
+ }
// Shift+Alt+l - Go to last page in batch
- if (e.shiftKey && e.altKey && e.keyCode == 76) {
- link = Y.one('
- if (link){
- window.
- }
- }
- });
+ if (e.shiftKey && e.altKey && e.keyCode == 76) {
+ link = Y.one('
+ if (link !== null){
+ window.
+ }
+ }
+ });
};
=== modified file 'lib/lp/ app/templates/ base-layout- macros. pt' app/templates/ base-layout- macros. pt 2010-03-15 17:17:05 +0000 app/templates/ base-layout- macros. pt 2010-03-17 23:14:12 +0000 javascript"
tal: attributes= "src string: ${lp_js} /registry/ team.js" ></script>
--- lib/lp/
+++ lib/lp/
@@ -211,6 +211,9 @@
<script type="text/
+ <script type="text/ javascript" ${lp_js} /translations/ pofile. js"></script> "not:devmode" > javascript"
+ tal:attributes="src string:
+
</tal:devmode>
<tal:production condition=
<script type="text/
=== modified file 'lib/lp/ translations/ templates/ pofile- translate. pt' translations/ templates/ pofile- translate. pt 2010-03-17 12:00:59 +0000 translations/ templates/ pofile- translate. pt 2010-03-17 22:12:53 +0000
--- lib/lp/
+++ lib/lp/
@@ -14,22 +14,12 @@
}
</style>
- <script type="text/ javascript" "devmode" ${icingroot} /build" ${lp_js} /translations/ pofile. js"></script> javascript" >
registerLaunchp adFunction( insertAllExpans ionButtons) ;
- tal:condition=
- tal:define="lp_js string:
- tal:attributes="src string:
<script type="text/
- });
-
- LPS.use(
- });
-
- LPS.use(
=== modified file 'lib/lp/ translations/ templates/ translationmess age-translate. pt' translations/ templates/ translationmess age-translate. pt 2010-02-25 00:47:17 +0000 translations/ templates/ translationmess age-translate. pt 2010-03-17 23:14:49 +0000 javascript" "devmode" ${icingroot} /build" ${lp_js} /translations/ pofile. js"></script> javascript" >
LPS.use( 'node', 'lp.pofile', function(Y) {
Y.on( 'domready' , Y.lp.pofile. setupSuggestion Dismissal) ;
--- lib/lp/
+++ lib/lp/
@@ -13,10 +13,6 @@
color: lightgray;
}
</style>
- <script type="text/
- tal:condition=
- tal:define="lp_js string:
- tal:attributes="src string:
<script type="text/