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": {
"level": "guest",
"ui": {
"annotationsCalendarSize": 192,
"annotationsCalendarSize": 128,
"annotationsFont": "small",
"annotationsMapSize": 192,
"annotationsMapSize": 128,
"annotationsRange": "position",
"annotationsSize": 256,
"annotationsSort": "position",

View file

@ -271,17 +271,16 @@ pandora.ui.item = function() {
}).bindEvent({
addannotation: function(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'],
item: pandora.user.ui.item,
layer: data.layer,
out: data.out,
value: data.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);
value: '',
});
});
},
annotationsfont: function(data) {
@ -317,19 +316,26 @@ pandora.ui.item = function() {
},
editannotation: function(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({
id: data.id,
'in': data['in'],
out: data.out,
value: data.value,
}, function(result) {
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);
});
value: data.value
}, callback);
}
},
embedSelection: function(data) {
pandora.$ui.embedDialog && pandora.$ui.embedDialog.remove();