Opened 12 years ago

Closed 11 years ago

Last modified 7 years ago

#2470 closed feature (duplicate)

Having tabs limit, sortable, and closable.

Reported by: k776 Owned by: klaus.hartl
Priority: minor Milestone:
Component: ui.tabs Version: 1.5
Keywords: Cc:
Blocked by: Blocking:

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 (2)

jquery-ui-2470-closable.patch (4.6 KB) - added by mdalessio 12 years ago.
Patch to jquery.ui-1.5b4 for closable tabs
examples.tar.gz (49.1 KB) - added by mdalessio 12 years ago.
Sample html, css and modified js - self contained in examples.tar.gz

Download all attachments as: .zip

Change History (13)

comment:1 Changed 12 years ago by paul

Owner: changed from paul to klaus

comment:2 Changed 12 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 12 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 12 years ago by mdalessio

Patch to jquery.ui-1.5b4 for closable tabs

Changed 12 years ago by mdalessio

Attachment: examples.tar.gz added

Sample html, css and modified js - self contained in examples.tar.gz

comment:4 Changed 12 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:5 Changed 12 years ago by mdalessio

Any feedback on this patch? Good or bad?

comment:6 Changed 12 years ago by (none)

Milestone: 1.2.4

Milestone 1.2.4 deleted

comment:7 Changed 12 years ago by paul

Component: ui.coreui.tabs
Version: 1.2.31.5b4

comment:8 Changed 12 years ago by klaus.hartl

Owner: changed from klaus to klaus.hartl
Status: newassigned
Version: 1.5b41.5

comment:9 Changed 11 years ago by Cloudream

Milestone: TDB

comment:10 Changed 11 years ago by klaus.hartl

Resolution: duplicate
Status: assignedclosed

Broke this ticket down into smaller tasks.

comment:11 Changed 7 years ago by Scott González

Milestone: TBD

Milestone TBD deleted

Note: See TracTickets for help on using tickets.