Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > JavaScript > Re: TransModal ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 10 of 13 Topic 35494 of 37484
Post > Topic >>

Re: TransModal modal dialog project : beta testing

by VK <schools_ring@[EMAIL PROTECTED] > May 6, 2008 at 11:20 AM

On May 6, 6:01 pm, Matthias Watermann <li...@[EMAIL PROTECTED]
> wrote:
> On Tue, 06 May 2008 02:25:41 -0700, VK wrote:
> > [...]
>
> Just some hints after reading (w/o testing) it:
>
> >   if ('userLanguage' in navigator) {
> >    var lang = navigator.userLanguage.substring(0,2);
> >   }
> >   else if ('language' in navigator) {
> >    var lang = navigator.language.substring(0,2);
> >   }
> >   else {
> >    var lang = 'en';
> >   }
>
> Should be:
>
>    var lang = 'en';
>    if ('userLanguage' in navigator) {
>      lang = navigator.userLanguage.substring(0,2);
>    }
>    else if ('language' in navigator) {
>      lang = navigator.language.substring(0,2);
>    }

with pending else{} left this way. Not a crime of any kind and often
met, but we have here a standard logical construct
 if X then do this
 else if Y then do that
  (if neither of both then)
 else do default

which is

 if (X) {}
 else if (Y) {}
 else {}

what would be benefits to break the logic flow? I am not claiming that
there are not any, but what are they?


> >   TransModal.lang = (lang in TransModal.buttonLabelSet) ?
> >                      lang : 'en';
>
> I'd assume that "lang" is unknown here since there are only three
> vars with that name each of which inside a different "if"-scope.

Variable scope in Javascript was already explained by other posters as
I see.

> > [...]
> >  var wndDialog = do***ent.createElement('DIV');
>
> >  wndDialog.id = 'TransModalDialog';
>
> >  /* Some complex styling of a completely empty element
> >   * may make IE to act strange. To avoid that we are
> >   * setting the default content to NO-BREAK SPACE
> >   */
> >  wndDialog.innerHTML = '<span>\u00A0</span>';
>
> Why use "innerHTML" (instead of "createElement()") here?

because then we have to add TextNode into it which is a royal pain in
IE6 - not talking about adding form controls this way which is a
headache beyond tolerance IMO with IE. Also innerHTML is 10-15 times
quicker then per-node manipulations.
This being said, I am ready to replace both innerHTML usages by a
reliable DOM alternative if anyone has it.

> >  with (wndDialog.style) {
> >   position = 'absolute';
> >   zIndex = '1002';
> >   left = '0px';
> >   top = '0px';
> >   cursor = 'default';
> >   visibility = 'hidden';
> >  }
>
> Just a matter of style & opinion:
>
>   var s;
>   if ((s = wndDialog.style)) {
>     s.position = 'absolute';
>     s.zIndex = '1002';
>     s.left = '0px';
>     s.top = '0px';
>     s.cursor = 'default';
>     s.visibility = 'hidden';
>   }

Yeah... "To WITH, or not to WITH" :-)
Javascript WITH implementation is indeed a ticking bomb to handle with
extreme care. I myself once was a complete fool with it:
http://groups.google.com/group/mozilla.dev.tech.svg/msg/e3ef5a71b7d95318

So I do agree with Matt Kruse at
http://www.javascripttoolbox.com/bestpractices/#with
as overall - but I do not agree to make WITH as some self-contained
evilness that acts by its own no matter what :-) In case as above
is .style is available then all these properties should be here as
well. Or still better do not take the risk?

> > [...]
 




 13 Posts in Topic:
TransModal modal dialog project : beta testing
VK <schools_ring@[EMAI  2008-05-06 02:25:41 
Re: TransModal modal dialog project : beta testing
Laser Lips <loudsphier  2008-05-06 05:32:40 
Re: TransModal modal dialog project : beta testing
VK <schools_ring@[EMAI  2008-05-06 05:49:44 
Re: TransModal modal dialog project : beta testing
Matthias Watermann <li  2008-05-06 16:01:49 
Re: TransModal modal dialog project : beta testing
Thomas 'PointedEars' Lahn  2008-05-06 23:07:10 
Re: TransModal modal dialog project : beta testing
Henry <rcornford@[EMAI  2008-05-06 08:17:21 
Re: TransModal modal dialog project : beta testing
Jorge <jorge@[EMAIL PR  2008-05-06 08:51:22 
Re: TransModal modal dialog project : beta testing
Jorge <jorge@[EMAIL PR  2008-05-06 08:55:04 
Re: TransModal modal dialog project : beta testing
VK <schools_ring@[EMAI  2008-05-06 10:55:57 
Re: TransModal modal dialog project : beta testing
VK <schools_ring@[EMAI  2008-05-06 11:20:13 
Re: TransModal modal dialog project : beta testing
Jorge <jorge@[EMAIL PR  2008-05-06 11:31:04 
Re: TransModal modal dialog project : beta testing
VK <schools_ring@[EMAI  2008-05-06 11:53:50 
Re: TransModal modal dialog project : beta testing
VK <schools_ring@[EMAI  2008-05-06 12:01:48 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Nov 22 17:02:05 CST 2008.