cancel/save button for annotations

This commit is contained in:
j 2011-02-21 18:31:02 +01:00
parent fb6d793772
commit e698fda8c2

View file

@ -7694,10 +7694,12 @@ requires
var width = $item.width(), // fixme: don't lookup in DOM var width = $item.width(), // fixme: don't lookup in DOM
height = $item.height(); height = $item.height();
$item $item
.height(height + 8) .height(height + 8 + 16)
.empty() .empty()
.addClass('OxEdit'); .addClass('OxEdit');
$input = new Ox.Input({
new Ox.Element()
.append($input = new Ox.Input({
height: height, height: height,
style: 'square', style: 'square',
type: 'textarea', type: 'textarea',
@ -7710,11 +7712,38 @@ requires
e.stopPropagation(); e.stopPropagation();
} }
}) })
)
.append(new Ox.Element()
.append(
new Ox.Button({type: 'text', title: 'Cancel'})
.css('width', '42%')
.bindEvent({ .bindEvent({
blur: submit, 'click': cancel
}) })
.appendTo($item.$element) )
.gainFocus(); .append(
new Ox.Button({type: 'text', title: 'Save'})
.css('width', '42%')
.bindEvent({
'click': submit
})
).css({
'margin-top': height-8,
'height': '16px',
'text-align': 'right',
})
)
.appendTo($item.$element);
//gain focus async, otherwise enter gets
//passed on to input and removes all data
setTimeout(function() {
$input.gainFocus();
$input.focus();
});
function cancel() {
$item.options('data', item);
//fixme: trigger event to reset i/o points
}
function submit() { function submit() {
item.value = $input.value(); item.value = $input.value();
//$input.loseFocus().remove(); //$input.loseFocus().remove();
@ -12166,6 +12195,8 @@ requires
setPoints(); setPoints();
} }
function updateAnnotation(event, data) { function updateAnnotation(event, data) {
data.in = self.options.points[0];
data.out = self.options.points[1];
that.triggerEvent('updateAnnotation', data); that.triggerEvent('updateAnnotation', data);
} }