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
67a557d5
Commit
67a557d5
authored
Feb 11, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update Save/Cancel button state on typing events.
parent
044a8a5c
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
9 deletions
+27
-9
cms/static/js/views/settings/advanced_view.js
+27
-9
No files found.
cms/static/js/views/settings/advanced_view.js
View file @
67a557d5
...
...
@@ -14,8 +14,9 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
'click .cancel-button'
:
"revertView"
,
'click .new-button'
:
"addEntry"
,
// update model on changes
'change #course-advanced-policy-key'
:
"updateKey"
// TODO enable/disable save (add disabled class) based on validation & dirty
'change #course-advanced-policy-key'
:
"updateKey"
,
'keydown #course-advanced-policy-key'
:
"enableSaveCancelButtons"
// TODO enable/disable save based on validation (currently enabled whenever there are changes)
// TODO enable/disable new button?
},
initialize
:
function
()
{
...
...
@@ -56,6 +57,9 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
var
self
=
this
;
CodeMirror
.
fromTextArea
(
textarea
,
{
mode
:
"application/json"
,
lineNumbers
:
false
,
lineWrapping
:
true
,
onChange
:
function
()
{
self
.
enableSaveCancelButtons
();
},
onBlur
:
function
(
mirror
)
{
var
key
=
$
(
mirror
.
getWrapperElement
()).
closest
(
'.row'
).
children
(
'.key'
).
attr
(
'id'
);
var
quotedValue
=
mirror
.
getValue
();
...
...
@@ -69,22 +73,36 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
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'
);
if
(
type
)
{
if
(
type
===
this
.
error_saving
)
{
this
.
$el
.
find
(
".message-status.error"
).
addClass
(
"is-shown"
);
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"
);
}
else
if
(
type
===
this
.
successful_changes
)
else
if
(
type
===
this
.
successful_changes
)
{
this
.
$el
.
find
(
".message-status.confirm"
).
addClass
(
"is-shown"
);
this
.
disableSaveCancelButtons
();
}
}
else
{
// This is the case of the page first rendering.
this
.
disableSaveCancelButtons
();
}
},
enableSaveCancelButtons
:
function
()
{
if
(
!
this
.
buttonsEnabled
)
{
this
.
$el
.
find
(
".save-button"
).
removeClass
(
'disabled'
);
this
.
$el
.
find
(
".cancel-button"
).
show
();
this
.
buttonsEnabled
=
true
;
}
},
disableSaveCancelButtons
:
function
()
{
this
.
$el
.
find
(
".save-button"
).
addClass
(
'disabled'
);
this
.
$el
.
find
(
".cancel-button"
).
hide
();
this
.
buttonsEnabled
=
false
;
},
deleteEntry
:
function
(
event
)
{
...
...
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