Ticket #2470 (closed feature: duplicate)
Having tabs limit, sortable, and closable.
| Reported by: | k776 | Owned by: | klaus.hartl |
|---|---|---|---|
| Priority: | minor | Milestone: | TBD |
| Component: | ui.tabs | Version: | 1.5 |
| Keywords: | Cc: | ||
| Blocking: | Blocked by: |
Description
I have a script that you add a new tab/div when you press something. Trouble is, after a while these pile up.
Is there way to close a tab, make them sortable and also have them limited like Firefox does (if you have 100 tabs open, you get arrows to scroll through them)?
I looked at ExtJS but its too complicated. Ultimately it would be neat to do something like (combining with other plugins and such):
$('#tab_uls').setuptabs(closable, limit, sortable);
That would setup all li items in a ul tag into divs, with the div inside each li made into the content, then I could add a new li item using dom, and refresh tabs. The functionality of close/reorder would instantly become available.
Maybe perhaps for a future version? Would be VERY useful.
Attachments
Change History
comment:2 Changed 4 years ago by mdalessio
Klaus, I'd like to work on the "closable" requirement. If you have any strong opinions on the code or HTML/CSS designs, please let me know (you can reach me at mike@…).
comment:3 Changed 4 years ago by mdalessio
Attaching patch (apply to 1.5b4) that implements closable tabs.
Attaching "examples.tar.gz" which contains Klaus's examples from http://stilbuero.de/jquery/tabs_3/ with different 'closable' options applied, along with an appropriately modified CSS theme.
General Description:
- A clickable "button" (really an <A> tag) appears on the tab. When the button is clicked, the tab is removed.
- <LI> tags are dynamically modified to contain a second tag:
<a onclick="return false;"><span>#{text}</span></a> - The #{text} snippet will be replaced by the configuration option closeText (which is '(x)' by default), and the snippet itself can be set via the configuration option closeTemplate.
Specifics:
- New creation option closable can be set to false, 'all' or 'selected'
- default is false, meaning no closable tabs.
- 'all' means all tabs have are closable.
- 'selected' means only the selected tab is closable.
- New creation options closeTemplate and closeText allow overriding default markup.
- When a tab is closable, a second <A> is dynamically added to the tab <LI> after the normal <A>
- this tag is only added to the DOM if options.closable is non-false
- this tag is hidden in unselected tabs if options.closable is 'selected'
- CSS / styles
- Note that this patch is backwards-compatible with CSS as long as the closable option is not turned on.
- Close-button tag has class ui-tabs-close
- However, existing CSS will probably need to be modified to support the new close button.
- A new class, ui-tabs-tab is associated with the normal <A> to allow differentiation for themes/styles.
- see examples.tar.gz for example CSS support
Changed 4 years ago by mdalessio
-
attachment
jquery-ui-2470-closable.patch
added
Patch to jquery.ui-1.5b4 for closable tabs
Changed 4 years ago by mdalessio
-
attachment
examples.tar.gz
added
Sample html, css and modified js - self contained in examples.tar.gz
comment:4 Changed 4 years ago by mdalessio
I've posted a live demo of the "closable tabs" patch.
Please try it out at http://pharos-ei.com/mike/jquery/examples/index.html
comment:7 Changed 4 years ago by paul
- Version changed from 1.2.3 to 1.5b4
- Component changed from ui.core to ui.tabs
comment:8 Changed 4 years ago by klaus.hartl
- Owner changed from klaus to klaus.hartl
- Status changed from new to assigned
- Version changed from 1.5b4 to 1.5
comment:10 Changed 3 years ago by klaus.hartl
- Status changed from assigned to closed
- Resolution set to duplicate
Broke this ticket down into smaller tasks.

