TheDJ has uploaded a new change for review. https://gerrit.wikimedia.org/r/288122
Change subject: Very simple info button for video.js ...................................................................... Very simple info button for video.js Bug: T132493 Change-Id: I5d9e655ea1711d98152fe4f961f252b390007257 --- M TimedMediaHandler.hooks.php M resources/ext.tmh.player.js A resources/mw-info-button/mw-info-button.css A resources/mw-info-button/mw-info-button.js 4 files changed, 70 insertions(+), 1 deletion(-) git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/TimedMediaHandler refs/changes/22/288122/1 diff --git a/TimedMediaHandler.hooks.php b/TimedMediaHandler.hooks.php index ddfcdc2..7931aa0 100644 --- a/TimedMediaHandler.hooks.php +++ b/TimedMediaHandler.hooks.php @@ -149,7 +149,15 @@ 'dependencies' => [ 'ext.tmh.video-js', ], + ], + 'ext.tmh.mw-info-button' => $baseExtensionResource + [ + 'scripts' => 'resources/mw-info-button/mw-info-button.js', + 'styles' => 'resources/mw-info-button/mw-info-button.css', + 'targets' => [ 'mobile', 'desktop' ], + 'dependencies' => [ + 'ext.tmh.video-js', ], + ], 'ext.tmh.player' => $baseExtensionResource + [ 'scripts' => 'resources/ext.tmh.player.js', 'targets' => [ 'mobile', 'desktop' ], @@ -158,6 +166,7 @@ 'ext.tmh.videojs-resolution-switcher', 'ext.tmh.videojs-ogvjs', 'ext.tmh.videojs-responsive-layout', + 'ext.tmh.mw-info-button', ], ], 'ext.tmh.player.styles' => $baseExtensionResource + [ diff --git a/resources/ext.tmh.player.js b/resources/ext.tmh.player.js index db41a06..6734bf1 100755 --- a/resources/ext.tmh.player.js +++ b/resources/ext.tmh.player.js @@ -112,7 +112,7 @@ } ); // Launch the player - videojs( videoplayer, playerConfig ).ready( function () { + videojs( videoplayer, playerConfig ).infoButton().ready( function () { // TODO disabled the 'enlarging' for now. reconsidering alternative presentation modes // this.on( 'play', growPlayer ); // this.on( 'ended', shrinkPlayer ); diff --git a/resources/mw-info-button/mw-info-button.css b/resources/mw-info-button/mw-info-button.css new file mode 100644 index 0000000..25972e7 --- /dev/null +++ b/resources/mw-info-button/mw-info-button.css @@ -0,0 +1,8 @@ +/* Move this into videojs-font */ +.vjs-control.mw-info-button { + background-image: url( data:image/svg+xml;charset=utf-8;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHhtbG5zOnhsaW5rPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5L3hsaW5rIiB2ZXJzaW9uPSIxLjEiIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0Ij48cGF0aCBkPSJNMTEsOUgxM1Y3SDExTTEyLDIwQzcuNTksMjAgNCwxNi40MSA0LDEyQzQsNy41OSA3LjU5LDQgMTIsNEMxNi40MSw0IDIwLDcuNTkgMjAsMTJDMjAsMTYuNDEgMTYuNDEsMjAgMTIsMjBNMTIsMkExMCwxMCAwIDAsMCAyLDEyQTEwLDEwIDAgMCwwIDEyLDIyQTEwLDEwIDAgMCwwIDIyLDEyQTEwLDEwIDAgMCwwIDEyLDJNMTEsMTdIMTNWMTFIMTFWMTdaIiBmaWxsPSJ3aGl0ZSIvPjwvc3ZnPg== ); + background-repeat: no-repeat; + background-position: center; + background-size: 18px 18px; + cursor: pointer; +} \ No newline at end of file diff --git a/resources/mw-info-button/mw-info-button.js b/resources/mw-info-button/mw-info-button.js new file mode 100644 index 0000000..eb9e87d --- /dev/null +++ b/resources/mw-info-button/mw-info-button.js @@ -0,0 +1,52 @@ +(function() { + /* jshint eqnull: true*/ + /* global require */ + var videojs = null; + if(typeof window.videojs === 'undefined' && typeof require === 'function') { + videojs = require('video.js'); + } else { + videojs = window.videojs; + } + + (function(window, videojs, mw) { + var infoButton; + // defaults = {}; + + var Button = videojs.getComponent('Button'); + var InfoButton = videojs.extend(Button, { + constructor: function(player, link){ + this.link = link; + Button.call(this, player, {}); + this.controlText('More information'); + }, + handleClick: function () { + window.navigator.url = window.open(this.link, '_blank'); + }, + buildCSSClass: function() { + return Button.prototype.buildCSSClass.call(this) + ' mw-info-button'; + } + }); + + /** + * Initialize the plugin. + * @param {object} [options] configuration for the plugin + */ + infoButton = function(/*options*/) { + // var settings = videojs.mergeOptions(defaults, options), + var player = this; + + player.ready(function(){ + var link = mw.config.get('wgScript') + '?title=' + + mw.config.get( 'wgFormattedNamespaces' )['6'] + ':' + + encodeURIComponent( player.el().getAttribute( 'data-mwtitle' ) ); + var button = new InfoButton( Button, link ); + player.controlBar.infoButton = player.controlBar.addChild(button); + }); + + return this; + }; + + // register the plugin + videojs.plugin('infoButton', infoButton); + })(window, videojs, mediaWiki); +})(); -- To view, visit https://gerrit.wikimedia.org/r/288122 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I5d9e655ea1711d98152fe4f961f252b390007257 Gerrit-PatchSet: 1 Gerrit-Project: mediawiki/extensions/TimedMediaHandler Gerrit-Branch: master Gerrit-Owner: TheDJ <hartman.w...@gmail.com> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits