dont wait for server adding new annotations

This commit is contained in:
j 2012-01-31 10:54:22 +00:00
parent 256dcd956d
commit caf8630d61
2 changed files with 32 additions and 26 deletions

View file

@ -516,9 +516,9 @@
"user": { "user": {
"level": "guest", "level": "guest",
"ui": { "ui": {
"annotationsCalendarSize": 192, "annotationsCalendarSize": 128,
"annotationsFont": "small", "annotationsFont": "small",
"annotationsMapSize": 192, "annotationsMapSize": 128,
"annotationsRange": "position", "annotationsRange": "position",
"annotationsSize": 256, "annotationsSize": 256,
"annotationsSort": "position", "annotationsSort": "position",

View file

@ -271,17 +271,16 @@ pandora.ui.item = function() {
}).bindEvent({ }).bindEvent({
addannotation: function(data) { addannotation: function(data) {
Ox.Log('', 'addAnnotation', data); Ox.Log('', 'addAnnotation', data);
pandora.api.addAnnotation({ //async to not capture keyboard input
setTimeout(function() {
pandora.$ui.editor.addAnnotation(data.layer, {
duration: data.out - data['in'],
editable: true,
id: '_' + Ox.uid(),
'in': data['in'], 'in': data['in'],
item: pandora.user.ui.item,
layer: data.layer,
out: data.out, out: data.out,
value: data.value, value: '',
}, function(result) { });
// fixme: both should come from backend
result.data.duration = result.data.out - result.data['in'];
result.data.editable = true;
pandora.$ui.editor.addAnnotation(data.layer, result.data);
}); });
}, },
annotationsfont: function(data) { annotationsfont: function(data) {
@ -317,19 +316,26 @@ pandora.ui.item = function() {
}, },
editannotation: function(data) { editannotation: function(data) {
Ox.Log('', 'editAnnotation', data); Ox.Log('', 'editAnnotation', data);
//fixme: check that edit was successfull function callback(result) {
Ox.Log('', 'editAnnotation result', result);
pandora.$ui.editor.updateAnnotation(data.id, result.data);
};
if (data.id[0] == '_') {
pandora.api.addAnnotation({
'in': data['in'],
item: pandora.user.ui.item,
layer: data.layer,
out: data.out,
value: data.value
}, callback);
} else {
pandora.api.editAnnotation({ pandora.api.editAnnotation({
id: data.id, id: data.id,
'in': data['in'], 'in': data['in'],
out: data.out, out: data.out,
value: data.value, value: data.value
}, function(result) { }, callback);
Ox.print('', 'editAnnotation result', result); }
// fixme: both should come from backend
result.data.duration = result.data.out - result.data['in'];
result.data.editable = true;
pandora.$ui.editor.updateAnnotation(result.data);
});
}, },
embedSelection: function(data) { embedSelection: function(data) {
pandora.$ui.embedDialog && pandora.$ui.embedDialog.remove(); pandora.$ui.embedDialog && pandora.$ui.embedDialog.remove();