X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widgets.js;h=b286705e50597a9b8d40b2a827634fc38637d02d;hb=acc4c917f360440927547e958ebd32b1d2aca711;hp=2154f5a2c5fffbd68a55832858113cafcb1f5efb;hpb=ecc63de02627f2300669a086befc31600c2efcd0;p=mkws-moved-to-github.git diff --git a/src/mkws-widgets.js b/src/mkws-widgets.js index 2154f5a..b286705 100644 --- a/src/mkws-widgets.js +++ b/src/mkws-widgets.js @@ -28,8 +28,9 @@ function widget($, team, type, node) { // Functions follow for promoting the regular widget object into -// widgets of specific types. These could be moved outside of the -// widget object, or even into their own source files. +// widgets of specific types. These could be moved into their own +// source files. + function promoteToTargets() { var that = this; @@ -57,6 +58,7 @@ function promoteToTargets() { subnode.html(table); }); } +mkws.registerWidgetType('Targets', promoteToTargets); function promoteToStat() { @@ -73,6 +75,7 @@ function promoteToStat() { '' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + ''); }); } +mkws.registerWidgetType('Stat', promoteToStat); function promoteToTermlists() { @@ -138,6 +141,7 @@ function promoteToTermlists() { } }); } +mkws.registerWidgetType('Termlists', promoteToTermlists); function promoteToPager() { @@ -202,6 +206,7 @@ function promoteToPager() { } }); } +mkws.registerWidgetType('Pager', promoteToPager); function promoteToRecords() { @@ -233,6 +238,7 @@ function promoteToRecords() { } }); } +mkws.registerWidgetType('Records', promoteToRecords); function promoteToNavi() { @@ -262,41 +268,36 @@ 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() { - // It seems this and the Perpage widget doen't need to - // subscribe to anything, since they produce events rather - // than consuming them. + var that = this; + $(this.node).change(function () { - this.team.set_sortOrder($(node).val()); - if (this.team.submitted()) { - this.team.resetPage(); - this.team.reShow(); + that.team.set_sortOrder($(that.node).val()); + if (that.team.submitted()) { + that.team.resetPage(); + that.team.reShow(); } return false; }); } +mkws.registerWidgetType('Sort', promoteToSort); + +mkws.registerWidgetType('Perpage', function() { + var that = this; -function promoteToPerpage() { $(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); - - +});