X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widgets.js;h=2366614b7dcf2f456ca4cde2e9103812c34efb81;hb=016f2007ab90d0f3d0a8bcb552b7a8b1607081de;hp=ba42ff0d8e2851b98a1bbeab5aa610f5d1d1b87d;hpb=94b925b309c6dee3c2d4d09c455c5bd165f7c206;p=mkws-moved-to-github.git diff --git a/src/mkws-widgets.js b/src/mkws-widgets.js index ba42ff0..2366614 100644 --- a/src/mkws-widgets.js +++ b/src/mkws-widgets.js @@ -13,14 +13,14 @@ function widget($, team, type, node) { that.toString = function() { return '[Widget ' + team.name() + ':' + type + ']'; - } + }; var fn = mkws.promotionFunction(type); if (fn) { fn.call(that); log("made " + type + " widget(node=" + node + ")"); } else { - log("made UNENCAPSULATED widget(type=" + type + ", node=" + node + ")"); + log("made UNPROMOTED widget(type=" + type + ", node=" + node + ")"); } return that; @@ -32,7 +32,7 @@ function widget($, team, type, node) { // source files. -function promoteToTargets() { +mkws.registerWidgetType('Targets', function() { var that = this; var M = mkws.M; @@ -57,10 +57,10 @@ function promoteToTargets() { var subnode = $(that.node).children('.mkwsBytarget'); subnode.html(table); }); -} +}); -function promoteToStat() { +mkws.registerWidgetType('Stat', function() { var that = this; var M = mkws.M; @@ -73,10 +73,10 @@ function promoteToStat() { ' -- ' + '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ''); }); -} +}); -function promoteToTermlists() { +mkws.registerWidgetType('Termlists', function() { var that = this; var M = mkws.M; @@ -87,7 +87,8 @@ function promoteToTermlists() { } // no facets: this should never happen - if (!mkws_config.facets || mkws_config.facets.length == 0) { + var facets = mkws.config.facets; + if (!facets || facets.length == 0) { alert("onTerm called even though we have no facets: " + $.toJSON(data)); $(that.node).hide(); return; @@ -98,7 +99,6 @@ function promoteToTermlists() { var acc = []; acc.push('
' + M('Termlists') + '
'); - var facets = mkws_config.facets; for (var i = 0; i < facets.length; i++) { if (facets[i] == "xtargets") { @@ -138,10 +138,10 @@ function promoteToTermlists() { acc.push(''); } }); -} +}); -function promoteToPager() { +mkws.registerWidgetType('Pager', function() { var that = this; var M = mkws.M; @@ -202,10 +202,10 @@ function promoteToPager() { return s; } }); -} +}); -function promoteToRecords() { +mkws.registerWidgetType('Records', function() { var that = this; var team = this.team; @@ -233,10 +233,10 @@ function promoteToRecords() { return template(hit); } }); -} +}); -function promoteToNavi() { +mkws.registerWidgetType('Navi', function() { var that = this; var teamName = this.team.name(); var M = mkws.M; @@ -262,42 +262,35 @@ function promoteToNavi() { $(that.node).html(text); }); -} +}); -function promoteToSort() { - // It seems this and the Perpage widget doen't need to - // subscribe to anything, since they produce events rather - // than consuming them. - $(this.node).change(function () { - this.team.set_sortOrder($(node).val()); - if (this.team.submitted()) { - this.team.resetPage(); - this.team.reShow(); +// It seems this and the Perpage widget doen't need to subscribe to +// anything, since they produce events rather than consuming them. +// +mkws.registerWidgetType('Sort', function() { + var that = this; + + $(this.node).change(function() { + that.team.set_sortOrder($(that.node).val()); + if (that.team.submitted()) { + that.team.resetPage(); + that.team.reShow(); } return false; }); -} +}); -function promoteToPerpage() { +mkws.registerWidgetType('Perpage', function() { + var that = this; + $(this.node).change(function() { - this.team.set_perpage($(node).val()); - if (this.team.submitted()) { - this.team.resetPage(); - this.team.reShow(); + that.team.set_perpage($(that.node).val()); + if (that.team.submitted()) { + that.team.resetPage(); + that.team.reShow(); } return false; }); -} - -mkws.registerWidgetType('Targets', promoteToTargets); -mkws.registerWidgetType('Stat', promoteToStat); -mkws.registerWidgetType('Termlists', promoteToTermlists); -mkws.registerWidgetType('Pager', promoteToPager); -mkws.registerWidgetType('Records', promoteToRecords); -mkws.registerWidgetType('Navi', promoteToNavi); -mkws.registerWidgetType('Sort', promoteToSort); -mkws.registerWidgetType('Perpage', promoteToPerpage); - - +});