From: Jordan Humphreys Date: Mon, 23 Sep 2013 23:39:28 +0000 (-0700) Subject: Recommit of PR #3220 from @anitagraham: X-Git-Tag: v5.2.3~81^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F4911%2Fhead;p=thirdparty%2Ffoundation%2Ffoundation-sites.git Recommit of PR #3220 from @anitagraham: - add events to clearing - adds documentation for those events with changes: - removed extra parameter from open event - updated docs to match current style --- diff --git a/doc/includes/clearing/examples_clearing_events.html b/doc/includes/clearing/examples_clearing_events.html new file mode 100644 index 000000000..7a8d6b3f6 --- /dev/null +++ b/doc/includes/clearing/examples_clearing_events.html @@ -0,0 +1,7 @@ +{{#markdown}} +```javascript +$(document.body).on("open.fndtn.clearing", function(event) { + console.info("About to open thumbnail with src ", $('img', event.target).attr('src')); +}); +``` +{{/markdown}} diff --git a/doc/pages/components/clearing.html b/doc/pages/components/clearing.html index 670430838..d258a21de 100644 --- a/doc/pages/components/clearing.html +++ b/doc/pages/components/clearing.html @@ -80,6 +80,25 @@ Clearing supports `data-options` on-the-fly configuration: {{> examples_clearing_data_options}} +### Available Javascript Events + +Clearing supports several javascript events that you can listen to: + + + +

Here is an example of binding to the open event.

+ +

JS

+ +{{> examples_clearing_events}} + *** ### Sass Errors? diff --git a/js/foundation/foundation.clearing.js b/js/foundation/foundation.clearing.js index 677c51e3b..a9ce14626 100644 --- a/js/foundation/foundation.clearing.js +++ b/js/foundation/foundation.clearing.js @@ -218,16 +218,17 @@ target.siblings().removeClass('visible'); target.addClass('visible'); }); + visible_image.trigger('opened.fndtn.clearing') } if (!this.locked()) { + visible_image.trigger('open.fndtn.clearing'); // set the image to the selected thumbnail image .attr('src', this.load($image)) .css('visibility', 'hidden'); startLoad.call(this); - } }, @@ -247,12 +248,14 @@ body.css('overflow', ''); container = $('div', root).first(); visible_image = $('.visible-img', container); + visible_image.trigger('close.fndtn.clearing'); this.settings.prev_index = 0; $('ul[' + this.attr_name() + ']', root) .attr('style', '').closest('.clearing-blackout') .removeClass('clearing-blackout'); container.removeClass('clearing-container'); visible_image.hide(); + visible_image.trigger('closed.fndtn.clearing'); } return false; @@ -286,6 +289,7 @@ if (image.length) { this.center_and_label(image, label); + image.trigger('resized.fndtn.clearing') } }, @@ -423,7 +427,8 @@ if (target.length) { this.S('img', target) - .trigger('click', [current, target]); + .trigger('click', [current, target]) + .trigger('change.fndtn.clearing'); } },