Skip to content

Instantly share code, notes, and snippets.

@patsToms
Created August 17, 2013 09:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save patsToms/8827813dd6b992ce44e7 to your computer and use it in GitHub Desktop.
Save patsToms/8827813dd6b992ce44e7 to your computer and use it in GitHub Desktop.
/*jslint unparam: true, browser: true, indent: 2 */
;(function ($, window, document, undefined) {
'use strict';
Foundation.libs.alerts = {
name : 'alerts',
version : '4.0.0',
settings : {
speed: 300, // fade out speed
callback: function (){}
},
init : function (scope, method, options) {
this.scope = scope || this.scope;
if (typeof method === 'object') {
$.extend(true, this.settings, method);
}
if (typeof method != 'string') {
if (!this.settings.init) this.events();
return this.settings.init;
} else {
return this[method].call(this, options);
}
},
events : function () {
var self = this;
$(this.scope).on('click.fndtn.alerts', '[data-alert] a.close', function (e) {
e.preventDefault();
$(this).closest("[data-alert]").fadeOut(self.speed, function () {
$(this).remove();
self.settings.callback();
});
});
this.settings.init = true;
},
off : function () {
$(this.scope).off('.fndtn.alerts');
}
};
}(Foundation.zj, this, this.document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment