Commit 2306e7c1 by Christina Roberts

Merge pull request #1417 from MITx/feature/christina/misc2

Try, try again.
parents 43c2acdb aac179f1
...@@ -50,7 +50,7 @@ class @HTMLEditingDescriptor ...@@ -50,7 +50,7 @@ class @HTMLEditingDescriptor
}) })
@showingVisualEditor = true @showingVisualEditor = true
@element.on('click', '.editor-tabs .tab', @onSwitchEditor) @element.on('click', '.editor-tabs .tab', this, @onSwitchEditor)
@setupTinyMCE: (ed) -> @setupTinyMCE: (ed) ->
ed.addButton('wrapAsCode', { ed.addButton('wrapAsCode', {
...@@ -71,16 +71,18 @@ class @HTMLEditingDescriptor ...@@ -71,16 +71,18 @@ class @HTMLEditingDescriptor
e.preventDefault(); e.preventDefault();
if not $(e.currentTarget).hasClass('current') if not $(e.currentTarget).hasClass('current')
element = e.data.element
$(e.currentTarget).addClass('current') $(e.currentTarget).addClass('current')
$('table.mceToolbar', @element).toggleClass(HTMLEditingDescriptor.isInactiveClass) $(element).find('table.mceToolbar').toggleClass(HTMLEditingDescriptor.isInactiveClass)
$(@advanced_editor.getWrapperElement()).toggleClass(HTMLEditingDescriptor.isInactiveClass) $(@advanced_editor.getWrapperElement()).toggleClass(HTMLEditingDescriptor.isInactiveClass)
visualEditor = @getVisualEditor() visualEditor = @getVisualEditor(element)
if $(e.currentTarget).attr('data-tab') is 'visual' if $(e.currentTarget).attr('data-tab') is 'visual'
$('.html-tab', @element).removeClass('current') $(element).find('.html-tab').removeClass('current')
@showVisualEditor(visualEditor) @showVisualEditor(visualEditor)
else else
$('.visual-tab', @element).removeClass('current') $(element).find('.visual-tab').removeClass('current')
@showAdvancedEditor(visualEditor) @showAdvancedEditor(visualEditor)
# Show the Advanced (codemirror) Editor. Pulled out as a helper method for unit testing. # Show the Advanced (codemirror) Editor. Pulled out as a helper method for unit testing.
...@@ -105,17 +107,17 @@ class @HTMLEditingDescriptor ...@@ -105,17 +107,17 @@ class @HTMLEditingDescriptor
focusVisualEditor: (visualEditor) -> focusVisualEditor: (visualEditor) ->
visualEditor.focus() visualEditor.focus()
getVisualEditor: -> getVisualEditor: (element) ->
### ###
Returns the instance of TinyMCE. Returns the instance of TinyMCE.
This is different from the textarea that exists in the HTML template (@tiny_mce_textarea. This is different from the textarea that exists in the HTML template (@tiny_mce_textarea.
### ###
return tinyMCE.get($('.tiny-mce', this.element).attr('id')) return tinyMCE.get($(element).find('.tiny-mce').attr('id'))
save: -> save: ->
@element.off('click', '.editor-tabs .tab', @onSwitchEditor) @element.off('click', '.editor-tabs .tab', @onSwitchEditor)
text = @advanced_editor.getValue() text = @advanced_editor.getValue()
visualEditor = @getVisualEditor() visualEditor = @getVisualEditor(@element)
if @showingVisualEditor and visualEditor.isDirty() if @showingVisualEditor and visualEditor.isDirty()
text = visualEditor.getContent({no_events: 1}) text = visualEditor.getContent({no_events: 1})
data: text data: text
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment