[hidden email] wrote:
> Author: jleroux > Date: Fri Sep 24 22:56:01 2010 > New Revision: 1001101 > > URL: http://svn.apache.org/viewvc?rev=1001101&view=rev > Log: > Convert waitSpinner/Hide/Show > > Modified: > ofbiz/branches/jquery/framework/images/webapp/images/selectall.js > > Modified: ofbiz/branches/jquery/framework/images/webapp/images/selectall.js > URL: http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/images/webapp/images/selectall.js?rev=1001101&r1=1001100&r2=1001101&view=diff > ============================================================================== > --- ofbiz/branches/jquery/framework/images/webapp/images/selectall.js (original) > +++ ofbiz/branches/jquery/framework/images/webapp/images/selectall.js Fri Sep 24 22:56:01 2010 > @@ -667,25 +667,22 @@ function waitSpinnerShow() { > } > spinner.style.display = 'block'; > var bdy = document.body; > + jSpinner = "#wait-spinner"; > > - var dimensions = $(spinner).getDimensions(); > - var lookupLeft = (bdy.offsetWidth / 2) - (dimensions.width / 2); > + var lookupLeft = (bdy.offsetWidth / 2) - (jQuery(jSpinner).width() / 2); > var scrollOffY = document.viewport.getScrollOffsets().top; > var winHeight = document.viewport.getHeight(); > - var lookupTop = (scrollOffY + winHeight / 2) - (dimensions.height / 2); > + var lookupTop = (scrollOffY + winHeight / 2) - (jQuery(jSpinner).height() / 2); This is not optimal. You're asking jquery to find the spinner multiple times; ie, do a document scan. var jSpinner = jQuery("#wait-spinner"); jSpinner.width() etc. > > spinner.style.left = lookupLeft + "px"; > spinner.style.top = lookupTop + "px"; > - Effect.Appear(spinner, {duration: 0.3}); > + jQuery(jSpinner).show(); > } > > function waitSpinnerHide() { > var spinner = document.getElementById("wait-spinner"); > - if (spinner == null) { > - return; > + if (spinner != null) { > + jQuery("#wait-spinner").fadeOut(); > + jQuery("#wait-spinner").hide(); > } > - Effect.Fade(spinner, {duration: 0.3}); > - window.setTimeout(function() { > - spinner.style.display = 'none'; > - }, 400); > } > > |
Administrator
|
From: "Adam Heath" <[hidden email]> > [hidden email] wrote: >> Author: jleroux >> Date: Fri Sep 24 22:56:01 2010 >> New Revision: 1001101 >> >> URL: http://svn.apache.org/viewvc?rev=1001101&view=rev >> Log: >> Convert waitSpinner/Hide/Show >> >> Modified: >> ofbiz/branches/jquery/framework/images/webapp/images/selectall.js >> >> Modified: ofbiz/branches/jquery/framework/images/webapp/images/selectall.js >> URL: >> http://svn.apache.org/viewvc/ofbiz/branches/jquery/framework/images/webapp/images/selectall.js?rev=1001101&r1=1001100&r2=1001101&view=diff >> ============================================================================== >> --- ofbiz/branches/jquery/framework/images/webapp/images/selectall.js (original) >> +++ ofbiz/branches/jquery/framework/images/webapp/images/selectall.js Fri Sep 24 22:56:01 2010 >> @@ -667,25 +667,22 @@ function waitSpinnerShow() { >> } >> spinner.style.display = 'block'; >> var bdy = document.body; >> + jSpinner = "#wait-spinner"; >> >> - var dimensions = $(spinner).getDimensions(); >> - var lookupLeft = (bdy.offsetWidth / 2) - (dimensions.width / 2); >> + var lookupLeft = (bdy.offsetWidth / 2) - (jQuery(jSpinner).width() / 2); >> var scrollOffY = document.viewport.getScrollOffsets().top; >> var winHeight = document.viewport.getHeight(); >> - var lookupTop = (scrollOffY + winHeight / 2) - (dimensions.height / 2); >> + var lookupTop = (scrollOffY + winHeight / 2) - (jQuery(jSpinner).height() / 2); > > This is not optimal. You're asking jquery to find the spinner > multiple times; ie, do a document scan. > > var jSpinner = jQuery("#wait-spinner"); > jSpinner.width() > > etc. Right, focused on another problem, I migrated it fast from previous code . It's totally rewrote in real jQuery code at r1001158 Jacques >> >> spinner.style.left = lookupLeft + "px"; >> spinner.style.top = lookupTop + "px"; >> - Effect.Appear(spinner, {duration: 0.3}); >> + jQuery(jSpinner).show(); >> } >> >> function waitSpinnerHide() { >> var spinner = document.getElementById("wait-spinner"); >> - if (spinner == null) { >> - return; >> + if (spinner != null) { >> + jQuery("#wait-spinner").fadeOut(); >> + jQuery("#wait-spinner").hide(); >> } >> - Effect.Fade(spinner, {duration: 0.3}); >> - window.setTimeout(function() { >> - spinner.style.display = 'none'; >> - }, 400); >> } >> >> > |
Jacques Le Roux wrote:
>>> --- ofbiz/branches/jquery/framework/images/webapp/images/selectall.js >>> (original) >>> +++ ofbiz/branches/jquery/framework/images/webapp/images/selectall.js >>> Fri Sep 24 22:56:01 2010 >>> @@ -667,25 +667,22 @@ function waitSpinnerShow() { >>> } >>> spinner.style.display = 'block'; >>> var bdy = document.body; >>> + jSpinner = "#wait-spinner"; >>> >>> - var dimensions = $(spinner).getDimensions(); >>> - var lookupLeft = (bdy.offsetWidth / 2) - (dimensions.width / 2); >>> + var lookupLeft = (bdy.offsetWidth / 2) - >>> (jQuery(jSpinner).width() / 2); >>> var scrollOffY = document.viewport.getScrollOffsets().top; >>> var winHeight = document.viewport.getHeight(); >>> - var lookupTop = (scrollOffY + winHeight / 2) - >>> (dimensions.height / 2); >>> + var lookupTop = (scrollOffY + winHeight / 2) - >>> (jQuery(jSpinner).height() / 2); >> >> This is not optimal. You're asking jquery to find the spinner >> multiple times; ie, do a document scan. >> >> var jSpinner = jQuery("#wait-spinner"); >> jSpinner.width() >> >> etc. > > Right, focused on another problem, I migrated it fast from previous code > . It's totally rewrote in real jQuery code at r1001158 In all honesty, the rest of the code should be written to the same pattern. But I haven't looked at it at all. |
Administrator
|
From: "Adam Heath" <[hidden email]>
> Jacques Le Roux wrote: >>>> --- ofbiz/branches/jquery/framework/images/webapp/images/selectall.js >>>> (original) >>>> +++ ofbiz/branches/jquery/framework/images/webapp/images/selectall.js >>>> Fri Sep 24 22:56:01 2010 >>>> @@ -667,25 +667,22 @@ function waitSpinnerShow() { >>>> } >>>> spinner.style.display = 'block'; >>>> var bdy = document.body; >>>> + jSpinner = "#wait-spinner"; >>>> >>>> - var dimensions = $(spinner).getDimensions(); >>>> - var lookupLeft = (bdy.offsetWidth / 2) - (dimensions.width / 2); >>>> + var lookupLeft = (bdy.offsetWidth / 2) - >>>> (jQuery(jSpinner).width() / 2); >>>> var scrollOffY = document.viewport.getScrollOffsets().top; >>>> var winHeight = document.viewport.getHeight(); >>>> - var lookupTop = (scrollOffY + winHeight / 2) - >>>> (dimensions.height / 2); >>>> + var lookupTop = (scrollOffY + winHeight / 2) - >>>> (jQuery(jSpinner).height() / 2); >>> >>> This is not optimal. You're asking jquery to find the spinner >>> multiple times; ie, do a document scan. >>> >>> var jSpinner = jQuery("#wait-spinner"); >>> jSpinner.width() >>> >>> etc. >> >> Right, focused on another problem, I migrated it fast from previous code >> . It's totally rewrote in real jQuery code at r1001158 > > In all honesty, the rest of the code should be written to the same > pattern. But I haven't looked at it at all. I want to better group things (there are plenty of not related to "select all" in selectall.js). When I will do I will keep that in mind... Jacques |
Free forum by Nabble | Edit this page |