From: Mike Taylor Date: Thu, 1 May 2014 16:01:37 +0000 (+0100) Subject: New widget-setup utility function, hideWhenNarrow. X-Git-Tag: 1.0.0~754 X-Git-Url: http://lists.indexdata.dk/cgi-bin?a=commitdiff_plain;ds=sidebyside;h=87b2c72772dfc8cfcb820e52f40e0694e4bb2dd3;hp=d74efb549c24e20fb3c42a61154f9c2bd3f47e83;p=mkws-moved-to-github.git New widget-setup utility function, hideWhenNarrow. Teaches the widget to disappear when the window changes from wide to narrow, and reappear when it changes from narrow to wide. --- diff --git a/src/mkws-widget.js b/src/mkws-widget.js index a16dec1..faee22d 100644 --- a/src/mkws-widget.js +++ b/src/mkws-widget.js @@ -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(); + }); +}; + +