|
1 | | -(function(define) { |
2 | | - 'use strict'; |
| 1 | +'use strict'; |
3 | 2 |
|
4 | | - define('video/00_component.js', [], |
5 | | - function() { |
6 | | - /** |
7 | | - * Creates a new object with the specified prototype object and properties. |
8 | | - * @param {Object} o The object which should be the prototype of the |
9 | | - * newly-created object. |
10 | | - * @private |
11 | | - * @throws {TypeError, Error} |
12 | | - * @return {Object} |
13 | | - */ |
14 | | - var inherit = Object.create || (function() { |
15 | | - var F = function() {}; |
| 3 | +import _ from 'underscore'; |
| 4 | +import $ from 'jquery'; |
16 | 5 |
|
17 | | - return function(o) { |
18 | | - if (arguments.length > 1) { |
19 | | - throw Error('Second argument not supported'); |
20 | | - } |
21 | | - if (_.isNull(o) || _.isUndefined(o)) { |
22 | | - throw Error('Cannot set a null [[Prototype]]'); |
23 | | - } |
24 | | - if (!_.isObject(o)) { |
25 | | - throw TypeError('Argument must be an object'); |
26 | | - } |
| 6 | +/** |
| 7 | + * Creates a new object with the specified prototype object and properties. |
| 8 | + * @param {Object} o The object which should be the prototype of the |
| 9 | + * newly-created object. |
| 10 | + * @private |
| 11 | + * @throws {TypeError, Error} |
| 12 | + * @return {Object} |
| 13 | + */ |
| 14 | +let inherit = Object.create || (function() { |
| 15 | + let F = function() {}; |
27 | 16 |
|
28 | | - F.prototype = o; |
| 17 | + return function(o) { |
| 18 | + if (arguments.length > 1) { |
| 19 | + throw Error('Second argument not supported'); |
| 20 | + } |
| 21 | + if (_.isNull(o) || _.isUndefined(o)) { |
| 22 | + throw Error('Cannot set a null [[Prototype]]'); |
| 23 | + } |
| 24 | + if (!_.isObject(o)) { |
| 25 | + throw TypeError('Argument must be an object'); |
| 26 | + } |
29 | 27 |
|
30 | | - return new F(); |
31 | | - }; |
32 | | - }()); |
| 28 | + F.prototype = o; |
33 | 29 |
|
34 | | - /** |
35 | | - * Component module. |
36 | | - * @exports video/00_component.js |
37 | | - * @constructor |
38 | | - * @return {jquery Promise} |
39 | | - */ |
40 | | - var Component = function() { |
41 | | - if ($.isFunction(this.initialize)) { |
42 | | - // eslint-disable-next-line prefer-spread |
43 | | - return this.initialize.apply(this, arguments); |
44 | | - } |
45 | | - }; |
| 30 | + return new F(); |
| 31 | + }; |
| 32 | +}()); |
46 | 33 |
|
47 | | - /** |
48 | | - * Returns new constructor that inherits form the current constructor. |
49 | | - * @static |
50 | | - * @param {Object} protoProps The object containing which will be added to |
51 | | - * the prototype. |
52 | | - * @return {Object} |
53 | | - */ |
54 | | - Component.extend = function(protoProps, staticProps) { |
55 | | - var Parent = this, |
56 | | - Child = function() { |
57 | | - if ($.isFunction(this.initialize)) { |
58 | | - // eslint-disable-next-line prefer-spread |
59 | | - return this.initialize.apply(this, arguments); |
60 | | - } |
61 | | - }; |
| 34 | +/** |
| 35 | + * Component module. |
| 36 | + * @exports video/00_component.js |
| 37 | + * @constructor |
| 38 | + * @return {jquery Promise} |
| 39 | + */ |
| 40 | +let Component = function() { |
| 41 | + if ($.isFunction(this.initialize)) { |
| 42 | + // eslint-disable-next-line prefer-spread |
| 43 | + return this.initialize.apply(this, arguments); |
| 44 | + } |
| 45 | +}; |
62 | 46 |
|
63 | | - // Inherit methods and properties from the Parent prototype. |
64 | | - Child.prototype = inherit(Parent.prototype); |
65 | | - Child.constructor = Parent; |
66 | | - // Provide access to parent's methods and properties |
67 | | - Child.__super__ = Parent.prototype; |
| 47 | +/** |
| 48 | + * Returns new constructor that inherits form the current constructor. |
| 49 | + * @static |
| 50 | + * @param {Object} protoProps The object containing which will be added to |
| 51 | + * the prototype. |
| 52 | + * @return {Object} |
| 53 | + */ |
| 54 | +Component.extend = function(protoProps, staticProps) { |
| 55 | + let Parent = this; |
| 56 | + let Child = function() { |
| 57 | + if ($.isFunction(this.initialize)) { |
| 58 | + // eslint-disable-next-line prefer-spread |
| 59 | + return this.initialize.apply(this, arguments); |
| 60 | + } |
| 61 | + }; |
68 | 62 |
|
69 | | - // Extends inherited methods and properties by methods/properties |
70 | | - // passed as argument. |
71 | | - if (protoProps) { |
72 | | - $.extend(Child.prototype, protoProps); |
73 | | - } |
| 63 | + // Inherit methods and properties from the Parent prototype. |
| 64 | + Child.prototype = inherit(Parent.prototype); |
| 65 | + Child.constructor = Parent; |
| 66 | + // Provide access to parent's methods and properties |
| 67 | + Child.__super__ = Parent.prototype; |
74 | 68 |
|
75 | | - // Inherit static methods and properties |
76 | | - $.extend(Child, Parent, staticProps); |
| 69 | + // Extends inherited methods and properties by methods/properties |
| 70 | + // passed as argument. |
| 71 | + if (protoProps) { |
| 72 | + $.extend(Child.prototype, protoProps); |
| 73 | + } |
77 | 74 |
|
78 | | - return Child; |
79 | | - }; |
| 75 | + // Inherit static methods and properties |
| 76 | + $.extend(Child, Parent, staticProps); |
80 | 77 |
|
81 | | - return Component; |
82 | | - }); |
83 | | -}(RequireJS.define)); |
| 78 | + return Child; |
| 79 | +}; |
| 80 | + |
| 81 | +export default Component; |
0 commit comments