Created
February 5, 2013 10:54
-
-
Save squeaky-pl/4713712 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/boot.js b/lib/boot.js | |
index 9ad4076..66cc56c 100644 | |
--- a/lib/boot.js | |
+++ b/lib/boot.js | |
@@ -27,6 +27,9 @@ requirejs.config({ | |
'vendor/crypto': { | |
exports: 'CryptoJS' | |
}, | |
+ 'vendor/videojs/video': { | |
+ exports: '_V_' | |
+ }, | |
'vendor/swfobject': { | |
exports: 'swfobject' | |
}, | |
diff --git a/lib/utils.js b/lib/utils.js | |
new file mode 100644 | |
index 0000000..ca41fcd | |
--- /dev/null | |
+++ b/lib/utils.js | |
@@ -0,0 +1,40 @@ | |
+define(['vendor/jquery', 'vendor/underscore'], function($, _) { | |
+ | |
+var encodeQuery = function(data) { | |
+ var result = []; | |
+ for(var d in data) { | |
+ if(data.hasOwnProperty(d) && data[d]) | |
+ result.push(encodeURIComponent(d) + "=" + encodeURIComponent(data[d])); | |
+ } | |
+ return result.join("&"); | |
+}; | |
+ | |
+var appendStyle = function(url) { | |
+ var link = '<link href=' + require.toUrl(url) + ' rel=stylesheet>'; | |
+ $('head').append(link); | |
+ return link; | |
+}; | |
+ | |
+var joinUrl = function() { | |
+ var params = {}; | |
+ var segments = []; | |
+ | |
+ for(var i = 0; i < arguments.length; i++) { | |
+ var item = arguments[i]; | |
+ if(_.isString(item)) /* strip leading and trailing slashes */ | |
+ segments.push(item.replace(/^\/+|\/+$/g, '')); | |
+ else if(_.isObject(item)) | |
+ params = _.extend(params, item); | |
+ } | |
+ | |
+ return segments.join('/') + | |
+ (_.isEmpty(params) ? '' : '?' + encodeQuery(params)); | |
+}; | |
+ | |
+return { | |
+ appendStyle: appendStyle, | |
+ encodeQuery: encodeQuery, | |
+ joinUrl: joinUrl | |
+}; | |
+ | |
+}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment