add/remove annotations
This commit is contained in:
parent
bb6ddcc3dd
commit
fb6d793772
1 changed files with 72 additions and 35 deletions
|
@ -7690,9 +7690,8 @@ requires
|
|||
var $input,
|
||||
item = self.options.items[pos],
|
||||
$item = self.$items[pos];
|
||||
Ox.print('****', $item)
|
||||
var html = $item.$element.html(),
|
||||
width = $item.width(), // fixme: don't lookup in DOM
|
||||
Ox.print('****', item, $item)
|
||||
var width = $item.width(), // fixme: don't lookup in DOM
|
||||
height = $item.height();
|
||||
$item
|
||||
.height(height + 8)
|
||||
|
@ -7756,19 +7755,31 @@ requires
|
|||
};
|
||||
|
||||
that.removeItems = function(pos, length) {
|
||||
Ox.range(pos, pos + length).forEach(function(i) {
|
||||
self.selected.indexOf(i) > -1 && deselect(i);
|
||||
self.$items[i].remove();
|
||||
});
|
||||
self.options.items.splice(pos, length);
|
||||
self.$items.splice(pos, length);
|
||||
self.selected.forEach(function(v, i) {
|
||||
if (v >= pos + length) {
|
||||
self.selected[i] -= length;
|
||||
}
|
||||
});
|
||||
updatePositions();
|
||||
}
|
||||
/*
|
||||
removeItems(ids)
|
||||
or
|
||||
removeItems(pos, length)
|
||||
*/
|
||||
if(!length) { //pos is list of ids
|
||||
pos.forEach(function(id) {
|
||||
var p = getPositionById(id);
|
||||
that.removeItems(p, 1);
|
||||
});
|
||||
} else { //remove items from pos to pos+length
|
||||
Ox.range(pos, pos + length).forEach(function(i) {
|
||||
self.selected.indexOf(i) > -1 && deselect(i);
|
||||
self.$items[i].remove();
|
||||
});
|
||||
self.options.items.splice(pos, length);
|
||||
self.$items.splice(pos, length);
|
||||
self.selected.forEach(function(v, i) {
|
||||
if (v >= pos + length) {
|
||||
self.selected[i] -= length;
|
||||
}
|
||||
});
|
||||
updatePositions();
|
||||
}
|
||||
}
|
||||
|
||||
that.scrollToSelection = function() {
|
||||
self.selected.length && scrollToPosition(self.selected[0]);
|
||||
|
@ -10737,6 +10748,10 @@ requires
|
|||
style: 'symbol',
|
||||
title: 'Add',
|
||||
type: 'image'
|
||||
}).bindEvent({
|
||||
click: function(event, data) {
|
||||
that.triggerEvent('add', {value: ''});
|
||||
}
|
||||
})
|
||||
],
|
||||
size: 16,
|
||||
|
@ -10764,10 +10779,15 @@ requires
|
|||
})
|
||||
.bindEvent({
|
||||
open: function(event, data) {
|
||||
if (data.ids.length == 1)
|
||||
self.$annotations.editItem(data.ids[0]);
|
||||
if (data.ids.length == 1) {
|
||||
var pos = Ox.getPositionById(self.$annotations.options('items'), data.ids[0]);
|
||||
self.$annotations.editItem(pos);
|
||||
|
||||
}
|
||||
},
|
||||
'delete': function(event, data) {
|
||||
that.triggerEvent('delete', data);
|
||||
},
|
||||
//edit: editAnnotation,
|
||||
select: selectAnnotation,
|
||||
submit: updateAnnotation
|
||||
})
|
||||
|
@ -10787,21 +10807,6 @@ requires
|
|||
.appendTo(self.$annotations);
|
||||
});
|
||||
*/
|
||||
/* done in list now
|
||||
function editAnnotation(event, data) {
|
||||
return;
|
||||
var pos = parseInt(data.id),
|
||||
item = self.options.items[pos];
|
||||
self.$annotation[pos].html(
|
||||
new Ox.Input({
|
||||
height: 128,
|
||||
type: 'textarea',
|
||||
value: item.value,
|
||||
width: self.options.width
|
||||
})
|
||||
);
|
||||
}
|
||||
*/
|
||||
function selectAnnotation(event, data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.ids[0]);
|
||||
that.triggerEvent('select', {
|
||||
|
@ -10819,6 +10824,17 @@ requires
|
|||
|
||||
}
|
||||
|
||||
that.addItem = function(item) {
|
||||
var pos = 0;
|
||||
self.options.items.splice(pos, 0, item);
|
||||
self.$annotations.addItems(pos, [item]);
|
||||
self.$annotations.editItem(pos);
|
||||
}
|
||||
|
||||
that.removeItems = function(ids) {
|
||||
self.$annotations.removeItems(ids);
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
@ -11895,9 +11911,20 @@ requires
|
|||
}, layer)
|
||||
)
|
||||
.bindEvent({
|
||||
add: function(event, data) {
|
||||
data.layer = layer.id;
|
||||
data.in = self.options.points[0];
|
||||
data.out = self.options.points[1];
|
||||
that.triggerEvent('addAnnotation', data);
|
||||
},
|
||||
'delete': function(event, data) {
|
||||
data.layer = layer.id;
|
||||
that.triggerEvent('removeAnnotations', data);
|
||||
},
|
||||
select: selectAnnotation,
|
||||
submit: updateAnnotation
|
||||
})
|
||||
});
|
||||
self.$annotationPanel[i]
|
||||
.appendTo(self.$annotations);
|
||||
});
|
||||
|
||||
|
@ -12234,6 +12261,16 @@ requires
|
|||
}
|
||||
};
|
||||
|
||||
that.addAnnotation = function(layer, item) {
|
||||
var i = Ox.getPositionById(self.options.layers, layer);
|
||||
self.$annotationPanel[i].addItem(item);
|
||||
}
|
||||
|
||||
that.removeAnnotations = function(layer, ids) {
|
||||
var i = Ox.getPositionById(self.options.layers, layer);
|
||||
self.$annotationPanel[i].removeItems(ids);
|
||||
}
|
||||
|
||||
return that;
|
||||
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue