forked from 0x2620/oxjs
update video editor (maps, calendars)
This commit is contained in:
parent
dc47e901ad
commit
961f4f959a
6 changed files with 62 additions and 71 deletions
|
|
@ -42,6 +42,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
})
|
||||
.options(options || {});
|
||||
|
||||
self.annotations = getAnnotations();
|
||||
self.points = getPoints();
|
||||
self.position = self.options.position;
|
||||
self.sort = getSort();
|
||||
|
|
@ -181,7 +182,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
|
||||
self.$annotations = Ox.ArrayEditable({
|
||||
editable: self.options.editable,
|
||||
items: getAnnotations(),
|
||||
items: self.annotations,
|
||||
placeholder: 'No ' + self.options.title,
|
||||
selected: self.options.selected,
|
||||
separator: ';',
|
||||
|
|
@ -204,10 +205,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
that.triggerEvent('blur');
|
||||
},
|
||||
change: changeAnnotation,
|
||||
'delete': function(data) {
|
||||
self.editing = false;
|
||||
that.triggerEvent('remove', {id: data.id});
|
||||
},
|
||||
'delete': removeAnnotation,
|
||||
edit: function() {
|
||||
self.editing = true;
|
||||
that.triggerEvent('edit');
|
||||
|
|
@ -303,7 +301,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
|
||||
function getEvents() {
|
||||
var events = [];
|
||||
getAnnotations().filter(function(item) {
|
||||
self.annotations.filter(function(item) {
|
||||
return !!item.event;
|
||||
}).forEach(function(item) {
|
||||
var index = Ox.getIndexById(events, item.event.id);
|
||||
|
|
@ -320,7 +318,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
|
||||
function getPlaces() {
|
||||
var places = [];
|
||||
getAnnotations().filter(function(item) {
|
||||
self.annotations.filter(function(item) {
|
||||
return !!item.place;
|
||||
}).forEach(function(item) {
|
||||
var index = Ox.getIndexById(places, item.place.id);
|
||||
|
|
@ -343,6 +341,25 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
})[self.options.sort];
|
||||
}
|
||||
|
||||
function removeAnnotation(data) {
|
||||
var item;
|
||||
Ox.print('REMOVE:::::::::', data)
|
||||
self.editing = false;
|
||||
if (self.widget) {
|
||||
item = Ox.getObjectById(self.options.items, data.id);
|
||||
if (item[self.options.type]) {
|
||||
if (self.options.type == 'event') {
|
||||
self.$calendar.removeEvent(data.id);
|
||||
} else {
|
||||
self.$map.removePlace(data.id)
|
||||
.options({selected: ''}) // deselect resultPlace
|
||||
.triggerEvent('key_escape'); // remove resultPlace
|
||||
}
|
||||
}
|
||||
}
|
||||
that.triggerEvent('remove', {id: data.id});
|
||||
}
|
||||
|
||||
function selectAnnotation(data) {
|
||||
Ox.print('SELECT annotation', data)
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
|
|
@ -369,15 +386,13 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
|
||||
function showWarnings() {
|
||||
if (self.widget && self.options.items.length) {
|
||||
self.$annotations.find('.OxValue').each(function() {
|
||||
self.$annotations.find('.OxEditableElement').each(function() {
|
||||
var $element = $(this);
|
||||
try { // FIXME: bad data, remove later!!
|
||||
if (!Ox.getObject(
|
||||
self.options.items, 'value', $element.html()
|
||||
)[self.options.type]) {
|
||||
$element.css({color: 'rgb(192, 64, 64)'});
|
||||
}
|
||||
} catch(e) {}
|
||||
if (!Ox.getObjectById(
|
||||
self.options.items, $element.data('id')
|
||||
)[self.options.type]) {
|
||||
$element.addClass('OxWarning');
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -408,14 +423,14 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
}
|
||||
|
||||
function updateAnnotations() {
|
||||
self.$annotations.options({items: getAnnotations()});
|
||||
self.annotations = getAnnotations();
|
||||
self.$annotations.options({items: self.annotations});
|
||||
showWarnings();
|
||||
}
|
||||
|
||||
function updateWidget() {
|
||||
self.options.type == 'event'
|
||||
? self.$calendar.options({events: getEvents()})
|
||||
: self.$map.options({places: getPlaces()});
|
||||
if (self.widget) {
|
||||
self.options.type == 'event'
|
||||
? self.$calendar.options({events: getEvents()})
|
||||
: self.$map.options({places: getPlaces()});
|
||||
}
|
||||
}
|
||||
|
||||
self.setOption = function(key, value) {
|
||||
|
|
@ -427,25 +442,15 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
}
|
||||
if (key == 'in') {
|
||||
//fixme: array editable should support item updates while editing
|
||||
if (self.options.range == 'selection') {
|
||||
self.widget && updateWidget();
|
||||
updateAnnotations();
|
||||
}
|
||||
self.options.range == 'selection' && updateAnnotations();
|
||||
} else if (key == 'out') {
|
||||
if (self.options.range == 'selection') {
|
||||
self.widget && updateWidget();
|
||||
updateAnnotations();
|
||||
}
|
||||
self.options.range == 'selection' && updateAnnotations();
|
||||
} else if (key == 'position') {
|
||||
if (self.options.range == 'position') {
|
||||
if (crossesPoint()) {
|
||||
self.widget && updateWidget();
|
||||
updateAnnotations();
|
||||
}
|
||||
crossesPoint() && updateAnnotations();
|
||||
self.position = self.options.position;
|
||||
}
|
||||
} else if (key == 'range') {
|
||||
self.widget && updateWidget();
|
||||
updateAnnotations();
|
||||
} else if (key == 'selected') {
|
||||
if (value === '') {
|
||||
|
|
@ -486,6 +491,7 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
.addItem(pos, item)
|
||||
.options({selected: item.id})
|
||||
.editItem();
|
||||
showWarnings();
|
||||
//selectAnnotation(item);
|
||||
//that.triggerEvent('edit');
|
||||
return that;
|
||||
|
|
@ -517,15 +523,13 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
that.updateItem = function(item) {
|
||||
var index = Ox.getIndexById(self.options.items, item.id);
|
||||
self.options.items[index] = item;
|
||||
if (self.widget) {
|
||||
updateWidget();
|
||||
if (item[self.options.type]) {
|
||||
// if updating has made the item match
|
||||
// an event / a place, then select it
|
||||
self.$widget.options({selected: item[self.options.type].id});
|
||||
}
|
||||
}
|
||||
updateAnnotations();
|
||||
Ox.print('updating.......', item[self.options.type])
|
||||
if (self.widget && item[self.options.type]) {
|
||||
// if updating has made the item match
|
||||
// an event / a place, then select it
|
||||
self.$widget.options({selected: item[self.options.type].id});
|
||||
}
|
||||
return that;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue