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
09e86280
Commit
09e86280
authored
Feb 08, 2013
by
Don Mitchell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add editor to new entries and when key changes
parent
5254af29
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
12 deletions
+18
-12
cms/static/js/views/settings/advanced_view.js
+18
-12
No files found.
cms/static/js/views/settings/advanced_view.js
View file @
09e86280
...
@@ -44,10 +44,12 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -44,10 +44,12 @@ 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
policyValueDivs
=
listEle$
.
find
(
'.ace'
);
var
policyValueDivs
=
listEle$
.
find
(
'.ace'
);
_
.
each
(
policyValueDivs
,
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
function
(
div
)
{
return
this
;
},
attachAce
:
function
(
div
)
{
var
self
=
this
;
var
editor
=
ace
.
edit
(
div
);
var
editor
=
ace
.
edit
(
div
);
editor
.
setTheme
(
"ace/theme/chrome"
);
editor
.
setTheme
(
"ace/theme/chrome"
);
editor
.
setHighlightActiveLine
(
false
);
editor
.
setHighlightActiveLine
(
false
);
...
@@ -63,8 +65,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -63,8 +65,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// Calling getSession() directly in render causes a crash on Chrome.
// Calling getSession() directly in render causes a crash on Chrome.
// Seems to be OK in afterRender method.
// Seems to be OK in afterRender method.
editor
.
getSession
().
setMode
(
"ace/mode/json"
);
editor
.
getSession
().
setMode
(
"ace/mode/json"
);
});
return
this
;
},
},
deleteEntry
:
function
(
event
)
{
deleteEntry
:
function
(
event
)
{
...
@@ -106,10 +106,15 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -106,10 +106,15 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
},
},
addEntry
:
function
()
{
addEntry
:
function
()
{
var
listEle$
=
this
.
$el
.
find
(
'.course-advanced-policy-list'
);
var
listEle$
=
this
.
$el
.
find
(
'.course-advanced-policy-list'
);
listEle$
.
append
(
this
.
template
({
key
:
""
,
value
:
""
}));
var
newEle
=
this
.
template
({
key
:
""
,
value
:
JSON
.
stringify
(
""
)});
listEle$
.
append
(
newEle
);
// disable the value entry until there's an acceptable key
// disable the value entry until there's an acceptable key
listEle$
.
find
(
'.course-advanced-policy-value'
).
addClass
(
'disabled'
);
$
(
newEle
)
.
find
(
'.course-advanced-policy-value'
).
addClass
(
'disabled'
);
this
.
fieldToSelectorMap
[
this
.
new_key
]
=
this
.
new_key
;
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'
);
// only 1 but hey, let's take advantage of the context mechanism
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
},
},
updateKey
:
function
(
event
)
{
updateKey
:
function
(
event
)
{
// old key: either the key as in the model or new_key.
// old key: either the key as in the model or new_key.
...
@@ -160,10 +165,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -160,10 +165,6 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
this
.
model
.
deleteKeys
.
push
(
oldKey
);
this
.
model
.
deleteKeys
.
push
(
oldKey
);
this
.
model
.
unset
(
oldKey
)
;
this
.
model
.
unset
(
oldKey
)
;
}
}
else
{
// enable the value entry
this
.
$el
.
find
(
'.course-advanced-policy-value'
).
removeClass
(
'disabled'
);
}
// check for newkey being the name of one which was previously deleted in this session
// check for newkey being the name of one which was previously deleted in this session
var
wasDeleting
=
this
.
model
.
deleteKeys
.
indexOf
(
newKey
);
var
wasDeleting
=
this
.
model
.
deleteKeys
.
indexOf
(
newKey
);
...
@@ -172,7 +173,12 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -172,7 +173,12 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
}
}
// update gui (sets all the ids etc)
// update gui (sets all the ids etc)
$
(
event
.
currentTarget
).
closest
(
'li'
).
replaceWith
(
this
.
template
({
key
:
newKey
,
value
:
this
.
model
.
get
(
newKey
)
}));
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'
);
// only 1 but hey, let's take advantage of the context mechanism
_
.
each
(
policyValueDivs
,
this
.
attachAce
,
this
);
this
.
fieldToSelectorMap
[
newKey
]
=
newKey
;
this
.
fieldToSelectorMap
[
newKey
]
=
newKey
;
}
}
...
...
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