From cf7ed2625456a5e619f68408f8ebfe78f443a672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Asbj=C3=B8rn=20Sloth=20T=C3=B8nnesen?= Date: Tue, 10 Jul 2012 19:51:16 +0000 Subject: upgrade to bootstrap 2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Asbjørn Sloth Tønnesen --- web/js/labitrack.d/38-labelform.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'web/js/labitrack.d/38-labelform.js') diff --git a/web/js/labitrack.d/38-labelform.js b/web/js/labitrack.d/38-labelform.js index 04031cf..6136e6b 100644 --- a/web/js/labitrack.d/38-labelform.js +++ b/web/js/labitrack.d/38-labelform.js @@ -4,13 +4,15 @@ var model = opts.model; var canvas = $('#label')[0]; var label = new λ.label(); - label.set_data(model.toJSON()); label.set_canvas(canvas); var rendertime = $('#rendertime'); - function updateimg(data, ms) { - rendertime.text(ms); - } + (label.trigger_refresh = function(){ + label.set_data(model.toJSON()); + label.render(function(data, ms){ + rendertime.text(ms); + }); + })(); var f = $('#labelform'); function update_data(){ @@ -40,8 +42,7 @@ break; } model.set(foo); - label.set_data(model.toJSON()); - label.render(updateimg); + label.trigger_refresh(); }, 0); }; f.find(':input').each(function (i,e){ @@ -50,10 +51,29 @@ $(e).bind('change', update_data); update_data.apply(this); }); - label.render(updateimg); + + print = null; + + submit_btn = f.find('button[type="submit"]'); + + f.find('a#saveandprint').bind('click', function(){ + print = true; + submit_btn.click(); + }); + + f.find('a#justsave').bind('click', function(){ + print = false; + submit_btn.click(); + }); + + reset_btn = f.find('button[type="reset"]'); + + f.find('a#reset').bind('click', function(){ + reset_btn.click(); + }); f.bind('submit', function(){ - opts.submit(label, model); + opts.submit(label, model, print); return false; }); }; -- cgit v1.2.1