X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widgets.js;h=2366614b7dcf2f456ca4cde2e9103812c34efb81;hb=c4848ba08bb08b8dcb6d191869d876c19f23ad6e;hp=b29538efbf13834d73cf5dbeafbe7c1954b80233;hpb=e2693f1f51590458bc20b23bb03701385529740f;p=mkws-moved-to-github.git diff --git a/src/mkws-widgets.js b/src/mkws-widgets.js index b29538e..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,11 +57,10 @@ function promoteToTargets() { var subnode = $(that.node).children('.mkwsBytarget'); subnode.html(table); }); -} -mkws.registerWidgetType('Targets', promoteToTargets); +}); -function promoteToStat() { +mkws.registerWidgetType('Stat', function() { var that = this; var M = mkws.M; @@ -74,11 +73,10 @@ function promoteToStat() { ' -- ' + '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ''); }); -} -mkws.registerWidgetType('Stat', promoteToStat); +}); -function promoteToTermlists() { +mkws.registerWidgetType('Termlists', function() { var that = this; var M = mkws.M; @@ -89,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; @@ -100,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") { @@ -140,11 +138,10 @@ function promoteToTermlists() { acc.push(''); } }); -} -mkws.registerWidgetType('Termlists', promoteToTermlists); +}); -function promoteToPager() { +mkws.registerWidgetType('Pager', function() { var that = this; var M = mkws.M; @@ -205,11 +202,10 @@ function promoteToPager() { return s; } }); -} -mkws.registerWidgetType('Pager', promoteToPager); +}); -function promoteToRecords() { +mkws.registerWidgetType('Records', function() { var that = this; var team = this.team; @@ -237,11 +233,10 @@ function promoteToRecords() { return template(hit); } }); -} -mkws.registerWidgetType('Records', promoteToRecords); +}); -function promoteToNavi() { +mkws.registerWidgetType('Navi', function() { var that = this; var teamName = this.team.name(); var M = mkws.M; @@ -267,17 +262,16 @@ function promoteToNavi() { $(that.node).html(text); }); -} -mkws.registerWidgetType('Navi', promoteToNavi); +}); // It seems this and the Perpage widget doen't need to subscribe to // anything, since they produce events rather than consuming them. // -function promoteToSort() { +mkws.registerWidgetType('Sort', function() { var that = this; - $(this.node).change(function () { + $(this.node).change(function() { that.team.set_sortOrder($(that.node).val()); if (that.team.submitted()) { that.team.resetPage(); @@ -285,11 +279,10 @@ function promoteToSort() { } return false; }); -} -mkws.registerWidgetType('Sort', promoteToSort); +}); -function promoteToPerpage() { +mkws.registerWidgetType('Perpage', function() { var that = this; $(this.node).change(function() { @@ -300,5 +293,4 @@ function promoteToPerpage() { } return false; }); -} -mkws.registerWidgetType('Perpage', promoteToPerpage); +});