@@ -68,24 +68,25 @@ define([
6868 } ) ;
6969 var idx = 0 ;
7070 $ ( "#edit_page_form .section" ) . each ( function ( ) {
71- var section_type = $ ( this ) . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type ;
72- if ( section_type == "rich_text" || section_type == "html" || $ ( this ) . hasClass ( 'read_only' ) ) {
71+ var $section = $ ( this )
72+ var section_type = $section . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type ;
73+ if ( section_type == "rich_text" || section_type == "html" || $section . hasClass ( 'read_only' ) ) {
7374 idx ++ ;
7475 var name = "section_" + idx ;
7576 if ( section_type == "rich_text" ) {
7677 data [ name + '[section_type]' ] = "rich_text" ;
77- var editorContent = richContentEditor . callOnRCE ( $ ( this ) . find ( ".edit_section" ) , "get_code" )
78+ var $richText = $section . find ( '.edit_section' ) ;
79+ var editorContent = richContentEditor . callOnRCE ( $richText , "get_code" )
7880 if ( editorContent ) { data [ name + '[content]' ] = editorContent ; }
79-
8081 } else if ( section_type == "html" ) {
8182 data [ name + '[section_type]' ] = "html" ;
82- data [ name + '[content]' ] = $ ( this ) . find ( ".edit_section" ) . val ( ) ;
83+ data [ name + '[content]' ] = $section . find ( ".edit_section" ) . val ( ) ;
8384 } else if ( section_type == "submission" ) {
8485 data [ name + '[section_type]' ] = "submission" ;
85- data [ name + '[submission_id]' ] = $ ( this ) . getTemplateData ( { textValues : [ 'submission_id' ] } ) . submission_id ;
86+ data [ name + '[submission_id]' ] = $section . getTemplateData ( { textValues : [ 'submission_id' ] } ) . submission_id ;
8687 } else if ( section_type == "attachment" ) {
8788 data [ name + '[section_type]' ] = "attachment" ;
88- data [ name + '[attachment_id]' ] = $ ( this ) . getTemplateData ( { textValues : [ 'attachment_id' ] } ) . attachment_id ;
89+ data [ name + '[attachment_id]' ] = $section . getTemplateData ( { textValues : [ 'attachment_id' ] } ) . attachment_id ;
8990 }
9091 }
9192 } ) ;
@@ -154,8 +155,9 @@ define([
154155 $edit . find ( ".edit_section" ) . attr ( 'id' , 'edit_' + $section . attr ( 'id' ) ) ;
155156 $edit . find ( ".edit_section" ) . val ( sectionData . section_content ) ;
156157 } else if ( edit_type == "edit_rich_text_content" ) {
157- $edit . find ( ".edit_section" ) . attr ( 'id' , 'edit_' + $section . attr ( 'id' ) ) ;
158- richContentEditor . loadNewEditor ( $edit . find ( ".edit_section" ) , { defaultContent : sectionData . section_content } )
158+ var $richText = $edit . find ( ".edit_section" )
159+ $richText . attr ( 'id' , 'edit_' + $section . attr ( 'id' ) ) ;
160+ richContentEditor . loadNewEditor ( $richText , { defaultContent : sectionData . section_content } )
159161 }
160162 } ) ;
161163 $ ( "#edit_page_form :text:first" ) . focus ( ) . select ( ) ;
@@ -172,26 +174,26 @@ define([
172174 $ ( "#page_content .section.failed" ) . remove ( ) ;
173175 $ ( "#edit_page_form,#page_content,#page_sidebar" ) . addClass ( 'previewing' ) ;
174176 $ ( "#page_content .section" ) . each ( function ( ) {
175- var $preview = $ ( this ) . find ( ".section_content" ) . clone ( ) . removeClass ( 'section_content' ) . addClass ( 'preview_content' ) . addClass ( 'preview_section' ) ;
176- var section_type = $ ( this ) . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type ;
177+ var $section = $ ( this )
178+ var $preview = $section . find ( ".section_content" ) . clone ( ) . removeClass ( 'section_content' ) . addClass ( 'preview_content' ) . addClass ( 'preview_section' ) ;
179+ var section_type = $section . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type ;
177180 if ( section_type == "html" ) {
178- $preview . html ( $ ( this ) . find ( ".edit_section" ) . val ( ) ) ;
179- $ ( this ) . find ( ".section_content" ) . after ( $preview ) ;
181+ $preview . html ( $section . find ( ".edit_section" ) . val ( ) ) ;
182+ $section . find ( ".section_content" ) . after ( $preview ) ;
180183 } else if ( section_type == "rich_text" ) {
181-
182- var editorContent = richContentEditor . callOnRCE ( $ ( this ) . find ( ".edit_section" ) , "get_code" )
184+ var $richText = $section . find ( '.edit_section)' ) ;
185+ var editorContent = richContentEditor . callOnRCE ( $richText , "get_code" ) ;
183186 if ( editorContent ) { $preview . html ( $ . raw ( editorContent ) ) }
184-
185- $ ( this ) . find ( ".section_content" ) . after ( $preview ) ;
187+ $section . find ( ".section_content" ) . after ( $preview ) ;
186188 }
187189 } ) ;
188190 } ) . end ( ) . find ( ".keep_editing_button" ) . click ( function ( ) {
189191 $ ( "#edit_page_form,#page_content,#page_sidebar" ) . removeClass ( 'previewing' ) ;
190192 $ ( "#page_content .preview_section" ) . remove ( ) ;
191193 } ) . end ( ) . find ( ".cancel_button" ) . click ( function ( ) {
192-
193- richContentEditor . callOnRCE ( $ ( '.edit_section' ) , "destroy" )
194-
194+ $ ( "#edit_page_form .edit_rich_text_content .edit_section" ) . each ( function ( ) {
195+ richContentEditor . callOnRCE ( $ ( this ) , "destroy" ) ;
196+ } ) ;
195197 $ ( "#edit_page_form,#page_content,#page_sidebar" ) . removeClass ( 'editing' ) ;
196198 $ ( "#page_content .section.unsaved" ) . remove ( ) ;
197199 $ ( ".edit_content_link_holder" ) . show ( ) ;
@@ -206,27 +208,31 @@ define([
206208 $ ( "#page_content .section.unsaved" ) . removeClass ( 'unsaved' ) ;
207209 $ ( "#page_content .section.failed" ) . remove ( ) ;
208210 $ ( "#page_content .section" ) . each ( function ( ) {
209- var section_type = $ ( this ) . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type ;
211+ var $section = $ ( this )
212+ var section_type = $section . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type ;
210213 if ( section_type == "rich_text" || section_type == "html" ) {
211- var code = $ ( this ) . find ( ".edit_section" ) . val ( ) ;
214+ var code = $section . find ( ".edit_section" ) . val ( ) ;
212215 if ( section_type == "rich_text" ) {
213- var editorContent = richContentEditor . callOnRCE ( $ ( this ) . find ( ".edit_section" ) , "get_code" )
216+ var $richText = $section . find ( '.edit_section' )
217+ var editorContent = richContentEditor . callOnRCE ( $richText , "get_code" )
214218 if ( editorContent ) {
215- $ ( this ) . find ( ".section_content" ) . html ( $ . raw ( editorContent ) ) ;
219+ $section . find ( ".section_content" ) . html ( $ . raw ( editorContent ) ) ;
216220 }
217- richContentEditor . callOnRCE ( $ ( this ) . find ( ".edit_section" ) , "destroy" )
221+ richContentEditor . callOnRCE ( $richText , "destroy" )
218222 } else {
219- $ ( this ) . find ( ".section_content" ) . html ( $ . raw ( code ) ) ;
223+ $section . find ( ".section_content" ) . html ( $ . raw ( code ) ) ;
220224 }
221- } else if ( ! $ ( this ) . hasClass ( 'read_only' ) ) {
222- $ ( this ) . remove ( ) ;
225+ } else if ( ! $section . hasClass ( 'read_only' ) ) {
226+ $section . remove ( ) ;
223227 }
224228 } ) ;
225229 var data = ePortfolioFormData ( ) ;
226230 return data ;
227231 } ,
228232 beforeSubmit : function ( data ) {
229- richContentEditor . callOnRCE ( $ ( '.edit_section' ) , "destroy" )
233+ $ ( "#edit_page_form .edit_rich_text_content .edit_section" ) . each ( function ( ) {
234+ richContentEditor . callOnRCE ( $ ( this ) , "destroy" ) ;
235+ } ) ;
230236 $ ( "#edit_page_form,#page_content,#page_sidebar" ) . removeClass ( 'editing' ) . removeClass ( 'previewing' ) ;
231237 $ ( "#page_content .section.unsaved,#page_content .section .form_content" ) . remove ( ) ;
232238 $ ( "#edit_page_form .edit_section" ) . each ( function ( ) {
@@ -277,13 +283,15 @@ define([
277283 if ( edit_type == "edit_html_content" ) {
278284 $edit . find ( ".edit_section" ) . attr ( 'id' , 'edit_' + $section . attr ( 'id' ) ) ;
279285 } else if ( edit_type == "edit_rich_text_content" ) {
280- $edit . find ( ".edit_section" ) . attr ( 'id' , 'edit_' + $section . attr ( 'id' ) ) ;
281- richContentEditor . loadNewEditor ( $edit . find ( ".edit_section" ) , { defaultContent : "" } )
286+ var $richText = $edit . find ( ".edit_section" )
287+ $richText . attr ( 'id' , 'edit_' + $section . attr ( 'id' ) ) ;
288+ richContentEditor . loadNewEditor ( $richText , { defaultContent : "" } )
282289 }
283290 $section . hide ( ) . slideDown ( 'fast' , function ( ) {
284291 $ ( "html,body" ) . scrollTo ( $section ) ;
285292 if ( section_type == "rich_text" ) {
286- richContentEditor . callOnRCE ( $edit . find ( ".edit_section" ) , "focus" )
293+ var $richText = $edit . find ( ".edit_section" )
294+ richContentEditor . callOnRCE ( $richText , "focus" )
287295 } else if ( section_type == "html" ) {
288296 $edit . find ( ".edit_section" ) . focus ( ) . select ( ) ;
289297 }
@@ -304,15 +312,17 @@ define([
304312 helper : 'clone' ,
305313 axis : 'y' ,
306314 start : function ( event , ui ) {
307- var $item = $ ( ui . item ) ;
308- if ( $item . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type == 'rich_text' ) {
309- richContentEditor . callOnRCE ( $item . find ( "textarea" ) , "destroy" )
315+ var $section = $ ( ui . item ) ;
316+ if ( $section . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type == 'rich_text' ) {
317+ var $richText = $section . find ( '.edit_section' ) ;
318+ richContentEditor . callOnRCE ( $richText , "destroy" ) ;
310319 }
311320 } ,
312321 stop : function ( event , ui ) {
313- var $item = $ ( ui . item ) ;
314- if ( $item . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type == 'rich_text' ) {
315- richContentEditor . loadNewEditor ( $item . find ( "textarea" ) )
322+ var $section = $ ( ui . item ) ;
323+ if ( $section . getTemplateData ( { textValues : [ 'section_type' ] } ) . section_type == 'rich_text' ) {
324+ var $richText = $section . find ( '.edit_section' ) ;
325+ richContentEditor . loadNewEditor ( $richText )
316326 }
317327 }
318328 } ) ;
0 commit comments