@@ -46,11 +46,10 @@ Reveal.prototype.init = function (opts) {
4646 this . showtitle = null ; // Title of button that shows the concealed data
4747 this . hidetitle = null ;
4848 this . origContent = $ ( this . origElem ) . html ( ) ;
49- this . children = this . origElem . childNodes ;
49+ this . children = [ ] ;
50+ this . adoptChildren ( ) ;
5051
51- if ( this . dataModal ) {
52- this . checkForTitle ( ) ;
53- }
52+ this . checkForTitle ( ) ;
5453
5554 this . getButtonTitles ( ) ;
5655 this . createShowButton ( ) ;
@@ -63,6 +62,13 @@ Reveal.prototype.init = function (opts) {
6362/*====================================
6463== Get text for buttons/modal title ==
6564====================================*/
65+
66+ Reveal . prototype . adoptChildren = function ( ) {
67+ for ( var i = 0 ; i < this . origElem . childNodes . length ; i ++ ) {
68+ this . children . push ( this . origElem . childNodes [ i ] ) ;
69+ }
70+ } ;
71+
6672Reveal . prototype . getButtonTitles = function ( ) { // to support old functionality
6773 this . showtitle = $ ( this . origElem ) . data ( "showtitle" ) ;
6874 if ( this . showtitle === undefined ) {
@@ -87,21 +93,24 @@ Reveal.prototype.checkForTitle = function () {
8793Reveal . prototype . createShowButton = function ( ) {
8894 var _this = this ;
8995 this . wrapDiv = document . createElement ( "div" ) ; // wrapper div
90- this . revealDiv = document . createElement ( "div" ) ; // Div that is hidden that contains content
91- this . revealDiv . id = this . divid ;
92- this . wrapDiv . appendChild ( this . revealDiv ) ;
96+ if ( ! this . dataModal ) {
97+ this . revealDiv = document . createElement ( "div" ) ; // Div that is hidden that contains content
98+ this . revealDiv . id = this . divid ;
9399
94- // Get original content, put it inside revealDiv and replace original div with revealDiv
95- //$(this.revealDiv).html(this.origContent);
96- for ( var i = 0 ; i < this . children . length ; i ++ ) {
97- this . revealDiv . appendChild ( this . children [ i ] ) ;
100+ // Get original content, put it inside revealDiv and replace original div with revealDiv
101+ //$(this.revealDiv).html(this.origContent);
102+
103+ for ( var i = 0 ; i < this . children . length ; i ++ ) {
104+ this . revealDiv . appendChild ( this . children [ i ] ) ;
105+ }
106+ $ ( this . revealDiv ) . hide ( ) ;
107+ this . wrapDiv . appendChild ( this . revealDiv ) ;
98108 }
99- $ ( this . revealDiv ) . hide ( ) ;
100- $ ( this . origElem ) . replaceWith ( this . wrapDiv ) ;
109+
101110
102111 this . sbutt = document . createElement ( "button" ) ;
103- this . sbutt . style = "margin-bottom:10px" ;
104- this . sbutt . class = "btn btn-default reveal_button" ;
112+ $ ( this . sbutt ) . addClass ( "btn btn-default reveal_button" ) ;
113+ $ ( this . sbutt ) . css ( "margin-bottom" , "10px" ) ;
105114 this . sbutt . textContent = this . showtitle ;
106115 this . sbutt . id = this . divid + "_show" ;
107116 if ( ! this . dataModal ) {
@@ -115,14 +124,17 @@ Reveal.prototype.createShowButton = function () {
115124 "data-target" :"#" + this . divid + "_modal" } ) ;
116125 }
117126 this . wrapDiv . appendChild ( this . sbutt ) ;
127+ $ ( this . origElem ) . replaceWith ( this . wrapDiv ) ;
118128} ;
119129
120130Reveal . prototype . createHideButton = function ( ) {
121131 var _this = this ;
122132 this . hbutt = document . createElement ( "button" ) ;
123133 $ ( this . hbutt ) . hide ( ) ;
124134 this . hbutt . textContent = this . hidetitle ;
125- this . hbutt . class = "btn btn-default reveal_button" ;
135+ this . hbutt . className = "btn btn-default reveal_button" ;
136+ $ ( this . hbutt ) . css ( "margin-bottom" , "10px" ) ;
137+
126138 this . hbutt . id = this . divid + "_hide" ;
127139 this . hbutt . onclick = function ( ) {
128140 _this . hideInline ( ) ;
0 commit comments