Skip to content

Commit

Permalink
AMD module support, closes #18
Browse files Browse the repository at this point in the history
  • Loading branch information
joelfillmore committed Feb 14, 2013
1 parent 229cce9 commit 8928f97
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
10 changes: 10 additions & 0 deletions PxLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -369,10 +369,20 @@ function PxLoaderTags(values) {
}
}

// AMD module support
if (typeof define === 'function' && define.amd) {
define('PxLoader', [], function() {
return PxLoader;
});
}

// shims to ensure we have newer Array utility methods
// https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Array/isArray
if (!Array.isArray) {
Array.isArray = function(arg) {
return Object.prototype.toString.call(arg) == '[object Array]';
};
}



9 changes: 8 additions & 1 deletion PxLoaderImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,4 +99,11 @@ PxLoader.prototype.addImage = function(url, tags, priority) {

// return the img element to the caller
return imageLoader.img;
};
};

// AMD module support
if (typeof define === 'function' && define.amd) {
define('PxLoaderImage', [], function() {
return PxLoaderImage;
});
}
9 changes: 8 additions & 1 deletion PxLoaderSound.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,4 +88,11 @@ PxLoader.prototype.addSound = function(id, url, tags, priority) {
var soundLoader = new PxLoaderSound(id, url, tags, priority);
this.add(soundLoader);
return soundLoader.sound;
};
};

// AMD module support
if (typeof define === 'function' && define.amd) {
define('PxLoaderSound', [], function() {
return PxLoaderSound;
});
}
9 changes: 8 additions & 1 deletion PxLoaderVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,11 @@ PxLoader.prototype.addVideo = function(url, tags, priority) {

// return the vid element to the caller
return videoLoader.vid;
};
};

// AMD module support
if (typeof define === 'function' && define.amd) {
define('PxLoaderVideo', [], function() {
return PxLoaderVideo;
});
}

0 comments on commit 8928f97

Please sign in to comment.