Go Back   SitePoint Forums > Forum Index > Program Your Site > JavaScript
Newsletter FAQ Members List Calendar Mark Forums Read

New to SitePoint Forums? Register here for free!

SitePoint Sponsor
 
Reply
 
Thread Tools Display Modes
Old May 2, 2005, 16:40   #1
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
x_tpg.js

Whenever I use this tab script with firefox I lose the ability to click on a form field and see the cursor blinking in the field. It only works for the last tab in the set. If I start typing I'm in that form element and it get's filled out fine, there's just no cursor indication - which is anoying. Anybody got a clue why? Heres the code (from cross-browser.com)...


Code:
function xTabPanelGroupEditor(id, w, h, th, clsTP, clsTG, clsTD, clsTS,initialTab) // object prototype
{
  var panelGrp = xGetElementById(id);
  if (!panelGrp) { return null; }
  var panels = xGetElementsByClassName(clsTP, panelGrp);
  var tabs = xGetElementsByClassName(clsTD, panelGrp);
  var tabGrp = xGetElementsByClassName(clsTG, panelGrp);
  if (!panels || !tabs || !tabGrp || panels.length != tabs.length || tabGrp.length != 1) { return null; }

  var selectedIndex = 0, highZ, x = 0, i;   
  var pgw = xWidth(panelGrp);
  var pgh = xClientHeight() - 120;  
  xHeight(panelGrp,pgh);
  xResizeTo(panelGrp, pgw, pgh);
  xResizeTo(tabGrp[0], w, th);
  xMoveTo(tabGrp[0], 0, 0);
  
  w -= 2; // remove border widths
  var tw = 100;

  for (i = 0; i < tabs.length; ++i) {
    xResizeTo(tabs[i], tw, th); 
    xMoveTo(tabs[i], x, 0);
    x += tw;
    tabs[i].xTabIndex = i;
    tabs[i].onclick = tabOnClick;
    xHeight(panels[i],pgh - th - 2); //new
    xMoveTo(panels[i], 0, th);
  }
  highZ = i;
  tabs[initialTab-1].onclick();
  
  function tabOnClick()
  {
    tabs[selectedIndex].className = clsTD;
    this.className = clsTS;
   xZIndex(this, highZ++);
   xZIndex(panels[this.xTabIndex], highZ++);     
    for (i = 0; i < tabs.length; ++i) {//PW: fix IE window objects ignoring zIndex
     xHide(panels[i]);
    }
    xShow(panels[this.xTabIndex]);
    selectedIndex = this.xTabIndex;
  }

  this.onUnload = function()
  {
    for (var i = 0; i < tabs.length; ++i) {tabs[i].onclick = null;}
  }
}
pdub23 is offline   Reply With Quote
Old May 2, 2005, 16:43   #2
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
yikes, I just removed 'overflow:hidden;' from all the related styles and that fixed the issue, however now things are pretty messed up visually...
pdub23 is offline   Reply With Quote
Old May 2, 2005, 16:53   #3
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
actually it's the overflow:auto; on the tabPanel class that mucks up the focus... no idea why though...
pdub23 is offline   Reply With Quote
Old May 2, 2005, 19:55   #4
Maian
SitePoint Guru
 
Join Date: Feb 2005
Posts: 608
Might be a Firefox bug.
Maian is offline   Reply With Quote
Old May 2, 2005, 21:19   #5
MikeFoster
I'll take mine raw
silver trophy
 
MikeFoster's Avatar
 
Join Date: Dec 2002
Location: Alabama, USA
Posts: 2,562
Hi pdub23,

Post a link to your page and I'll have a look.
__________________
Cross-Browser.com, Home of the X Library
MikeFoster is offline   Reply With Quote
Old May 3, 2005, 16:44   #6
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
Hey Mike, I think it might be a Mozilla bug... dunno... I PM'd you link with my example, don't want it accessed by the public right now...

thanks!
pdub23 is offline   Reply With Quote
Old May 3, 2005, 20:44   #7
MikeFoster
I'll take mine raw
silver trophy
 
MikeFoster's Avatar
 
Join Date: Dec 2002
Location: Alabama, USA
Posts: 2,562
I'm taking a look at it. But run it thru a validator and fix the html errors first.
__________________
Cross-Browser.com, Home of the X Library
MikeFoster is offline   Reply With Quote
Old May 4, 2005, 10:13   #8
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
thanks,

i whipped up the page pretty quick just as a demo, there is no doctype, do you think that could make a difference?
pdub23 is offline   Reply With Quote
Old May 4, 2005, 11:00   #9
MikeFoster
I'll take mine raw
silver trophy
 
MikeFoster's Avatar
 
Join Date: Dec 2002
Location: Alabama, USA
Posts: 2,562
been experimenting with that demo - I have it working - cleaning up now and still testing...
__________________
Cross-Browser.com, Home of the X Library
MikeFoster is offline   Reply With Quote
Old May 4, 2005, 15:24   #10
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
nice, looks good! thanks for the support. works good, cept busts up my dynamic tab width code, now xWidth(tabs[i]) always = 0... hmm
pdub23 is offline   Reply With Quote
Old May 5, 2005, 11:11   #11
MikeFoster
I'll take mine raw
silver trophy
 
MikeFoster's Avatar
 
Join Date: Dec 2002
Location: Alabama, USA
Posts: 2,562
I added an alert after one of the lines you added...
Code:
    x += xWidth(tabs[i]);
    alert(xWidth(tabs[i]));/////////////////////////////
It works for me in Opera, Firefox, and IE (all on WinXP).
And your online test page works for me too.

Why won't you post that link here so others can see it and join in? I wrote most of the code on your test page - there's nothing there that you should mind anyone else seeing.
__________________
Cross-Browser.com, Home of the X Library
MikeFoster is offline   Reply With Quote
Old May 5, 2005, 12:28   #12
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
yes sorry, here's the link...
http://peter.yvr.levelcms.com/petertest2

xWidth(tabs[i]) = zero for me in IE only now (XP) ...
pdub23 is offline   Reply With Quote
Old May 5, 2005, 19:52   #13
MikeFoster
I'll take mine raw
silver trophy
 
MikeFoster's Avatar
 
Join Date: Dec 2002
Location: Alabama, USA
Posts: 2,562
Create the xTabPanelGroup object in the window.onload handler. Put it in a script element in the head element - like my demo does. I would not put Javascript in the body. But if you really, really want onload code in the body then put it immediately before the closing body tag. Don't nest it in any other html - especially not a table.
__________________
Cross-Browser.com, Home of the X Library
MikeFoster is offline   Reply With Quote
Old May 6, 2005, 08:36   #14
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
ah ok... I remember that being a general rule, but I can't remember why... this might fix my other problem with the new tab script, which is some other objects are being 'uninitialized' or something once I tab back and forth...

can you give me the quick 3 line summary as to why script should always be in the head, or know of any good threads or info on the matter, just for general knowledge sake? just the rules, ya?
pdub23 is offline   Reply With Quote
Old May 6, 2005, 09:55   #15
MikeFoster
I'll take mine raw
silver trophy
 
MikeFoster's Avatar
 
Join Date: Dec 2002
Location: Alabama, USA
Posts: 2,562
Opinions on this differ. I just don't like mixing Javascript with HTML. There are a few exceptions, but I just think they should be separate. When someone puts a script element (except for "document.write"s) at the end of their html it is obvious that their intention is for that code to run after the html has been parsed - that's what the window.onload event is for.
__________________
Cross-Browser.com, Home of the X Library
MikeFoster is offline   Reply With Quote
Old May 6, 2005, 11:12   #16
pdub23
SitePoint Enthusiast
 
Join Date: Mar 2005
Posts: 35
well this seemed to fix the xWidth issue... so I'm happy about that...

for me its a bit harder to always have things in the head, because I'm always working with dynamic content, so it's nice if my logic is more self-contained and not repeated. I think I can get around this by being smart about it and maybe pushing things to a standard onload function, I'm just not quite there yet...
pdub23 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread | Next Thread »

Thread Tools
Display Modes

 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

 
Forum Jump


All times are GMT -7. The time now is 05:53.


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright 1998-2009, SitePoint Pty Ltd. All Rights Reserved