aboutsummaryrefslogtreecommitdiffstats
path: root/youtubeamp.js
diff options
context:
space:
mode:
authoroniatsu2014-05-01 14:09:59 +0900
committeroniatsu2014-05-01 14:11:00 +0900
commitd61a493ad1df3f9b620e2650b6f3a7b55dfb72d6 (patch)
tree54f82b2bb98755722fc6c175f766d6d344c8d6ac /youtubeamp.js
parentd936e2f7b2b0bdb6f05860b35ccc1f23aca68cdb (diff)
downloadvimperator-plugins-d61a493ad1df3f9b620e2650b6f3a7b55dfb72d6.tar.bz2
youtubeamp: Fix ':ytsize' command to switch maximize/normal
Diffstat (limited to 'youtubeamp.js')
-rw-r--r--youtubeamp.js79
1 files changed, 37 insertions, 42 deletions
diff --git a/youtubeamp.js b/youtubeamp.js
index 1ab8833..3a8de0a 100644
--- a/youtubeamp.js
+++ b/youtubeamp.js
@@ -94,6 +94,23 @@ YouTubePlayerController.prototype = {
'chrome-promo',
'watch-video-quality-setting',
],
+
+ PLAYER_WRAPPER_NODE_ID: 'player-api',
+ TOGGLE_PLAYER_WRAPPER_STYLE: {
+ position: 'fixed',
+ visibility: 'visible',
+ top: '0px',
+ left: '0px',
+ margin: '0px',
+ padding: '0px',
+ width: '100%',
+ height: '100%',
+ zIndex: '99999999999',
+ borderWidth: '0px',
+ backgroundImage: 'none',
+ backgroundColor: '#000',
+ overflow: 'hidden',
+ },
},
getControllerVersion: function() { return this.constants.VERSION; },
@@ -128,10 +145,11 @@ YouTubePlayerController.prototype = {
},
toggleSize: function() {
- var p = this._player();
- (p.width == this.constants.SIZE_WIDTH_DEFAULT && p.height == this.constants.SIZE_HEIGHT_DEFAULT)
- ? this._fullSize()
- : this._normalSize();
+ var playerWrapper = this._getElementById(this.constants.PLAYER_WRAPPER_NODE_ID);
+
+ (playerWrapper.style.position == 'fixed')
+ ? this._normalSize()
+ : this._fullSize();
},
_changeToFull: function() {
@@ -152,48 +170,25 @@ YouTubePlayerController.prototype = {
},
_fullSize: function() {
- var b = this._getElementById('baseDiv');
- this.defMargin = b.style.margin;
- this.defPadding = b.style.padding;
- this.defWidth = b.style.width;
- b.style.margin = 0;
- b.style.padding = 0;
- b.style.width = '100%';
-
- for(let i=0, max=this.constants.HIDE_NODES.length ; i<max ; ++i) {
- let h = this._getElementById(this.constants.HIDE_NODES[i]);
- if(h) { h.style.display = 'none'; }
- }
-
- this._changeToFull();
-
- window.addEventListener(
- 'resize',
- this.fuller,
- false
- );
+ var playerWrapper = this._getElementById(this.constants.PLAYER_WRAPPER_NODE_ID);
+ this._setStyle(playerWrapper, this.constants.TOGGLE_PLAYER_WRAPPER_STYLE);
},
_normalSize: function() {
- var b = this._getElementById('baseDiv');
- b.style.margin = this.defMargin;
- b.style.padding = this.defPadding;
- b.style.width = this.defWidth;
-
- for(let i=0, max=this.constants.HIDE_NODES.length ; i<max ; ++i) {
- let h = this._getElementById(this.constants.HIDE_NODES[i]);
- if(h) { h.style.display = 'block'; }
- }
+ var playerWrapper = this._getElementById(this.constants.PLAYER_WRAPPER_NODE_ID);
+ this._clearStyle(playerWrapper, this.constants.TOGGLE_PLAYER_WRAPPER_STYLE);
+ },
- var p = this._player();
- p.width = this.constants.SIZE_WIDTH_DEFAULT;
- p.height = this.constants.SIZE_HEIGHT_DEFAULT;
-
- window.removeEventListener(
- 'resize',
- this.fuller,
- false
- );
+ _setStyle: function(ele, style) {
+ Object.keys(style).forEach(function (key) {
+ ele.style[key] = style[key];
+ });
+ },
+
+ _clearStyle: function(ele, style) {
+ Object.keys(style).forEach(function (key) {
+ ele.style[key] = '';
+ });
},
seekTo: function(position) {