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
bee04095
Commit
bee04095
authored
Oct 07, 2016
by
cahrens
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix eslint violations.
parent
b8ddf709
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
48 additions
and
40 deletions
+48
-40
common/lib/xmodule/xmodule/js/src/javascript_loader.js
+48
-40
No files found.
common/lib/xmodule/xmodule/js/src/javascript_loader.js
View file @
bee04095
// Generated by CoffeeScript 1.6.1
(
function
()
{
this
.
JavascriptLoader
=
(
function
()
{
(
function
()
{
'use strict'
;
this
.
JavascriptLoader
=
(
function
()
{
function
JavascriptLoader
()
{
}
JavascriptLoader
.
executeModuleScripts
=
function
(
el
,
callback
)
{
var
callbackCalled
,
completed
,
completionHandlerGenerator
,
completionHandlerGeneratorIE
,
i
,
loaded
,
placeholders
,
_this
=
this
;
if
(
callback
==
null
)
{
callback
=
null
;
/**
* Set of library functions that provide common interface for javascript loading
* for all module types. All functionality provided by JavascriptLoader should take
* place at module scope, i.e. don't run jQuery over entire page.
*
* executeModuleScripts:
* Scan the module ('el') for "script_placeholder"s, then:
*
* 1) Fetch each script from server
* 2) Explicitly attach the script to the <head> of document
* 3) Explicitly wait for each script to be loaded
* 4) Return to callback function when all scripts loaded
*/
JavascriptLoader
.
executeModuleScripts
=
function
(
el
,
callback
)
{
var
callbackCalled
,
completed
,
completionHandlerGenerator
,
loaded
,
placeholders
;
if
(
!
callback
)
{
callback
=
null
;
// eslint-disable-line no-param-reassign
}
placeholders
=
el
.
find
(
".script_placeholder"
);
placeholders
=
el
.
find
(
'.script_placeholder'
);
if
(
placeholders
.
length
===
0
)
{
if
(
callback
!=
null
)
{
if
(
callback
!=
=
null
)
{
callback
();
}
return
;
return
[]
;
}
completed
=
(
function
()
{
var
_i
,
_ref
,
_results
;
_results
=
[];
for
(
i
=
_i
=
1
,
_ref
=
placeholders
.
length
;
1
<=
_ref
?
_i
<=
_ref
:
_i
>=
_ref
;
i
=
1
<=
_ref
?
++
_i
:
--
_i
)
{
_results
.
push
(
false
);
// TODO: Verify the execution order of multiple placeholders
completed
=
(
function
()
{
var
i
,
ref
,
results
;
results
=
[];
for
(
i
=
1
,
ref
=
placeholders
.
length
;
ref
>=
1
?
i
<=
ref
:
i
>=
ref
;
ref
>=
1
?
++
i
:
--
i
)
{
results
.
push
(
false
);
}
return
_
results
;
}
)(
);
return
results
;
}
()
);
callbackCalled
=
false
;
completionHandlerGeneratorIE
=
function
(
index
)
{
return
function
()
{
if
(
this
.
readyState
===
'complete'
||
this
.
readyState
===
'loaded'
)
{
return
completionHandlerGenerator
(
index
)();
}
};
};
completionHandlerGenerator
=
function
(
index
)
{
return
function
()
{
var
allComplete
,
flag
,
_i
,
_len
;
completionHandlerGenerator
=
function
(
index
)
{
return
function
()
{
var
allComplete
,
flag
,
i
,
len
;
allComplete
=
true
;
completed
[
index
]
=
true
;
for
(
_i
=
0
,
_len
=
completed
.
length
;
_i
<
_len
;
_
i
++
)
{
flag
=
completed
[
_
i
];
for
(
i
=
0
,
len
=
completed
.
length
;
i
<
len
;
i
++
)
{
flag
=
completed
[
i
];
if
(
!
flag
)
{
allComplete
=
false
;
break
;
...
...
@@ -49,25 +53,31 @@
}
if
(
allComplete
&&
!
callbackCalled
)
{
callbackCalled
=
true
;
if
(
callback
!=
null
)
{
if
(
callback
!=
=
null
)
{
return
callback
();
}
}
return
undefined
;
};
};
// Keep a map of what sources we're loaded from, and don't do it twice.
loaded
=
{};
return
placeholders
.
each
(
function
(
index
,
placeholder
)
{
return
placeholders
.
each
(
function
(
index
,
placeholder
)
{
var
s
,
src
;
src
=
$
(
placeholder
).
attr
(
"data-src"
);
// TODO: Check if the script already exists in DOM. If so, (1) copy it
// into memory; (2) delete the DOM script element; (3) reappend it.
// This would prevent memory bloat and save a network request.
src
=
$
(
placeholder
).
attr
(
'data-src'
);
if
(
!
(
src
in
loaded
))
{
loaded
[
src
]
=
true
;
s
=
document
.
createElement
(
'script'
);
s
.
setAttribute
(
'src'
,
src
);
s
.
setAttribute
(
'type'
,
"text/javascript"
);
s
.
setAttribute
(
'type'
,
'text/javascript'
);
s
.
onload
=
completionHandlerGenerator
(
index
);
s
.
onreadystatechange
=
completionHandlerGeneratorIE
(
index
);
// Need to use the DOM elements directly or the scripts won't execute properly.
$
(
'head'
)[
0
].
appendChild
(
s
);
}
else
{
// just call the completion callback directly, without reloading the file
completionHandlerGenerator
(
index
)();
}
return
$
(
placeholder
).
remove
();
...
...
@@ -75,7 +85,5 @@
};
return
JavascriptLoader
;
})();
}());
}).
call
(
this
);
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