Commit b6fcf3a5 by cahrens

Some refactoring from Brian's submission.

parent db7443ce
......@@ -673,7 +673,7 @@ class CapaDescriptor(RawDescriptor):
mako_template = "widgets/problem-edit.html"
js = {'coffee': [resource_string(__name__, 'js/src/problem/edit.coffee')]}
js_module_name = "MarkdownEditingDescriptor"
css = {'scss': [resource_string(__name__, 'css/editor/display.scss'), resource_string(__name__, 'css/problem/edit.scss')]}
css = {'scss': [resource_string(__name__, 'css/editor/edit.scss'), resource_string(__name__, 'css/problem/edit.scss')]}
# Capa modules have some additional metadata:
# TODO (vshnayder): do problems have any other metadata? Do they
......
// This is shared CSS between the xmodule problem editor and the xmodule HTML editor.
.editor {
position: relative;
......@@ -13,8 +14,6 @@
border-radius: 3px 3px 0 0;
border-bottom-color: #a5aaaf;
@include clearfix;
// TODO: I added this -- Brian to fix roperly
height: 34px;
a {
display: block;
......
......@@ -48,7 +48,7 @@ class HtmlDescriptor(XmlDescriptor, EditingDescriptor):
js = {'coffee': [resource_string(__name__, 'js/src/html/edit.coffee')]}
js_module_name = "HTMLEditingDescriptor"
css = {'scss': [resource_string(__name__, 'css/editor/display.scss'), resource_string(__name__, 'css/html/edit.scss')]}
css = {'scss': [resource_string(__name__, 'css/editor/edit.scss'), resource_string(__name__, 'css/html/edit.scss')]}
# VS[compat] TODO (cpennington): Delete this method once all fall 2012 course
# are being edited in the cms
......
<section class="html-edit">
<ul class="editor-tabs">
<li><a href="#" class="visual-tab tab current" data-tab="visual">Visual</a></li>
<li><a href="#" class="html-tab tab" data-tab="advanced">HTML</a></li>
</ul>
<div class="row">
<div class="editor-bar">
<ul class="editor-tabs">
<li><a href="#" class="visual-tab tab current" data-tab="visual">Visual</a></li>
<li><a href="#" class="html-tab tab" data-tab="advanced">Advanced</a></li>
</ul>
</div>
<textarea class="tiny-mce">dummy text</textarea>
<div name="" class="edit-box">Advanced Editor Text</div>
</div>
......
......@@ -78,7 +78,6 @@ describe 'HTMLEditingDescriptor', ->
isNotDirty: false
content: 'not set'
startContent: 'not set',
show: () -> true
focus: () -> true
isDirty: () -> not @isNotDirty
setContent: (x) -> @content = x
......
class @HTMLEditingDescriptor
@isInactiveClass : "is-inactive"
constructor: (element) ->
@element = element;
text = $(".edit-box", @element)[0];
......@@ -9,7 +11,7 @@ class @HTMLEditingDescriptor
lineNumbers: true
lineWrapping: true})
$(@advanced_editor.getWrapperElement()).addClass('is-inactive')
$(@advanced_editor.getWrapperElement()).addClass(HTMLEditingDescriptor.isInactiveClass)
@tiny_mce_textarea = $(".tiny-mce", @element).tinymce({
script_url : '/static/js/vendor/tiny_mce/tiny_mce.js',
......@@ -29,7 +31,7 @@ class @HTMLEditingDescriptor
height: '400px',
# Cannot get access to tinyMCE Editor instance (for focusing) until after it is rendered.
# The tinyMCE callback passes in the editor as a paramter.
init_instance_callback: @initializeVisualEditor
init_instance_callback: @focusVisualEditor
})
@showingVisualEditor = true
......@@ -41,19 +43,14 @@ class @HTMLEditingDescriptor
if not $(e.currentTarget).hasClass('current')
$('.editor-tabs .current').removeClass('current')
$(e.currentTarget).addClass('current')
visualEditor = @getVisualEditor()
$('table.mceToolbar').toggleClass(HTMLEditingDescriptor.isInactiveClass)
$(@advanced_editor.getWrapperElement()).toggleClass(HTMLEditingDescriptor.isInactiveClass)
visualEditor = @getVisualEditor()
if $(e.currentTarget).attr('data-tab') is 'visual'
@showVisualEditor(visualEditor)
$('table.mceToolbar').removeClass('is-inactive')
$(@advanced_editor.getWrapperElement()).addClass('is-inactive')
else
# @tiny_mce_textarea.hide()
@showAdvancedEditor(visualEditor)
$('table.mceToolbar').addClass('is-inactive')
$(@advanced_editor.getWrapperElement()).removeClass('is-inactive')
# Show the Advanced (codemirror) Editor. Pulled out as a helper method for unit testing.
showAdvancedEditor: (visualEditor) ->
......@@ -66,16 +63,15 @@ class @HTMLEditingDescriptor
# Show the Visual (tinyMCE) Editor. Pulled out as a helper method for unit testing.
showVisualEditor: (visualEditor) ->
# visualEditor.show()
visualEditor.setContent(@advanced_editor.getValue())
# In order for isDirty() to return true ONLY if edits have been made after setting the text,
# both the startContent must be sync'ed up and the dirty flag set to false.
visualEditor.startContent = visualEditor.getContent({format: "raw", no_events: 1});
visualEditor.isNotDirty = true
visualEditor.focus()
@focusVisualEditor(visualEditor)
@showingVisualEditor = true
initializeVisualEditor: (visualEditor) ->
focusVisualEditor: (visualEditor) ->
visualEditor.focus()
getVisualEditor: ->
......
......@@ -524,7 +524,7 @@ class SelfAssessmentDescriptor(XmlDescriptor, EditingDescriptor):
js = {'coffee': [resource_string(__name__, 'js/src/html/edit.coffee')]}
js_module_name = "HTMLEditingDescriptor"
css = {'scss': [resource_string(__name__, 'css/html/edit.scss')]}
css = {'scss': [resource_string(__name__, 'css/editor/edit.scss'), resource_string(__name__, 'css/html/edit.scss')]}
@classmethod
def definition_from_xml(cls, xml_object, system):
......
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