Skip to content

Instantly share code, notes, and snippets.

@humphd
Created August 1, 2012 17:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save humphd/3229279 to your computer and use it in GitHub Desktop.
Save humphd/3229279 to your computer and use it in GitHub Desktop.
Embed Structure
tools/embed.js
({
baseUrl: '../src',
paths: {
'text': '../external/require/text'
},
has: {
'source-config': false
},
name: '../tools/almond',
include: [ 'embed/embed' ],
wrap: {
startFile: '../tools/wrap.start',
endFile: '../tools/wrap.end'
},
out: '../dist/embed.js',
optimize: 'none'
})
src/embed/embed.js
function init( window, document ) {
var ctx = requirejs.config({
context: "embed",
baseUrl: module.uri.substring(0, module.uri.lastIndexOf('/')),
paths: {
'text': '../external/require/text'
}
});
require([
"../util/uri",
"../util/shims"
],
function( URI ) {
var Butter = {
version: "Butter-Embed-@VERSION@",
embed: {}
},
embed = Butter.embed;
// Guts of embed stuff here, put on Butter.embed
embed.config = {
autohide: qs.autohide === "0" ? false : true,
autoplay: qs.autoplay === "1" ? true : false,
controls: qs.controls === "0" ? false : true,
start: qs.start|0,
end: qs.end|0,
fullscreen: qs.fullscreen === "0" ? false : (function( document ) {
if( "fullScreenElement" in document ) {
return true;
}
var pre = "khtml o ms webkit moz".split( " " ),
i = pre.length,
prefix;
while( i-- ) {
prefix = pre[ i ];
if( (prefix + "FullscreenElement" ) in document ) {
return true;
}
}
return false;
}( document )),
loop: qs.loop === "1" ? true : false,
branding: qs.branding === "0" ? false : true,
showinfo: qs.showinfo === "0" ? false : true
};
...
if( window.Butter && console && console.warn ){
console.warn( "Butter Warning: page already contains Butter, removing." );
delete window.Butter;
}
window.Butter = Butter;
}
);
}
if( !window.require ) {
Popcorn.getScript( "../../external/require/require.js", function() {
init( window, window.document );
});
} else {
init( window, window.document );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment