Created
August 1, 2012 17:56
-
-
Save humphd/3229279 to your computer and use it in GitHub Desktop.
Embed Structure
This file contains 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
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