-
Notifications
You must be signed in to change notification settings - Fork 54
feat: Support toggling the select icon with the source label (#28) #56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,8 +5,9 @@ var _ = require('underscore'), | |||||
| qualityOptionFactory = require('./QualityOption'), | ||||||
| QUALITY_CHANGE_CLASS = 'vjs-quality-changing'; | ||||||
|
|
||||||
| module.exports = function(videojs) { | ||||||
| var MenuButton = videojs.getComponent('MenuButton'), | ||||||
| module.exports = function(videojs, userOpts) { | ||||||
| var userOptions = _.defaults(_.extend({}, userOpts), { showQualitySelectionLabelInControlBar: false }), | ||||||
| MenuButton = videojs.getComponent('MenuButton'), | ||||||
| QualityOption = qualityOptionFactory(videojs), | ||||||
| QualitySelector; | ||||||
|
|
||||||
|
|
@@ -22,6 +23,8 @@ module.exports = function(videojs) { | |||||
| * @inheritdoc | ||||||
| */ | ||||||
| constructor: function(player, options) { | ||||||
| var qualitySelectMenuButton = this.children_[0].controlTextEl_.previousSibling; | ||||||
|
|
||||||
| MenuButton.call(this, player, options); | ||||||
|
|
||||||
| // Update interface instantly so the user's change is acknowledged | ||||||
|
|
@@ -42,6 +45,15 @@ module.exports = function(videojs) { | |||||
| player.on(events.QUALITY_SELECTED, function(event, newSource) { | ||||||
| // Update the selected source with the source that was actually selected | ||||||
| this.setSelectedSource(newSource); | ||||||
|
|
||||||
| // Check for quality select label flag | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| if (userOptions.showQualitySelectionLabelInControlBar !== false) { | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| qualitySelectMenuButton.innerHTML = newSource.label; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Setting if (!this._qualitySelectorLabel) {
this._qualitySelectorLabel = document.createElement('span');
this._qualitySelectorLabel.classList.add('vjs-quality-selector-label');
qualitySelectMenuButton.prepend(this._qualitySelectorLabel);
}
this._qualitySelectorLabel.innerHTML = newSource.label;and then add this bit of CSS: // Hide the quality selector icon if there is a quality selector label present
.vjs-quality-selector-label ~ .vjs-quality-selector-icon {
display: none;
}This would also make the |
||||||
| } else if (qualitySelectMenuButton.className.indexOf('vjs-quality-selector-icon') === -1) { | ||||||
| // Add class to show gear icon. Blank out innerHTML for safety precations. | ||||||
| qualitySelectMenuButton.className += ' vjs-quality-selector-icon'; | ||||||
| qualitySelectMenuButton.innerHTML = ''; | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why blank out |
||||||
| } | ||||||
| }.bind(this)); | ||||||
|
|
||||||
| // Since it's possible for the player to get a source before the selector is | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| 'use strict'; | ||
|
|
||
| require('./index')(); | ||
| require('./index')(undefined, window.SILVERMINE_VIDEOJS_QUALITY_SELECTOR_CONFIG); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.