@@ -37,6 +37,7 @@ ActiveCode.prototype.init = function(opts) {
3737 this . language = $ ( orig ) . data ( 'lang' ) ;
3838 this . timelimit = $ ( orig ) . data ( 'timelimit' ) ;
3939 this . includes = $ ( orig ) . data ( 'include' ) ;
40+ this . hidecode = $ ( orig ) . data ( 'hidecode' ) ;
4041 this . runButton = null ;
4142 this . saveButton = null ;
4243 this . loadButton = null ;
@@ -95,6 +96,9 @@ ActiveCode.prototype.createEditor = function (index) {
9596 } ) . bind ( this ) ) ; // use bind to preserve *this* inside the on handler.
9697
9798 this . editor = editor ;
99+ if ( this . hidecode ) {
100+ $ ( this . codeDiv ) . css ( "display" , "none" ) ;
101+ }
98102} ;
99103
100104ActiveCode . prototype . createControls = function ( ) {
@@ -116,14 +120,33 @@ ActiveCode.prototype.createControls = function () {
116120 $ ( butt ) . css ( "margin-left" , "10px" ) ;
117121 this . saveButton = butt ;
118122 ctrlDiv . appendChild ( butt ) ;
119-
123+ if ( this . hidecode ) {
124+ $ ( butt ) . css ( "display" , "none" )
125+ }
120126 // Load
121127 butt = document . createElement ( "button" ) ;
122128 $ ( butt ) . addClass ( "ac_opt btn btn-default" ) ;
123129 $ ( butt ) . text ( "Load" ) ;
124130 $ ( butt ) . css ( "margin-left" , "10px" ) ;
125131 this . loadButton = butt ;
126132 ctrlDiv . appendChild ( butt ) ;
133+ if ( this . hidecode ) {
134+ $ ( butt ) . css ( "display" , "none" )
135+ }
136+
137+ // Show/Hide Code
138+ if ( this . hidecode ) {
139+ butt = document . createElement ( "button" ) ;
140+ $ ( butt ) . addClass ( "ac_opt btn btn-default" ) ;
141+ $ ( butt ) . text ( "Show/Hide Code" ) ;
142+ $ ( butt ) . css ( "margin-left" , "10px" ) ;
143+ this . showHideButt = butt ;
144+ ctrlDiv . appendChild ( butt ) ;
145+ $ ( butt ) . click ( ( function ( ) { $ ( this . codeDiv ) . toggle ( ) ;
146+ $ ( this . loadButton ) . toggle ( ) ;
147+ $ ( this . saveButton ) . toggle ( ) ;
148+ } ) . bind ( this ) ) ;
149+ }
127150
128151 // CodeLens
129152 if ( $ ( this . origElem ) . data ( "codelens" ) ) {
0 commit comments