2 * Copyright 2013 vtt.js Contributors
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 // If we're in Node.js then require VTTRegion so we can extend it, otherwise assume
18 // VTTRegion is on the global.
19 if (typeof module !== "undefined" && module.exports) {
20 this.VTTRegion = require("./vttregion").VTTRegion;
23 // Extend VTTRegion with methods to convert to JSON, from JSON, and construct a
24 // VTTRegion from an options object. The primary purpose of this is for use in the
25 // vtt.js test suite. It's also useful if you need to work with VTTRegions in
29 root.VTTRegion.create = function(options) {
30 var region = new root.VTTRegion();
31 for (var key in options) {
32 if (region.hasOwnProperty(key)) {
33 region[key] = options[key];
39 root.VTTRegion.fromJSON = function(json) {
40 return this.create(JSON.parse(json));