Version 1
[yaffs-website] / node_modules / video.js / es5 / control-bar / track-button.js
diff --git a/node_modules/video.js/es5/control-bar/track-button.js b/node_modules/video.js/es5/control-bar/track-button.js
new file mode 100644 (file)
index 0000000..32216e6
--- /dev/null
@@ -0,0 +1,78 @@
+'use strict';
+
+exports.__esModule = true;
+
+var _menuButton = require('../menu/menu-button.js');
+
+var _menuButton2 = _interopRequireDefault(_menuButton);
+
+var _component = require('../component.js');
+
+var _component2 = _interopRequireDefault(_component);
+
+var _fn = require('../utils/fn.js');
+
+var Fn = _interopRequireWildcard(_fn);
+
+function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj['default'] = obj; return newObj; } }
+
+function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
+
+function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
+
+function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
+
+function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } /**
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                * @file track-button.js
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                */
+
+
+/**
+ * The base class for buttons that toggle specific  track types (e.g. subtitles).
+ *
+ * @extends MenuButton
+ */
+var TrackButton = function (_MenuButton) {
+  _inherits(TrackButton, _MenuButton);
+
+  /**
+   * Creates an instance of this class.
+   *
+   * @param {Player} player
+   *        The `Player` that this class should be attached to.
+   *
+   * @param {Object} [options]
+   *        The key/value store of player options.
+   */
+  function TrackButton(player, options) {
+    _classCallCheck(this, TrackButton);
+
+    var tracks = options.tracks;
+
+    var _this = _possibleConstructorReturn(this, _MenuButton.call(this, player, options));
+
+    if (_this.items.length <= 1) {
+      _this.hide();
+    }
+
+    if (!tracks) {
+      return _possibleConstructorReturn(_this);
+    }
+
+    var updateHandler = Fn.bind(_this, _this.update);
+
+    tracks.addEventListener('removetrack', updateHandler);
+    tracks.addEventListener('addtrack', updateHandler);
+
+    _this.player_.on('dispose', function () {
+      tracks.removeEventListener('removetrack', updateHandler);
+      tracks.removeEventListener('addtrack', updateHandler);
+    });
+    return _this;
+  }
+
+  return TrackButton;
+}(_menuButton2['default']);
+
+_component2['default'].registerComponent('TrackButton', TrackButton);
+exports['default'] = TrackButton;