diff --git a/.gitmodules b/.gitmodules
index 962c7fabe..6456a362c 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -1,3 +1,9 @@
[submodule "public/external/popcorn-js"]
path = public/external/popcorn-js
url = git://github.com/mozilla/popcorn-js.git
+[submodule "public/external/WebComponents"]
+ path = public/external/WebComponents
+ url = git://github.com/toolkitchen/WebComponents.git
+[submodule "public/external/CustomElements"]
+ path = public/external/CustomElements
+ url = git://github.com/toolkitchen/CustomElements.git
diff --git a/public/external/CustomElements b/public/external/CustomElements
new file mode 160000
index 000000000..d1f37da2f
--- /dev/null
+++ b/public/external/CustomElements
@@ -0,0 +1 @@
+Subproject commit d1f37da2f2fce3faa47ed3394104ac296b64381b
diff --git a/public/external/WebComponents b/public/external/WebComponents
new file mode 160000
index 000000000..a83133654
--- /dev/null
+++ b/public/external/WebComponents
@@ -0,0 +1 @@
+Subproject commit a83133654378ebdb23c781dc73a109e29e9be77f
diff --git a/public/src/embed.js b/public/src/embed.js
index 2ebca9402..948a88207 100644
--- a/public/src/embed.js
+++ b/public/src/embed.js
@@ -266,8 +266,17 @@ function init() {
"popcorn"
],
function( URI, Controls, TextboxWrapper ) {
- // cornfield writes out the Popcorn initialization code as popcornDataFn()
- window.popcornDataFn();
+
+ // Popcorn loads after our custom elements have been parsed so we need to run through
+ // any popcorn calls they tried to make first.
+ var queuedFunctions = window.popcornFunctionQueue;
+
+ for ( var i = 0; i < queuedFunctions.length; i++ ) {
+ queuedFunctions[ i ]();
+ }
+
+ window.queuedFunctions = null;
+
/**
* Expose Butter so we can get version info out of the iframe doc's embed.
* This "butter" is never meant to live in a page with the full "butter".
diff --git a/public/src/popcorn.js b/public/src/popcorn.js
index d95bfed81..28a4ebddd 100644
--- a/public/src/popcorn.js
+++ b/public/src/popcorn.js
@@ -64,6 +64,7 @@ requirejs.config({
"popcorn.text": [ "popcorn.core" ],
"popcorn.twitter": [ "popcorn.core" ],
"popcorn.wikipedia": [ "popcorn.core" ]
+
}
});
diff --git a/public/src/web-components/webmaker-components.html b/public/src/web-components/webmaker-components.html
new file mode 100755
index 000000000..09a90de44
--- /dev/null
+++ b/public/src/web-components/webmaker-components.html
@@ -0,0 +1,753 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/public/templates/assets/plugins/image/popcorn.image.js b/public/templates/assets/plugins/image/popcorn.image.js
index 5e25c70e1..b0b64ec09 100644
--- a/public/templates/assets/plugins/image/popcorn.image.js
+++ b/public/templates/assets/plugins/image/popcorn.image.js
@@ -78,10 +78,11 @@
}
function validateDimension( value, fallback ) {
- if ( typeof value === "number" ) {
- return value;
+ value = parseFloat( value );
+ if ( value < 0 || value > 100 ) {
+ return fallback;
}
- return fallback;
+ return value;
}
function createImageDiv( imageUrl, linkUrl, instance ) {
diff --git a/public/templates/assets/plugins/text/popcorn.text.js b/public/templates/assets/plugins/text/popcorn.text.js
index 1c8060e67..9a276ac96 100644
--- a/public/templates/assets/plugins/text/popcorn.text.js
+++ b/public/templates/assets/plugins/text/popcorn.text.js
@@ -157,6 +157,9 @@
},
zindex: {
hidden: true
+ },
+ target: {
+ hidden: true
}
}
},
diff --git a/public/templates/assets/plugins/wikipedia/popcorn.wikipedia.js b/public/templates/assets/plugins/wikipedia/popcorn.wikipedia.js
index cd68a24cf..f8488dea1 100644
--- a/public/templates/assets/plugins/wikipedia/popcorn.wikipedia.js
+++ b/public/templates/assets/plugins/wikipedia/popcorn.wikipedia.js
@@ -28,10 +28,11 @@
}
function validateDimension( value, fallback ) {
- if ( typeof value === "number" ) {
- return value;
+ value = parseFloat( value );
+ if ( value < 0 || value > 100 ) {
+ return fallback;
}
- return fallback;
+ return value;
}
function sanitize( text ) {
diff --git a/server.js b/server.js
index babcbf403..e17016bb5 100644
--- a/server.js
+++ b/server.js
@@ -172,6 +172,7 @@ app.post( '/api/publish/:id',
externalAssetsString = '',
popcornString = '',
currentMedia,
+ popcornElements = [],
currentTrack,
currentTrackEvent,
mediaPopcornOptions,
@@ -181,7 +182,7 @@ app.post( '/api/publish/:id',
templateScripts,
startString,
numSources,
- j, k, len;
+ j, k, len, option;
templateURL = templateFile.substring( templateFile.indexOf( '/templates' ), templateFile.lastIndexOf( '/' ) );
baseHref = APP_HOSTNAME + templateURL + "/";
@@ -208,11 +209,10 @@ app.post( '/api/publish/:id',
externalAssetsString += '\n';
}
- popcornString += '\n';
-
- data = startString + baseString + templateScripts + externalAssetsString +
- data.substring( headEndTagIndex, bodyEndTagIndex ) +
- popcornString + data.substring( bodyEndTagIndex );
// Convert 1234567890 => "kf12oi"
var idBase36 = utils.generateIdString( id ),
diff --git a/views/embed.jade b/views/embed.jade
index 27a7c3d60..c38fc298a 100644
--- a/views/embed.jade
+++ b/views/embed.jade
@@ -4,7 +4,6 @@ html(lang='en')
base(href='#{baseHref}')
!{templateScripts}
!{externalAssets}
- !{popcorn}
link(rel='stylesheet', href='/css/embed.css')
link(rel='stylesheet', href="/css/controls.css")
// This is the embed, the actual content is at the following URL
@@ -15,12 +14,16 @@ html(lang='en')
@-ms-viewport { width: device-width; }
@-webkit-viewport { width: device-width; }
@viewport { width: device-width; }
+ script(src='/external/WebComponents/web-components.js')
+ script(src='/external/CustomElements/custom-elements.js')
+ link(href='/src/web-components/webmaker-components.html', rel='component')
script(src='/src/embed.js')
body.embed
#container.container
#video-container.video.video-container
#video.video
.loading-message
+ !{popcorn}
#controls-big-play-button
#post-roll-container
#post-roll.embed-overlay