X-Git-Url: http://sru.miketaylor.org.uk/?a=blobdiff_plain;f=src%2Fmkws-widget-builder.js;h=6468e869f54903903abf67a77a8a23d1a0e02906;hb=f46b615e92b693ca8bea0eb3fb0fab65c4fbf46e;hp=fb8491cb8c2a192970b27420fd089fc5985d26e6;hpb=bf93a005d881d9db885eb9b5f8c82e9e00001f6f;p=mkws-moved-to-github.git diff --git a/src/mkws-widget-builder.js b/src/mkws-widget-builder.js index fb8491c..6468e86 100644 --- a/src/mkws-widget-builder.js +++ b/src/mkws-widget-builder.js @@ -1,20 +1,29 @@ mkws.registerWidgetType('Builder', function() { - var team = this.team; + var that = this; + var team = this.team; - this.button = $('', { - type: 'button', - text: this.config.text || "Build!" - }); - $(this.node).append(this.button); - this.button.click(function() { - var query = team.widget('Query').value(); - var sort = team.widget('Sort').value(); - var perpage = team.widget('Perpage').value(); + var button = mkws.$('', { + type: 'button', + text: this.config.text || "Build!" + }); + this.node.append(button); + button.click(function() { + var query = team.widget('Query').value(); + var sort = team.widget('Sort').value(); + var perpage = team.widget('Perpage').value(); - var html = ('
'); - alert(html); - }); + var html = (''); + var fn = that.callback || alert; + fn(html); + }); +}); + +mkws.registerWidgetType('ConsoleBuilder', function() { + mkws.promotionFunction('Builder').call(this); + this.callback = function(s) { + console.log("generated widget: " + s); + } });