Skip to content

Commit

Permalink
Add namespacing to emitted events
Browse files Browse the repository at this point in the history
  • Loading branch information
thedeerchild committed Jun 17, 2014
1 parent cf0156d commit 179f3d1
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 25 deletions.
6 changes: 3 additions & 3 deletions js/foundation/foundation.abide.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions js/foundation/foundation.alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
}
Expand Down
4 changes: 2 additions & 2 deletions js/foundation/foundation.clearing.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
}
},
Expand Down
4 changes: 2 additions & 2 deletions js/foundation/foundation.dropdown.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
}
});
},
Expand All @@ -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 () {
Expand Down
4 changes: 2 additions & 2 deletions js/foundation/foundation.equalizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion js/foundation/foundation.interchange.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions js/foundation/foundation.offcanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
},

Expand Down
16 changes: 8 additions & 8 deletions js/foundation/foundation.reveal.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
3 changes: 1 addition & 2 deletions js/foundation/foundation.slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion js/foundation/foundation.topbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down

3 comments on commit 179f3d1

@istrasoft
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fndtn = foundation +'tn' > what is TN ? something namespace ?

@thedeerchild
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FouNDaTioN :)

@istrasoft
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooookay !

Please sign in to comment.