@@ -58,6 +58,9 @@ Parsons.prototype.populateContentArray = function () {
5858 var temp = fulltext . split ( delimiter ) ;
5959 var content = temp [ 1 ] ;
6060 this . contentArray = content . split ( "---" ) ;
61+ if ( this . contentArray . length === 1 ) { // If there are no ---, then every line is its own block
62+ this . contentArray = content . split ( "\n" ) ;
63+ }
6164
6265 // remove newline characters that precede and follow the --- delimiters
6366 for ( var i = 0 ; i < this . contentArray . length ; i ++ ) {
@@ -68,6 +71,19 @@ Parsons.prototype.populateContentArray = function () {
6871 this . contentArray [ i ] = this . contentArray [ i ] . slice ( 0 , - 1 ) ;
6972 }
7073 }
74+ for ( var i = 0 ; i < this . contentArray . length ; i ++ ) {
75+ if ( $ . inArray ( "\n" , this . contentArray [ i ] ) ) {
76+ var newString = "" ;
77+ for ( var j = 0 ; j < this . contentArray [ i ] . length ; j ++ ) {
78+ if ( this . contentArray [ i ] [ j ] === "\n" ) {
79+ newString += "</br>" ;
80+ } else {
81+ newString += this . contentArray [ i ] [ j ] ;
82+ }
83+ }
84+ this . contentArray [ i ] = newString ;
85+ }
86+ }
7187} ;
7288
7389/*====================================
@@ -186,7 +202,6 @@ Parsons.prototype.createParsonsWidget = function () {
186202 return false ;
187203 } ) ;
188204
189- this . styleNewHTML ( ) ;
190205 this . pwidget = new ParsonsWidget ( {
191206 "sortableId" : "parsons-sortableCode-" + Parsons . counter ,
192207 "trashId" : "parsons-sortableTrash-" + Parsons . counter ,
@@ -195,28 +210,29 @@ Parsons.prototype.createParsonsWidget = function () {
195210 "feedback_cb" : this . displayErrors . bind ( this )
196211 } ) ;
197212
198- this . pwidget . init ( $ ( this . origDiv ) . text ( ) ) ;
213+ this . pwidget . init ( $ ( this . origDiv ) . html ( ) ) ;
199214 this . pwidget . shuffleLines ( ) ;
200215 this . tryLocalStorage ( ) ;
216+ this . styleNewHTML ( ) ;
201217} ;
202218
203219Parsons . prototype . styleNewHTML = function ( ) {
204- $ ( window ) . load ( function ( ) {
205- // set min width and height
206- var sortableul = $ ( "#ul-parsons-sortableCode -" + Parsons . counter ) ;
207- var trashul = $ ( "#ul-parsons-sortableTrash-" + Parsons . counter ) ;
208- var sortableHeight = sortableul . height ( ) ;
209- var sortableWidth = sortableul . width ( ) ;
210- var trashWidth = trashul . width ( ) ;
211- var trashHeight = trashul . height ( ) ;
212- var minHeight = Math . max ( trashHeight , sortableHeight ) ;
213- var minWidth = Math . max ( trashWidth , sortableWidth ) ;
214- trashul . css ( "min-height" , minHeight + "px" ) ;
215- sortableul . css ( "min-height" , minHeight + "px" ) ;
216- sortableul . height ( minHeight ) ;
217- trashul . css ( "min-width" , minWidth + "px" ) ;
218- sortableul . css ( "min-width" , minWidth + "px" ) ;
219- } ) ;
220+ // set min width and height
221+ var sortableul = $ ( "#ul-parsons-sortableCode-" + Parsons . counter ) ;
222+ var trashul = $ ( "#ul-parsons-sortableTrash -" + Parsons . counter ) ;
223+ var sortableHeight = sortableul . height ( ) ;
224+ var sortableWidth = sortableul . width ( ) ;
225+ var trashWidth = trashul . width ( ) ;
226+ var trashHeight = trashul . height ( ) ;
227+ var minHeight = Math . max ( trashHeight , sortableHeight ) ;
228+ var minWidth = Math . max ( trashWidth , sortableWidth ) ;
229+ var test = document . getElementById ( "ul-parsons-sortableTrash-" + Parsons . counter ) ;
230+ trashul . css ( "min-height" , minHeight + "px" ) ;
231+ sortableul . css ( "min-height" , minHeight + "px" ) ;
232+ sortableul . height ( minHeight ) ;
233+ trashul . css ( "min-width" , minWidth + "px" ) ;
234+ sortableul . css ( "min-width" , minWidth + "px" ) ;
235+ test . minWidth = minWidth + "px" ;
220236} ;
221237
222238Parsons . prototype . displayErrors = function ( fb ) { // Feedback function
0 commit comments