Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Base URL Feature #110

Merged
merged 4 commits into from Apr 12, 2012
@@ -0,0 +1,35 @@
+/**
+ * YepNope Path Filter
+ *
+ * Usage:
+ * yepnope.paths = {
+ * 'google': '//ajax.googleapis.com/ajax',
+ * 'my-cdn': '//cdn.myawesomesite.com'
+ * };
+ * yepnope({
+ * load: ['google/jquery/1.7.2/jquery.min.js', 'google/jqueryui/1.8.18/jquery-ui.min.js', 'my-cdn/style.css', '/non/path/directory/file.js']
+ * });
+ *
+ * Official Yepnope Plugin
+ *
+ * WTFPL License
+ *
+ * by Kenneth Powers | mail@kenpowers.net
+ */
+(function () {
+ var addPathFilter = function (yn) {
+ // add each prefix
+ yn.addFilter(function (resource) {
+ // check each url for path
+ for (path in yn.paths) {
+ resource.url = resource.url.replace(new RegExp('^' + path), yn.paths[path]);
+ return resource;
+ }
+ // carry on my wayward, son
+ return resource;
+ });
+ };
+ console.log(yepnope);
+ if (yepnope) addPathFilter(yepnope);
+ else if (modernizr.load) addPathFilter(modernizr.load);
+})();
View
@@ -15,6 +15,12 @@
<!-- load the supported plugins so they can be tested as well. Will break them out when it makes sense -->
<script type="text/javascript" src="../prefixes/yepnope.ie-prefix.js"></script>
<script type="text/javascript" src="../prefixes/yepnope.preload.js"></script>
+<script type="text/javascript" src="../filters/yepnope.pathfilter.js"></script>
+<script type="text/javascript">
+ yepnope.paths = {
+ 'jsb': 'js/basetest'
+ };
+</script>
<script type="text/javascript" src="qunit.js"></script>
<script type="text/javascript" src="jquery-1.6.4.min.js"></script>
View
@@ -3,6 +3,6 @@
, "version": "0.0.1"
, "private": true
, "dependencies": {
- "express": "2.4.7"
+ "express": "2.5.9"
}
}
View
@@ -327,6 +327,25 @@ if ( ! window.console ) {
})
});
+ asyncTest("Yepnope loads several files with a common base", 1, function() {
+ yepnope({
+ load: ['jsb/file3.js', 'jsb/file4.js'],
+ complete: function(){
+ ok( w.file3 && w.file4, 'js/basetest/file3.js and js/basetest/file4.js have loaded.');
+ start();
+ }
+ })
+ });
+
+ asyncTest("Yepnope loads a single file with a given base", 1, function() {
+ yepnope({
+ load: 'jsb/file5.js',
+ complete: function(){
+ ok( w.file5, 'basetest/file5.js has loaded.');
+ start();
+ }
+ })
+ });
/** /
asyncTest("CSS Callback Timing", 4, function() {
View
@@ -397,7 +397,7 @@ var docElement = doc.documentElement,
complete = testObject['complete'] || noop,
needGroupSize,
callbackKey;
-
+
// Reusable function for dealing with the different input types
// NOTE:: relies on closures to keep 'chain' up to date, a bit confusing, but
// much smaller than the functional equivalent in this case.