Skip to content

Commit 890e51f

Browse files
committed
chore: Pending JS files converted with help of cursor'
1 parent a84e004 commit 890e51f

29 files changed

Lines changed: 889 additions & 857 deletions

xmodule/assets/video/public/js/00_component.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
'use strict';
22

3+
import _ from 'underscore';
4+
import $ from 'jquery';
5+
36
/**
47
* Creates a new object with the specified prototype object and properties.
58
* @param {Object} o The object which should be the prototype of the

xmodule/assets/video/public/js/00_resizer.js

Lines changed: 84 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,26 @@
11
'use strict';
22

3+
import _ from 'underscore';
4+
import $ from 'jquery';
5+
36
const Resizer = function(params) {
47
const defaults = {
5-
container: window,
6-
element: null,
7-
containerRatio: null,
8-
elementRatio: null
9-
};
10-
const callbacksList = [];
11-
const delta = {
12-
height: 0,
13-
width: 0
14-
};
15-
const module = {};
16-
let mode = null;
17-
let config;
8+
container: window,
9+
element: null,
10+
containerRatio: null,
11+
elementRatio: null
12+
},
13+
callbacksList = [],
14+
delta = {
15+
height: 0,
16+
width: 0
17+
},
18+
module = {};
19+
let mode = null,
20+
config;
1821

1922
// eslint-disable-next-line no-shadow
20-
const initialize = (params) => {
23+
const initialize = function(params) {
2124
if (!config) {
2225
config = defaults;
2326
}
@@ -33,10 +36,10 @@ const Resizer = function(params) {
3336
return module;
3437
};
3538

36-
const getData = () => {
37-
const $container = $(config.container);
38-
const containerWidth = $container.width() + delta.width;
39-
const containerHeight = $container.height() + delta.height;
39+
const getData = function() {
40+
const $container = $(config.container),
41+
containerWidth = $container.width() + delta.width,
42+
containerHeight = $container.height() + delta.height;
4043
let containerRatio = config.containerRatio;
4144

4245
const $element = $(config.element);
@@ -51,57 +54,15 @@ const Resizer = function(params) {
5154
}
5255

5356
return {
54-
containerWidth,
55-
containerHeight,
56-
containerRatio,
57+
containerWidth: containerWidth,
58+
containerHeight: containerHeight,
59+
containerRatio: containerRatio,
5760
element: $element,
58-
elementRatio
61+
elementRatio: elementRatio
5962
};
6063
};
6164

62-
const alignByWidthOnly = () => {
63-
const data = getData();
64-
const height = data.containerWidth / data.elementRatio;
65-
66-
data.element.css({
67-
height,
68-
width: data.containerWidth,
69-
top: 0.5 * (data.containerHeight - height),
70-
left: 0
71-
});
72-
73-
return module;
74-
};
75-
76-
const alignByHeightOnly = () => {
77-
const data = getData();
78-
const width = data.containerHeight * data.elementRatio;
79-
80-
data.element.css({
81-
height: data.containerHeight,
82-
width: data.containerHeight * data.elementRatio,
83-
top: 0,
84-
left: 0.5 * (data.containerWidth - width)
85-
});
86-
87-
return module;
88-
};
89-
90-
const fireCallbacks = () => {
91-
$.each(callbacksList, (index, callback) => {
92-
callback();
93-
});
94-
};
95-
96-
const removeCallback = (func) => {
97-
const index = $.inArray(func, callbacksList);
98-
99-
if (index !== -1) {
100-
return callbacksList.splice(index, 1);
101-
}
102-
};
103-
104-
const align = () => {
65+
const align = function() {
10566
const data = getData();
10667

10768
switch (mode) {
@@ -127,7 +88,35 @@ const Resizer = function(params) {
12788
return module;
12889
};
12990

130-
const setMode = (param) => {
91+
const alignByWidthOnly = function() {
92+
const data = getData(),
93+
height = data.containerWidth / data.elementRatio;
94+
95+
data.element.css({
96+
height: height,
97+
width: data.containerWidth,
98+
top: 0.5 * (data.containerHeight - height),
99+
left: 0
100+
});
101+
102+
return module;
103+
};
104+
105+
const alignByHeightOnly = function() {
106+
const data = getData(),
107+
width = data.containerHeight * data.elementRatio;
108+
109+
data.element.css({
110+
height: data.containerHeight,
111+
width: data.containerHeight * data.elementRatio,
112+
top: 0,
113+
left: 0.5 * (data.containerWidth - width)
114+
});
115+
116+
return module;
117+
};
118+
119+
const setMode = function(param) {
131120
if (_.isString(param)) {
132121
mode = param;
133122
align();
@@ -136,13 +125,13 @@ const Resizer = function(params) {
136125
return module;
137126
};
138127

139-
const setElement = (element) => {
128+
const setElement = function(element) {
140129
config.element = element;
141130

142131
return module;
143132
};
144133

145-
const addCallback = (func) => {
134+
const addCallback = function(func) {
146135
if ($.isFunction(func)) {
147136
callbacksList.push(func);
148137
} else {
@@ -152,9 +141,9 @@ const Resizer = function(params) {
152141
return module;
153142
};
154143

155-
const addOnceCallback = (func) => {
144+
const addOnceCallback = function(func) {
156145
if ($.isFunction(func)) {
157-
const decorator = () => {
146+
const decorator = function() {
158147
func();
159148
removeCallback(func);
160149
};
@@ -167,36 +156,50 @@ const Resizer = function(params) {
167156
return module;
168157
};
169158

170-
const removeCallbacks = () => {
159+
const fireCallbacks = function() {
160+
$.each(callbacksList, function(index, callback) {
161+
callback();
162+
});
163+
};
164+
165+
const removeCallbacks = function() {
171166
callbacksList.length = 0;
172167

173168
return module;
174169
};
175170

176-
const resetDelta = () => {
171+
const removeCallback = function(func) {
172+
const index = $.inArray(func, callbacksList);
173+
174+
if (index !== -1) {
175+
return callbacksList.splice(index, 1);
176+
}
177+
};
178+
179+
const resetDelta = function() {
177180
// eslint-disable-next-line no-multi-assign
178181
delta.height = delta.width = 0;
179182

180183
return module;
181184
};
182185

183-
const addDelta = (value, side) => {
186+
const addDelta = function(value, side) {
184187
if (_.isNumber(value) && _.isNumber(delta[side])) {
185188
delta[side] += value;
186189
}
187190

188191
return module;
189192
};
190193

191-
const substractDelta = (value, side) => {
194+
const substractDelta = function(value, side) {
192195
if (_.isNumber(value) && _.isNumber(delta[side])) {
193196
delta[side] -= value;
194197
}
195198

196199
return module;
197200
};
198201

199-
const destroy = () => {
202+
const destroy = function() {
200203
const data = getData();
201204
data.element.css({
202205
height: '', width: '', top: '', left: ''
@@ -209,13 +212,13 @@ const Resizer = function(params) {
209212
initialize.apply(module, arguments);
210213

211214
return $.extend(true, module, {
212-
align,
213-
alignByWidthOnly,
214-
alignByHeightOnly,
215-
destroy,
215+
align: align,
216+
alignByWidthOnly: alignByWidthOnly,
217+
alignByHeightOnly: alignByHeightOnly,
218+
destroy: destroy,
216219
setParams: initialize,
217-
setMode,
218-
setElement,
220+
setMode: setMode,
221+
setElement: setElement,
219222
callbacks: {
220223
add: addCallback,
221224
once: addOnceCallback,

xmodule/assets/video/public/js/00_sjson.js

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
'use strict';
22

3-
const Sjson = function(data) {
4-
const sjson = {
5-
start: data.start.concat(),
6-
text: data.text.concat()
7-
};
8-
const module = {};
9-
10-
const getter = function(propertyName) {
3+
let Sjson = function(data) {
4+
let sjson = {
5+
start: data.start.concat(),
6+
text: data.text.concat()
7+
},
8+
module = {};
9+
10+
let getter = function(propertyName) {
1111
return function() {
1212
return sjson[propertyName];
1313
};
1414
};
1515

16-
const getStartTimes = getter('start');
16+
let getStartTimes = getter('start');
1717

18-
const getCaptions = getter('text');
18+
let getCaptions = getter('text');
1919

20-
const size = function() {
20+
let size = function() {
2121
return sjson.text.length;
2222
};
2323

@@ -33,7 +33,7 @@ const Sjson = function(data) {
3333
// the start / end times.
3434
// Else, search the unfiltered list.
3535
if (typeof startTime !== 'undefined'
36-
&& typeof endTime !== 'undefined') {
36+
&& typeof endTime !== 'undefined') {
3737
results = filter(startTime, endTime);
3838
start = results.start;
3939
max = results.captions.length - 1;
@@ -67,10 +67,10 @@ const Sjson = function(data) {
6767
* parallel arrays of start times and
6868
* their corresponding captions.
6969
*/
70-
const filteredTimes = [];
71-
const filteredCaptions = [];
72-
const startTimes = getStartTimes();
73-
const captions = getCaptions();
70+
let filteredTimes = [];
71+
let filteredCaptions = [];
72+
let startTimes = getStartTimes();
73+
let captions = getCaptions();
7474

7575
if (startTimes.length !== captions.length) {
7676
console.warn('video caption and start time arrays do not match in length');

0 commit comments

Comments
 (0)