This repository was archived by the owner on Jun 7, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +19
-10
lines changed
Expand file tree Collapse file tree 2 files changed +19
-10
lines changed Original file line number Diff line number Diff line change @@ -54,20 +54,11 @@ def setup(app):
5454
5555
5656TEMPLATE = """
57- <pre data-component="activecode" id=%(divid)s data-lang="%(language)s" %(autorun)s %(hidecode)s %(include)s %(timelimit)s %(coach)s %(codelens)s data-audio='%(ctext)s' %(sourcefile)s %(datafile)s %(stdin)s %(gradebutton)s>
57+ <pre data-component="activecode" id=%(divid)s data-lang="%(language)s" %(autorun)s %(hidecode)s %(include)s %(timelimit)s %(coach)s %(codelens)s data-audio='%(ctext)s' %(sourcefile)s %(datafile)s %(stdin)s %(gradebutton)s %(caption)s >
5858%(initialcode)s
5959</pre>
6060"""
6161
62-
63- CAPTION = '''
64- <div class="clearfix"></div>
65- <p class="ac_caption"><span class="ac_caption_text">%(caption)s (%(divid)s)</span> </p>
66- '''
67-
68-
69-
70-
7162class ActivcodeNode (nodes .General , nodes .Element ):
7263 def __init__ (self , content ):
7364 """
@@ -175,6 +166,8 @@ def run(self):
175166
176167 if 'caption' not in self .options :
177168 self .options ['caption' ] = ''
169+ else :
170+ self .options ['caption' ] = "data-caption='%s'" % self .options ['caption' ]
178171
179172 if 'include' not in self .options :
180173 self .options ['include' ] = ''
Original file line number Diff line number Diff line change @@ -60,6 +60,12 @@ ActiveCode.prototype.init = function(opts) {
6060 this . createEditor ( ) ;
6161 this . createOutput ( ) ;
6262 this . createControls ( ) ;
63+ if ( $ ( orig ) . data ( 'caption' ) ) {
64+ this . caption = $ ( orig ) . data ( 'caption' ) ;
65+ } else {
66+ this . caption = ""
67+ }
68+ this . addCaption ( )
6369
6470 if ( $ ( orig ) . data ( 'autorun' ) ) {
6571 $ ( document ) . ready ( this . runProg . bind ( this ) ) ;
@@ -224,6 +230,16 @@ ActiveCode.prototype.createOutput = function () {
224230
225231} ;
226232
233+ ActiveCode . prototype . addCaption = function ( ) {
234+ //someElement.parentNode.insertBefore(newElement, someElement.nextSibling);
235+ var capDiv = document . createElement ( 'p' ) ;
236+ $ ( capDiv ) . html ( this . caption + " (" + this . divid + ")" ) ;
237+ $ ( capDiv ) . addClass ( "ac_caption" ) ;
238+ $ ( capDiv ) . addClass ( "ac_caption_text" ) ;
239+
240+ this . outerDiv . parentNode . insertBefore ( capDiv , this . outerDiv . nextSibling ) ;
241+ } ;
242+
227243ActiveCode . prototype . saveEditor = function ( ) {
228244
229245} ;
You can’t perform that action at this time.
0 commit comments