From e698fda8c2b042e1cd44572fbb850bfaebdadccf Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 21 Feb 2011 18:31:02 +0100 Subject: [PATCH] cancel/save button for annotations --- build/js/ox.ui.js | 69 ++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 19 deletions(-) diff --git a/build/js/ox.ui.js b/build/js/ox.ui.js index 2a6c52f1..ddafafc4 100644 --- a/build/js/ox.ui.js +++ b/build/js/ox.ui.js @@ -7694,27 +7694,56 @@ requires var width = $item.width(), // fixme: don't lookup in DOM height = $item.height(); $item - .height(height + 8) + .height(height + 8 + 16) .empty() .addClass('OxEdit'); - $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(); - } - }) - .bindEvent({ - blur: submit, - }) - .appendTo($item.$element) - .gainFocus(); + + 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 + 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(); //$input.loseFocus().remove(); @@ -12166,6 +12195,8 @@ requires setPoints(); } function updateAnnotation(event, data) { + data.in = self.options.points[0]; + data.out = self.options.points[1]; that.triggerEvent('updateAnnotation', data); }