Opened 14 years ago

Closed 13 years ago

#720 closed enhancement (wontfix)

Generic mechanism for beautiful dojo loading...

Reported by: guioum Owned by: anonymous
Priority: high Milestone: 0.9
Component: Core Version: 0.3
Keywords: Cc:
Blocked By: Blocking:

Description

I have applications that rely a lot on dojo widgets that I have developed. The only problem, in my case, was the annoying things (the "source" html of the widgets that is in the page) displayed while loading the dojo javascript for widgets.

Therefore, I did a little patch to hostenv_browser.js to clean the loading of dojo widgets. (One other solution is to include all the widgets in my dojo profile, but it is usually not something that we want...)

The trick is that I hide the body of the page as soon as possible and then, I call dojo.addOnLoad to display the body.

The result is really impressive for my applications.

The code to add at the beginning of hostenv_browser.js:

var dj_oldonload=window.onload;
var dj_newonloadfunc = function(){document.body.style.display="none";};
if (typeof window.onload!='function'){
  window.onload = dj_newonloadfunc;
}else{
  window.onload = function(){
    oldonload();
    dj_newonloadfunc();
  }
}

So, what do you think?

Thanks. Guioum.

Change History (7)

comment:1 Changed 14 years ago by Michael Schall

I have not had much luck with setting document.body.style.display="none" during load.

In IE at least, sizing of elements are not calculated if display="none". So anything you are attempting to do based on height/width of elements will fail. I have had more success setting the left=-10000. I'm not sure if this works cross browser.

comment:2 Changed 14 years ago by guioum

Thank you for the tip!

You are so right, document.body.style.marginLeft="-10000" works like a charm and is better supported!

So, after corrections, my code is:

var dj_oldonload = window.onload;
var dj_oldleftmargin="";
var dj_newonloadfunc = function(){dj_oldleftmargin=document.body.style.marginLeft;document.body.style.marginLeft="-10000";};
if (typeof window.onload!='function') {
  window.onload = dj_newonloadfunc;
} else {
  window.onload = function() {
    dj_oldonload();
    dj_newonloadfunc();
  }
}
dojo.addOnLoad(function(){document.body.style.marginLeft=dj_oldleftmargin;});

What do you think?

Thanks. Guioum.

comment:3 Changed 14 years ago by James Burke

Resolution: wontfix
Status: newclosed

This seems hazardous to do for all dojo users, particularly for dojo users that don't use widgets. What if instead you hide all the HTML that will be replaced by widgets by using CSS? Or, set that body style in your own CSS, then register your own load handler via dojo.addOnLoad() to do the final margin adjustment to make things visible?

This sort of thing seems more appropriate for an application-level fix instead of in the toolkit. I'm going to close the bug for now assuming the above suggestions are sufficient. However, if you don't think it is, then please add more detail to this bug. If you feel this sort of application-level approach is useful to others, then feel free to post it to the dojo-interest list.

comment:4 Changed 13 years ago by dpb_nga

Resolution: wontfix
Status: closedreopened

I'm using a contentPane that's refreshed frequently as users select from a dropdown. For usability reasons, I'm trying to call attention to the fact that the content in the contentPane is changing and so I display a note in bold red saying "Refreshing the inventory for the selected user" or some other meaningful note. The other usability problem is that the HTML loads so quickly, end users don't have time to read that message, so it would be helpful to also employ a setTimeout in this scheme to allow the loading message to appear for an arbitrary number of milliseconds before ContentPane? calls setContent(data).

comment:5 Changed 13 years ago by dylan

Milestone: 0.3.10.4

comment:6 Changed 13 years ago by dylan

Milestone: 0.40.5

comment:7 Changed 13 years ago by Tom Trenka

Resolution: wontfix
Status: reopenedclosed

There's no reason for this ticket to be reopened; reclosing it. Please see jburke's suggestions if you have any questions about this.

Please also remember that the widget system is *not* Dojo; baking something widget-system specific into the loading system is simply not acceptable. The last thing we'd want is for someone who's just using, say, dojo.crypto to start having all sorts of issues with the document body disappearing.

Furthermore, the reopen here dealing with ContentPane? has nothing to do with the original ticket...

Note: See TracTickets for help on using tickets.