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
9ec33928
Commit
9ec33928
authored
Mar 07, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
New version of Backbone has separate invalid event.
parent
4434ca63
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
10 additions
and
15 deletions
+10
-15
cms/static/js/views/settings/advanced_view.js
+2
-1
cms/static/js/views/settings/main_settings_view.js
+2
-1
cms/static/js/views/settings/settings_grading_view.js
+3
-2
cms/static/js/views/validating_view.js
+3
-11
No files found.
cms/static/js/views/settings/advanced_view.js
View file @
9ec33928
...
@@ -31,7 +31,8 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
...
@@ -31,7 +31,8 @@ CMS.Views.Settings.Advanced = CMS.Views.ValidatingView.extend({
// because these are outside of this.$el, they can't be in the event hash
// because these are outside of this.$el, they can't be in the event hash
$
(
'.save-button'
).
on
(
'click'
,
this
,
this
.
saveView
);
$
(
'.save-button'
).
on
(
'click'
,
this
,
this
.
saveView
);
$
(
'.cancel-button'
).
on
(
'click'
,
this
,
this
.
revertView
);
$
(
'.cancel-button'
).
on
(
'click'
,
this
,
this
.
revertView
);
this
.
model
.
on
(
'error'
,
this
.
handleValidationError
,
this
);
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
},
},
render
:
function
()
{
render
:
function
()
{
// catch potential outside call before template loaded
// catch potential outside call before template loaded
...
...
cms/static/js/views/settings/main_settings_view.js
View file @
9ec33928
...
@@ -26,7 +26,8 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
...
@@ -26,7 +26,8 @@ CMS.Views.Settings.Details = CMS.Views.ValidatingView.extend({
var
dateIntrospect
=
new
Date
();
var
dateIntrospect
=
new
Date
();
this
.
$el
.
find
(
'#timezone'
).
html
(
"("
+
dateIntrospect
.
getTimezone
()
+
")"
);
this
.
$el
.
find
(
'#timezone'
).
html
(
"("
+
dateIntrospect
.
getTimezone
()
+
")"
);
this
.
model
.
on
(
'error'
,
this
.
handleValidationError
,
this
);
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
},
},
...
...
cms/static/js/views/settings/settings_grading_view.js
View file @
9ec33928
...
@@ -44,7 +44,8 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
...
@@ -44,7 +44,8 @@ CMS.Views.Settings.Grading = CMS.Views.ValidatingView.extend({
self
.
render
();
self
.
render
();
}
}
);
);
this
.
model
.
on
(
'error'
,
this
.
handleValidationError
,
this
);
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
model
.
get
(
'graders'
).
on
(
'remove'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'remove'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'reset'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'reset'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'add'
,
this
.
render
,
this
);
this
.
model
.
get
(
'graders'
).
on
(
'add'
,
this
.
render
,
this
);
...
@@ -316,7 +317,7 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
...
@@ -316,7 +317,7 @@ CMS.Views.Settings.GraderView = CMS.Views.ValidatingView.extend({
'blur :input'
:
"inputUnfocus"
'blur :input'
:
"inputUnfocus"
},
},
initialize
:
function
()
{
initialize
:
function
()
{
this
.
model
.
on
(
'error'
,
this
.
handleValidationError
,
this
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
render
();
this
.
render
();
},
},
...
...
cms/static/js/views/validating_view.js
View file @
9ec33928
...
@@ -3,7 +3,8 @@ CMS.Views.ValidatingView = Backbone.View.extend({
...
@@ -3,7 +3,8 @@ CMS.Views.ValidatingView = Backbone.View.extend({
// decorates the fields. Needs wiring per class, but this initialization shows how
// decorates the fields. Needs wiring per class, but this initialization shows how
// either have your init call this one or copy the contents
// either have your init call this one or copy the contents
initialize
:
function
()
{
initialize
:
function
()
{
this
.
model
.
on
(
'error'
,
this
.
handleValidationError
,
this
);
this
.
listenTo
(
this
.
model
,
'error'
,
CMS
.
ServerError
);
this
.
listenTo
(
this
.
model
,
'invalid'
,
this
.
handleValidationError
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
this
.
selectorToField
=
_
.
invert
(
this
.
fieldToSelectorMap
);
},
},
...
@@ -18,20 +19,11 @@ CMS.Views.ValidatingView = Backbone.View.extend({
...
@@ -18,20 +19,11 @@ CMS.Views.ValidatingView = Backbone.View.extend({
// which may be the subjects of validation errors
// which may be the subjects of validation errors
},
},
_cacheValidationErrors
:
[],
_cacheValidationErrors
:
[],
handleValidationError
:
function
(
model
,
error
)
{
handleValidationError
:
function
(
model
,
error
)
{
// error triggered either by validation or server error
// error is object w/ fields and error strings
// error is object w/ fields and error strings
for
(
var
field
in
error
)
{
for
(
var
field
in
error
)
{
var
ele
=
this
.
$el
.
find
(
'#'
+
this
.
fieldToSelectorMap
[
field
]);
var
ele
=
this
.
$el
.
find
(
'#'
+
this
.
fieldToSelectorMap
[
field
]);
if
(
ele
.
length
===
0
)
{
// check if it might a server error: note a typo in the field name
// or failure to put in a map may cause this to muffle validation errors
if
(
_
.
has
(
error
,
'error'
)
&&
_
.
has
(
error
,
'responseText'
))
{
CMS
.
ServerError
(
model
,
error
);
return
;
}
else
continue
;
}
this
.
_cacheValidationErrors
.
push
(
ele
);
this
.
_cacheValidationErrors
.
push
(
ele
);
if
(
$
(
ele
).
is
(
'div'
))
{
if
(
$
(
ele
).
is
(
'div'
))
{
// put error on the contained inputs
// put error on the contained inputs
...
...
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