Closed Bug 209885 Opened 22 years ago Closed 22 years ago

Support <tab linkedpanel="panelId"/>

Categories

(Core :: XUL, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: WeirdAl, Assigned: WeirdAl)

References

()

Details

Attachments

(3 files, 3 obsolete files)

We should support a panel attribute for the <xul:tab/> element, where the panel designated an appropriate <xul:tabpanel/> element. The idea is multiple tabs should be able to reference a single tabpanel, and use event listeners to apply style sheets, etc. to that tabpanel. This RFE started as an e-mail I sent to jag, rginda, and glazman, and has picked up significant interest in 24 hours. Hence, this bug. I truly believe the fix for this will be trivial to implement.
Attached file testcase (obsolete) —
Attached file patch, v1 (obsolete) —
This patch implements a linkedPanel attribute and corresponding property for the <xul:tab/> element.
Attachment #126080 - Flags: superreview?(jaggernaut)
Attachment #126080 - Flags: review?(timeless)
I decided to call it "linkedPanel" instead of "panel" to avoid confusion with the <xul:tabpanel/> element.
Summary: Support <tab panel="panelId"/> → Support <tab linkedPanel="panelId"/>
jag: timeless wants your sr+/- on this before he gives r+/-. I'm having second thoughts about something in the patch, the linkedPanel setter. Do we really want a setter? If so, what if the panel doesn't have an id?
Alternatively, have the linked panel be a field, rather than a property. Initialize it in the constructor (compare _eventNode).
Is there any code that goes back from selected panel to selected tab and now won't know which tab to select?
jag: I hope not, since that pretty much implies infinite recursion (tab sets tabpanel, which sets tab, which sets tabpanel...) More specifically, there is no binding for <xul:tabpanel/> elements. I think we're okay on that. neil: good idea, but I would be more comfortable setting <xul:tab/>'s _linkedPanel property from the <xul:tabbox/>'s constructor. Reason: we cannot tell whether <xul:tabbox> <xul:tabs> <xul:tab/> </xul:tabs> <xul:tabpanels> <xul:tabpanel/> </xul:tabpanels> </xul:tabbox> or <xul:tabbox> <xul:tabpanels> <xul:tabpanel/> </xul:tabpanels> <xul:tabs> <xul:tab/> </xul:tabs> </xul:tabbox> I've found the order of bindings' constructors firing sometimes matters. Opinion?
Comment on attachment 126080 [details] patch, v1 patch v2 coming up in 15 seconds.
Attachment #126080 - Attachment is obsolete: true
Attachment #126080 - Attachment is patch: false
Attachment #126080 - Flags: superreview?(jaggernaut)
Attachment #126080 - Flags: review?(timeless)
Attached patch patch, v2 (obsolete) — Splinter Review
Attachment #126875 - Flags: superreview?(jaggernaut)
Attachment #126875 - Flags: review?(timeless)
Comment on attachment 126875 [details] [diff] [review] patch, v2 >+ for (var i = 0; i < this._tabpanels.childNodes.length; i++) { We like to save the childNodes result in a temporary variable (it's a computed property). >+ var panel = this._tabpanels.childNodes.item(i); What's wrong with [i]? >+ if (panel.id) { >+ panelsById[panel.id] = panel; >+ } Hmm... what's brace style around here? >+ if (linkedPanelId) { >+ if (typeof panelsById[linkedPanelId] == "object") { You can use if (linkPanelID in panelsById) here. >+ if (linkedPanel == null) { >- tabpanels.selectedIndex = val; >+ tabpanels.selectedIndex = val; >+ } else { >+ tabpanels.selectedPanel = linkedPanel; >+ } Reverse the clauses and use if (linkedPanel) instead?
Re Neil's comment 10: Okay, I've fixed all the sections you refer to. caillon explained to me brace style refers to consistency for braces throughout the document. In tabbox.xml, one-line statements belonging to conditional and looping statements don't use braces, so I've got that straightened out. Other commentary? The changes are quite minor; if you want the revised patch I can post it. jag: I've confirmed setting a tabpanel as selected does not affect the tabs.
Comment on attachment 126875 [details] [diff] [review] patch, v2 reassigning r? based on jag's advice.
Attachment #126875 - Flags: review?(timeless) → review?(neil.parkwaycc.co.uk)
Comment on attachment 126875 [details] [diff] [review] patch, v2 I think the xul styleguide says all attributes should be completely lowercase, so "linkedpanel". This code doesn't deal well with tabs / panels dynamically being added/removed. If you want to deal with that, I think it'd be okay to do document.getElementById(tabs[val].getAttribute("selectedpanel")) to get the panel to show (and if that returns null, do tabpanels.selectedIndex = val)
Attachment #126875 - Flags: review?(neil.parkwaycc.co.uk) → review?(timeless)
Not forgetting to check for hasAttribute first, of course :-)
Neil: of course, null checks are needed in the above suggestion :-)
Comment on attachment 126875 [details] [diff] [review] patch, v2 Marking -. ajvincent and I discussed a new approach on irc and he'll come up with a patch soonish.
Attachment #126875 - Flags: superreview?(jaggernaut)
Attachment #126875 - Flags: superreview-
Attachment #126875 - Flags: review?(timeless)
Attached file revised testcase
Now using lowercase linkedpanel attribute.
Attachment #126079 - Attachment is obsolete: true
Attached patch patch, v3Splinter Review
answering jag's concerns as voiced on irc.
Attachment #126875 - Attachment is obsolete: true
Attachment #127701 - Flags: superreview?(jaggernaut)
Attachment #127701 - Flags: review?(neil.parkwaycc.co.uk)
Comment on attachment 127701 [details] [diff] [review] patch, v3 >+ var linkedPanelId = tabs[val].linkedPanel Dropped a ; >+ if (linkedPanelId) >+ var linkedPanel = document.getElementById(linkedPanelId); >+ else >+ linkedPanel = null; "Badly" scoped var - although JS uses function scope humans use block scope, easiest fix should be to use ?: operator instead of if/else.
neil: ok, I'll fix that. Anything else I should change to get an r+/-?
Blocks: 212815
No, I think that's all, thanks.
Comment on attachment 127701 [details] [diff] [review] patch, v3 sr=jag with Neil's comments addressed
Attachment #127701 - Flags: superreview?(jaggernaut) → superreview+
Attached patch final patchSplinter Review
patch conforming to neil r+, jag sr+
patch checked in by jag.
Status: NEW → RESOLVED
Closed: 22 years ago
Resolution: --- → FIXED
Summary: Support <tab linkedPanel="panelId"/> → Support <tab linkedpanel="panelId"/>
Attachment #127701 - Flags: review?(neil.parkwaycc.co.uk)
Component: XP Toolkit/Widgets: XUL → XUL
QA Contact: shrir → xptoolkit.widgets
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: