make small timeline work in player view

This commit is contained in:
rlx 2011-01-18 04:07:33 +00:00
parent b64c66bad5
commit 5a06413d5e

View file

@ -121,7 +121,8 @@ requires
/** /**
Creates an App instance. Creates an App instance.
*/ */
Ox.App = function() { Ox.App = (function() {
return function(options) { return function(options) {
options = options || {}; options = options || {};
@ -206,6 +207,10 @@ requires
} }
}; };
that.bindEvent = function() {
};
that.launch = function(callback) { that.launch = function(callback) {
var time = +new Date(), var time = +new Date(),
userAgent = getUserAgent(), userAgent = getUserAgent(),
@ -273,7 +278,7 @@ requires
}; };
}(); }());
Ox.Clipboard = function() { Ox.Clipboard = function() {
var clipboard = {}; var clipboard = {};
@ -1532,7 +1537,7 @@ requires
}) })
*/ */
.bindEvent({ .bindEvent({
doubleclick: toggle, anyclick: toggle,
dragstart: dragstart, dragstart: dragstart,
drag: drag, drag: drag,
dragend: dragend dragend: dragend
@ -1550,11 +1555,12 @@ requires
function dragstart(event, e) { function dragstart(event, e) {
if (self.options.resizable && !self.options.collapsed) { if (self.options.resizable && !self.options.collapsed) {
Ox.print('DRAGSTART')
self.drag = { self.drag = {
startPos: e[self.clientXY], startPos: e[self.clientXY],
startSize: self.options.size startSize: self.options.size
} }
} } else { Ox.print('NO DRAGSTART r !c', self.options.resizable, !self.options.collapsed) }
} }
function drag(event, e) { function drag(event, e) {
@ -7118,6 +7124,7 @@ requires
loadPages(self.page); loadPages(self.page);
} }
}, 250); }, 250);
that.gainFocus();
} }
function scrollPageDown() { function scrollPageDown() {
@ -10002,6 +10009,8 @@ requires
function setSizes(init) { function setSizes(init) {
self.options.elements.forEach(function(v, i) { self.options.elements.forEach(function(v, i) {
// fixme: maybe we can add a conditional here, since init
// is about elements that are collapsed splitpanels
var edges = [ var edges = [
(init && parseInt(that.$elements[i].css(self.edges[0]))) || 0, (init && parseInt(that.$elements[i].css(self.edges[0]))) || 0,
(init && parseInt(that.$elements[i].css(self.edges[1]))) || 0 (init && parseInt(that.$elements[i].css(self.edges[1]))) || 0
@ -10107,7 +10116,6 @@ requires
that.toggle = function(id) { that.toggle = function(id) {
// one can pass pos instead of id // one can pass pos instead of id
//Ox.print('toggle', id);
var pos = Ox.isNumber(id) ? id : getPositionById(id), var pos = Ox.isNumber(id) ? id : getPositionById(id),
element = self.options.elements[pos], element = self.options.elements[pos],
value = parseInt(that.css(self.edges[pos == 0 ? 0 : 1])) + value = parseInt(that.css(self.edges[pos == 0 ? 0 : 1])) +
@ -10115,8 +10123,7 @@ requires
(element.collapsed ? 1 : -1), (element.collapsed ? 1 : -1),
animate = {}; animate = {};
animate[self.edges[pos == 0 ? 0 : 1]] = value; animate[self.edges[pos == 0 ? 0 : 1]] = value;
//Ox.print('animate', animate, self.resizebarElements) that.animate(animate, 200, function() { // fixme: 250?
that.animate(animate, 200, function() {
element.collapsed = !element.collapsed; element.collapsed = !element.collapsed;
element.element.triggerEvent('toggle', { element.element.triggerEvent('toggle', {
'collapsed': element.collapsed 'collapsed': element.collapsed
@ -10761,12 +10768,14 @@ requires
}); });
self.$line = $('<img>') self.$line = $('<img>')
.addClass('OxTimelineSmallImage')
.attr({ .attr({
src: '/' + self.options.videoId + '/timelines/timeline.16.0.png' src: '/' + self.options.videoId + '/timelines/timeline.16.0.png'
}) })
.css({ .css({
position: 'absolute', position: 'absolute',
left: '4px', left: '4px',
top: '4px',
width: self.options.width, width: self.options.width,
height: '16px' height: '16px'
}) })
@ -10799,8 +10808,7 @@ requires
}); });
function getPosition(e) { function getPosition(e) {
//FIXME: this might still be broken in opera according to http://acko.net/blog/mouse-handling-and-absolute-positions-in-javascript return e.offsetX / self.options.width * self.options.duration;
return (e.offsetX ? e.offsetX : e.clientX - $(e.target).offset().left);
} }
function getSubtitle(position) { function getSubtitle(position) {
@ -10863,8 +10871,10 @@ requires
function setMarker() { function setMarker() {
self.$markerPosition self.$markerPosition
.css({ .css({
left: (self.options.position % self.options.width) + 'px', left: parseInt(
top: (parseInt(self.options.position / self.options.width) * (self.height + self.margin) + 2) + 'px', self.options.position / self.options.duration * self.options.width
) + 'px',
top: '2px',
}); });
} }
@ -10883,10 +10893,8 @@ requires
} }
function setWidth() { function setWidth() {
self.lines = Math.ceil(self.options.duration / self.options.width); self.$line.css({
that.css({ width: self.options.width + 'px',
width: (self.options.width + self.margin) + 'px',
height: (self.height + self.margin) + 'px'
}); });
setMarker(); setMarker();
setMarkerPoint(0); setMarkerPoint(0);
@ -11927,6 +11935,7 @@ requires
poster: '', poster: '',
showAnnotations: true, showAnnotations: true,
showControls: true, showControls: true,
subtitles: [],
videoHeight: 0, videoHeight: 0,
videoSize: 'fit', videoSize: 'fit',
videoWidth: 0, videoWidth: 0,
@ -11942,7 +11951,10 @@ requires
resize: resizeElement resize: resizeElement
}); });
self.videoCSS = getVideoCSS(); $.extend(self, {
fullscreen: false,
videoCSS: getVideoCSS()
});
//alert(JSON.stringify([self.playerHeight, self.playerWidth, self.videoCSS])) //alert(JSON.stringify([self.playerHeight, self.playerWidth, self.videoCSS]))
self.$player = new Ox.Element() self.$player = new Ox.Element()
@ -11995,15 +12007,6 @@ requires
.bindEvent({ .bindEvent({
click: self.$video.togglePlay click: self.$video.togglePlay
}), }),
playInToOut: new Ox.Button({
id: 'playInToOut',
title: 'PlayInToOut',
tooltip: 'Play In to Out',
type: 'image'
})
.bindEvent({
click: playInToOut
}),
mute: new Ox.Button({ mute: new Ox.Button({
id: 'mute', id: 'mute',
title: [ title: [
@ -12034,6 +12037,20 @@ requires
}) })
.bindEvent({ .bindEvent({
click: toggleSize click: toggleSize
}),
fullscreen: new Ox.Button({
id: 'size',
title: [
{id: 'grow', title: 'grow'},
{id: 'shrink', title: 'shrink'}
],
tooltip: [
'Enter Fullscreen', 'Exit Fullscreen'
],
type: 'image'
})
.bindEvent({
click: toggleFullscreen
}) })
} }
var i = 0; var i = 0;
@ -12056,6 +12073,7 @@ requires
self.$timeline = { self.$timeline = {
large: new Ox.LargeTimeline({ large: new Ox.LargeTimeline({
duration: self.options.duration, duration: self.options.duration,
subtitles: self.options.subtitles,
videoId: self.options.videoId, videoId: self.options.videoId,
width: getTimelineWidth() width: getTimelineWidth()
}) })
@ -12063,17 +12081,19 @@ requires
top: '4px' top: '4px'
}) })
.bindEvent({ .bindEvent({
change: function(event, data) { change: changeLargeTimeline
self.$video.position(data.position);
}
}), }),
small: new Ox.SmallTimeline({ small: new Ox.SmallTimeline({
duration: self.options.duration, duration: self.options.duration,
subtitles: self.options.subtitles,
videoId: self.options.videoId, videoId: self.options.videoId,
width: getTimelineWidth() width: getTimelineWidth()
}) })
.css({ .css({
top: '80px' top: '76px'
})
.bindEvent({
change: changeSmallTimeline
}) })
}; };
$.each(self.$timeline, function(i, $timeline) { $.each(self.$timeline, function(i, $timeline) {
@ -12122,6 +12142,20 @@ requires
orientation: 'horizontal' orientation: 'horizontal'
}); });
function changeLargeTimeline(event, data) {
self.$video.position(data.position);
self.$timeline.small.options({
position: data.position
});
}
function changeSmallTimeline(event, data) {
self.$video.position(data.position);
self.$timeline.large.options({
position: data.position
});
}
function getPlayerHeight() { function getPlayerHeight() {
return self.options.height - return self.options.height -
self.options.showControls * 104 - 1; self.options.showControls * 104 - 1;
@ -12129,13 +12163,13 @@ requires
function getPlayerWidth() { function getPlayerWidth() {
return self.options.width - return self.options.width -
self.options.showAnnotations * (self.options.showAnnotations && !self.fullscreen) *
self.options.annotationsSize - 1; self.options.annotationsSize - 1;
} }
function getTimelineWidth() { function getTimelineWidth() {
return self.options.width - return self.options.width -
self.options.showAnnotations * (self.options.showAnnotations && !self.fullscreen) *
self.options.annotationsSize - 40 self.options.annotationsSize - 40
} }
@ -12170,18 +12204,13 @@ requires
} }
function play() {
}
function playing(event, data) { function playing(event, data) {
self.$timeline.large.options({ self.$timeline.large.options({
position: data.position position: data.position
}); });
} self.$timeline.small.options({
position: data.position
function playInToOut() { });
} }
function resizeAnnotations(event, data) { function resizeAnnotations(event, data) {
@ -12240,6 +12269,13 @@ requires
}); });
} }
function toggleFullscreen() {
self.fullscreen = !self.fullscreen;
self.options.showAnnotations && that.$element.toggle(1);
self.fullscreen && self.options.showControls && self.$panel.toggle(1);
that.triggerEvent((self.fullscreen ? 'enter' : 'exit') + 'fullscreen', {});
}
function toggleSize() { function toggleSize() {
self.options.videoSize = self.options.videoSize == 'fit' ? 'fill' : 'fit'; self.options.videoSize = self.options.videoSize == 'fit' ? 'fill' : 'fit';
resizeVideo(); resizeVideo();