fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-05-12 08:30 am

[dw-free] Quick tweak: Use jQuery's document.ready function instead of DW.whenPageLoaded

[commit: http://hg.dwscoalition.org/dw-free/rev/dcbe47ef354f]

http://bugs.dwscoalition.org/show_bug.cgi?id=3670

Remove DW.whenPageLoaded, replace with jQuery's
$(document).ready(function...) -- short form $(function...)

Patch by [personal profile] fu.

Files modified:
  • htdocs/js/dw/dw-core.js
  • htdocs/js/nav-jquery.js
  • htdocs/js/shop/creditcard.js
  • htdocs/js/subfilters.js
  • views/shop/points.tt
--------------------------------------------------------------------------------
diff -r 91b163585ba8 -r dcbe47ef354f htdocs/js/dw/dw-core.js
--- a/htdocs/js/dw/dw-core.js	Thu May 12 16:17:09 2011 +0800
+++ b/htdocs/js/dw/dw-core.js	Thu May 12 16:30:21 2011 +0800
@@ -17,34 +17,6 @@
 
 var DW = new Object();
 
-// usage: DW.whenPageLoaded( function() { do something; } );
-//
-// this function will register a callback to be called as soon as the
-// page has finished loading.  note that if the page has already loaded
-// your callback will be dispatched immediately.
-DW.whenPageLoaded = function(fn) {
-    if ( DW._pageLoaded )
-        return fn();
-    DW._pageLoadCBs.push( fn );
-};
-
 /*****************************************************************************
  * INTERNAL FUNCTIONS BELOW HERE
  *****************************************************************************/
-
-// internal variable setup
-DW._pageLoaded = false;
-DW._pageLoadCBs = [];
-
-// called when the page has finished loading
-DW._pageIsLoaded = function() {
-    for ( cb in DW._pageLoadCBs )
-        DW._pageLoadCBs[cb]();
-    DW._pageLoadCBs = [];
-    DW._pageLoaded = true;
-};
-
-// now register with jQuery so we know when things are ready to go
-$(document).ready(function() {
-    DW._pageIsLoaded();
-});
diff -r 91b163585ba8 -r dcbe47ef354f htdocs/js/nav-jquery.js
--- a/htdocs/js/nav-jquery.js	Thu May 12 16:17:09 2011 +0800
+++ b/htdocs/js/nav-jquery.js	Thu May 12 16:30:21 2011 +0800
@@ -13,7 +13,7 @@
     'perldoc perlartistic' or 'perldoc perlgpl'.
 */
 
-DW.whenPageLoaded( function() {
+jQuery( function($) {
 
     // used below
     var hideNavs = function() {
diff -r 91b163585ba8 -r dcbe47ef354f htdocs/js/shop/creditcard.js
--- a/htdocs/js/shop/creditcard.js	Thu May 12 16:17:09 2011 +0800
+++ b/htdocs/js/shop/creditcard.js	Thu May 12 16:30:21 2011 +0800
@@ -27,7 +27,7 @@
     }
 }
 
-DW.whenPageLoaded( function() {
+jQuery( function($) {
     shop_cc_ShowHideBoxes();
 
     $('#country').change( shop_cc_ShowHideBoxes );
diff -r 91b163585ba8 -r dcbe47ef354f htdocs/js/subfilters.js
--- a/htdocs/js/subfilters.js	Thu May 12 16:17:09 2011 +0800
+++ b/htdocs/js/subfilters.js	Thu May 12 16:30:21 2011 +0800
@@ -591,7 +591,7 @@
 }
 
 
-DW.whenPageLoaded( function() {
+jQuery( function($) {
 
     // load the current filters into the box
     cfRefreshFilterList();
diff -r 91b163585ba8 -r dcbe47ef354f views/shop/points.tt
--- a/views/shop/points.tt	Thu May 12 16:17:09 2011 +0800
+++ b/views/shop/points.tt	Thu May 12 16:30:21 2011 +0800
@@ -28,7 +28,7 @@
 
 [%# FIXME: move this to shop.js or something %]
 <script type='text/javascript'>
-    DW.whenPageLoaded( function() {
+    jQuery( function($) {
         setInterval(
             function() {
                 $('#points-cost').html( 'Cost: <strong>$' + ($('#points').val() / 10).toFixed(2) + ' USD</strong>' );
--------------------------------------------------------------------------------