mirror of
https://github.com/jquery/jquery-ui.git
synced 2025-01-07 20:34:24 +00:00
core: implemented experimental async dependency loading
This commit is contained in:
parent
79d25190cd
commit
fd1e948928
26
tests/visual/dep_loader.html
Normal file
26
tests/visual/dep_loader.html
Normal file
@ -0,0 +1,26 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
||||
<title>Dependency loading</title>
|
||||
<script type="text/javascript" src="../../jquery-1.2.6.js"></script>
|
||||
<script type="text/javascript" src="../../ui/ui.core.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
$(document).ready(function() {
|
||||
|
||||
$("div").draggable();
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div style="width: 100px; height: 100px; background: green;"></div>
|
||||
|
||||
</body>
|
||||
</html>
|
@ -9,6 +9,31 @@
|
||||
*/
|
||||
;(function($) {
|
||||
|
||||
|
||||
/** Lazy loading stub functions **/
|
||||
var uiPath;
|
||||
$("script").each(function() {
|
||||
if((/ui/i).test(this.src)) {
|
||||
var splitted = this.src.split('/'); splitted.pop();
|
||||
uiPath = splitted.join('/') + ( splitted.join('/') == '' ? '' : '/' );
|
||||
}
|
||||
});
|
||||
|
||||
$.each( ("accordion,colorpicker,datepicker,dialog,draggable,droppable,magnifier,progressbar," +
|
||||
"resizable,selectable,slider,sortable,spinner,tabs").split(","), function(i, name){
|
||||
|
||||
// Handle event binding
|
||||
$.fn[name] = function(){
|
||||
|
||||
var selector = this, args = arguments;
|
||||
$.getScript(uiPath+'ui.'+name+'.js', function() {
|
||||
selector[name].apply(selector, args);
|
||||
});
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
|
||||
/** jQuery core modifications and additions **/
|
||||
|
||||
var _remove = $.fn.remove;
|
||||
|
Loading…
Reference in New Issue
Block a user