move Item edit into its own widget

This commit is contained in:
j 2011-02-22 10:34:43 +01:00
parent e698fda8c2
commit 94fb1b4d1d

View file

@ -7698,54 +7698,27 @@ requires
.empty()
.addClass('OxEdit');
new Ox.Element()
.append($input = new Ox.Input({
height: height,
style: 'square',
type: 'textarea',
value: item.value,
width: width + 6
})
.bind({
mousedown: function(e) {
// keep mousedown from reaching list
e.stopPropagation();
}
})
)
.append(new Ox.Element()
.append(
new Ox.Button({type: 'text', title: 'Cancel'})
.css('width', '42%')
.bindEvent({
'click': cancel
})
)
.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
$input = new Ox.ItemInput({
type: 'textarea',
value: item.value,
height: height,
width: width
}).bindEvent({
cancel: cancel,
save: submit
}).appendTo($item.$element);
/*
setTimeout(function() {
$input.gainFocus();
$input.focus();
});
*/
function cancel() {
$item.options('data', item);
//fixme: trigger event to reset i/o points
}
function submit() {
item.value = $input.value();
function submit(event, data) {
item.value = data.value;
//$input.loseFocus().remove();
// fixme: leaky, inputs remain in focus stack
$item.options('data', item);
@ -7883,6 +7856,59 @@ requires
};
Ox.ItemInput = function(options, self) {
var self = self || {},
that = new Ox.Element({}, self)
.defaults({
type: 'textarea',
value: '',
height: 300,
width: 100
})
.options(options || {}),
$input;
that.append($input = new Ox.Input({
height: self.options.height,
style: 'square',
type: self.options.type,
value: self.options.value,
width: self.options.width + 6
})
.bind({
mousedown: function(e) {
// keep mousedown from reaching list
e.stopPropagation();
}
}))
.append(new Ox.Element()
.append(new Ox.Button({type: 'text', title: 'Cancel'})
.css('width', '42%')
.bindEvent({
'click': function() {
that.triggerEvent('cancel');
}
}))
.append(new Ox.Button({type: 'text', title: 'Save'})
.css('width', '42%')
.bindEvent({
'click': function() {
that.triggerEvent('save', {
value: $input.value()
});
}
}))
.css({
'margin-top': self.options.height-8,
'height': '16px',
'text-align': 'right',
})
);
Ox.print($input);
return that;
}
Ox.ListItem = function(options, self) {
var self = self || {},
@ -10840,7 +10866,8 @@ requires
var item = Ox.getObjectById(self.options.items, data.ids[0]);
that.triggerEvent('select', {
'in': item.in,
'out': item.out
'out': item.out,
'layer': self.options.id
});
}
function updateAnnotation(event, data) {