From 5435f53702160660e52f38d5b62dcc833b5fc664 Mon Sep 17 00:00:00 2001 From: Maxime Beauchemin Date: Fri, 18 Dec 2015 15:08:09 -0800 Subject: [PATCH] Passing a controller object to widget --- panoramix/static/panoramix.js | 15 ++++++++++++--- panoramix/static/widgets/viz_table.js | 2 +- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/panoramix/static/panoramix.js b/panoramix/static/panoramix.js index a408514017..c4f0ca016c 100644 --- a/panoramix/static/panoramix.js +++ b/panoramix/static/panoramix.js @@ -25,7 +25,8 @@ var px = (function() { dttm += 10; $('#timer').text(Math.round(dttm/10)/100 + " sec"); } - var done = function (data) { + var controler = { + done: function (data) { clearInterval(timer); token.find("img.loading").hide(); if(data !== undefined) @@ -33,11 +34,19 @@ var px = (function() { $('#timer').removeClass('btn-warning'); $('span.query').removeClass('disabled'); $('#timer').addClass('btn-success'); - } + }, + error: function (data) { + clearInterval(timer); + token.find("img.loading").hide(); + $('#timer').removeClass('btn-warning'); + $('span.query').removeClass('disabled'); + $('#timer').addClass('btn-error'); + } + }; widget = { render: function() { timer = setInterval(stopwatch, 10); - user_defined_widget.render(done); + user_defined_widget.render(controler); }, resize: function() { user_defined_widget.resize(); diff --git a/panoramix/static/widgets/viz_table.js b/panoramix/static/widgets/viz_table.js index 5f628a28d2..024addd2ca 100644 --- a/panoramix/static/widgets/viz_table.js +++ b/panoramix/static/widgets/viz_table.js @@ -55,7 +55,7 @@ px.registerWidget('table', function(data_attribute) { var err = '
' + xhr.responseText + '
'; token.html(err); token.show(); - done(); + ctrl.done(); }); }