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
f6d046dd
Commit
f6d046dd
authored
Oct 16, 2012
by
Tom Giannattasio
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added autosaving to field inputs on unit and subsection pages
parent
3a612a4d
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
59 additions
and
2 deletions
+59
-2
cms/static/img/spinner-in-field.gif
+0
-0
cms/static/js/base.js
+50
-2
cms/static/sass/_graphics.scss
+8
-0
cms/static/sass/_unit.scss
+1
-0
No files found.
cms/static/img/spinner-in-field.gif
0 → 100644
View file @
f6d046dd
5.35 KB
cms/static/js/base.js
View file @
f6d046dd
...
...
@@ -4,6 +4,8 @@ var $modalCover;
var
$newComponentItem
;
var
$newComponentStep1
;
var
$newComponentStep2
;
var
$changedInput
;
var
$spinner
;
$
(
document
).
ready
(
function
()
{
$body
=
$
(
'body'
);
...
...
@@ -13,6 +15,7 @@ $(document).ready(function() {
$newComponentTypePicker
=
$
(
'.new-component'
);
$newComponentTemplatePickers
=
$
(
'.new-component-templates'
);
$newComponentButton
=
$
(
'.new-component-button'
);
$spinner
=
$
(
'<span class="spinner-in-field-icon"></span>'
);
$body
.
bind
(
'keyup'
,
onKeyUp
);
$
(
'.expand-collapse-icon'
).
bind
(
'click'
,
toggleSubmodules
);
...
...
@@ -31,6 +34,14 @@ $(document).ready(function() {
$
(
'.new-unit-item'
).
bind
(
'click'
,
createNewUnit
);
$
(
'.save-subsection'
).
bind
(
'click'
,
saveSubsection
);
// autosave when a field is updated on the subsection page
$body
.
on
(
'keyup'
,
'.subsection-display-name-input, .unit-subtitle, .policy-list-name, .policy-list-value'
,
checkForNewValue
);
$
(
'.subsection-display-name-input, .unit-subtitle, .policy-list-name, .policy-list-value'
).
each
(
function
(
i
)
{
this
.
nameString
=
$
(
this
).
val
();
});
$
(
"#start_date, #start_time, #due_date, #due_time"
).
bind
(
'change'
,
autosaveInput
);
$
(
'.sync-date, .remove-date'
).
bind
(
'click'
,
autosaveInput
);
// making the unit list sortable
$
(
'.sortable-unit-list'
).
sortable
({
axis
:
'y'
,
...
...
@@ -207,8 +218,45 @@ function getEdxTimeFromDateTimeInputs(date_id, time_id, format) {
return
getEdxTimeFromDateTimeVals
(
input_date
,
input_time
,
format
);
}
function
checkForNewValue
(
e
)
{
this
.
hasChanged
=
this
.
nameString
!=
$
(
this
).
val
()
&&
this
.
nameString
;
this
.
nameString
=
$
(
this
).
val
();
if
(
this
.
hasChanged
)
{
if
(
this
.
saveTimer
)
{
clearTimeout
(
this
.
saveTimer
);
}
this
.
saveTimer
=
setTimeout
(
function
()
{
$changedInput
=
$
(
e
.
target
);
$
(
'.save-subsection'
).
click
();
this
.
saveTimer
=
null
;
},
500
);
}
}
function
autosaveInput
(
e
)
{
if
(
this
.
saveTimer
)
{
clearTimeout
(
this
.
saveTimer
);
}
this
.
saveTimer
=
setTimeout
(
function
()
{
$changedInput
=
$
(
e
.
target
);
$
(
'.save-subsection'
).
click
();
this
.
saveTimer
=
null
;
},
500
);
}
function
saveSubsection
(
e
)
{
e
.
preventDefault
();
// add an inline spinner
$spinner
.
css
({
'position'
:
'absolute'
,
'top'
:
Math
.
floor
(
$changedInput
.
position
().
top
+
(
$changedInput
.
outerHeight
()
/
2
)
+
3
),
'left'
:
$changedInput
.
position
().
left
+
$changedInput
.
outerWidth
()
-
24
,
'margin-top'
:
'-10px'
});
$changedInput
.
after
(
$spinner
);
var
id
=
$
(
this
).
data
(
'id'
);
...
...
@@ -252,10 +300,10 @@ function saveSubsection(e) {
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
id
,
'metadata'
:
metadata
,
'data'
:
null
,
'children'
:
children
}),
success
:
function
()
{
showToastMessage
(
'Your changes have been saved.'
,
null
,
3
);
$spinner
.
delay
(
500
).
fadeOut
(
150
);
},
error
:
function
()
{
showToastMessage
(
'There has been an error while saving your changes.'
,
null
,
3
);
showToastMessage
(
'There has been an error while saving your changes.'
);
}
});
}
...
...
cms/static/sass/_graphics.scss
View file @
f6d046dd
...
...
@@ -269,3 +269,11 @@
vertical-align
:
middle
;
background
:
url(../img/blue-spinner.gif)
no-repeat
;
}
.spinner-in-field-icon
{
display
:
inline-block
;
width
:
14px
;
height
:
14px
;
vertical-align
:
middle
;
background
:
url(../img/spinner-in-field.gif)
no-repeat
;
}
cms/static/sass/_unit.scss
View file @
f6d046dd
...
...
@@ -323,6 +323,7 @@
.save-button
{
@include
blue-button
;
display
:
none
;
}
.save-button
,
...
...
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