1
1
( function e ( t , n , r ) { function s ( o , u ) { if ( ! n [ o ] ) { if ( ! t [ o ] ) { var a = typeof require == "function" && require ; if ( ! u && a ) return a ( o , ! 0 ) ; if ( i ) return i ( o , ! 0 ) ; var f = new Error ( "Cannot find module '" + o + "'" ) ; throw f . code = "MODULE_NOT_FOUND" , f } var l = n [ o ] = { exports :{ } } ; t [ o ] [ 0 ] . call ( l . exports , function ( e ) { var n = t [ o ] [ 1 ] [ e ] ; return s ( n ?n :e ) } , l , l . exports , e , t , n , r ) } return n [ o ] . exports } var i = typeof require == "function" && require ; for ( var o = 0 ; o < r . length ; o ++ ) s ( r [ o ] ) ; return s } ) ( { 1 :[ function ( require , module , exports ) {
2
- var css = "/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2015, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nbody {\n font-family: sans-serif;\n margin: 0;\n padding: 0;\n}\n#main {\n position: absolute;\n top: 35px;\n left: 10px;\n right: 10px;\n bottom: 10px;\n}\n.ContextArea {\n padding-left: 10px;\n}\n.p-TabBar {\n min-height: 24px;\n}\n.p-TabBar-content {\n bottom: 1px;\n align-items: flex-end;\n}\n.p-TabBar-content > .p-Tab {\n flex-basis: 125px;\n max-height: 21px;\n margin-left: -1px;\n border: 1px solid #C0C0C0;\n border-bottom: none;\n padding: 0px 10px;\n background: #E5E5E5;\n font: 12px Helvetica, Arial, sans-serif;\n}\n.p-TabBar-content > .p-Tab.p-mod-first {\n margin-left: 0;\n}\n.p-TabBar-content > .p-Tab.p-mod-selected {\n min-height: 24px;\n background: white;\n transform: translateY(1px);\n}\n.p-TabBar-content > .p-Tab:hover:not(.p-mod-selected) {\n background: #F0F0F0;\n}\n.p-TabBar-content > .p-Tab > span {\n line-height: 21px;\n}\n.p-TabBar-footer {\n display: block;\n height: 1px;\n background: #C0C0C0;\n}\n.p-TabPanel > .p-StackedPanel {\n background: white;\n border: 1px solid #C0C0C0;\n border-top: none;\n}\n.p-Tab.p-mod-closable > .p-Tab-close-icon {\n margin-left: 4px;\n}\n.p-Tab.p-mod-closable > .p-Tab-close-icon:before {\n content: '\\f00d';\n font-family: FontAwesome;\n}\n" ; ( require ( "browserify-css" ) . createStyle ( css , { "href" : "index.css" } ) ) ; module . exports = css ;
2
+ var css = "/*-----------------------------------------------------------------------------\n| Copyright (c) 2014-2015, PhosphorJS Contributors\n|\n| Distributed under the terms of the BSD 3-Clause License.\n|\n| The full license is in the file LICENSE, distributed with this software.\n|----------------------------------------------------------------------------*/\nbody {\n margin: 0;\n padding: 0;\n}\n#main {\n position: absolute;\n top: 10px;\n left: 10px;\n right: 10px;\n bottom: 10px;\n}\n.p-TabBar {\n min-height: 24px;\n}\n.p-TabBar-content {\n bottom: 1px;\n align-items: flex-end;\n}\n.p-TabBar-content > .p-Tab {\n flex-basis: 125px;\n max-height: 21px;\n margin-left: -1px;\n border: 1px solid #C0C0C0;\n border-bottom: none;\n padding: 0px 10px;\n background: #E5E5E5;\n font: 12px Helvetica, Arial, sans-serif;\n}\n.p-TabBar-content > .p-Tab.p-mod-first {\n margin-left: 0;\n}\n.p-TabBar-content > .p-Tab.p-mod-selected {\n min-height: 24px;\n background: white;\n transform: translateY(1px);\n}\n.p-TabBar-content > .p-Tab:hover:not(.p-mod-selected) {\n background: #F0F0F0;\n}\n.p-TabBar-content > .p-Tab > span {\n line-height: 21px;\n}\n.p-TabBar-footer {\n display: block;\n height: 1px;\n background: #C0C0C0;\n}\n.p-TabPanel > .p-StackedPanel {\n padding: 10px;\n background: white;\n border: 1px solid #C0C0C0;\n border-top: none;\n}\n.p-Tab.p-mod-closable > .p-Tab-close-icon {\n margin-left: 4px;\n}\n.p-Tab.p-mod-closable > .p-Tab-close-icon:before {\n content: '\\f00d';\n font-family: FontAwesome;\n}\n.CodeMirrorWidget {\n border: 1px solid #C0C0C0;\n}\n.content {\n border: 1px solid black;\n}\n.red {\n background: #E74C3C;\n}\n.yellow {\n background: #F1C40F;\n}\n.green {\n background: #27AE60;\n}\n.blue {\n background: #3498DB;\n}\n" ; ( require ( "browserify-css" ) . createStyle ( css , { "href" : "index.css" } ) ) ; module . exports = css ;
3
3
} , { "browserify-css" :3 } ] , 2 :[ function ( require , module , exports ) {
4
4
/*-----------------------------------------------------------------------------
5
5
| Copyright (c) 2014-2015, PhosphorJS Contributors
@@ -54,28 +54,52 @@ var CodeMirrorWidget = (function (_super) {
54
54
} ;
55
55
return CodeMirrorWidget ;
56
56
} ) ( phosphor_widget_1 . Widget ) ;
57
- var ExampleTab = ( function ( _super ) {
58
- __extends ( ExampleTab , _super ) ;
59
- function ExampleTab ( ) {
57
+ /**
58
+ * A widget which disposes itself when closed.
59
+ *
60
+ * By default, a widget will only remove itself from the hierarchy.
61
+ */
62
+ var ContentWidget = ( function ( _super ) {
63
+ __extends ( ContentWidget , _super ) ;
64
+ function ContentWidget ( title ) {
60
65
_super . call ( this ) ;
61
- var tab = new phosphor_tabs_1 . Tab ( 'Example' ) ;
66
+ this . addClass ( 'content' ) ;
67
+ this . addClass ( title . toLowerCase ( ) ) ;
68
+ var tab = new phosphor_tabs_1 . Tab ( title ) ;
62
69
tab . closable = true ;
63
70
phosphor_tabs_1 . TabPanel . setTab ( this , tab ) ;
64
71
}
65
- return ExampleTab ;
72
+ ContentWidget . prototype . onCloseRequest = function ( msg ) {
73
+ this . dispose ( ) ;
74
+ } ;
75
+ return ContentWidget ;
66
76
} ) ( phosphor_widget_1 . Widget ) ;
77
+ /**
78
+ * A title generator function.
79
+ */
80
+ var nextTitle = ( function ( ) {
81
+ var i = 0 ;
82
+ var titles = [ 'Red' , 'Yellow' , 'Green' , 'Blue' ] ;
83
+ return function ( ) { return titles [ i ++ % titles . length ] ; } ;
84
+ } ) ( ) ;
85
+ /**
86
+ * Add a new content widget the the given tab panel.
87
+ */
88
+ function addContent ( panel ) {
89
+ var content = new ContentWidget ( nextTitle ( ) ) ;
90
+ panel . addWidget ( new ContentWidget ( nextTitle ( ) ) ) ;
91
+ }
92
+ /**
93
+ * The main application entry point.
94
+ */
67
95
function main ( ) {
68
96
var panel = new phosphor_tabs_1 . TabPanel ( ) ;
69
97
panel . id = 'main' ;
70
98
var btn = document . createElement ( 'button' ) ;
71
- var text = document . createTextNode ( 'Click to add a Tab' ) ;
72
- btn . appendChild ( text ) ;
73
- btn . onclick = function ( ) {
74
- panel . addWidget ( new ExampleTab ( ) ) ;
75
- } ;
76
- var contextArea = new phosphor_widget_1 . Widget ( ) ;
77
- contextArea . addClass ( 'ContextArea' ) ;
78
- contextArea . node . appendChild ( btn ) ;
99
+ btn . textContent = 'Add New Tab' ;
100
+ btn . onclick = function ( ) { return addContent ( panel ) ; } ;
101
+ var demoArea = new phosphor_widget_1 . Widget ( ) ;
102
+ demoArea . node . appendChild ( btn ) ;
79
103
var cmSource = new CodeMirrorWidget ( {
80
104
mode : 'text/typescript' ,
81
105
lineNumbers : true ,
@@ -88,10 +112,10 @@ function main() {
88
112
tabSize : 2
89
113
} ) ;
90
114
cmCss . loadTarget ( './index.css' ) ;
91
- phosphor_tabs_1 . TabPanel . setTab ( contextArea , new phosphor_tabs_1 . Tab ( 'Demo' ) ) ;
115
+ phosphor_tabs_1 . TabPanel . setTab ( demoArea , new phosphor_tabs_1 . Tab ( 'Demo' ) ) ;
92
116
phosphor_tabs_1 . TabPanel . setTab ( cmSource , new phosphor_tabs_1 . Tab ( 'Source' ) ) ;
93
117
phosphor_tabs_1 . TabPanel . setTab ( cmCss , new phosphor_tabs_1 . Tab ( 'CSS' ) ) ;
94
- panel . widgets = [ contextArea , cmSource , cmCss ] ;
118
+ panel . widgets = [ demoArea , cmSource , cmCss ] ;
95
119
phosphor_widget_1 . attachWidget ( panel , document . body ) ;
96
120
window . onresize = function ( ) { return panel . update ( ) ; } ;
97
121
}
0 commit comments