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
039160f5
Commit
039160f5
authored
Feb 11, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Beginning of CodeMirror.
parent
ac732f6b
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
20 deletions
+19
-20
cms/static/client_templates/advanced_entry.html
+1
-1
cms/static/js/template_loader.js
+1
-1
cms/static/js/views/settings/advanced_view.js
+17
-18
No files found.
cms/static/client_templates/advanced_entry.html
View file @
039160f5
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
<div
class=
"value"
>
<div
class=
"value"
>
<label
for=
"course-advanced-policy-value"
>
Policy Value:
</label>
<label
for=
"course-advanced-policy-value"
>
Policy Value:
</label>
<div
class=
"field"
>
<div
class=
"field"
>
<
div
class=
"ace text"
id=
"course-advanced-policy-value"
><
%=
value
%
></div
>
<
textarea
class=
"json text"
id=
"course-advanced-policy-value"
><
%=
value
%
></textarea
>
</div>
</div>
</div>
</div>
</div>
<a
href=
"#"
class=
"delete-button standard remove-item advanced-policy-data"
>
</div>
<a
href=
"#"
class=
"delete-button standard remove-item advanced-policy-data"
>
...
...
cms/static/js/template_loader.js
View file @
039160f5
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
if
(
typeof
window
.
templateLoader
==
'function'
)
return
;
if
(
typeof
window
.
templateLoader
==
'function'
)
return
;
var
templateLoader
=
{
var
templateLoader
=
{
templateVersion
:
"0.0.1
4
"
,
templateVersion
:
"0.0.1
5
"
,
templates
:
{},
templates
:
{},
loadRemoteTemplate
:
function
(
templateName
,
filename
,
callback
)
{
loadRemoteTemplate
:
function
(
templateName
,
filename
,
callback
)
{
if
(
!
this
.
templates
[
templateName
])
{
if
(
!
this
.
templates
[
templateName
])
{
...
...
cms/static/js/views/settings/advanced_view.js
View file @
039160f5
...
@@ -47,29 +47,28 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -47,29 +47,28 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
listEle$
.
append
(
self
.
template
({
key
:
key
,
value
:
JSON
.
stringify
(
self
.
model
.
get
(
key
))}));
listEle$
.
append
(
self
.
template
({
key
:
key
,
value
:
JSON
.
stringify
(
self
.
model
.
get
(
key
))}));
self
.
fieldToSelectorMap
[
key
]
=
key
;
self
.
fieldToSelectorMap
[
key
]
=
key
;
});
});
var
policyValue
Divs
=
listEle$
.
find
(
'.ace
'
);
var
policyValue
s
=
listEle$
.
find
(
'.json
'
);
_
.
each
(
policyValue
Divs
,
this
.
attachAce
,
this
);
_
.
each
(
policyValue
s
,
this
.
attachJSONEditor
,
this
);
this
.
showMessage
();
this
.
showMessage
();
return
this
;
return
this
;
},
},
attach
Ace
:
function
(
div
)
{
attach
JSONEditor
:
function
(
textarea
)
{
var
self
=
this
;
var
self
=
this
;
var
editor
=
ace
.
edit
(
div
);
CodeMirror
.
fromTextArea
(
textarea
,
{
editor
.
setTheme
(
"ace/theme/chrome"
);
mode
:
"text/html"
,
lineNumbers
:
true
,
lineWrapping
:
true
,
editor
.
setHighlightActiveLine
(
false
);
onBlur
:
function
(
mirror
)
{
editor
.
on
(
"blur"
,
var
key
=
$
(
mirror
.
getWrapperElement
()).
closest
(
'.row'
).
children
(
'.key'
).
attr
(
'id'
);
function
(
e
)
{
mirror
.
save
();
var
key
=
$
(
editor
.
container
).
closest
(
'.row'
).
children
(
'.key'
).
attr
(
'id'
);
var
quotedValue
=
mirror
.
getValue
();
// TODO: error checking in case it does not parse!
var
quotedValue
=
editor
.
getValue
();
var
JSONValue
=
JSON
.
parse
(
quotedValue
);
var
JSONValue
=
JSON
.
parse
(
quotedValue
);
self
.
model
.
set
(
key
,
JSONValue
,
{
validate
:
true
});
self
.
model
.
set
(
key
,
JSONValue
,
{
validate
:
true
});
self
.
showMessage
(
self
.
unsaved_changes
);
self
.
showMessage
(
self
.
unsaved_changes
);
// cachethis.clearValidationErrors();
});
// var newVal = mirror.getValue();
// Calling getSession() directly in render causes a crash on Chrome.
// if (cachethis.model.get(field) != newVal) cachethis.model.save(field, newVal,
// Seems to be OK in afterRender method.
// { error: CMS.ServerError});
editor
.
getSession
().
setMode
(
"ace/mode/json"
);
}
});
},
},
showMessage
:
function
(
type
)
{
showMessage
:
function
(
type
)
{
...
@@ -140,7 +139,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -140,7 +139,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// need to refind b/c replaceWith seems to copy rather than use the specific ele instance
// need to refind b/c replaceWith seems to copy rather than use the specific ele instance
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
this
.
new_key
).
closest
(
'li'
).
find
(
'.ace'
);
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
this
.
new_key
).
closest
(
'li'
).
find
(
'.ace'
);
// only 1 but hey, let's take advantage of the context mechanism
// only 1 but hey, let's take advantage of the context mechanism
_
.
each
(
policyValueDivs
,
this
.
attach
Ace
,
this
);
_
.
each
(
policyValueDivs
,
this
.
attach
JSONEditor
,
this
);
this
.
showMessage
(
this
.
unsaved_changes
);
this
.
showMessage
(
this
.
unsaved_changes
);
},
},
updateKey
:
function
(
event
)
{
updateKey
:
function
(
event
)
{
...
@@ -205,7 +204,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -205,7 +204,7 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// need to refind b/c replaceWith seems to copy rather than use the specific ele instance
// need to refind b/c replaceWith seems to copy rather than use the specific ele instance
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
newKey
).
closest
(
'li'
).
find
(
'.ace'
);
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
newKey
).
closest
(
'li'
).
find
(
'.ace'
);
// only 1 but hey, let's take advantage of the context mechanism
// only 1 but hey, let's take advantage of the context mechanism
_
.
each
(
policyValueDivs
,
this
.
attach
Ace
,
this
);
_
.
each
(
policyValueDivs
,
this
.
attach
JSONEditor
,
this
);
this
.
fieldToSelectorMap
[
newKey
]
=
newKey
;
this
.
fieldToSelectorMap
[
newKey
]
=
newKey
;
this
.
showMessage
(
this
.
unsaved_changes
);
this
.
showMessage
(
this
.
unsaved_changes
);
...
...
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