Move mkws.log out of immediate-execute wrapper.
[mkws-moved-to-github.git] / src / mkws-widgets.js
index 4173301..78e98cf 100644 (file)
@@ -20,7 +20,7 @@ function widget($, team, type, node) {
        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() {
            ' -- ' +
            '<span class="records">' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + '</span>');
     });
-}
-mkws.registerWidgetType('Stat', promoteToStat);
+});
 
 
-function promoteToTermlists() {
+mkws.registerWidgetType('Termlists', function() {
     var that = this;
     var M = mkws.M;
 
@@ -140,11 +138,10 @@ function promoteToTermlists() {
            acc.push('</div>');
        }
     });
-}
-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,34 +262,35 @@ 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() {
-    $(this.node).change(function () {
-       this.team.set_sortOrder($(node).val());
-       if (this.team.submitted()) {
-           this.team.resetPage();
-           this.team.reShow();
+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;
     });
-}
-mkws.registerWidgetType('Sort', promoteToSort);
+});
 
 
-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('Perpage', promoteToPerpage);
+});