Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
1252181f
Commit
1252181f
authored
Jan 09, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code review cleanup.
parent
144c6bca
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
23 deletions
+29
-23
cms/templates/widgets/problem-edit.html
+1
-1
common/lib/xmodule/xmodule/js/src/problem/edit.coffee
+28
-22
No files found.
cms/templates/widgets/problem-edit.html
View file @
1252181f
<
%
include
file=
"metadata-edit.html"
/>
<
%
include
file=
"metadata-edit.html"
/>
<section
class=
"problem-editor editor"
>
<section
class=
"problem-editor editor"
>
<div
class=
"row"
>
<div
class=
"row"
>
%if markdown != '' or data == '
<problem>
\n
</problem>
\n':
<div
class=
"editor-bar"
>
<div
class=
"editor-bar"
>
<ul
class=
"format-buttons"
>
<ul
class=
"format-buttons"
>
<li><a
href=
"#"
class=
"multiple-choice-button"
data-tooltip=
"Multiple Choice"
><span
<li><a
href=
"#"
class=
"multiple-choice-button"
data-tooltip=
"Multiple Choice"
><span
...
@@ -19,7 +20,6 @@
...
@@ -19,7 +20,6 @@
<li><a
href=
"#"
class=
"cheatsheet-toggle"
data-tooltip=
"Toggle Cheatsheet"
>
?
</a></li>
<li><a
href=
"#"
class=
"cheatsheet-toggle"
data-tooltip=
"Toggle Cheatsheet"
>
?
</a></li>
</ul>
</ul>
</div>
</div>
%if markdown != '' or data == '
<problem>
\n
</problem>
\n':
<textarea
class=
"markdown-box"
>
${markdown}
</textarea>
<textarea
class=
"markdown-box"
>
${markdown}
</textarea>
%endif
%endif
<textarea
class=
"xml-box"
rows=
"8"
cols=
"40"
>
${data | h}
</textarea>
<textarea
class=
"xml-box"
rows=
"8"
cols=
"40"
>
${data | h}
</textarea>
...
...
common/lib/xmodule/xmodule/js/src/problem/edit.coffee
View file @
1252181f
...
@@ -7,16 +7,6 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
...
@@ -7,16 +7,6 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
constructor
:
(
element
)
->
constructor
:
(
element
)
->
@
element
=
element
@
element
=
element
@
element
.
on
(
'click'
,
'.xml-tab'
,
@
showXMLEditor
)
@
element
.
on
(
'click'
,
'.format-buttons a'
,
@
onToolbarButton
);
@
element
.
on
(
'click'
,
'.cheatsheet-toggle'
,
@
toggleCheatsheet
);
@
xml_editor
=
CodeMirror
.
fromTextArea
(
$
(
".xml-box"
,
element
)[
0
],
{
mode
:
"xml"
lineNumbers
:
true
lineWrapping
:
true
})
@
current_editor
=
@
xml_editor
if
$
(
".markdown-box"
,
@
element
).
length
!=
0
if
$
(
".markdown-box"
,
@
element
).
length
!=
0
@
markdown_editor
=
CodeMirror
.
fromTextArea
(
$
(
".markdown-box"
,
element
)[
0
],
{
@
markdown_editor
=
CodeMirror
.
fromTextArea
(
$
(
".markdown-box"
,
element
)[
0
],
{
...
@@ -24,36 +14,51 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
...
@@ -24,36 +14,51 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
mode
:
null
mode
:
null
})
})
@
setCurrentEditor
(
@
markdown_editor
)
@
setCurrentEditor
(
@
markdown_editor
)
# Add listeners for toolbar buttons (only present for markdown editor)
@
element
.
on
(
'click'
,
'.xml-tab'
,
@
onShowXMLButton
)
@
element
.
on
(
'click'
,
'.format-buttons a'
,
@
onToolbarButton
)
@
element
.
on
(
'click'
,
'.cheatsheet-toggle'
,
@
toggleCheatsheet
)
# Hide the XML text area
$
(
@
element
.
find
(
'.xml-box'
)).
hide
()
else
else
@
hideMarkdownElements
()
@
createXMLEditor
()
###
###
Hides the toolbar buttons, as they only apply to the markdown editor.
Creates the XML Editor and sets it as the current editor. If text is passed in,
it will replace the text present in the HTML template.
text: optional argument to override the text passed in via the HTML template
###
###
hideMarkdownElements
:
()
->
createXMLEditor
:
(
text
)
->
$
(
@
element
.
find
(
'.editor-bar'
)).
hide
()
@
xml_editor
=
CodeMirror
.
fromTextArea
(
$
(
".xml-box"
,
@
element
)[
0
],
{
$
(
@
element
.
find
(
'.editor-tabs'
)).
hide
()
mode
:
"xml"
lineNumbers
:
true
lineWrapping
:
true
})
if
text
@
xml_editor
.
setValue
(
text
)
@
setCurrentEditor
(
@
xml_editor
)
###
###
User has clicked to show the XML editor. Before XML editor is swapped in,
User has clicked to show the XML editor. Before XML editor is swapped in,
the user will need to confirm the one-way conversion.
the user will need to confirm the one-way conversion.
###
###
showXMLEditor
:
(
e
)
=>
onShowXMLButton
:
(
e
)
=>
e
.
preventDefault
();
e
.
preventDefault
();
if
@
confirmConversionToXml
()
if
@
confirmConversionToXml
()
@
xml_editor
.
setValue
(
MarkdownEditingDescriptor
.
markdownToXml
(
@
markdown_editor
.
getValue
()))
@
createXMLEditor
(
MarkdownEditingDescriptor
.
markdownToXml
(
@
markdown_editor
.
getValue
()))
@
setCurrentEditor
(
@
xml_editor
)
# Need to refresh to get line numbers to display properly (and put cursor position to 0)
# Need this to get line numbers to display properly (and put caret position to 0)
@
xml_editor
.
setCursor
(
0
)
@
xml_editor
.
setCursor
(
0
)
@
xml_editor
.
refresh
()
@
xml_editor
.
refresh
()
@
hideMarkdownElements
()
# Hide markdown-specific toolbar buttons
$
(
@
element
.
find
(
'.editor-bar'
)).
hide
()
###
###
Have the user confirm the one-way conversion to XML.
Have the user confirm the one-way conversion to XML.
Returns true if the user clicked OK, else false.
Returns true if the user clicked OK, else false.
###
###
confirmConversionToXml
:
->
confirmConversionToXml
:
->
#
TODO: use something besides a JavaScript confirm dialog?
#
TODO: use something besides a JavaScript confirm dialog?
return
confirm
(
"If you convert to the XML source representation, you cannot go back to using markdown.
\n\n
Proceed with conversion to XML?"
)
return
confirm
(
"If you convert to the XML source representation, you cannot go back to using markdown.
\n\n
Proceed with conversion to XML?"
)
###
###
...
@@ -90,7 +95,8 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
...
@@ -90,7 +95,8 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
Stores the current editor and hides the one that is not displayed.
Stores the current editor and hides the one that is not displayed.
###
###
setCurrentEditor
:
(
editor
)
->
setCurrentEditor
:
(
editor
)
->
$
(
@
current_editor
.
getWrapperElement
()).
hide
()
if
@
current_editor
$
(
@
current_editor
.
getWrapperElement
()).
hide
()
@
current_editor
=
editor
@
current_editor
=
editor
$
(
@
current_editor
.
getWrapperElement
()).
show
()
$
(
@
current_editor
.
getWrapperElement
()).
show
()
$
(
@
current_editor
).
focus
();
$
(
@
current_editor
).
focus
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment