mirror of
				https://gitea.invidious.io/iv-org/videojs-quality-selector.git
				synced 2024-08-15 00:43:13 +00:00 
			
		
		
		
	Merge pull request #93 from absidue/no-vjs-extend
refactor: Use ES6 classes instead of videojs.extend
This commit is contained in:
		
						commit
						d16842b1ac
					
				
					 2 changed files with 21 additions and 24 deletions
				
			
		|  | @ -10,12 +10,12 @@ module.exports = function(videojs) { | ||||||
|     * @class QualityOption |     * @class QualityOption | ||||||
|     * @extends videojs.MenuItem |     * @extends videojs.MenuItem | ||||||
|     */ |     */ | ||||||
|    return videojs.extend(MenuItem, { |    return class QualityOption extends MenuItem { | ||||||
| 
 | 
 | ||||||
|       /** |       /** | ||||||
|        * @inheritdoc |        * @inheritdoc | ||||||
|        */ |        */ | ||||||
|       constructor: function(player, options) { |       constructor(player, options) { | ||||||
|          var source = options.source; |          var source = options.source; | ||||||
| 
 | 
 | ||||||
|          if (!_.isObject(source)) { |          if (!_.isObject(source)) { | ||||||
|  | @ -27,18 +27,17 @@ module.exports = function(videojs) { | ||||||
|             label: source.label, |             label: source.label, | ||||||
|          }, options); |          }, options); | ||||||
| 
 | 
 | ||||||
|          MenuItem.call(this, player, options); |          super(player, options); | ||||||
| 
 | 
 | ||||||
|          this.source = source; |          this.source = source; | ||||||
|       }, |       } | ||||||
| 
 | 
 | ||||||
|       /** |       /** | ||||||
|        * @inheritdoc |        * @inheritdoc | ||||||
|        */ |        */ | ||||||
|       handleClick: function(event) { |       handleClick(event) { | ||||||
|          MenuItem.prototype.handleClick.call(this, event); |          super.handleClick(event); | ||||||
|          this.player().trigger(events.QUALITY_REQUESTED, this.source); |          this.player().trigger(events.QUALITY_REQUESTED, this.source); | ||||||
|       }, |       } | ||||||
| 
 |    }; | ||||||
|    }); |  | ||||||
| }; | }; | ||||||
|  |  | ||||||
|  | @ -5,8 +5,7 @@ var _ = require('underscore'), | ||||||
| 
 | 
 | ||||||
| module.exports = function(videojs) { | module.exports = function(videojs) { | ||||||
|    var MenuButton = videojs.getComponent('MenuButton'), |    var MenuButton = videojs.getComponent('MenuButton'), | ||||||
|        QualityOption = qualityOptionFactory(videojs), |        QualityOption = qualityOptionFactory(videojs); | ||||||
|        QualitySelector; |  | ||||||
| 
 | 
 | ||||||
|    /** |    /** | ||||||
|     * A component for changing video resolutions |     * A component for changing video resolutions | ||||||
|  | @ -14,13 +13,13 @@ module.exports = function(videojs) { | ||||||
|     * @class QualitySelector |     * @class QualitySelector | ||||||
|     * @extends videojs.Button |     * @extends videojs.Button | ||||||
|     */ |     */ | ||||||
|    QualitySelector = videojs.extend(MenuButton, { |    class QualitySelector extends MenuButton { | ||||||
| 
 | 
 | ||||||
|       /** |       /** | ||||||
|        * @inheritdoc |        * @inheritdoc | ||||||
|        */ |        */ | ||||||
|       constructor: function(player, options) { |       constructor(player, options) { | ||||||
|          MenuButton.call(this, player, options); |          super(player, options); | ||||||
| 
 | 
 | ||||||
|          // Update interface instantly so the user's change is acknowledged
 |          // Update interface instantly so the user's change is acknowledged
 | ||||||
|          player.on(events.QUALITY_REQUESTED, function(event, newSource) { |          player.on(events.QUALITY_REQUESTED, function(event, newSource) { | ||||||
|  | @ -50,14 +49,14 @@ module.exports = function(videojs) { | ||||||
|          }.bind(this)); |          }.bind(this)); | ||||||
| 
 | 
 | ||||||
|          this.controlText('Open quality selector menu'); |          this.controlText('Open quality selector menu'); | ||||||
|       }, |       } | ||||||
| 
 | 
 | ||||||
|       /** |       /** | ||||||
|        * Updates the source that is selected in the menu |        * Updates the source that is selected in the menu | ||||||
|        * |        * | ||||||
|        * @param source {object} player source to display as selected |        * @param source {object} player source to display as selected | ||||||
|        */ |        */ | ||||||
|       setSelectedSource: function(source) { |       setSelectedSource(source) { | ||||||
|          var src = (source ? source.src : undefined); |          var src = (source ? source.src : undefined); | ||||||
| 
 | 
 | ||||||
|          if (this.selectedSrc !== src) { |          if (this.selectedSrc !== src) { | ||||||
|  | @ -66,12 +65,12 @@ module.exports = function(videojs) { | ||||||
|                item.selected(item.source.src === src); |                item.selected(item.source.src === src); | ||||||
|             }); |             }); | ||||||
|          } |          } | ||||||
|       }, |       } | ||||||
| 
 | 
 | ||||||
|       /** |       /** | ||||||
|        * @inheritdoc |        * @inheritdoc | ||||||
|        */ |        */ | ||||||
|       createItems: function() { |       createItems() { | ||||||
|          var player = this.player(), |          var player = this.player(), | ||||||
|              sources = player.currentSources(); |              sources = player.currentSources(); | ||||||
| 
 | 
 | ||||||
|  | @ -85,16 +84,15 @@ module.exports = function(videojs) { | ||||||
|                selected: source.src === this.selectedSrc, |                selected: source.src === this.selectedSrc, | ||||||
|             }); |             }); | ||||||
|          }.bind(this)); |          }.bind(this)); | ||||||
|       }, |       } | ||||||
| 
 | 
 | ||||||
|       /** |       /** | ||||||
|        * @inheritdoc |        * @inheritdoc | ||||||
|        */ |        */ | ||||||
|       buildWrapperCSSClass: function() { |       buildWrapperCSSClass() { | ||||||
|          return 'vjs-quality-selector ' + MenuButton.prototype.buildWrapperCSSClass.call(this); |          return 'vjs-quality-selector ' + super.buildWrapperCSSClass(); | ||||||
|       }, |       } | ||||||
| 
 |    } | ||||||
|    }); |  | ||||||
| 
 | 
 | ||||||
|    videojs.registerComponent('QualitySelector', QualitySelector); |    videojs.registerComponent('QualitySelector', QualitySelector); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue