update Ox.URL

This commit is contained in:
rlx 2012-01-06 17:28:53 +05:30
parent 093edd57d0
commit dc4a8bf464
3 changed files with 38 additions and 41 deletions

View file

@ -125,9 +125,12 @@ example.com/2001/2001 -> example.com/0062622/video/00:33:21
example.com/2002/2002 -> example.com/calendar/2002/2002 example.com/2002/2002 -> example.com/calendar/2002/2002
2002 is a valid duration, but no list view supports durations. Then it is 2002 is a valid duration, but no list view supports durations. Then it is
read as a year, and we get calendar view with find *=2002 read as a year, and we get calendar view with find *=2002
example.com/@paris/london -> example.com/map/@paris/london
paris matches place ABC (case-insensitive), but (assuming) find *=london
does not match place ABC, "paris" becomes the map query
example.com/@paris/paris -> example.com/map/ABC/paris example.com/@paris/paris -> example.com/map/ABC/paris
paris matches a place name (case-insensitive), so we get map view, zoomed to paris matches place ABC (case-insensitive), so we get map view, zoomed to
Paris, with find *=paris ABC/Paris, which is selected, with find *=paris
example.com/@renaissance/renaissance -> example.com/calendar/ABC/renaissance example.com/@renaissance/renaissance -> example.com/calendar/ABC/renaissance
renaissaince matches an event name (case-insensitive), so we get calendar renaissaince matches an event name (case-insensitive), so we get calendar
view, zoomed to the Renaissance, with find *=renaissance view, zoomed to the Renaissance, with find *=renaissance
@ -200,13 +203,9 @@ Ox.URL = function(options) {
function constructFind(find) { function constructFind(find) {
return find.conditions.map(function(condition) { return find.conditions.map(function(condition) {
var ret; return condition.conditions
if (condition.conditions) { ? '(' + constructFind(condition) + ')'
ret = '(' + constructFind(condition) + ')'; : constructCondition(condition);
} else {
ret = constructCondition(condition);
}
return ret;
}).join(find.operator); }).join(find.operator);
} }
@ -275,10 +274,7 @@ Ox.URL = function(options) {
type = Ox.isArray(findKey.type) ? findKey.type[0] : findKey.type, type = Ox.isArray(findKey.type) ? findKey.type[0] : findKey.type,
value = str, value = str,
values = findKey.values; values = findKey.values;
if (type == 'enum') { return type == 'enum' ? values[value] : value;
return values[value];
}
return value;
} }
function decodeValue(str) { function decodeValue(str) {
@ -531,6 +527,7 @@ Ox.URL = function(options) {
if (!state.span && /^[A-Z@]/.test(parts[0])) { if (!state.span && /^[A-Z@]/.test(parts[0])) {
// test for span id or name // test for span id or name
self.options.getSpan(state.item, state.view, parts[0].replace(/%20/g, ' '), function(span, view) { self.options.getSpan(state.item, state.view, parts[0].replace(/%20/g, ' '), function(span, view) {
Ox.Log('Core', 'span/view', span, view)
if (span) { if (span) {
if (!state.view) { if (!state.view) {
// set list or item view // set list or item view

View file

@ -82,6 +82,7 @@ Ox.AnnotationPanel = function(options, self) {
self.$annotations = Ox.ArrayEditable({ self.$annotations = Ox.ArrayEditable({
editable: self.options.editable, editable: self.options.editable,
items: getAnnotations(), items: getAnnotations(),
selected: self.options.selected,
sort: self.sort, sort: self.sort,
width: self.options.width, width: self.options.width,
type: self.options.type == 'text' ? 'textarea' : 'input' type: self.options.type == 'text' ? 'textarea' : 'input'
@ -104,20 +105,16 @@ Ox.AnnotationPanel = function(options, self) {
} }
self.$annotations.appendTo(that.$content); self.$annotations.appendTo(that.$content);
/* Ox.print('SOS', self.options.selected);
self.$annotations = Ox.Element() self.options.selected && setTimeout(function() {
.appendTo(that.$content); selectAnnotation({id: self.options.selected});
self.$annotation = []; }, 0);
self.options.items.forEach(function(item, i) {
self.$annotation[i] = Ox.Element() function editAnnotation(data) {
.addClass('OxAnnotation') var item = Ox.getObjectById(self.options.items, data.id);
.html(item.value.replace(/\n/g, '<br/>')) item.value = data.value;
.click(function() { that.triggerEvent('submit', item);
clickAnnotation(i); }
})
.appendTo(self.$annotations);
});
*/
function getAnnotations() { function getAnnotations() {
return self.options.items.filter(function(item) { return self.options.items.filter(function(item) {
@ -128,7 +125,7 @@ Ox.AnnotationPanel = function(options, self) {
) || ( ) || (
self.options.range == 'position' self.options.range == 'position'
&& item['in'] <= self.options.position && item['in'] <= self.options.position
&& item.out > self.options.position && item.out >= self.options.position
) )
}); });
} }
@ -144,12 +141,6 @@ Ox.AnnotationPanel = function(options, self) {
} : {})); } : {}));
} }
function editAnnotation(data) {
var item = Ox.getObjectById(self.options.items, data.id);
item.value = data.value;
that.triggerEvent('submit', item);
}
function togglePanel() { function togglePanel() {
} }

View file

@ -157,6 +157,8 @@ Ox.VideoEditor = function(options, self) {
margin: 8, margin: 8,
}); });
Ox.print('VIDEO EDITOR OPTIONS', self.options)
self.words = []; self.words = [];
Ox.forEach(Ox.count(Ox.words(self.options.subtitles.map(function(subtitle) { Ox.forEach(Ox.count(Ox.words(self.options.subtitles.map(function(subtitle) {
return subtitle.text; return subtitle.text;
@ -309,6 +311,8 @@ Ox.VideoEditor = function(options, self) {
self.$annotationPanel = []; self.$annotationPanel = [];
self.options.layers.forEach(function(layer, i) { self.options.layers.forEach(function(layer, i) {
var item = Ox.getObjectById(layer.items, self.options.selected),
selected = item ? item.id : '';
self.$annotationPanel[i] = Ox.AnnotationPanel( self.$annotationPanel[i] = Ox.AnnotationPanel(
Ox.extend({ Ox.extend({
font: self.options.annotationsFont, font: self.options.annotationsFont,
@ -316,7 +320,7 @@ Ox.VideoEditor = function(options, self) {
out: self.options.out, out: self.options.out,
position: self.options.position, position: self.options.position,
range: self.options.annotationsRange, range: self.options.annotationsRange,
// selected: self.options.selected, selected: selected,
sort: self.options.annotationsSort, sort: self.options.annotationsSort,
width: self.options.annotationsSize - Ox.UI.SCROLLBAR_SIZE width: self.options.annotationsSize - Ox.UI.SCROLLBAR_SIZE
}, layer) }, layer)
@ -338,13 +342,15 @@ Ox.VideoEditor = function(options, self) {
}); });
}, },
select: function(data) { select: function(data) {
if(data.id) { if (data.id) {
self.options.layers.forEach(function(layer_, i_) { self.options.layers.forEach(function(layer_, i_) {
if (i_ != i) { if (i_ != i) {
self.$annotationPanel[i_].deselectItems(); self.$annotationPanel[i_].deselectItems();
} }
}); });
selectAnnotation(data); selectAnnotation(data);
} else {
// ...
} }
}, },
submit: editAnnotation submit: editAnnotation
@ -873,9 +879,9 @@ Ox.VideoEditor = function(options, self) {
//Ox.Log('Video', 'getSizes', scrollbarIsVisible, height, self.options.height, size) //Ox.Log('Video', 'getSizes', scrollbarIsVisible, height, self.options.height, size)
return (!scrollbarIsVisible && height > self.options.height - 16) ? getSizes(true) : size; return (!scrollbarIsVisible && height > self.options.height - 16) ? getSizes(true) : size;
function getHeight() { function getHeight() {
return size.player[0].height + self.controlsHeight + return size.player[0].height + self.controlsHeight
size.timeline[0].height + lines * 16 + + size.timeline[0].height + lines * 16
(lines + 3) * self.margin; + (lines + 3) * self.margin;
} }
} }
@ -930,11 +936,14 @@ Ox.VideoEditor = function(options, self) {
function selectAnnotation(data) { function selectAnnotation(data) {
self.options.annotationsRange != 'position' && setPosition(data['in']); self.options.annotationsRange != 'position' && setPosition(data['in']);
setState(data.id ? 'selected' : 'default');
that.triggerEvent('select', {
id: data.id || ''
});
if (data.id) { if (data.id) {
setPoint('in', data['in']); setPoint('in', data['in']);
setPoint('out', data.out); setPoint('out', data.out);
} }
setState(data.id ? 'selected' : 'default');
} }
function select(type) { function select(type) {
@ -942,7 +951,7 @@ Ox.VideoEditor = function(options, self) {
setPoints(); setPoints();
} }
function setPoint(point, position) { function setPoint(point, position, annotation) {
var otherPoint = point == 'in' ? 'out' : 'in'; var otherPoint = point == 'in' ? 'out' : 'in';
self.options[point] = position; self.options[point] = position;
if (self.options.state == 'selected') { if (self.options.state == 'selected') {