Skip to content

Commit

Permalink
stable 4, adds css and js files
Browse files Browse the repository at this point in the history
  • Loading branch information
farhan committed Feb 25, 2025
1 parent abc3f48 commit 218be7a
Show file tree
Hide file tree
Showing 38 changed files with 10,278 additions and 41 deletions.
1,160 changes: 1,158 additions & 2 deletions xblocks_contrib/video/static/css/video.css

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions xblocks_contrib/video/static/js/src/00_async_process.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
(function(define) {
define(
'video/00_async_process.js',
[],
function() {
'use strict';

/**
* Provides convenient way to process big amount of data without UI blocking.
*
* @param {array} list Array to process.
* @param {function} process Calls this function on each item in the list.
* @return {array} Returns a Promise object to observe when all actions of a
* certain type bound to the collection, queued or not, have finished.
*/
var AsyncProcess = {
array: function(list, process) {
if (!_.isArray(list)) {
return $.Deferred().reject().promise();
}

if (!_.isFunction(process) || !list.length) {
return $.Deferred().resolve(list).promise();
}

var MAX_DELAY = 50, // maximum amount of time that js code should be allowed to run continuously
dfd = $.Deferred(),
result = [],
index = 0,
len = list.length;

var getCurrentTime = function() {
return (new Date()).getTime();
};

var handler = function() {
var start = getCurrentTime();

do {
result[index] = process(list[index], index);
index++;
} while (index < len && getCurrentTime() - start < MAX_DELAY);

if (index < len) {
setTimeout(handler, 25);
} else {
dfd.resolve(result);
}
};

setTimeout(handler, 25);

return dfd.promise();
}
};

return AsyncProcess;
});
}(RequireJS.define));
83 changes: 83 additions & 0 deletions xblocks_contrib/video/static/js/src/00_component.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
(function(define) {
'use strict';

define('video/00_component.js', [],
function() {
/**
* Creates a new object with the specified prototype object and properties.
* @param {Object} o The object which should be the prototype of the
* newly-created object.
* @private
* @throws {TypeError, Error}
* @return {Object}
*/
var inherit = Object.create || (function() {
var F = function() {};

return function(o) {
if (arguments.length > 1) {
throw Error('Second argument not supported');
}
if (_.isNull(o) || _.isUndefined(o)) {
throw Error('Cannot set a null [[Prototype]]');
}
if (!_.isObject(o)) {
throw TypeError('Argument must be an object');
}

F.prototype = o;

return new F();
};
}());

/**
* Component module.
* @exports video/00_component.js
* @constructor
* @return {jquery Promise}
*/
var Component = function() {
if ($.isFunction(this.initialize)) {
// eslint-disable-next-line prefer-spread
return this.initialize.apply(this, arguments);
}
};

/**
* Returns new constructor that inherits form the current constructor.
* @static
* @param {Object} protoProps The object containing which will be added to
* the prototype.
* @return {Object}
*/
Component.extend = function(protoProps, staticProps) {
var Parent = this,
Child = function() {
if ($.isFunction(this.initialize)) {
// eslint-disable-next-line prefer-spread
return this.initialize.apply(this, arguments);
}
};

// Inherit methods and properties from the Parent prototype.
Child.prototype = inherit(Parent.prototype);
Child.constructor = Parent;
// Provide access to parent's methods and properties
Child.__super__ = Parent.prototype;

// Extends inherited methods and properties by methods/properties
// passed as argument.
if (protoProps) {
$.extend(Child.prototype, protoProps);
}

// Inherit static methods and properties
$.extend(Child, Parent, staticProps);

return Child;
};

return Component;
});
}(RequireJS.define));
40 changes: 40 additions & 0 deletions xblocks_contrib/video/static/js/src/00_i18n.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
(function(define) {
'use strict';

define(
'video/00_i18n.js',
[],
function() {
/**
* i18n module.
* @exports video/00_i18n.js
* @return {object}
*/

return {
Play: gettext('Play'),
Pause: gettext('Pause'),
Mute: gettext('Mute'),
Unmute: gettext('Unmute'),
'Exit full browser': gettext('Exit full browser'),
'Fill browser': gettext('Fill browser'),
Speed: gettext('Speed'),
'Auto-advance': gettext('Auto-advance'),
Volume: gettext('Volume'),
// Translators: Volume level equals 0%.
Muted: gettext('Muted'),
// Translators: Volume level in range ]0,20]%
'Very low': gettext('Very low'),
// Translators: Volume level in range ]20,40]%
Low: gettext('Low'),
// Translators: Volume level in range ]40,60]%
Average: gettext('Average'),
// Translators: Volume level in range ]60,80]%
Loud: gettext('Loud'),
// Translators: Volume level in range ]80,99]%
'Very loud': gettext('Very loud'),
// Translators: Volume level equals 100%.
Maximum: gettext('Maximum')
};
});
}(RequireJS.define));
90 changes: 90 additions & 0 deletions xblocks_contrib/video/static/js/src/00_iterator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
(function(define) {
define(
'video/00_iterator.js',
[],
function() {
'use strict';

/**
* Provides convenient way to work with iterable data.
* @exports video/00_iterator.js
* @constructor
* @param {array} list Array to be iterated.
*/
var Iterator = function(list) {
this.list = list;
this.index = 0;
this.size = this.list.length;
this.lastIndex = this.list.length - 1;
};

Iterator.prototype = {

/**
* Checks validity of provided index for the iterator.
* @access protected
* @param {numebr} index
* @return {boolean}
*/
_isValid: function(index) {
return _.isNumber(index) && index < this.size && index >= 0;
},

/**
* Returns next element.
* @param {number} [index] Updates current position.
* @return {any}
*/
next: function(index) {
if (!(this._isValid(index))) {
index = this.index;
}

this.index = (index >= this.lastIndex) ? 0 : index + 1;

return this.list[this.index];
},

/**
* Returns previous element.
* @param {number} [index] Updates current position.
* @return {any}
*/
prev: function(index) {
if (!(this._isValid(index))) {
index = this.index;
}

this.index = (index < 1) ? this.lastIndex : index - 1;

return this.list[this.index];
},

/**
* Returns last element in the list.
* @return {any}
*/
last: function() {
return this.list[this.lastIndex];
},

/**
* Returns first element in the list.
* @return {any}
*/
first: function() {
return this.list[0];
},

/**
* Returns `true` if current position is last for the iterator.
* @return {boolean}
*/
isEnd: function() {
return this.index === this.lastIndex;
}
};

return Iterator;
});
}(RequireJS.define));
Loading

0 comments on commit 218be7a

Please sign in to comment.