Skip to content
This repository has been archived by the owner on Jan 31, 2018. It is now read-only.

[#3157] Dry out on/off class toggling and Safari iframe hack #1500

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cornfield/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"exportAssets": [
"../external/popcorn-js/ie8/popcorn.ie8.js",
"../external/popcorn-js/popcorn.js",
"../src/util/butterOnOff.js",
"../external/popcorn-js/wrappers/common/popcorn._MediaElementProto.js",
"../external/popcorn-js/wrappers/html5/popcorn.HTMLMediaElement.js",
"../external/popcorn-js/wrappers/null/popcorn.HTMLNullVideoElement.js",
Expand Down
3 changes: 3 additions & 0 deletions make.js
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,9 @@ function butteredPopcorn() {
// popcorn.js
popcornFiles.push( popcornDir + '/popcorn.js' );

// Safari iframe fix
popcornFiles.push( './src/util/butterOnOff.js' );

// plugins
if ( defaultConfig.plugin && defaultConfig.plugin.plugins ) {
defaultConfig.plugin.plugins.forEach( function( plugin ){
Expand Down
7 changes: 7 additions & 0 deletions src/core/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,13 @@ define( [ "core/logger", "core/eventmanager" ], function( Logger, EventManager )
return !!window.Popcorn;
}
},
{
type: "js",
url: "{util}butterOnOff.js",
check: function() {
return !!Popcorn.toggleOn && Popcorn.toggleOff;
}
},
{
type: "js",
url: "{popcorn-js}/modules/player/popcorn.player.js",
Expand Down
3 changes: 2 additions & 1 deletion src/default-config.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@
"popcorn-js": "{{baseDir}}external/popcorn-js/",
"css": "{{baseDir}}css/",
"resources": "{{baseDir}}resources/",
"tools": "{{baseDir}}tools/"
"tools": "{{baseDir}}tools/",
"util": "{{baseDir}}src/util/"
},
"icons": {
"default": "popcorn-icon.png",
Expand Down
16 changes: 16 additions & 0 deletions src/util/butterOnOff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
(function() {
Popcorn.toggleOn = function( container ) {
container.classList.remove( "off" )
container.classList.add( "on" );

container.style.display = "none";
var junk = container.offsetHeight;
container.style.display = "";
};

Popcorn.toggleOff = function( container ) {
container.classList.remove( "on" );
container.classList.add( "off" );
};

})();
11 changes: 2 additions & 9 deletions templates/assets/plugins/googlemap/popcorn.googlemap.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,13 +412,7 @@ var googleCallback;
}

} else if ( ranOnce ) {
outerdiv.classList.remove( "off" );
outerdiv.classList.add( "on" );

// Safari Redraw hack - #3066
outerdiv.style.display = "none";
redrawBug = outerdiv.offsetHeight;
outerdiv.style.display = "";
Popcorn.toggleOn( outerdiv );
} else {
setTimeout(function () {
isMapSetup();
Expand All @@ -438,8 +432,7 @@ var googleCallback;
// if the map exists hide it do not delete the map just in
// case the user seeks back to time b/w start and end
if ( map ) {
outerdiv.classList.remove( "on" );
outerdiv.classList.add( "off" );
Popcorn.toggleOff( outerdiv );
}
},
_teardown: function ( options ) {
Expand Down
16 changes: 3 additions & 13 deletions templates/assets/plugins/image/popcorn.image.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,21 +259,12 @@
},

start: function( event, options ) {
var container = options._container,
redrawBug;

if ( container ) {
if ( options._container ) {
if ( options._updateImage ) {
this.on( "timeupdate", options._updateImage );
}

container.classList.add( "on" );
container.classList.remove( "off" );

// Safari Redraw hack - #3066
container.style.display = "none";
redrawBug = container.offsetHeight;
container.style.display = "";
Popcorn.toggleOn( options._container );
}
},

Expand All @@ -283,8 +274,7 @@
this.off( "timeupdate", options._updateImage );
}

options._container.classList.add( "off" );
options._container.classList.remove( "on" );
Popcorn.toggleOff( options._container );
}
},

Expand Down
14 changes: 3 additions & 11 deletions templates/assets/plugins/text/popcorn.text.js
Original file line number Diff line number Diff line change
Expand Up @@ -281,24 +281,16 @@
},

start: function( event, options ) {
var transitionContainer = options._transitionContainer,
redrawBug;
var transitionContainer = options._transitionContainer;

if ( transitionContainer ) {
transitionContainer.classList.add( "on" );
transitionContainer.classList.remove( "off" );

// Safari Redraw hack - #3066
transitionContainer.style.display = "none";
redrawBug = transitionContainer.offsetHeight;
transitionContainer.style.display = "";
Popcorn.toggleOn( transitionContainer );
}
},

end: function( event, options ) {
if ( options._transitionContainer ) {
options._transitionContainer.classList.remove( "on" );
options._transitionContainer.classList.add( "off" );
Popcorn.toggleOff( options._transitionContainer );
}
},

Expand Down
16 changes: 3 additions & 13 deletions templates/assets/plugins/twitter/popcorn.twitter.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,23 +278,13 @@
};
},
start: function( event, options ) {
var container = options._container,
redrawBug;

if ( container ) {
container.classList.add( "on" );
container.classList.remove( "off" );

// Safari Redraw hack - #3066
container.style.display = "none";
redrawBug = container.offsetHeight;
container.style.display = "";
if ( options._container ) {
Popcorn.toggleOn( options._container );
}
},
end: function( event, options ) {
if ( options._container ) {
options._container.classList.add( "off" );
options._container.classList.remove( "on" );
Popcorn.toggleOff( options._container );
}
},
_teardown: function( options ) {
Expand Down
16 changes: 3 additions & 13 deletions templates/assets/plugins/wikipedia/popcorn.wikipedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,24 +170,14 @@
},

start: function( event, options ){
var container = options._container,
redrawBug;

if ( container ) {
container.classList.add( "on" );
container.classList.remove( "off" );

// Safari Redraw hack - #3066
container.style.display = "none";
redrawBug = container.offsetHeight;
container.style.display = "";
if ( options._container ) {
Popcorn.toggleOn( options._container );
}
},

end: function( event, options ){
if ( options._container ) {
options._container.classList.add( "off" );
options._container.classList.remove( "on" );
Popcorn.toggleOff( options._container );
}
},

Expand Down