Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / node_modules / video.js / es5 / tracks / text-track-cue-list.js
1 'use strict';
2
3 exports.__esModule = true;
4
5 var _browser = require('../utils/browser.js');
6
7 var browser = _interopRequireWildcard(_browser);
8
9 var _document = require('global/document');
10
11 var _document2 = _interopRequireDefault(_document);
12
13 function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }
14
15 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; } }
16
17 function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /**
18                                                                                                                                                            * @file text-track-cue-list.js
19                                                                                                                                                            */
20
21
22 /**
23  * @typedef {Object} TextTrackCue
24  *
25  * @property {string} id
26  *           The unique id for this text track cue
27  *
28  * @property {number} startTime
29  *           The start time for this text track cue
30  *
31  * @property {number} endTime
32  *           The end time for this text track cue
33  *
34  * @property {boolean} pauseOnExit
35  *           Pause when the end time is reached if true.
36  *
37  * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcue}
38  */
39
40 /**
41  * A List of TextTrackCues.
42  *
43  * @see [Spec]{@link https://html.spec.whatwg.org/multipage/embedded-content.html#texttrackcuelist}
44  */
45 var TextTrackCueList = function () {
46
47   /**
48    * Create an instance of this class..
49    *
50    * @param {Array} cues
51    *        A list of cues to be initialized with
52    */
53   function TextTrackCueList(cues) {
54     _classCallCheck(this, TextTrackCueList);
55
56     var list = this; // eslint-disable-line
57
58     if (browser.IS_IE8) {
59       list = _document2['default'].createElement('custom');
60
61       for (var prop in TextTrackCueList.prototype) {
62         if (prop !== 'constructor') {
63           list[prop] = TextTrackCueList.prototype[prop];
64         }
65       }
66     }
67
68     TextTrackCueList.prototype.setCues_.call(list, cues);
69
70     /**
71      * @member {number} length
72      *         The current number of `TextTrackCue`s in the TextTrackCueList.
73      */
74     Object.defineProperty(list, 'length', {
75       get: function get() {
76         return this.length_;
77       }
78     });
79
80     if (browser.IS_IE8) {
81       return list;
82     }
83   }
84
85   /**
86    * A setter for cues in this list. Creates getters
87    * an an index for the cues.
88    *
89    * @param {Array} cues
90    *        An array of cues to set
91    *
92    * @private
93    */
94
95
96   TextTrackCueList.prototype.setCues_ = function setCues_(cues) {
97     var oldLength = this.length || 0;
98     var i = 0;
99     var l = cues.length;
100
101     this.cues_ = cues;
102     this.length_ = cues.length;
103
104     var defineProp = function defineProp(index) {
105       if (!('' + index in this)) {
106         Object.defineProperty(this, '' + index, {
107           get: function get() {
108             return this.cues_[index];
109           }
110         });
111       }
112     };
113
114     if (oldLength < l) {
115       i = oldLength;
116
117       for (; i < l; i++) {
118         defineProp.call(this, i);
119       }
120     }
121   };
122
123   /**
124    * Get a `TextTrackCue` that is currently in the `TextTrackCueList` by id.
125    *
126    * @param {string} id
127    *        The id of the cue that should be searched for.
128    *
129    * @return {TextTrackCue|null}
130    *         A single cue or null if none was found.
131    */
132
133
134   TextTrackCueList.prototype.getCueById = function getCueById(id) {
135     var result = null;
136
137     for (var i = 0, l = this.length; i < l; i++) {
138       var cue = this[i];
139
140       if (cue.id === id) {
141         result = cue;
142         break;
143       }
144     }
145
146     return result;
147   };
148
149   return TextTrackCueList;
150 }();
151
152 exports['default'] = TextTrackCueList;