From: Thierry Parmentelat Date: Sat, 14 Dec 2013 10:03:08 +0000 (+0100) Subject: use the ‘pubsub’ class as a means to tag DOM elements that need to receive API events X-Git-Tag: myslice-0.3-0~86 X-Git-Url: http://git.onelab.eu/?p=unfold.git;a=commitdiff_plain;h=2c59023275130fa32c3a215df0c192b750aa190f use the ‘pubsub’ class as a means to tag DOM elements that need to receive API events this is instead of the ‘plugin’ class that was used previously, and that relied on the DOM building helpers and conventions that we have in place for ‘real’ plugins However we want to be able to deal with plugins that piggyback on existing DOM elts that do not necessarily have .plugin As a side effect the topmenu buttons do not need to have .plugin to work with validatebutton --- diff --git a/manifold/static/js/manifold.js b/manifold/static/js/manifold.js index 58f28485..dc728264 100644 --- a/manifold/static/js/manifold.js +++ b/manifold/static/js/manifold.js @@ -780,10 +780,10 @@ var manifold = { $.each(channels, function(i, channel) { if (value === undefined) { if (manifold.publish_result_debug) messages.debug("triggering [no value] on channel="+channel+" and event_type="+event_type); - $('.plugin').trigger(channel, [event_type]); + $('.pubsub').trigger(channel, [event_type]); } else { if (manifold.publish_result_debug) messages.debug("triggering [value="+value+"] on channel="+channel+" and event_type="+event_type); - $('.plugin').trigger(channel, [event_type, value]); + $('.pubsub').trigger(channel, [event_type, value]); } }); }, diff --git a/manifold/static/js/plugin.js b/manifold/static/js/plugin.js index 41d8e8b0..fb7bf595 100644 --- a/manifold/static/js/plugin.js +++ b/manifold/static/js/plugin.js @@ -30,6 +30,9 @@ var Plugin = Class.extend({ // reference and a normal reference this.element = element; this.$element = $(element); + // programmatically add specific class for publishing events + // used in manifold.js for triggering API events + if ( ! this.$element.hasClass('pubsub')) this.$element.addClass('pubsub'); // return this so we can chain/use the bridge with less code. return this; diff --git a/ui/templates/widget-topmenu.html b/ui/templates/widget-topmenu.html index 79f1bf83..12cddb92 100644 --- a/ui/templates/widget-topmenu.html +++ b/ui/templates/widget-topmenu.html @@ -28,7 +28,7 @@ {% else %} -
  • {{ d.label }}
  • {% endif %}