X-Git-Url: http://jsfdemo.indexdata.com/?a=blobdiff_plain;f=src%2Fmkws-widgets.js;h=2366614b7dcf2f456ca4cde2e9103812c34efb81;hb=c4848ba08bb08b8dcb6d191869d876c19f23ad6e;hp=cd66272cc1cbc6e3e80f3c680ae66f917063c577;hpb=1e35eba08343dc5278c88446bd680a46ba6c3a7e;p=mkws-moved-to-github.git
diff --git a/src/mkws-widgets.js b/src/mkws-widgets.js
index cd66272..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 promote = mkws.promotionFunction(type);
- if (promote) {
- promote.call(that);
+ 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;
@@ -28,10 +28,11 @@ 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 promoteTargets() {
+mkws.registerWidgetType('Targets', function() {
var that = this;
var M = mkws.M;
@@ -56,10 +57,10 @@ function promoteTargets() {
var subnode = $(that.node).children('.mkwsBytarget');
subnode.html(table);
});
-}
+});
-function promoteStat() {
+mkws.registerWidgetType('Stat', function() {
var that = this;
var M = mkws.M;
@@ -72,10 +73,10 @@ function promoteStat() {
' -- ' +
'' + M('Retrieved records') + ': ' + data.records + '/' + data.hits + '');
});
-}
+});
-function promoteTermlists() {
+mkws.registerWidgetType('Termlists', function() {
var that = this;
var M = mkws.M;
@@ -86,7 +87,8 @@ function promoteTermlists() {
}
// 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;
@@ -97,7 +99,6 @@ function promoteTermlists() {
var acc = [];
acc.push('
' + M('Termlists') + '
');
- var facets = mkws_config.facets;
for (var i = 0; i < facets.length; i++) {
if (facets[i] == "xtargets") {
@@ -137,10 +138,10 @@ function promoteTermlists() {
acc.push('');
}
});
-}
+});
-function promotePager() {
+mkws.registerWidgetType('Pager', function() {
var that = this;
var M = mkws.M;
@@ -201,10 +202,10 @@ function promotePager() {
return s;
}
});
-}
+});
-function promoteRecords() {
+mkws.registerWidgetType('Records', function() {
var that = this;
var team = this.team;
@@ -232,10 +233,10 @@ function promoteRecords() {
return template(hit);
}
});
-}
+});
-function promoteNavi() {
+mkws.registerWidgetType('Navi', function() {
var that = this;
var teamName = this.team.name();
var M = mkws.M;
@@ -261,42 +262,35 @@ function promoteNavi() {
$(that.node).html(text);
});
-}
+});
+
+// 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;
-function promoteSort() {
- // 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();
+ $(this.node).change(function() {
+ that.team.set_sortOrder($(that.node).val());
+ if (that.team.submitted()) {
+ that.team.resetPage();
+ that.team.reShow();
}
return false;
});
-}
+});
-function promotePerpage() {
+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', promoteTargets);
-mkws.registerWidgetType('Stat', promoteStat);
-mkws.registerWidgetType('Termlists', promoteTermlists);
-mkws.registerWidgetType('Pager', promotePager);
-mkws.registerWidgetType('Records', promoteRecords);
-mkws.registerWidgetType('Navi', promoteNavi);
-mkws.registerWidgetType('Sort', promoteSort);
-mkws.registerWidgetType('Perpage', promotePerpage);
-
-
+});