From b6fcf3a51ec05c4905dd466965cf9cdc6ccdc193 Mon Sep 17 00:00:00 2001 From: cahrens Date: Thu, 17 Jan 2013 10:36:04 -0500 Subject: [PATCH] Some refactoring from Brian's submission. --- common/lib/xmodule/xmodule/capa_module.py | 2 +- .../css/editor/{display.scss => edit.scss} | 3 +-- common/lib/xmodule/xmodule/html_module.py | 2 +- .../xmodule/js/fixtures/html-edit.html | 10 ++++----- .../xmodule/js/spec/html/edit_spec.coffee | 1 - .../xmodule/xmodule/js/src/html/edit.coffee | 22 ++++++++----------- .../xmodule/xmodule/self_assessment_module.py | 2 +- 7 files changed, 17 insertions(+), 25 deletions(-) rename common/lib/xmodule/xmodule/css/editor/{display.scss => edit.scss} (93%) diff --git a/common/lib/xmodule/xmodule/capa_module.py b/common/lib/xmodule/xmodule/capa_module.py index 1c31a4154a..4b53244ec3 100644 --- a/common/lib/xmodule/xmodule/capa_module.py +++ b/common/lib/xmodule/xmodule/capa_module.py @@ -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 diff --git a/common/lib/xmodule/xmodule/css/editor/display.scss b/common/lib/xmodule/xmodule/css/editor/edit.scss similarity index 93% rename from common/lib/xmodule/xmodule/css/editor/display.scss rename to common/lib/xmodule/xmodule/css/editor/edit.scss index 40e1c60a28..ac53bb5a70 100644 --- a/common/lib/xmodule/xmodule/css/editor/display.scss +++ b/common/lib/xmodule/xmodule/css/editor/edit.scss @@ -1,3 +1,4 @@ +// 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; diff --git a/common/lib/xmodule/xmodule/html_module.py b/common/lib/xmodule/xmodule/html_module.py index 9a03b7d953..33711c8161 100644 --- a/common/lib/xmodule/xmodule/html_module.py +++ b/common/lib/xmodule/xmodule/html_module.py @@ -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 diff --git a/common/lib/xmodule/xmodule/js/fixtures/html-edit.html b/common/lib/xmodule/xmodule/js/fixtures/html-edit.html index 0f20dd47c1..62f46a00ea 100644 --- a/common/lib/xmodule/xmodule/js/fixtures/html-edit.html +++ b/common/lib/xmodule/xmodule/js/fixtures/html-edit.html @@ -1,11 +1,9 @@
+
-
- -
Advanced Editor Text
diff --git a/common/lib/xmodule/xmodule/js/spec/html/edit_spec.coffee b/common/lib/xmodule/xmodule/js/spec/html/edit_spec.coffee index 9b34ac28e6..d18fbf7172 100644 --- a/common/lib/xmodule/xmodule/js/spec/html/edit_spec.coffee +++ b/common/lib/xmodule/xmodule/js/spec/html/edit_spec.coffee @@ -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 diff --git a/common/lib/xmodule/xmodule/js/src/html/edit.coffee b/common/lib/xmodule/xmodule/js/src/html/edit.coffee index cfce4a32a0..63fed014dc 100644 --- a/common/lib/xmodule/xmodule/js/src/html/edit.coffee +++ b/common/lib/xmodule/xmodule/js/src/html/edit.coffee @@ -1,4 +1,6 @@ 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: -> diff --git a/common/lib/xmodule/xmodule/self_assessment_module.py b/common/lib/xmodule/xmodule/self_assessment_module.py index b5cf04c2f7..58c5d89c3a 100644 --- a/common/lib/xmodule/xmodule/self_assessment_module.py +++ b/common/lib/xmodule/xmodule/self_assessment_module.py @@ -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):