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
5acf9cb3
Commit
5acf9cb3
authored
Feb 15, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Reformat to 4 spaces.
parent
2486ebc2
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
68 deletions
+68
-68
cms/static/js/base.js
+68
-68
No files found.
cms/static/js/base.js
View file @
5acf9cb3
...
@@ -5,7 +5,7 @@ var $newComponentItem;
...
@@ -5,7 +5,7 @@ var $newComponentItem;
var
$changedInput
;
var
$changedInput
;
var
$spinner
;
var
$spinner
;
$
(
document
).
ready
(
function
()
{
$
(
document
).
ready
(
function
()
{
$body
=
$
(
'body'
);
$body
=
$
(
'body'
);
$modal
=
$
(
'.history-modal'
);
$modal
=
$
(
'.history-modal'
);
$modalCover
=
$
(
'<div class="modal-cover">'
);
$modalCover
=
$
(
'<div class="modal-cover">'
);
...
@@ -34,7 +34,9 @@ $(document).ready(function() {
...
@@ -34,7 +34,9 @@ $(document).ready(function() {
$
(
'.uploads .upload-button'
).
bind
(
'click'
,
showUploadModal
);
$
(
'.uploads .upload-button'
).
bind
(
'click'
,
showUploadModal
);
$
(
'.upload-modal .close-button'
).
bind
(
'click'
,
hideModal
);
$
(
'.upload-modal .close-button'
).
bind
(
'click'
,
hideModal
);
$body
.
on
(
'click'
,
'.embeddable-xml-input'
,
function
(){
$
(
this
).
select
();
});
$body
.
on
(
'click'
,
'.embeddable-xml-input'
,
function
()
{
$
(
this
).
select
();
});
$
(
'.unit .item-actions .delete-button'
).
bind
(
'click'
,
deleteUnit
);
$
(
'.unit .item-actions .delete-button'
).
bind
(
'click'
,
deleteUnit
);
$
(
'.new-unit-item'
).
bind
(
'click'
,
createNewUnit
);
$
(
'.new-unit-item'
).
bind
(
'click'
,
createNewUnit
);
...
@@ -42,12 +44,12 @@ $(document).ready(function() {
...
@@ -42,12 +44,12 @@ $(document).ready(function() {
$
(
'body'
).
addClass
(
'js'
);
$
(
'body'
).
addClass
(
'js'
);
// nav - dropdown related
// nav - dropdown related
$body
.
click
(
function
(
e
)
{
$body
.
click
(
function
(
e
)
{
$
(
'.nav-dropdown .nav-item .wrapper-nav-sub'
).
removeClass
(
'is-shown'
);
$
(
'.nav-dropdown .nav-item .wrapper-nav-sub'
).
removeClass
(
'is-shown'
);
$
(
'.nav-dropdown .nav-item .title'
).
removeClass
(
'is-selected'
);
$
(
'.nav-dropdown .nav-item .title'
).
removeClass
(
'is-selected'
);
});
});
$
(
'.nav-dropdown .nav-item .title'
).
click
(
function
(
e
)
{
$
(
'.nav-dropdown .nav-item .title'
).
click
(
function
(
e
)
{
$subnav
=
$
(
this
).
parent
().
find
(
'.wrapper-nav-sub'
);
$subnav
=
$
(
this
).
parent
().
find
(
'.wrapper-nav-sub'
);
$title
=
$
(
this
).
parent
().
find
(
'.title'
);
$title
=
$
(
this
).
parent
().
find
(
'.title'
);
...
@@ -68,20 +70,20 @@ $(document).ready(function() {
...
@@ -68,20 +70,20 @@ $(document).ready(function() {
});
});
// general link management - new window/tab
// general link management - new window/tab
$
(
'a[rel="external"]'
).
attr
(
'title'
,
'This link will open in a new browser window/tab'
).
click
(
function
(
e
)
{
$
(
'a[rel="external"]'
).
attr
(
'title'
,
'This link will open in a new browser window/tab'
).
click
(
function
(
e
)
{
window
.
open
(
$
(
this
).
attr
(
'href'
));
window
.
open
(
$
(
this
).
attr
(
'href'
));
e
.
preventDefault
();
e
.
preventDefault
();
});
});
// general link management - lean modal window
// general link management - lean modal window
$
(
'a[rel="modal"]'
).
attr
(
'title'
,
'This link will open in a modal window'
).
leanModal
({
overlay
:
0.50
,
closeButton
:
'.action-modal-close'
});
$
(
'a[rel="modal"]'
).
attr
(
'title'
,
'This link will open in a modal window'
).
leanModal
({
overlay
:
0.50
,
closeButton
:
'.action-modal-close'
});
$
(
'.action-modal-close'
).
click
(
function
(
e
)
{
$
(
'.action-modal-close'
).
click
(
function
(
e
)
{
(
e
).
preventDefault
();
(
e
).
preventDefault
();
});
});
// toggling overview section details
// toggling overview section details
$
(
function
()
{
$
(
function
()
{
if
(
$
(
'.courseware-section'
).
length
>
0
)
{
if
(
$
(
'.courseware-section'
).
length
>
0
)
{
$
(
'.toggle-button-sections'
).
addClass
(
'is-shown'
);
$
(
'.toggle-button-sections'
).
addClass
(
'is-shown'
);
}
}
});
});
...
@@ -89,7 +91,7 @@ $(document).ready(function() {
...
@@ -89,7 +91,7 @@ $(document).ready(function() {
// autosave when a field is updated on the subsection page
// autosave when a field is updated on the subsection page
$body
.
on
(
'keyup'
,
'.subsection-display-name-input, .unit-subtitle, .policy-list-value'
,
checkForNewValue
);
$body
.
on
(
'keyup'
,
'.subsection-display-name-input, .unit-subtitle, .policy-list-value'
,
checkForNewValue
);
$
(
'.subsection-display-name-input, .unit-subtitle, .policy-list-name, .policy-list-value'
).
each
(
function
(
i
)
{
$
(
'.subsection-display-name-input, .unit-subtitle, .policy-list-name, .policy-list-value'
).
each
(
function
(
i
)
{
this
.
val
=
$
(
this
).
val
();
this
.
val
=
$
(
this
).
val
();
});
});
$
(
"#start_date, #start_time, #due_date, #due_time"
).
bind
(
'change'
,
autosaveInput
);
$
(
"#start_date, #start_time, #due_date, #due_time"
).
bind
(
'change'
,
autosaveInput
);
...
@@ -115,7 +117,7 @@ $(document).ready(function() {
...
@@ -115,7 +117,7 @@ $(document).ready(function() {
// import form setup
// import form setup
$
(
'.import .file-input'
).
bind
(
'change'
,
showImportSubmit
);
$
(
'.import .file-input'
).
bind
(
'change'
,
showImportSubmit
);
$
(
'.import .choose-file-button, .import .choose-file-button-inline'
).
bind
(
'click'
,
function
(
e
)
{
$
(
'.import .choose-file-button, .import .choose-file-button-inline'
).
bind
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
$
(
'.import .file-input'
).
click
();
$
(
'.import .file-input'
).
click
();
});
});
...
@@ -138,12 +140,12 @@ $(document).ready(function() {
...
@@ -138,12 +140,12 @@ $(document).ready(function() {
$body
.
on
(
'click'
,
'.section-published-date .schedule-button'
,
editSectionPublishDate
);
$body
.
on
(
'click'
,
'.section-published-date .schedule-button'
,
editSectionPublishDate
);
$body
.
on
(
'click'
,
'.edit-subsection-publish-settings .save-button'
,
saveSetSectionScheduleDate
);
$body
.
on
(
'click'
,
'.edit-subsection-publish-settings .save-button'
,
saveSetSectionScheduleDate
);
$body
.
on
(
'click'
,
'.edit-subsection-publish-settings .cancel-button'
,
hideModal
);
$body
.
on
(
'click'
,
'.edit-subsection-publish-settings .cancel-button'
,
hideModal
);
$body
.
on
(
'change'
,
'.edit-subsection-publish-settings .start-date'
,
function
()
{
$body
.
on
(
'change'
,
'.edit-subsection-publish-settings .start-date'
,
function
()
{
if
(
$
(
'.edit-subsection-publish-settings'
).
find
(
'.start-time'
).
val
()
==
''
)
{
if
(
$
(
'.edit-subsection-publish-settings'
).
find
(
'.start-time'
).
val
()
==
''
)
{
$
(
'.edit-subsection-publish-settings'
).
find
(
'.start-time'
).
val
(
'12:00am'
);
$
(
'.edit-subsection-publish-settings'
).
find
(
'.start-time'
).
val
(
'12:00am'
);
}
}
});
});
$
(
'.edit-subsection-publish-settings'
).
on
(
'change'
,
'.start-date, .start-time'
,
function
()
{
$
(
'.edit-subsection-publish-settings'
).
on
(
'change'
,
'.start-date, .start-time'
,
function
()
{
$
(
'.edit-subsection-publish-settings'
).
find
(
'.save-button'
).
show
();
$
(
'.edit-subsection-publish-settings'
).
find
(
'.save-button'
).
show
();
});
});
});
});
...
@@ -165,7 +167,7 @@ function toggleSections(e) {
...
@@ -165,7 +167,7 @@ function toggleSections(e) {
var
buttonLabel
=
$button
.
hasClass
(
'is-activated'
)
?
$labelCollapsed
:
$labelExpanded
;
var
buttonLabel
=
$button
.
hasClass
(
'is-activated'
)
?
$labelCollapsed
:
$labelExpanded
;
$button
.
toggleClass
(
'is-activated'
).
html
(
buttonLabel
);
$button
.
toggleClass
(
'is-activated'
).
html
(
buttonLabel
);
if
(
$button
.
hasClass
(
'is-activated'
))
{
if
(
$button
.
hasClass
(
'is-activated'
))
{
$section
.
addClass
(
'collapsed'
);
$section
.
addClass
(
'collapsed'
);
// first child in order to avoid the icons on the subsection lists which are not in the first child
// first child in order to avoid the icons on the subsection lists which are not in the first child
$section
.
find
(
'header .expand-collapse-icon'
).
removeClass
(
'collapse'
).
addClass
(
'expand'
);
$section
.
find
(
'header .expand-collapse-icon'
).
removeClass
(
'collapse'
).
addClass
(
'expand'
);
...
@@ -183,7 +185,7 @@ function editSectionPublishDate(e) {
...
@@ -183,7 +185,7 @@ function editSectionPublishDate(e) {
$modal
.
attr
(
'data-id'
,
$
(
this
).
attr
(
'data-id'
));
$modal
.
attr
(
'data-id'
,
$
(
this
).
attr
(
'data-id'
));
$modal
.
find
(
'.start-date'
).
val
(
$
(
this
).
attr
(
'data-date'
));
$modal
.
find
(
'.start-date'
).
val
(
$
(
this
).
attr
(
'data-date'
));
$modal
.
find
(
'.start-time'
).
val
(
$
(
this
).
attr
(
'data-time'
));
$modal
.
find
(
'.start-time'
).
val
(
$
(
this
).
attr
(
'data-time'
));
if
(
$modal
.
find
(
'.start-date'
).
val
()
==
''
&&
$modal
.
find
(
'.start-time'
).
val
()
==
''
)
{
if
(
$modal
.
find
(
'.start-date'
).
val
()
==
''
&&
$modal
.
find
(
'.start-time'
).
val
()
==
''
)
{
$modal
.
find
(
'.save-button'
).
hide
();
$modal
.
find
(
'.save-button'
).
hide
();
}
}
$modal
.
find
(
'.section-name'
).
html
(
'"'
+
$
(
this
).
closest
(
'.courseware-section'
).
find
(
'.section-name-span'
).
text
()
+
'"'
);
$modal
.
find
(
'.section-name'
).
html
(
'"'
+
$
(
this
).
closest
(
'.courseware-section'
).
find
(
'.section-name-span'
).
text
()
+
'"'
);
...
@@ -192,7 +194,7 @@ function editSectionPublishDate(e) {
...
@@ -192,7 +194,7 @@ function editSectionPublishDate(e) {
function
showImportSubmit
(
e
)
{
function
showImportSubmit
(
e
)
{
var
filepath
=
$
(
this
).
val
();
var
filepath
=
$
(
this
).
val
();
if
(
filepath
.
substr
(
filepath
.
length
-
6
,
6
)
==
'tar.gz'
)
{
if
(
filepath
.
substr
(
filepath
.
length
-
6
,
6
)
==
'tar.gz'
)
{
$
(
'.error-block'
).
hide
();
$
(
'.error-block'
).
hide
();
$
(
'.file-name'
).
html
(
$
(
this
).
val
().
replace
(
'C:
\\
fakepath
\
\'
, ''));
$
(
'.file-name'
).
html
(
$
(
this
).
val
().
replace
(
'C:
\\
fakepath
\
\'
, ''));
$('
.
file
-
name
-
block
').show();
$('
.
file
-
name
-
block
').show();
...
@@ -213,7 +215,7 @@ function syncReleaseDate(e) {
...
@@ -213,7 +215,7 @@ function syncReleaseDate(e) {
function
addPolicyMetadata
(
e
)
{
function
addPolicyMetadata
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
var
template
=
$
(
'#add-new-policy-element-template > li'
);
var
template
=
$
(
'#add-new-policy-element-template > li'
);
var
newNode
=
template
.
clone
();
var
newNode
=
template
.
clone
();
var
_parent_el
=
$
(
this
).
parent
(
'ol:.policy-list'
);
var
_parent_el
=
$
(
this
).
parent
(
'ol:.policy-list'
);
newNode
.
insertBefore
(
'.add-policy-data'
);
newNode
.
insertBefore
(
'.add-policy-data'
);
...
@@ -235,7 +237,7 @@ function cancelPolicyMetadata(e) {
...
@@ -235,7 +237,7 @@ function cancelPolicyMetadata(e) {
e
.
preventDefault
();
e
.
preventDefault
();
var
$policyElement
=
$
(
this
).
parents
(
'.policy-list-element'
);
var
$policyElement
=
$
(
this
).
parents
(
'.policy-list-element'
);
if
(
!
$policyElement
.
hasClass
(
'editing'
))
{
if
(
!
$policyElement
.
hasClass
(
'editing'
))
{
$policyElement
.
remove
();
$policyElement
.
remove
();
}
else
{
}
else
{
$policyElement
.
removeClass
(
'new-policy-list-element'
);
$policyElement
.
removeClass
(
'new-policy-list-element'
);
...
@@ -248,7 +250,7 @@ function cancelPolicyMetadata(e) {
...
@@ -248,7 +250,7 @@ function cancelPolicyMetadata(e) {
function
removePolicyMetadata
(
e
)
{
function
removePolicyMetadata
(
e
)
{
e
.
preventDefault
();
e
.
preventDefault
();
if
(
!
confirm
(
'Are you sure you wish to delete this item. It cannot be reversed!'
))
if
(
!
confirm
(
'Are you sure you wish to delete this item. It cannot be reversed!'
))
return
;
return
;
policy_name
=
$
(
this
).
data
(
'policy-name'
);
policy_name
=
$
(
this
).
data
(
'policy-name'
);
...
@@ -280,30 +282,30 @@ function getEdxTimeFromDateTimeVals(date_val, time_val, format) {
...
@@ -280,30 +282,30 @@ function getEdxTimeFromDateTimeVals(date_val, time_val, format) {
}
}
function
getEdxTimeFromDateTimeInputs
(
date_id
,
time_id
,
format
)
{
function
getEdxTimeFromDateTimeInputs
(
date_id
,
time_id
,
format
)
{
var
input_date
=
$
(
'#'
+
date_id
).
val
();
var
input_date
=
$
(
'#'
+
date_id
).
val
();
var
input_time
=
$
(
'#'
+
time_id
).
val
();
var
input_time
=
$
(
'#'
+
time_id
).
val
();
return
getEdxTimeFromDateTimeVals
(
input_date
,
input_time
,
format
);
return
getEdxTimeFromDateTimeVals
(
input_date
,
input_time
,
format
);
}
}
function
checkForNewValue
(
e
)
{
function
checkForNewValue
(
e
)
{
if
(
$
(
this
).
parents
(
'.new-policy-list-element'
)[
0
])
{
if
(
$
(
this
).
parents
(
'.new-policy-list-element'
)[
0
])
{
return
;
return
;
}
}
if
(
this
.
val
)
{
if
(
this
.
val
)
{
this
.
hasChanged
=
this
.
val
!=
$
(
this
).
val
();
this
.
hasChanged
=
this
.
val
!=
$
(
this
).
val
();
}
else
{
}
else
{
this
.
hasChanged
=
false
;
this
.
hasChanged
=
false
;
}
}
this
.
val
=
$
(
this
).
val
();
this
.
val
=
$
(
this
).
val
();
if
(
this
.
hasChanged
)
{
if
(
this
.
hasChanged
)
{
if
(
this
.
saveTimer
)
{
if
(
this
.
saveTimer
)
{
clearTimeout
(
this
.
saveTimer
);
clearTimeout
(
this
.
saveTimer
);
}
}
this
.
saveTimer
=
setTimeout
(
function
()
{
this
.
saveTimer
=
setTimeout
(
function
()
{
$changedInput
=
$
(
e
.
target
);
$changedInput
=
$
(
e
.
target
);
saveSubsection
();
saveSubsection
();
this
.
saveTimer
=
null
;
this
.
saveTimer
=
null
;
...
@@ -312,11 +314,11 @@ function checkForNewValue(e) {
...
@@ -312,11 +314,11 @@ function checkForNewValue(e) {
}
}
function
autosaveInput
(
e
)
{
function
autosaveInput
(
e
)
{
if
(
this
.
saveTimer
)
{
if
(
this
.
saveTimer
)
{
clearTimeout
(
this
.
saveTimer
);
clearTimeout
(
this
.
saveTimer
);
}
}
this
.
saveTimer
=
setTimeout
(
function
()
{
this
.
saveTimer
=
setTimeout
(
function
()
{
$changedInput
=
$
(
e
.
target
);
$changedInput
=
$
(
e
.
target
);
saveSubsection
();
saveSubsection
();
this
.
saveTimer
=
null
;
this
.
saveTimer
=
null
;
...
@@ -324,7 +326,7 @@ function autosaveInput(e) {
...
@@ -324,7 +326,7 @@ function autosaveInput(e) {
}
}
function
saveSubsection
()
{
function
saveSubsection
()
{
if
(
$changedInput
&&
!
$changedInput
.
hasClass
(
'no-spinner'
))
{
if
(
$changedInput
&&
!
$changedInput
.
hasClass
(
'no-spinner'
))
{
$spinner
.
css
({
$spinner
.
css
({
'position'
:
'absolute'
,
'position'
:
'absolute'
,
'top'
:
Math
.
floor
(
$changedInput
.
position
().
top
+
(
$changedInput
.
outerHeight
()
/
2
)
+
3
),
'top'
:
Math
.
floor
(
$changedInput
.
position
().
top
+
(
$changedInput
.
outerHeight
()
/
2
)
+
3
),
...
@@ -341,20 +343,20 @@ function saveSubsection() {
...
@@ -341,20 +343,20 @@ function saveSubsection() {
var
metadata_fields
=
$
(
'input[data-metadata-name]'
);
var
metadata_fields
=
$
(
'input[data-metadata-name]'
);
var
metadata
=
{};
var
metadata
=
{};
for
(
var
i
=
0
;
i
<
metadata_fields
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
metadata_fields
.
length
;
i
++
)
{
var
el
=
metadata_fields
[
i
];
var
el
=
metadata_fields
[
i
];
metadata
[
$
(
el
).
data
(
"metadata-name"
)]
=
el
.
value
;
metadata
[
$
(
el
).
data
(
"metadata-name"
)]
=
el
.
value
;
}
}
// now add 'free-formed' metadata which are presented to the user as dual input fields (name/value)
// now add 'free-formed' metadata which are presented to the user as dual input fields (name/value)
$
(
'ol.policy-list > li.policy-list-element'
).
each
(
function
(
i
,
element
)
{
$
(
'ol.policy-list > li.policy-list-element'
).
each
(
function
(
i
,
element
)
{
var
name
=
$
(
element
).
children
(
'.policy-list-name'
).
val
();
var
name
=
$
(
element
).
children
(
'.policy-list-name'
).
val
();
metadata
[
name
]
=
$
(
element
).
children
(
'.policy-list-value'
).
val
();
metadata
[
name
]
=
$
(
element
).
children
(
'.policy-list-value'
).
val
();
});
});
// now add any 'removed' policy metadata which is stored in a separate hidden div
// now add any 'removed' policy metadata which is stored in a separate hidden div
// 'null' presented to the server means 'remove'
// 'null' presented to the server means 'remove'
$
(
"#policy-to-delete > li.policy-list-element"
).
each
(
function
(
i
,
element
)
{
$
(
"#policy-to-delete > li.policy-list-element"
).
each
(
function
(
i
,
element
)
{
var
name
=
$
(
element
).
children
(
'.policy-list-name'
).
val
();
var
name
=
$
(
element
).
children
(
'.policy-list-name'
).
val
();
if
(
name
!=
""
)
if
(
name
!=
""
)
metadata
[
name
]
=
null
;
metadata
[
name
]
=
null
;
...
@@ -371,11 +373,11 @@ function saveSubsection() {
...
@@ -371,11 +373,11 @@ function saveSubsection() {
type
:
"POST"
,
type
:
"POST"
,
dataType
:
"json"
,
dataType
:
"json"
,
contentType
:
"application/json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
id
,
'metadata'
:
metadata
}),
data
:
JSON
.
stringify
({
'id'
:
id
,
'metadata'
:
metadata
}),
success
:
function
()
{
success
:
function
()
{
$spinner
.
delay
(
500
).
fadeOut
(
150
);
$spinner
.
delay
(
500
).
fadeOut
(
150
);
},
},
error
:
function
()
{
error
:
function
()
{
showToastMessage
(
'There has been an error while saving your changes.'
);
showToastMessage
(
'There has been an error while saving your changes.'
);
}
}
});
});
...
@@ -389,11 +391,11 @@ function createNewUnit(e) {
...
@@ -389,11 +391,11 @@ function createNewUnit(e) {
template
=
$
(
this
).
data
(
'template'
);
template
=
$
(
this
).
data
(
'template'
);
$
.
post
(
'/clone_item'
,
$
.
post
(
'/clone_item'
,
{
'parent_location'
:
parent
,
{
'parent_location'
:
parent
,
'template'
:
template
,
'template'
:
template
,
'display_name'
:
'New Unit'
'display_name'
:
'New Unit'
},
},
function
(
data
)
{
function
(
data
)
{
// redirect to the edit page
// redirect to the edit page
window
.
location
=
"/edit/"
+
data
[
'id'
];
window
.
location
=
"/edit/"
+
data
[
'id'
];
});
});
...
@@ -415,14 +417,14 @@ function deleteSection(e) {
...
@@ -415,14 +417,14 @@ function deleteSection(e) {
}
}
function
_deleteItem
(
$el
)
{
function
_deleteItem
(
$el
)
{
if
(
!
confirm
(
'Are you sure you wish to delete this item. It cannot be reversed!'
))
if
(
!
confirm
(
'Are you sure you wish to delete this item. It cannot be reversed!'
))
return
;
return
;
var
id
=
$el
.
data
(
'id'
);
var
id
=
$el
.
data
(
'id'
);
$
.
post
(
'/delete_item'
,
$
.
post
(
'/delete_item'
,
{
'id'
:
id
,
'delete_children'
:
true
,
'delete_all_versions'
:
true
},
{
'id'
:
id
,
'delete_children'
:
true
,
'delete_all_versions'
:
true
},
function
(
data
)
{
function
(
data
)
{
$el
.
remove
();
$el
.
remove
();
});
});
}
}
...
@@ -451,7 +453,7 @@ function startUpload(e) {
...
@@ -451,7 +453,7 @@ function startUpload(e) {
$('
.
upload
-
modal
.
progress
-
bar
').removeClass('
loaded
').show();
$('
.
upload
-
modal
.
progress
-
bar
').removeClass('
loaded
').show();
}
}
function resetUploadBar(){
function resetUploadBar()
{
var percentVal = '
0
%
';
var percentVal = '
0
%
';
$('
.
upload
-
modal
.
progress
-
fill
').width(percentVal);
$('
.
upload
-
modal
.
progress
-
fill
').width(percentVal);
$('
.
upload
-
modal
.
progress
-
fill
').html(percentVal);
$('
.
upload
-
modal
.
progress
-
fill
').html(percentVal);
...
@@ -464,7 +466,7 @@ function showUploadFeedback(event, position, total, percentComplete) {
...
@@ -464,7 +466,7 @@ function showUploadFeedback(event, position, total, percentComplete) {
}
}
function displayFinishedUpload(xhr) {
function displayFinishedUpload(xhr) {
if(xhr.status = 200)
{
if (xhr.status = 200)
{
markAsLoaded();
markAsLoaded();
}
}
...
@@ -491,7 +493,7 @@ function markAsLoaded() {
...
@@ -491,7 +493,7 @@ function markAsLoaded() {
}
}
function hideModal(e) {
function hideModal(e) {
if
(e) {
if
(e) {
e.preventDefault();
e.preventDefault();
}
}
// Unit editors do not want the modal cover to hide when users click outside
// Unit editors do not want the modal cover to hide when users click outside
...
@@ -505,7 +507,7 @@ function hideModal(e) {
...
@@ -505,7 +507,7 @@ function hideModal(e) {
}
}
function onKeyUp(e) {
function onKeyUp(e) {
if
(e.which == 87) {
if
(e.which == 87) {
$body.toggleClass('
show
-
wip
hide
-
wip
');
$body.toggleClass('
show
-
wip
hide
-
wip
');
}
}
}
}
...
@@ -555,14 +557,14 @@ function showToastMessage(message, $button, lifespan) {
...
@@ -555,14 +557,14 @@ function showToastMessage(message, $button, lifespan) {
var
$content
=
$
(
'<div class="notification-content"></div>'
);
var
$content
=
$
(
'<div class="notification-content"></div>'
);
$content
.
html
(
message
);
$content
.
html
(
message
);
$toast
.
append
(
$content
);
$toast
.
append
(
$content
);
if
(
$button
)
{
if
(
$button
)
{
$button
.
addClass
(
'action-button'
);
$button
.
addClass
(
'action-button'
);
$button
.
bind
(
'click'
,
hideToastMessage
);
$button
.
bind
(
'click'
,
hideToastMessage
);
$content
.
append
(
$button
);
$content
.
append
(
$button
);
}
}
$closeBtn
.
bind
(
'click'
,
hideToastMessage
);
$closeBtn
.
bind
(
'click'
,
hideToastMessage
);
if
(
$
(
'.toast-notification'
)[
0
])
{
if
(
$
(
'.toast-notification'
)[
0
])
{
var
targetY
=
$
(
'.toast-notification'
).
offset
().
top
+
$
(
'.toast-notification'
).
outerHeight
();
var
targetY
=
$
(
'.toast-notification'
).
offset
().
top
+
$
(
'.toast-notification'
).
outerHeight
();
$toast
.
css
(
'top'
,
(
targetY
+
10
)
+
'px'
);
$toast
.
css
(
'top'
,
(
targetY
+
10
)
+
'px'
);
}
}
...
@@ -570,8 +572,8 @@ function showToastMessage(message, $button, lifespan) {
...
@@ -570,8 +572,8 @@ function showToastMessage(message, $button, lifespan) {
$body
.
prepend
(
$toast
);
$body
.
prepend
(
$toast
);
$toast
.
fadeIn
(
200
);
$toast
.
fadeIn
(
200
);
if
(
lifespan
)
{
if
(
lifespan
)
{
$toast
.
timer
=
setTimeout
(
function
()
{
$toast
.
timer
=
setTimeout
(
function
()
{
$toast
.
fadeOut
(
300
);
$toast
.
fadeOut
(
300
);
},
lifespan
*
1000
);
},
lifespan
*
1000
);
}
}
...
@@ -597,7 +599,7 @@ function addNewSection(e, isTemplate) {
...
@@ -597,7 +599,7 @@ function addNewSection(e, isTemplate) {
}
}
function
checkForCancel
(
e
)
{
function
checkForCancel
(
e
)
{
if
(
e
.
which
==
27
)
{
if
(
e
.
which
==
27
)
{
$body
.
unbind
(
'keyup'
,
checkForCancel
);
$body
.
unbind
(
'keyup'
,
checkForCancel
);
e
.
data
.
$cancelButton
.
click
();
e
.
data
.
$cancelButton
.
click
();
}
}
...
@@ -613,11 +615,11 @@ function saveNewSection(e) {
...
@@ -613,11 +615,11 @@ function saveNewSection(e) {
var
display_name
=
$
(
this
).
find
(
'.new-section-name'
).
val
();
var
display_name
=
$
(
this
).
find
(
'.new-section-name'
).
val
();
$
.
post
(
'/clone_item'
,
{
$
.
post
(
'/clone_item'
,
{
'parent_location'
:
parent
,
'parent_location'
:
parent
,
'template'
:
template
,
'template'
:
template
,
'display_name'
:
display_name
,
'display_name'
:
display_name
,
},
},
function
(
data
)
{
function
(
data
)
{
if
(
data
.
id
!=
undefined
)
if
(
data
.
id
!=
undefined
)
location
.
reload
();
location
.
reload
();
}
}
...
@@ -652,18 +654,18 @@ function saveNewCourse(e) {
...
@@ -652,18 +654,18 @@ function saveNewCourse(e) {
var
number
=
$newCourse
.
find
(
'.new-course-number'
).
val
();
var
number
=
$newCourse
.
find
(
'.new-course-number'
).
val
();
var
display_name
=
$newCourse
.
find
(
'.new-course-name'
).
val
();
var
display_name
=
$newCourse
.
find
(
'.new-course-name'
).
val
();
if
(
org
==
''
||
number
==
''
||
display_name
==
''
)
{
if
(
org
==
''
||
number
==
''
||
display_name
==
''
)
{
alert
(
'You must specify all fields in order to create a new course.'
);
alert
(
'You must specify all fields in order to create a new course.'
);
return
;
return
;
}
}
$
.
post
(
'/create_new_course'
,
{
$
.
post
(
'/create_new_course'
,
{
'template'
:
template
,
'template'
:
template
,
'org'
:
org
,
'org'
:
org
,
'number'
:
number
,
'number'
:
number
,
'display_name'
:
display_name
'display_name'
:
display_name
},
},
function
(
data
)
{
function
(
data
)
{
if
(
data
.
id
!=
undefined
)
{
if
(
data
.
id
!=
undefined
)
{
window
.
location
=
'/'
+
data
.
id
.
replace
(
/.*:
\/\/
/
,
''
);
window
.
location
=
'/'
+
data
.
id
.
replace
(
/.*:
\/\/
/
,
''
);
}
else
if
(
data
.
ErrMsg
!=
undefined
)
{
}
else
if
(
data
.
ErrMsg
!=
undefined
)
{
...
@@ -707,11 +709,11 @@ function saveNewSubsection(e) {
...
@@ -707,11 +709,11 @@ function saveNewSubsection(e) {
var
display_name
=
$
(
this
).
find
(
'.new-subsection-name-input'
).
val
();
var
display_name
=
$
(
this
).
find
(
'.new-subsection-name-input'
).
val
();
$
.
post
(
'/clone_item'
,
{
$
.
post
(
'/clone_item'
,
{
'parent_location'
:
parent
,
'parent_location'
:
parent
,
'template'
:
template
,
'template'
:
template
,
'display_name'
:
display_name
'display_name'
:
display_name
},
},
function
(
data
)
{
function
(
data
)
{
if
(
data
.
id
!=
undefined
)
{
if
(
data
.
id
!=
undefined
)
{
location
.
reload
();
location
.
reload
();
}
}
...
@@ -766,9 +768,8 @@ function saveEditSectionName(e) {
...
@@ -766,9 +768,8 @@ function saveEditSectionName(e) {
type
:
"POST"
,
type
:
"POST"
,
dataType
:
"json"
,
dataType
:
"json"
,
contentType
:
"application/json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
id
,
'metadata'
:
{
'display_name'
:
display_name
}})
data
:
JSON
.
stringify
({
'id'
:
id
,
'metadata'
:
{
'display_name'
:
display_name
}})
}).
success
(
function
()
}).
success
(
function
()
{
{
$spinner
.
delay
(
250
).
fadeOut
(
250
);
$spinner
.
delay
(
250
).
fadeOut
(
250
);
$_this
.
closest
(
'h3'
).
find
(
'.section-name-span'
).
html
(
display_name
).
show
();
$_this
.
closest
(
'h3'
).
find
(
'.section-name-span'
).
html
(
display_name
).
show
();
$_this
.
hide
();
$_this
.
hide
();
...
@@ -805,9 +806,8 @@ function saveSetSectionScheduleDate(e) {
...
@@ -805,9 +806,8 @@ function saveSetSectionScheduleDate(e) {
type
:
"POST"
,
type
:
"POST"
,
dataType
:
"json"
,
dataType
:
"json"
,
contentType
:
"application/json"
,
contentType
:
"application/json"
,
data
:
JSON
.
stringify
({
'id'
:
id
,
'metadata'
:
{
'start'
:
start
}})
data
:
JSON
.
stringify
({
'id'
:
id
,
'metadata'
:
{
'start'
:
start
}})
}).
success
(
function
()
}).
success
(
function
()
{
{
var
$thisSection
=
$
(
'.courseware-section[data-id="'
+
id
+
'"]'
);
var
$thisSection
=
$
(
'.courseware-section[data-id="'
+
id
+
'"]'
);
$thisSection
.
find
(
'.section-published-date'
).
html
(
'<span class="published-status"><strong>Will Release:</strong> '
+
input_date
+
' at '
+
input_time
+
'</span><a href="#" class="edit-button" data-date="'
+
input_date
+
'" data-time="'
+
input_time
+
'" data-id="'
+
id
+
'">Edit</a>'
);
$thisSection
.
find
(
'.section-published-date'
).
html
(
'<span class="published-status"><strong>Will Release:</strong> '
+
input_date
+
' at '
+
input_time
+
'</span><a href="#" class="edit-button" data-date="'
+
input_date
+
'" data-time="'
+
input_time
+
'" data-id="'
+
id
+
'">Edit</a>'
);
$thisSection
.
find
(
'.section-published-date'
).
animate
({
$thisSection
.
find
(
'.section-published-date'
).
animate
({
...
...
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