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 @@
<div
class=
"value"
>
<label
for=
"course-advanced-policy-value"
>
Policy Value:
</label>
<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>
<a
href=
"#"
class=
"delete-button standard remove-item advanced-policy-data"
>
...
...
cms/static/js/template_loader.js
View file @
039160f5
...
...
@@ -5,7 +5,7 @@
if
(
typeof
window
.
templateLoader
==
'function'
)
return
;
var
templateLoader
=
{
templateVersion
:
"0.0.1
4
"
,
templateVersion
:
"0.0.1
5
"
,
templates
:
{},
loadRemoteTemplate
:
function
(
templateName
,
filename
,
callback
)
{
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({
listEle$
.
append
(
self
.
template
({
key
:
key
,
value
:
JSON
.
stringify
(
self
.
model
.
get
(
key
))}));
self
.
fieldToSelectorMap
[
key
]
=
key
;
});
var
policyValue
Divs
=
listEle$
.
find
(
'.ace
'
);
_
.
each
(
policyValue
Divs
,
this
.
attachAce
,
this
);
var
policyValue
s
=
listEle$
.
find
(
'.json
'
);
_
.
each
(
policyValue
s
,
this
.
attachJSONEditor
,
this
);
this
.
showMessage
();
return
this
;
},
attach
Ace
:
function
(
div
)
{
attach
JSONEditor
:
function
(
textarea
)
{
var
self
=
this
;
var
editor
=
ace
.
edit
(
div
);
editor
.
setTheme
(
"ace/theme/chrome"
);
editor
.
setHighlightActiveLine
(
false
);
editor
.
on
(
"blur"
,
function
(
e
)
{
var
key
=
$
(
editor
.
container
).
closest
(
'.row'
).
children
(
'.key'
).
attr
(
'id'
);
// TODO: error checking in case it does not parse!
var
quotedValue
=
editor
.
getValue
();
CodeMirror
.
fromTextArea
(
textarea
,
{
mode
:
"text/html"
,
lineNumbers
:
true
,
lineWrapping
:
true
,
onBlur
:
function
(
mirror
)
{
var
key
=
$
(
mirror
.
getWrapperElement
()).
closest
(
'.row'
).
children
(
'.key'
).
attr
(
'id'
);
mirror
.
save
();
var
quotedValue
=
mirror
.
getValue
();
var
JSONValue
=
JSON
.
parse
(
quotedValue
);
self
.
model
.
set
(
key
,
JSONValue
,
{
validate
:
true
});
self
.
showMessage
(
self
.
unsaved_changes
);
});
// Calling getSession() directly in render causes a crash on Chrome.
// Seems to be OK in afterRender method.
editor
.
getSession
().
setMode
(
"ace/mode/json"
);
// cachethis.clearValidationErrors();
// var newVal = mirror.getValue();
// if (cachethis.model.get(field) != newVal) cachethis.model.save(field, newVal,
// { error: CMS.ServerError});
}
});
},
showMessage
:
function
(
type
)
{
...
...
@@ -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
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
this
.
new_key
).
closest
(
'li'
).
find
(
'.ace'
);
// 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
);
},
updateKey
:
function
(
event
)
{
...
...
@@ -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
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
newKey
).
closest
(
'li'
).
find
(
'.ace'
);
// 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
.
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