diff options
author | Asbjørn Sloth Tønnesen <asbjorn@asbjorn.biz> | 2012-07-10 19:51:16 +0000 |
---|---|---|
committer | Asbjørn Sloth Tønnesen <asbjorn@asbjorn.biz> | 2012-07-10 19:51:16 +0000 |
commit | cf7ed2625456a5e619f68408f8ebfe78f443a672 (patch) | |
tree | ae6787275ea9b9b8bd29e320c55bb3dbcbb62d30 /web/js/labitrack.d/38-labelform.js | |
parent | 5e54ba7aa27b95d1e0568693915e735ab8058ff7 (diff) | |
download | labitrack-cf7ed2625456a5e619f68408f8ebfe78f443a672.tar.gz labitrack-cf7ed2625456a5e619f68408f8ebfe78f443a672.tar.xz labitrack-cf7ed2625456a5e619f68408f8ebfe78f443a672.zip |
upgrade to bootstrap 2
Signed-off-by: Asbjørn Sloth Tønnesen <asbjorn@asbjorn.biz>
Diffstat (limited to 'web/js/labitrack.d/38-labelform.js')
-rw-r--r-- | web/js/labitrack.d/38-labelform.js | 36 |
1 files changed, 28 insertions, 8 deletions
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; }); }; |