From 179f3d1fc2a0bc785438ec1a74faf5ef86855f81 Mon Sep 17 00:00:00 2001 From: Eric Morris Date: Tue, 17 Jun 2014 08:49:54 -0700 Subject: [PATCH] Add namespacing to emitted events --- js/foundation/foundation.abide.js | 6 +++--- js/foundation/foundation.alert.js | 4 ++-- js/foundation/foundation.clearing.js | 4 ++-- js/foundation/foundation.dropdown.js | 4 ++-- js/foundation/foundation.equalizer.js | 4 ++-- js/foundation/foundation.interchange.js | 2 +- js/foundation/foundation.offcanvas.js | 4 ++-- js/foundation/foundation.reveal.js | 16 ++++++++-------- js/foundation/foundation.slider.js | 3 +-- js/foundation/foundation.topbar.js | 2 +- 10 files changed, 24 insertions(+), 25 deletions(-) diff --git a/js/foundation/foundation.abide.js b/js/foundation/foundation.abide.js index a1c23841d0..a100be280a 100644 --- a/js/foundation/foundation.abide.js +++ b/js/foundation/foundation.abide.js @@ -101,19 +101,19 @@ settings = form.data(this.attr_name(true) + '-init') || {}, submit_event = /submit/.test(e.type); - form.trigger('validated'); + form.trigger('validated').trigger('validated.fndtn.abide'); // Has to count up to make sure the focus gets applied to the top error for (var i=0; i < validation_count; i++) { if (!validations[i] && (submit_event || is_ajax)) { if (settings.focus_on_invalid) els[i].focus(); - form.trigger('invalid'); + form.trigger('invalid').trigger('invalid.fndtn.abide'); this.S(els[i]).closest('[data-' + this.attr_name(true) + ']').attr(this.invalid_attr, ''); return false; } } if (submit_event || is_ajax) { - form.trigger('valid'); + form.trigger('valid').trigger('valid.fndtn.abide'); } form.removeAttr(this.invalid_attr); diff --git a/js/foundation/foundation.alert.js b/js/foundation/foundation.alert.js index c38f962ea2..4a02964512 100644 --- a/js/foundation/foundation.alert.js +++ b/js/foundation/foundation.alert.js @@ -26,12 +26,12 @@ if (Modernizr.csstransitions) { alertBox.addClass("alert-close"); alertBox.on('transitionend webkitTransitionEnd oTransitionEnd', function(e) { - S(this).trigger('close').remove(); + S(this).trigger('close').trigger('close.fndtn.alert').remove(); settings.callback(); }); } else { alertBox.fadeOut(300, function () { - S(this).trigger('close').remove(); + S(this).trigger('close').trigger('close.fndtn.alert').remove(); settings.callback(); }); } diff --git a/js/foundation/foundation.clearing.js b/js/foundation/foundation.clearing.js index c417c5e195..933b485ea2 100644 --- a/js/foundation/foundation.clearing.js +++ b/js/foundation/foundation.clearing.js @@ -282,7 +282,7 @@ if (e.which === NEXT_KEY) this.go(clearing, 'next'); if (e.which === PREV_KEY) this.go(clearing, 'prev'); - if (e.which === ESC_KEY) this.S('a.clearing-close').trigger('click'); + if (e.which === ESC_KEY) this.S('a.clearing-close').trigger('click').trigger('click.fndtn.clearing'); }, nav : function (e, direction) { @@ -435,7 +435,7 @@ if (target.length) { this.S('img', target) - .trigger('click', [current, target]) + .trigger('click', [current, target]).trigger('click.fndtn.clearing', [current, target]) .trigger('change.fndtn.clearing'); } }, diff --git a/js/foundation/foundation.dropdown.js b/js/foundation/foundation.dropdown.js index 5276b8810c..fff777390d 100644 --- a/js/foundation/foundation.dropdown.js +++ b/js/foundation/foundation.dropdown.js @@ -111,7 +111,7 @@ .removeClass(self.settings.active_class) .removeData('target'); - self.S(this).trigger('closed', [dropdown]); + self.S(this).trigger('closed').trigger('closed.fndtn.dropdown', [dropdown]); } }); }, @@ -128,7 +128,7 @@ .css(dropdown .addClass(this.settings.active_class), target); dropdown.prev('[' + this.attr_name() + ']').addClass(this.settings.active_class); - dropdown.data('target', target.get(0)).trigger('opened', [dropdown, target]); + dropdown.data('target', target.get(0)).trigger('opened').trigger('opened.fndtn.dropdown', [dropdown, target]); }, data_attr: function () { diff --git a/js/foundation/foundation.equalizer.js b/js/foundation/foundation.equalizer.js index c78920d478..da846dd319 100644 --- a/js/foundation/foundation.equalizer.js +++ b/js/foundation/foundation.equalizer.js @@ -33,7 +33,7 @@ if (vals.length === 0) return; var firstTopOffset = vals.first().offset().top; settings.before_height_change(); - equalizer.trigger('before-height-change'); + equalizer.trigger('before-height-change').trigger('before-height-change.fndth.equalizer'); vals.height('inherit'); vals.each(function(){ var el = $(this); @@ -56,7 +56,7 @@ vals.css('height', min); } settings.after_height_change(); - equalizer.trigger('after-height-change'); + equalizer.trigger('after-height-change').trigger('after-height-change.fndtn.equalizer'); }, reflow : function () { diff --git a/js/foundation/foundation.interchange.js b/js/foundation/foundation.interchange.js index 673c590214..beba1f64c7 100644 --- a/js/foundation/foundation.interchange.js +++ b/js/foundation/foundation.interchange.js @@ -232,7 +232,7 @@ this.object($(this['cached_' + type][i])); } - return $(window).trigger('resize'); + return $(window).trigger('resize').trigger('resize.fndtn.interchange'); }, convert_directive : function (directive) { diff --git a/js/foundation/foundation.offcanvas.js b/js/foundation/foundation.offcanvas.js index 3c9bde9dec..b8c273f200 100644 --- a/js/foundation/foundation.offcanvas.js +++ b/js/foundation/foundation.offcanvas.js @@ -67,13 +67,13 @@ show: function(class_name, $off_canvas) { $off_canvas = $off_canvas || this.get_wrapper(); - $off_canvas.trigger('open'); + $off_canvas.trigger('open').trigger('open.fndtn.offcanvas'); $off_canvas.addClass(class_name); }, hide: function(class_name, $off_canvas) { $off_canvas = $off_canvas || this.get_wrapper(); - $off_canvas.trigger('close'); + $off_canvas.trigger('close').trigger('close.fndtn.offcanvas'); $off_canvas.removeClass(class_name); }, diff --git a/js/foundation/foundation.reveal.js b/js/foundation/foundation.reveal.js index a5049a1c31..7c3cf38bca 100644 --- a/js/foundation/foundation.reveal.js +++ b/js/foundation/foundation.reveal.js @@ -163,7 +163,7 @@ } this.key_up_on(modal); // PATCH #3: turning on key up capture only when a reveal window is open - modal.trigger('open'); + modal.trigger('open').trigger('open.fndtn.reveal'); if (open_modal.length < 1) { this.toggle_bg(modal, true); @@ -214,7 +214,7 @@ if (open_modals.length > 0) { this.locked = true; this.key_up_off(modal); // PATCH #3: turning on key up capture only when a reveal window is open - modal.trigger('close'); + modal.trigger('close').trigger('close.fndtn.reveal'); this.toggle_bg(modal, false); this.hide(open_modals, settings.css.close, settings); } @@ -279,7 +279,7 @@ .css(css) .animate(end_css, settings.animation_speed, 'linear', function () { this.locked = false; - el.trigger('opened'); + el.trigger('opened').trigger('opened.fndtn.reveal'); }.bind(this)) .addClass('open'); }.bind(this), settings.animation_speed / 2); @@ -294,13 +294,13 @@ .css(css) .animate(end_css, settings.animation_speed, 'linear', function () { this.locked = false; - el.trigger('opened'); + el.trigger('opened').trigger('opened.fndtn.reveal'); }.bind(this)) .addClass('open'); }.bind(this), settings.animation_speed / 2); } - return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened'); + return el.css(css).show().css({opacity: 1}).addClass('open').trigger('opened').trigger('opened.fndtn.reveal'); } var settings = this.settings; @@ -335,7 +335,7 @@ return el .animate(end_css, settings.animation_speed, 'linear', function () { this.locked = false; - el.css(css).trigger('closed'); + el.css(css).trigger('closed').trigger('closed.fndtn.reveal'); }.bind(this)) .removeClass('open'); }.bind(this), settings.animation_speed / 2); @@ -348,13 +348,13 @@ return el .animate(end_css, settings.animation_speed, 'linear', function () { this.locked = false; - el.css(css).trigger('closed'); + el.css(css).trigger('closed').trigger('closed.fndtn.reveal'); }.bind(this)) .removeClass('open'); }.bind(this), settings.animation_speed / 2); } - return el.hide().css(css).removeClass('open').trigger('closed'); + return el.hide().css(css).removeClass('open').trigger('closed').trigger('closed.fndtn.reveal'); } var settings = this.settings; diff --git a/js/foundation/foundation.slider.js b/js/foundation/foundation.slider.js index fddd2c9f4d..07f19bcc44 100644 --- a/js/foundation/foundation.slider.js +++ b/js/foundation/foundation.slider.js @@ -119,8 +119,7 @@ $handle.siblings('.range-slider-active-segment').css('width', progress_bar_length + '%'); } - $handle.parent().attr(this.attr_name(), value); - $handle.parent().trigger('change'); + $handle.parent().attr(this.attr_name(), value).trigger('change').trigger('change.fndtn.slider'); $handle.parent().children('input[type=hidden]').val(value); diff --git a/js/foundation/foundation.topbar.js b/js/foundation/foundation.topbar.js index 480a3f058d..b1ddc20fbc 100644 --- a/js/foundation/foundation.topbar.js +++ b/js/foundation/foundation.topbar.js @@ -230,7 +230,7 @@ S(window).off('.topbar').on('resize.fndtn.topbar', self.throttle(function () { self.resize.call(self); - }, 50)).trigger('resize'); + }, 50)).trigger('resize').trigger('resize.fndtn.topbar'); S('body').off('.topbar').on('click.fndtn.topbar touchstart.fndtn.topbar', function (e) { var parent = S(e.target).closest('li').closest('li.hover');