3 exports.__esModule = true;
5 var _button = require('../button.js');
7 var _button2 = _interopRequireDefault(_button);
9 var _component = require('../component.js');
11 var _component2 = _interopRequireDefault(_component);
13 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
15 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
17 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; }
19 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; } /**
20 * @file play-toggle.js
25 * Button to toggle between play and pause.
29 var PlayToggle = function (_Button) {
30 _inherits(PlayToggle, _Button);
33 * Creates an instance of this class.
35 * @param {Player} player
36 * The `Player` that this class should be attached to.
38 * @param {Object} [options]
39 * The key/value store of player options.
41 function PlayToggle(player, options) {
42 _classCallCheck(this, PlayToggle);
44 var _this = _possibleConstructorReturn(this, _Button.call(this, player, options));
46 _this.on(player, 'play', _this.handlePlay);
47 _this.on(player, 'pause', _this.handlePause);
52 * Builds the default DOM `className`.
55 * The DOM `className` for this object.
59 PlayToggle.prototype.buildCSSClass = function buildCSSClass() {
60 return 'vjs-play-control ' + _Button.prototype.buildCSSClass.call(this);
64 * This gets called when an `PlayToggle` is "clicked". See
65 * {@link ClickableComponent} for more detailed information on what a click can be.
67 * @param {EventTarget~Event} [event]
68 * The `keydown`, `tap`, or `click` event that caused this function to be
76 PlayToggle.prototype.handleClick = function handleClick(event) {
77 if (this.player_.paused()) {
85 * Add the vjs-playing class to the element so it can change appearance.
87 * @param {EventTarget~Event} [event]
88 * The event that caused this function to run.
90 * @listens Player#play
94 PlayToggle.prototype.handlePlay = function handlePlay(event) {
95 this.removeClass('vjs-paused');
96 this.addClass('vjs-playing');
97 // change the button text to "Pause"
98 this.controlText('Pause');
102 * Add the vjs-paused class to the element so it can change appearance.
104 * @param {EventTarget~Event} [event]
105 * The event that caused this function to run.
107 * @listens Player#pause
111 PlayToggle.prototype.handlePause = function handlePause(event) {
112 this.removeClass('vjs-playing');
113 this.addClass('vjs-paused');
114 // change the button text to "Play"
115 this.controlText('Play');
119 }(_button2['default']);
122 * The text that should display over the `PlayToggle`s controls. Added for localization.
129 PlayToggle.prototype.controlText_ = 'Play';
131 _component2['default'].registerComponent('PlayToggle', PlayToggle);
132 exports['default'] = PlayToggle;