Skip to content

Commit

Permalink
Made it work.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmarcon committed Jul 11, 2012
1 parent d5d4a83 commit 68842ad
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
29 changes: 13 additions & 16 deletions examples/jquery-ui-ondemand/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,25 @@
$(window).load(function(){

// Accordion
$("#accordion").accordion({ header: "h3" });
$("#accordion").accordion({ header: "h3" }).fadeTo(0, 0.8);

// Tabs
$('#tabs').tabs();

// Dialog
$('#dialog').dialog({
autoOpen: false,
width: 600,
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});

// Dialog Link
$('#dialog_link').click(function(){
$('#dialog').dialog('open');
// Dialog
$('#dialog').dialog({
width: 600,
buttons: {
"Ok": function() {
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
return false;
});

Expand Down
18 changes: 16 additions & 2 deletions examples/jquery-ui-ondemand/js/jquery.on.demand.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
else if (isObj(that._proxy[fn])) {
rv = that._proxy[fn];
}
else if (this.options.jqueryPlugin) {
else if (that.options.jqueryPlugin) {
rv = $.fn[fn].apply(context, args);
}
deferred.resolve(rv);
Expand All @@ -80,6 +80,20 @@
return deferred.promise();
};

P.internalPreload = function(fn) {
var script = this.fn2script(fn);

if (isFn(that._proxy[fn])) {
return;
}
else {
if (!script) {
return;
}
$.getScript(script);
}
};

P.setOptions = function(options){
this.options = $.extend( {}, defaults, options);
};
Expand All @@ -96,7 +110,7 @@
//@endForTest

P.preload = function(fn){
this.firstLoad(fn);
this.internalPreload(fn);
};
P.invoke = function(fn, args, context){
return this.firstLoad(fn, args, context);
Expand Down
7 changes: 4 additions & 3 deletions examples/jquery-ui-ondemand/js/ondemandloader.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@

functions.forEach(function(f){
$.fn[f] = function(){
console.log(f, arguments);
$.onDemand.invoke(f, this, arguments);
$.onDemand.invoke(f, arguments, this);
return this;
};
});

$.onDemand.setOptions({
fn2script: function(fn){
return 'development-bundle/ui/minified/jquery.ui.' + fn + '.min.js';
},
jqueryPlugin: false
jqueryPlugin: true
});

$.onDemand.preload('core');
$.onDemand.preload('widget');
})();

0 comments on commit 68842ad

Please sign in to comment.