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
3eadcd29
Commit
3eadcd29
authored
Jun 22, 2012
by
Calen Pennington
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Call js module name dynamically, rather than statically calling the HTML module
parent
c5483def
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
18 additions
and
8 deletions
+18
-8
cms/djangoapps/contentstore/views.py
+4
-1
cms/static/coffee/main.coffee
+1
-1
cms/templates/unit.html
+3
-0
common/lib/xmodule/html_module.py
+2
-6
common/lib/xmodule/js/module/html.coffee
+5
-0
common/lib/xmodule/setup.py
+3
-0
No files found.
cms/djangoapps/contentstore/views.py
View file @
3eadcd29
...
@@ -17,4 +17,7 @@ def index(request):
...
@@ -17,4 +17,7 @@ def index(request):
def
edit_item
(
request
):
def
edit_item
(
request
):
item_id
=
request
.
GET
[
'id'
]
item_id
=
request
.
GET
[
'id'
]
item
=
keystore
()
.
get_item
(
item_id
)
item
=
keystore
()
.
get_item
(
item_id
)
return
HttpResponse
(
item
.
get_html
())
return
render_to_response
(
'unit.html'
,
{
'contents'
:
item
.
get_html
(),
'type'
:
item
.
type
,
})
cms/static/coffee/main.coffee
View file @
3eadcd29
...
@@ -9,7 +9,7 @@ edit_item = (id) ->
...
@@ -9,7 +9,7 @@ edit_item = (id) ->
bind_edit_links
()
bind_edit_links
()
$
(
'section.edit-pane'
).
show
()
$
(
'section.edit-pane'
).
show
()
$
(
'body'
).
addClass
(
'content'
)
$
(
'body'
).
addClass
(
'content'
)
window
[
'construct_html'
](
'module-html'
)
new
window
[
$
(
'#unit-wrapper'
).
attr
(
'class'
)]
'module-html'
)
)
$
->
$
->
...
...
cms/templates/unit.html
0 → 100644
View file @
3eadcd29
<div
id=
"unit-wrapper"
class=
"${type}"
>
${contents}
</div>
common/lib/xmodule/html_module.py
View file @
3eadcd29
...
@@ -4,6 +4,7 @@ import logging
...
@@ -4,6 +4,7 @@ import logging
from
x_module
import
XModule
from
x_module
import
XModule
from
mako_module
import
MakoModuleDescriptor
from
mako_module
import
MakoModuleDescriptor
from
lxml
import
etree
from
lxml
import
etree
from
pkg_resources
import
resource_string
log
=
logging
.
getLogger
(
"mitx.courseware"
)
log
=
logging
.
getLogger
(
"mitx.courseware"
)
...
@@ -16,12 +17,7 @@ class HtmlModuleDescriptor(MakoModuleDescriptor):
...
@@ -16,12 +17,7 @@ class HtmlModuleDescriptor(MakoModuleDescriptor):
mako_template
=
"widgets/html-edit.html"
mako_template
=
"widgets/html-edit.html"
# TODO (cpennington): Make this into a proper module
# TODO (cpennington): Make this into a proper module
js
=
{
'coffee'
:
[
"""
js
=
{
'coffee'
:
[
resource_string
(
__name__
,
'js/module/html.coffee'
)]}
window.construct_html = (id) ->
$('#' + id + " #edit-box").on('input', ->
$('#' + id + ' #edit-preview').empty().append($(this).val())
)
"""
]}
class
Module
(
XModule
):
class
Module
(
XModule
):
...
...
common/lib/xmodule/js/module/html.coffee
0 → 100644
View file @
3eadcd29
class
@
HTML
constructor
:
(
id
)
->
$
(
'#'
+
id
+
" #edit-box"
).
on
(
'input'
,
->
$
(
'#'
+
id
+
' #edit-preview'
).
empty
().
append
(
$
(
this
).
val
())
)
common/lib/xmodule/setup.py
View file @
3eadcd29
...
@@ -5,6 +5,9 @@ setup(
...
@@ -5,6 +5,9 @@ setup(
version
=
"0.1"
,
version
=
"0.1"
,
packages
=
find_packages
(),
packages
=
find_packages
(),
install_requires
=
[
'distribute'
],
install_requires
=
[
'distribute'
],
package_data
=
{
''
:
[
'js/*'
]
},
# See http://guide.python-distribute.org/creation.html#entry-points
# See http://guide.python-distribute.org/creation.html#entry-points
# for a description of entry_points
# for a description of entry_points
...
...
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