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
5dd8e491
Commit
5dd8e491
authored
Oct 11, 2013
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move import code into import.js.
parent
c53d86d6
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
39 deletions
+42
-39
cms/static/js/base.js
+0
-21
cms/static/js/views/import.js
+42
-18
No files found.
cms/static/js/base.js
View file @
5dd8e491
...
...
@@ -126,13 +126,6 @@ domReady(function() {
$
(
'.sync-date'
).
bind
(
'click'
,
syncReleaseDate
);
// import form setup
$
(
'.view-import .file-input'
).
bind
(
'change'
,
showImportSubmit
);
$
(
'.view-import .choose-file-button, .view-import .choose-file-button-inline'
).
bind
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
'.view-import .file-input'
).
click
();
});
$
(
'.new-course-button'
).
bind
(
'click'
,
addNewCourse
);
// section date setting
...
...
@@ -221,20 +214,6 @@ function editSectionPublishDate(e) {
$modalCover
.
show
();
}
function
showImportSubmit
(
e
)
{
var
filepath
=
$
(
this
).
val
();
if
(
filepath
.
substr
(
filepath
.
length
-
6
,
6
)
==
'tar.gz'
)
{
$
(
'.error-block'
).
hide
();
$
(
'.file-name'
).
html
(
$
(
this
).
val
().
replace
(
'C:
\\
fakepath
\
\'
, ''));
$('
.
file
-
name
-
block
').show();
$('
.
view
-
import
.
choose
-
file
-
button
').hide();
$('
.
submit
-
button
').show();
$('
.
progress
').show();
} else {
$('
.
error
-
block
').html(gettext('
File
format
not
supported
.
Please
upload
a
file
with
a
<
code
>
tar
.
gz
<
/code> extension.'
))
.show
()
;
}
}
function
syncReleaseDate
(
e
)
{
e
.
preventDefault
();
$
(
this
).
closest
(
'.notice'
).
hide
();
...
...
cms/static/js/views/import.js
View file @
5dd8e491
...
...
@@ -2,29 +2,29 @@
* Course import-related js.
*/
define
(
[
"jquery"
,
"underscore"
,
"gettext"
],
function
(
$
,
_
,
gettext
)
{
[
"domReady"
,
"jquery"
,
"underscore"
,
"gettext"
],
function
(
domReady
,
$
,
_
,
gettext
)
{
"use strict"
;
"use strict"
;
/********** Private functions ************************************************/
/********** Private functions ************************************************/
/**
/**
* Toggle the spin on the progress cog.
* @param {boolean} isSpinning Turns cog spin on if true, off otherwise.
*/
var
updateCog
=
function
(
elem
,
isSpinning
)
{
var
updateCog
=
function
(
elem
,
isSpinning
)
{
var
cogI
=
elem
.
find
(
'i.icon-cog'
);
if
(
isSpinning
)
{
cogI
.
addClass
(
"icon-spin"
);}
else
{
cogI
.
removeClass
(
"icon-spin"
);}
};
};
/**
/**
* Manipulate the DOM to reflect current status of upload.
* @param {int} stageNo Current stage.
*/
var
updateStage
=
function
(
stageNo
){
var
updateStage
=
function
(
stageNo
){
var
all
=
$
(
'ol.status-progress'
).
children
();
var
prevList
=
all
.
slice
(
0
,
stageNo
);
_
.
map
(
prevList
,
function
(
elem
){
...
...
@@ -37,9 +37,9 @@ var updateStage = function (stageNo){
var
curList
=
all
.
eq
(
stageNo
);
curList
.
removeClass
(
"is-not-started"
).
addClass
(
"is-started"
);
updateCog
(
curList
,
true
);
};
};
/**
/**
* Check for import status updates every `timemout` milliseconds, and update
* the page accordingly.
* @param {string} url Url to call for status updates.
...
...
@@ -47,7 +47,7 @@ var updateStage = function (stageNo){
* for new updates.
* @param {int} stage Starting stage.
*/
var
getStatus
=
function
(
url
,
timeout
,
stage
)
{
var
getStatus
=
function
(
url
,
timeout
,
stage
)
{
var
currentStage
=
stage
||
0
;
if
(
CourseImport
.
stopGetStatus
)
{
return
;}
updateStage
(
currentStage
);
...
...
@@ -60,13 +60,13 @@ var getStatus = function (url, timeout, stage) {
},
time
);
}
);
};
};
/********** Public functions *************************************************/
/********** Public functions *************************************************/
var
CourseImport
=
{
var
CourseImport
=
{
/**
* Whether to stop sending AJAX requests for updates on the import
...
...
@@ -144,7 +144,30 @@ var CourseImport = {
elem
.
find
(
'p.copy'
).
hide
().
after
(
"<p class='copy error'>"
+
message
+
"</p>"
);
}
};
};
var
showImportSubmit
=
function
(
e
)
{
var
filepath
=
$
(
this
).
val
();
if
(
filepath
.
substr
(
filepath
.
length
-
6
,
6
)
==
'tar.gz'
)
{
$
(
'.error-block'
).
hide
();
$
(
'.file-name'
).
html
(
$
(
this
).
val
().
replace
(
'C:
\\
fakepath
\
\'
, ''));
$('
.
file
-
name
-
block
').show();
$('
.
view
-
import
.
choose
-
file
-
button
').hide();
$('
.
submit
-
button
').show();
$('
.
progress
').show();
} else {
$('
.
error
-
block
').html(gettext('
File
format
not
supported
.
Please
upload
a
file
with
a
<
code
>
tar
.
gz
<
/code> extension.'
))
.show
()
;
}
};
domReady
(
function
()
{
// import form setup
$
(
'.view-import .file-input'
).
bind
(
'change'
,
showImportSubmit
);
$
(
'.view-import .choose-file-button, .view-import .choose-file-button-inline'
).
bind
(
'click'
,
function
(
e
)
{
e
.
preventDefault
();
$
(
'.view-import .file-input'
).
click
();
});
});
return
CourseImport
;
});
return
CourseImport
;
});
\ No newline at end of file
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