'use strict';
Ox.SmallVideoTimelineImage = function(options, self) {
self = self || {};
var that = Ox.Element({}, self)
.defaults({
duration: 0,
editing: false,
'in': 0,
out: 0,
results: [],
subtitles: [],
timeline: '',
width: 256,
type: 'player'
})
.options(options || {})
.css({
position: 'absolute',
width: self.options.width + 'px'
});
self.images = Ox.isString(self.options.timeline) ?
1 : Math.ceil(self.options.duration / 3600);
self.imageWidth = Ox.isString(self.options.timeline) ?
1920 : Math.round(self.options.duration);
self.height = self.options.type == 'player' ? 16 : 24;
self.imageHeight = self.options.type == 'player' ? 16 : 18;
self.imageTop = self.options.type == 'player' ? 0 : 3;
self.timelineTop = self.options.type == 'player' ? 0 : 4;
that.css({
height: self.height + 'px'
});
if (Ox.isString(self.options.timeline)) {
self.$timeline = $('')
.attr({
src: self.options.timeline
})
.css({
position: 'absolute',
top: self.timelineTop + 'px',
width: self.options.width + 'px',
height: '16px'
})
.appendTo(that.$element);
} else {
Ox.loop(self.images, function(i) {
$('')
.attr({
src: self.options.timeline(i)
})
.css({
position: 'absolute',
left: (i * 3600) + 'px',
top: self.timelineTop + 'px',
width: (i == self.images - 1 ? self.imageWidth % 3600 : 3600) + 'px',
height: '16px'
})
.appendTo(that.$element);
});
}
self.$subtitles = $('')
.attr({
src: getImageURL('subtitles')
})
.css({
position: 'absolute',
top: self.imageTop + 'px',
width: self.options.width + 'px',
height: self.imageHeight + 'px'
})
.appendTo(that.$element);
self.$results = $('')
.attr({
src: getImageURL('results')
})
.css({
position: 'absolute',
top: self.imageTop + 'px',
width: self.options.width + 'px',
height: self.imageHeight + 'px'
})
.appendTo(that.$element);
self.$selection = $('')
.attr({
src: getImageURL('selection')
})
.css({
position: 'absolute',
top: self.imageTop + 'px',
width: self.options.width + 'px',
height: self.imageHeight + 'px'
})
.appendTo(that.$element);
function getImageURL(image, callback) {
var width = image == 'results' || image == 'selection' ?
self.options.width : self.imageWidth,
height = self.imageHeight,
canvas = $('