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
044a8a5c
Commit
044a8a5c
authored
Feb 11, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CodeMirror.
parent
039160f5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
20 deletions
+22
-20
cms/static/js/views/settings/advanced_view.js
+12
-16
cms/static/sass/_settings.scss
+10
-4
common/static/js/vendor/CodeMirror/javascript.js
+0
-0
No files found.
cms/static/js/views/settings/advanced_view.js
View file @
044a8a5c
...
...
@@ -55,36 +55,32 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
attachJSONEditor
:
function
(
textarea
)
{
var
self
=
this
;
CodeMirror
.
fromTextArea
(
textarea
,
{
mode
:
"
text/html"
,
lineNumbers
:
tru
e
,
lineWrapping
:
true
,
mode
:
"
application/json"
,
lineNumbers
:
fals
e
,
lineWrapping
:
true
,
onBlur
:
function
(
mirror
)
{
var
key
=
$
(
mirror
.
getWrapperElement
()).
closest
(
'.row'
).
children
(
'.key'
).
attr
(
'id'
);
mirror
.
save
();
var
quotedValue
=
mirror
.
getValue
();
// TODO: error checking
var
JSONValue
=
JSON
.
parse
(
quotedValue
);
self
.
model
.
set
(
key
,
JSONValue
,
{
validate
:
true
});
self
.
showMessage
(
self
.
unsaved_changes
);
// cachethis.clearValidationErrors();
// var newVal = mirror.getValue();
// if (cachethis.model.get(field) != newVal) cachethis.model.save(field, newVal,
// { error: CMS.ServerError});
}
});
},
showMessage
:
function
(
type
)
{
this
.
$el
.
find
(
".message-status"
).
removeClass
(
"is-shown"
);
//
var saveButton = this.$el.find(".save-button").addClass('disabled');
//
var cancelButton = this.$el.find(".cancel-button").addClass('disabled');
var
saveButton
=
this
.
$el
.
find
(
".save-button"
).
addClass
(
'disabled'
);
var
cancelButton
=
this
.
$el
.
find
(
".cancel-button"
).
addClass
(
'disabled'
);
if
(
type
)
{
if
(
type
===
this
.
error_saving
)
{
this
.
$el
.
find
(
".message-status.error"
).
addClass
(
"is-shown"
);
//
saveButton.removeClass("disabled");
//
cancelButton.removeClass("disabled");
saveButton
.
removeClass
(
"disabled"
);
cancelButton
.
removeClass
(
"disabled"
);
}
else
if
(
type
===
this
.
unsaved_changes
)
{
this
.
$el
.
find
(
".message-status.warning"
).
addClass
(
"is-shown"
);
//
saveButton.removeClass("disabled");
//
cancelButton.removeClass("disabled");
saveButton
.
removeClass
(
"disabled"
);
cancelButton
.
removeClass
(
"disabled"
);
}
else
if
(
type
===
this
.
successful_changes
)
this
.
$el
.
find
(
".message-status.confirm"
).
addClass
(
"is-shown"
);
...
...
@@ -136,8 +132,8 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// disable the value entry until there's an acceptable key
$
(
newEle
).
find
(
'.course-advanced-policy-value'
).
addClass
(
'disabled'
);
this
.
fieldToSelectorMap
[
this
.
new_key
]
=
this
.
new_key
;
// 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
'
);
// need to re
-
find b/c replaceWith seems to copy rather than use the specific ele instance
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
this
.
new_key
).
closest
(
'li'
).
find
(
'.
json
'
);
// only 1 but hey, let's take advantage of the context mechanism
_
.
each
(
policyValueDivs
,
this
.
attachJSONEditor
,
this
);
this
.
showMessage
(
this
.
unsaved_changes
);
...
...
@@ -201,8 +197,8 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// update gui (sets all the ids etc)
var
newEle
=
this
.
template
({
key
:
newKey
,
value
:
JSON
.
stringify
(
this
.
model
.
get
(
newKey
))
});
$
(
event
.
currentTarget
).
closest
(
'li'
).
replaceWith
(
newEle
);
// 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
'
);
// need to re
-
find b/c replaceWith seems to copy rather than use the specific ele instance
var
policyValueDivs
=
this
.
$el
.
find
(
'#'
+
newKey
).
closest
(
'li'
).
find
(
'.
json
'
);
// only 1 but hey, let's take advantage of the context mechanism
_
.
each
(
policyValueDivs
,
this
.
attachJSONEditor
,
this
);
...
...
cms/static/sass/_settings.scss
View file @
044a8a5c
...
...
@@ -550,10 +550,16 @@
}
.settings-advanced
{
.ace
{
height
:
80px
;
border
:
1px
solid
#DDD
;
}
//.CodeMirror {
// border: 1px solid #eee;
// height: auto;
//}
//.CodeMirror-scroll {
// overflow-y: hidden;
// overflow-x: auto;
//}
// messages - should be synced up with global messages in the future
.message
{
...
...
common/static/js/vendor/CodeMirror/javascript.js
0 → 100644
View file @
044a8a5c
This diff is collapsed.
Click to expand it.
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