Merge branch 'master' of ssh://git.indexdata.com:222/home/git/private/mkws
authorWolfram Schneider <wosch@indexdata.dk>
Thu, 8 May 2014 14:24:31 +0000 (14:24 +0000)
committerWolfram Schneider <wosch@indexdata.dk>
Thu, 8 May 2014 14:24:31 +0000 (14:24 +0000)
src/mkws-core.js
src/mkws-widget-builder.js
src/mkws-widget-main.js
test/spec/mkws-pazpar2.js
tools/htdocs/mkws.css

index c40a457..69bd47d 100644 (file)
@@ -431,8 +431,13 @@ mkws.pagerNext = function(tname) {
   function makeWidgetsWithin(level, node) {
     node.find('[class^="mkws"],[class*=" mkws"]').each(function() {
       handleNodeWithTeam(this, function(tname, type) {
-        var oldHTML = this.innerHTML;
         var myTeam = mkws.teams[tname];
+        if (!myTeam) {
+          myTeam = mkws.teams[tname] = team(j, tname);
+          log("Made MKWS team '" + tname + "'");
+        }
+
+        var oldHTML = this.innerHTML;
         var myWidget = widget(j, myTeam, type, this);
         myTeam.addWidget(myWidget);
         var newHTML = this.innerHTML;
@@ -509,21 +514,10 @@ mkws.pagerNext = function(tname) {
       }
     }
 
-    // Find all nodes with an MKWS class, and determine their team from
-    // the mkwsTeam_* class. Make all team objects.
     var then = $.now();
-    $('[class^="mkws"],[class*=" mkws"]').each(function() {
-      handleNodeWithTeam(this, function(tname, type) {
-        if (!mkws.teams[tname]) {
-          mkws.teams[tname] = team(j, tname);
-          log("Made MKWS team '" + tname + "'");
-        }
-      });
-    });
-
     makeWidgetsWithin(1, $(':root'));
-    
     var now = $.now();
+
     log("Walking MKWS nodes took " + (now-then) + " ms");
 
     /*
index e90e0ad..22f016d 100644 (file)
@@ -22,7 +22,7 @@ mkws.registerWidgetType('Builder', function() {
 });
 
 mkws.registerWidgetType('ConsoleBuilder', function() {
-  mkws.promotionFunction('Builder').call(this);    
+  mkws.promotionFunction('Builder').call(this);
   this.callback = function(s) {
     console.log("Generated widget: " + s);
   }
index 6fbf5de..980cde2 100644 (file)
@@ -7,10 +7,7 @@ mkws.registerWidgetType('Targets', function() {
   var that = this;
   var M = mkws.M;
 
-  $(this.node).html('\
-<div class="mkwsBytarget mkwsTeam_' + this.team.name() + '">\
-No information available yet.\
-</div>');
+  $(this.node).html('No information available yet.');
   $(this.node).css("display", "none");
 
   this.team.queue("targets").subscribe(function(data) {
@@ -31,8 +28,7 @@ No information available yet.\
     }
 
     table += '</tbody></table>';
-    var subnode = $(that.node).children('.mkwsBytarget');
-    subnode.html(table);
+    $(that.node).html(table);
   });
 });
 
@@ -89,7 +85,7 @@ mkws.registerWidgetType('Pager', function() {
       for(var i = firstClkbl; i <= lastClkbl; i++) {
         var numLabel = i;
         if(i == currentPage)
-          numLabel = '<span class="mkwsSelected">' + i + '</span>';
+          numLabel = '<span class="mkwsCurrentPage">' + i + '</span>';
 
         middle += '<a href="#" onclick="mkws.showPage(\'' + teamName + '\', ' + i + ')"> '
           + numLabel + ' </a>';
@@ -238,7 +234,7 @@ mkws.registerWidgetType('Search', function() {
 
 
 mkws.registerWidgetType('SearchForm', function() {
-  var team = this.team;    
+  var team = this.team;
   $(this.node).submit(function() {
     var val = team.widget('Query').value();
     team.newSearch(val);
@@ -279,7 +275,7 @@ mkws.registerWidgetType('Ranking', function() {
   var that = this;
   var M = mkws.M;
 
-  var s = '<form name="mkwsSelect" class="mkwsSelect mkwsTeam_' + tname + '" action="" >';
+  var s = '<form>';
   if (this.config.show_sort) {
     s +=  M('Sort by') + ' ' + mkwsHtmlSort() + ' ';
   }
@@ -420,8 +416,4 @@ mkws.registerWidgetType('MOTDContainer', function() {});
 mkws.registerWidgetType('Button', function() {});
 mkws.registerWidgetType('Popup', function() {});
 
-// Not sure whether the following should have functionality:
-// Select               HTMLFormElement
-// *-Container-wide     HTMLTableCellElement
-// *-Container-narrow   HTMLDivElement
-// Bytarget             HTMLDivElement
+
index 3433115..0affaac 100644 (file)
@@ -466,7 +466,7 @@ describe("Check switch menu Records/Targets", function () {
         $("div.mkwsSwitch").children('a').eq(1).trigger("click");
 
         // now the target table must be visible
-        expect($("div.mkwsBytarget").is(":visible")).toBe(true);
+        expect($("div.mkwsTargets").is(":visible")).toBe(true);
         expect($("div.mkwsRecords").is(":visible")).toBe(false);
 
         // wait a half second, to show the target view
@@ -477,7 +477,7 @@ describe("Check switch menu Records/Targets", function () {
 
         // look for table header
         runs(function () {
-            expect($("div.mkwsBytarget").html()).toMatch(/Target ID/);
+            expect($("div.mkwsTargets").html()).toMatch(/Target ID/);
         });
     });
 
@@ -485,7 +485,7 @@ describe("Check switch menu Records/Targets", function () {
         $("div.mkwsSwitch").children('a').eq(0).trigger("click");
 
         // now the target table must be visible
-        expect($("div.mkwsBytarget").is(":visible")).toBe(false);
+        expect($("div.mkwsTargets").is(":visible")).toBe(false);
         expect($("div.mkwsRecords").is(":visible")).toBe(true);
     });
 });
index f3acc34..bf9220a 100644 (file)
     padding: 0.3em;
 }
 
-.mkwsBytarget table thead tr td {
+.mkwsTargets table thead tr td {
     background-color: #132194;
     color: white;
     font-weight: bold;
     padding: 0.2em 0.5em;
 }
 
-.mkwsBytarget table tbody tr:nth-child(odd) {
+.mkwsTargets table tbody tr:nth-child(odd) {
     background-color: #e0f0ff;
 }
 
-.mkwsBytarget table tbody tr:nth-child(even) {
+.mkwsTargets table tbody tr:nth-child(even) {
     background-color: #d0e0ff;
 }
 
-.mkwsBytarget table tbody tr td {
+.mkwsTargets table tbody tr td {
     padding: 0.2em 0.5em;
 }
 
-.mkwsSelected {
+.mkwsCurrentPage {
     padding: 0.1em 0.5em;
     background: #508751;
     color: white;