New widget-setup utility function, hideWhenNarrow.
authorMike Taylor <mike@indexdata.com>
Thu, 1 May 2014 16:01:37 +0000 (17:01 +0100)
committerMike Taylor <mike@indexdata.com>
Thu, 1 May 2014 16:01:37 +0000 (17:01 +0100)
Teaches the widget to disappear when the window changes from wide to
narrow, and reappear when it changes from narrow to wide.

src/mkws-widget.js

index a16dec1..faee22d 100644 (file)
@@ -116,3 +116,14 @@ widget.autosearch = function(widget) {
 };
 
 
+// Utility function for all widgets that want to hide in narrow windows
+widget.hideWhenNarrow = function(widget) {
+    widget.team.queue("resize-narrow").subscribe(function(n) {
+       $(widget.node).hide();
+    });
+    widget.team.queue("resize-wide").subscribe(function(n) {
+       $(widget.node).show();
+    });
+};
+
+