File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 81
81
</ div >
82
82
< br />
83
83
< button onclick ="$('#example_0').scrollTabs('destroy') " > Destroy above tabs</ button >
84
+ < br />
85
+ < button id ="addRandomTab " type ="button "> Add new random tab</ button >
84
86
< br /> < br />
85
87
< div id ="example_1 ">
86
88
< ul role ="tablist ">
Original file line number Diff line number Diff line change @@ -16,6 +16,11 @@ $(() => {
16
16
}
17
17
} ) ;
18
18
19
+ // $('#addRandomTab').on('click', (e) => {
20
+ // $('#example_0').data('uiScrollTabs')
21
+ // .addTab(keywords[Math.floor(Math.random() * keywords.length) + 1], );
22
+ // });
23
+
19
24
if ( scrollEnabled ) {
20
25
$tabs = $ ( '#example_1' )
21
26
. scrollTabs ( {
@@ -49,14 +54,14 @@ $(() => {
49
54
$ ( '#example_2' ) . tabs ( ) ;
50
55
51
56
// Add new tab
52
- $ ( '#addTab_1 ' ) . click ( ( ) => {
57
+ $ ( '#addRandomTab ' ) . click ( ( ) => {
53
58
const label = keywords [ Math . floor ( Math . random ( ) * keywords . length ) ] ;
54
59
const content = 'This is the content for the ' + label + '<br>Lorem ipsum dolor sit amet,' +
55
60
' consectetur adipiscing elit. Quisque hendrerit vulputate porttitor. Fusce purus leo,' +
56
61
' faucibus a sagittis congue, molestie tempus felis. Donec convallis semper enim,' +
57
62
' varius sagittis eros imperdiet in. Vivamus semper sem at metus mattis a' +
58
63
' aliquam neque ornare. Proin sed semper lacus.' ;
59
- $tabs . trigger ( 'addTab' , [ label , content ] ) ;
64
+ $ ( '#example_0' ) . data ( 'uiScrollTabs' ) . addTab ( label , content ) ;
60
65
return false ;
61
66
} ) ;
62
67
} ) ;
Original file line number Diff line number Diff line change 442
442
} ) ;
443
443
} ) ;
444
444
} ,
445
+ addTab ( header : string , panelContent : string ) {
446
+ const newId : string = $ ( { } ) . uniqueId ( ) [ 0 ] . id ;
447
+ const tab = $ ( '<li><a href="#' + newId + '" role="tab">' + header + '</a></li>' ) ;
448
+ const panel = this . _createPanel ( newId ) ;
449
+ panel . html ( panelContent ) ;
445
450
451
+ this . $ul . append ( tab ) ;
452
+ panel . attr ( 'aria-live' , 'polite' ) ;
453
+
454
+ if ( panel . length ) {
455
+ $ ( this . panels [ this . panels . length - 1 ] ) . after ( panel ) ;
456
+ }
457
+
458
+ panel . attr ( 'role' , 'tabpanel' ) ;
459
+ this . _addclosebutton ( tab ) ;
460
+
461
+ this . refresh ( ) ;
462
+ this . _showNavsIfNeeded ( ) ;
463
+ } ,
446
464
removeTab ( anc : JQuery < HTMLElement > ) {
447
465
const tabId = anc . attr ( 'href' ) ;
448
466
// Remove the panel
481
499
$ ( window ) . off ( 'resize' , this . debounceEvent ( ( ) => { this . _showNavsIfNeeded ( ) ; } ) ) ;
482
500
}
483
501
} ) ;
502
+ return $ . ui . scrollTabs ;
484
503
} ) ( jQuery ) ;
You can’t perform that action at this time.
0 commit comments