Home » Snippets » Browse Snippet

Browse Snippet

use of tab-title rather than numeric tab-index for JPane startOffset
GNU General Public License (GPL)
Programming Language
Core Enhancements


Since the JPane-tabs are created by specifying a string title it would be very
practical to specify the initial tab by using this string title too instead of
a numeric tab-index. While the tab-index might change when more tabs are added,
the title sticks to its tab most likely.

Here is my solution, minor changes in one file:
in media/system/js/tabs.js change the definition of display function

display: function(which){ //specify which instead of tab-index i
if(isNaN(which)) //in case the spec is not numeric
//look for spec in tab-titles
for(var i=this.titles.length-1;i>=0; i--)
if(this.titles[i].id==which)break; //found, use index i
//if spec is not not found at this place i now is zero
//which means display first tab
else i=which; //spec is numeric: directly use as tab-index

//do what you do
this.fireEvent('onActive', [this.titles[i], this.descriptions[i]])

Files in this snippet:

No files for this snippet
Submitted by Mathias Hopf on 2008-01-17 05:21:41

©2005-2020 Open Source Matters, Inc. All rights reserved. Joomla Hosting by Rochen Ltd.    Accessibility Statement    Privacy Policy    Gforge