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
373c8eb2
Commit
373c8eb2
authored
Jan 09, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'feature/cas/speed-editor' of github.com:MITx/mitx into feature/cas/speed-editor
parents
8245ebac
71ee11bf
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
32 additions
and
46 deletions
+32
-46
cms/static/coffee/src/views/unit.coffee
+3
-0
cms/templates/widgets/problem-edit.html
+1
-1
common/lib/xmodule/xmodule/css/problem/edit.scss
+0
-23
common/lib/xmodule/xmodule/js/src/problem/edit.coffee
+28
-22
No files found.
cms/static/coffee/src/views/unit.coffee
View file @
373c8eb2
...
...
@@ -59,6 +59,9 @@ class CMS.Views.UnitEdit extends Backbone.View
type
=
$
(
event
.
currentTarget
).
data
(
'type'
)
@
$newComponentTypePicker
.
slideUp
(
250
)
@
$
(
".new-component-
#{
type
}
"
).
slideDown
(
250
)
$
(
'html, body'
).
animate
({
scrollTop
:
@
$
(
".new-component-
#{
type
}
"
).
offset
().
top
},
500
)
closeNewComponent
:
(
event
)
=>
event
.
preventDefault
()
...
...
cms/templates/widgets/problem-edit.html
View file @
373c8eb2
<
%
include
file=
"metadata-edit.html"
/>
<section
class=
"problem-editor editor"
>
<div
class=
"row"
>
%if markdown != '' or data == '
<problem>
\n
</problem>
\n':
<div
class=
"editor-bar"
>
<ul
class=
"format-buttons"
>
<li><a
href=
"#"
class=
"multiple-choice-button"
data-tooltip=
"Multiple Choice"
><span
...
...
@@ -19,7 +20,6 @@
<li><a
href=
"#"
class=
"cheatsheet-toggle"
data-tooltip=
"Toggle Cheatsheet"
>
?
</a></li>
</ul>
</div>
%if markdown != '' or data == '
<problem>
\n
</problem>
\n':
<textarea
class=
"markdown-box"
>
${markdown}
</textarea>
%endif
<textarea
class=
"xml-box"
rows=
"8"
cols=
"40"
>
${data | h}
</textarea>
...
...
common/lib/xmodule/xmodule/css/problem/edit.scss
View file @
373c8eb2
...
...
@@ -119,29 +119,6 @@
}
}
.tiny-link-dialog
{
position
:
fixed
;
top
:
40px
;
left
:
50%
;
z-index
:
99999
;
width
:
600px
;
margin-left
:
-300px
;
background
:
#fff
;
.close-button
{
@include
white-button
;
position
:
absolute
;
top
:
0
;
right
:
15px
;
width
:
29px
;
height
:
29px
;
padding
:
0
!
important
;
border-radius
:
17px
!
important
;
line-height
:
29px
;
text-align
:
center
;
}
}
.problem-editor-icon
{
display
:
inline-block
;
width
:
26px
;
...
...
common/lib/xmodule/xmodule/js/src/problem/edit.coffee
View file @
373c8eb2
...
...
@@ -7,16 +7,6 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
constructor
:
(
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
@
markdown_editor
=
CodeMirror
.
fromTextArea
(
$
(
".markdown-box"
,
element
)[
0
],
{
...
...
@@ -24,36 +14,51 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
mode
:
null
})
@
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
@
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
:
()
->
$
(
@
element
.
find
(
'.editor-bar'
)).
hide
()
$
(
@
element
.
find
(
'.editor-tabs'
)).
hide
()
createXMLEditor
:
(
text
)
->
@
xml_editor
=
CodeMirror
.
fromTextArea
(
$
(
".xml-box"
,
@
element
)[
0
],
{
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,
the user will need to confirm the one-way conversion.
###
showXMLEditor
:
(
e
)
=>
onShowXMLButton
:
(
e
)
=>
e
.
preventDefault
();
if
@
confirmConversionToXml
()
@
xml_editor
.
setValue
(
MarkdownEditingDescriptor
.
markdownToXml
(
@
markdown_editor
.
getValue
()))
@
setCurrentEditor
(
@
xml_editor
)
# Need this to get line numbers to display properly (and put caret position to 0)
@
createXMLEditor
(
MarkdownEditingDescriptor
.
markdownToXml
(
@
markdown_editor
.
getValue
()))
# Need to refresh to get line numbers to display properly (and put cursor position to 0)
@
xml_editor
.
setCursor
(
0
)
@
xml_editor
.
refresh
()
@
hideMarkdownElements
()
# Hide markdown-specific toolbar buttons
$
(
@
element
.
find
(
'.editor-bar'
)).
hide
()
###
Have the user confirm the one-way conversion to XML.
Returns true if the user clicked OK, else false.
###
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?"
)
###
...
...
@@ -90,7 +95,8 @@ class @MarkdownEditingDescriptor extends XModule.Descriptor
Stores the current editor and hides the one that is not displayed.
###
setCurrentEditor
:
(
editor
)
->
$
(
@
current_editor
.
getWrapperElement
()).
hide
()
if
@
current_editor
$
(
@
current_editor
.
getWrapperElement
()).
hide
()
@
current_editor
=
editor
$
(
@
current_editor
.
getWrapperElement
()).
show
()
$
(
@
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