refactoring editor to include annotations

This commit is contained in:
rlx 2011-02-03 21:39:22 +00:00
parent 08fd5b5870
commit 873951163c
3 changed files with 83 additions and 10 deletions

View file

@ -291,7 +291,6 @@ input::-moz-focus-inner {
textarea { textarea {
//padding: 2px 4px 2px 4px; //padding: 2px 4px 2px 4px;
padding: 0 4px 0 4px; padding: 0 4px 0 4px;
margin: -1px 0 0 0;
resize: none; resize: none;
-moz-border-radius: 8px; -moz-border-radius: 8px;
-webkit-border-radius: 8px; -webkit-border-radius: 8px;
@ -1285,11 +1284,11 @@ Video
================================================================================ ================================================================================
*/ */
.OxEditor { .OxVideoEditor {
overflow-x: hidden; overflow-x: hidden;
overflow-y: auto; overflow-y: auto;
} }
.OxEditor .OxVideoPlayer { .OxVideoEditor .OxVideoPlayer {
position: absolute; position: absolute;
margin: 4px; margin: 4px;
//background: red; //background: red;

View file

@ -98,6 +98,7 @@ Ox.uid = function() {
}(); }();
Ox.user = function() { Ox.user = function() {
// fixme: move to ox.ui
$.get("http://www.maxmind.com/app/locate_my_ip", function(data) { $.get("http://www.maxmind.com/app/locate_my_ip", function(data) {
var arr = data.split("tblProduct1"), var arr = data.split("tblProduct1"),
re = />(.+?)<\/td>\n<td class=output align="center">\n(.*?)\n/, re = />(.+?)<\/td>\n<td class=output align="center">\n(.*?)\n/,

View file

@ -3002,6 +3002,7 @@ requires
.appendTo(that.$element); .appendTo(that.$element);
// fixme: is there a better way than this one? // fixme: is there a better way than this one?
// should at least go into ox.ui.theme.foo.js
if (self.options.type == 'textarea') { if (self.options.type == 'textarea') {
$.extend(self, { $.extend(self, {
colors: Ox.theme() == 'classic' ? colors: Ox.theme() == 'classic' ?
@ -10420,6 +10421,34 @@ requires
============================================================================ ============================================================================
*/ */
Ox.AnnotationPanel = function(options, self) {
var self = self || {},
that = new Ox.Element('div', self)
.defaults({
id: '',
title: '',
type: 'text'
})
.options(options || {});
that.$element = new Ox.CollapsePanel({
collapsed: false,
size: 16,
title: self.options.title
})
.bindEvent({
toggle: togglePanel
});
function togglePanel() {
}
return that;
};
Ox.BlockTimeline = function(options, self) { Ox.BlockTimeline = function(options, self) {
var self = self || {}, var self = self || {},
@ -11217,16 +11246,19 @@ requires
var self = self || {}, var self = self || {},
that = new Ox.Element('div', self) that = new Ox.Element('div', self)
.defaults({ .defaults({
annotationsSize: 0,
cuts: [], cuts: [],
duration: 0, duration: 0,
find: '', find: '',
frameURL: function() {}, frameURL: function() {},
height: 0, height: 0,
largeTimeline: true, largeTimeline: true,
layers: [],
matches: [], matches: [],
points: [0, 0], points: [0, 0],
position: 0, position: 0,
posterFrame: 0, posterFrame: 0,
showAnnotations: false,
subtitles: [], subtitles: [],
videoHeight: 0, videoHeight: 0,
videoId: '', videoId: '',
@ -11236,7 +11268,6 @@ requires
width: 0 width: 0
}) })
.options(options || {}) .options(options || {})
.addClass('OxEditor')
.mousedown(function() { .mousedown(function() {
that.gainFocus(); that.gainFocus();
}) })
@ -11326,6 +11357,9 @@ requires
margin: 8, margin: 8,
videoRatio: self.options.videoWidth / self.options.videoHeight videoRatio: self.options.videoWidth / self.options.videoHeight
}); });
self.$video = new Ox.Element().addClass('OxVideoEditor');
self.sizes = getSizes(); self.sizes = getSizes();
$.each(['play', 'in', 'out'], function(i, type) { $.each(['play', 'in', 'out'], function(i, type) {
@ -11357,7 +11391,7 @@ requires
setPoint(type); setPoint(type);
} }
}) })
.appendTo(that); .appendTo(self.$video);
}); });
self.$timeline[0] = new Ox.LargeTimeline({ self.$timeline[0] = new Ox.LargeTimeline({
@ -11378,7 +11412,7 @@ requires
}) })
.bindEvent('change', changeTimelineLarge) .bindEvent('change', changeTimelineLarge)
.bindEvent('changeEnd', changeTimelineLarge) .bindEvent('changeEnd', changeTimelineLarge)
.appendTo(that); .appendTo(self.$video);
self.$timeline[1] = new Ox.BlockTimeline({ self.$timeline[1] = new Ox.BlockTimeline({
cuts: self.options.cuts, cuts: self.options.cuts,
@ -11397,9 +11431,36 @@ requires
top: self.sizes.timeline[1].top + 'px' top: self.sizes.timeline[1].top + 'px'
}) })
.bindEvent('change', changeTimelineSmall) .bindEvent('change', changeTimelineSmall)
.appendTo(that); .appendTo(self.$video);
// that.gainFocus(); self.$annotations = new Ox.Element()
.bindEvent({
resize: resizeAnnotations,
toggle: toggleAnnotations
});
self.$annotationPanel = [];
self.options.layers.forEach(function(layer, i) {
self.$annotationPanel[i] = new Ox.AnnotationPanel(layer)
.appendTo(self.$annotations);
});
that.$element = new Ox.SplitPanel({
elements: [
{
element: self.$video
},
{
collapsed: !self.options.showAnnotations,
collapsible: true,
element: self.$annotations,
resizable: true,
resize: [192, 256, 320, 384],
size: self.options.annotationsSize
}
],
orientation: 'horizontal'
});
function changePlayer(event, data) { function changePlayer(event, data) {
self.options.position = data.position; self.options.position = data.position;
@ -11464,7 +11525,9 @@ requires
function getSizes(scrollbarIsVisible) { function getSizes(scrollbarIsVisible) {
//Ox.print('getSizes', scrollbarIsVisible) //Ox.print('getSizes', scrollbarIsVisible)
var scrollbarWidth = oxui.scrollbarSize, var scrollbarWidth = oxui.scrollbarSize,
contentWidth = self.options.width - (scrollbarIsVisible ? scrollbarWidth : 0), contentWidth = self.options.width -
(self.options.showAnnotations * self.options.annotationsSize) - 1 -
(scrollbarIsVisible ? scrollbarWidth : 0),
height, height,
lines, lines,
size = { size = {
@ -11518,7 +11581,7 @@ requires
lines = Math.ceil(self.options.duration / size.timeline[1].width); lines = Math.ceil(self.options.duration / size.timeline[1].width);
height = getHeight(); height = getHeight();
//Ox.print('lines', lines, getHeight(), self.options.height, (scrollbarIsVisible && getHeight() <= self.options.height) ? 'scroll' : 'auto') //Ox.print('lines', lines, getHeight(), self.options.height, (scrollbarIsVisible && getHeight() <= self.options.height) ? 'scroll' : 'auto')
that.css({ self.$video.css({
overflowY: (scrollbarIsVisible && height <= self.options.height) ? 'scroll' : 'auto' overflowY: (scrollbarIsVisible && height <= self.options.height) ? 'scroll' : 'auto'
}); });
return (!scrollbarIsVisible && height > self.options.height) ? getSizes(true) : size; return (!scrollbarIsVisible && height > self.options.height) ? getSizes(true) : size;
@ -11557,6 +11620,11 @@ requires
self.$player[0].playInToOut(); self.$player[0].playInToOut();
} }
function resizeAnnotations(event, data) {
self.options.annotationsSize = data;
setSizes();
}
function resizeEditor(event, data) { function resizeEditor(event, data) {
var width = data - 2 * margin + 100; var width = data - 2 * margin + 100;
resizeVideoPlayers(width); resizeVideoPlayers(width);
@ -11639,6 +11707,11 @@ requires
}); });
} }
function toggleAnnotations(event, data) {
self.options.showAnnotations = !data.collapsed;
setSizes();
}
function toggleMute() { function toggleMute() {
self.$player[0].toggleMute(); self.$player[0].toggleMute();
} }