foundation.alert.js 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. ;(function ($, window, document, undefined) {
  2. 'use strict';
  3. Foundation.libs.alert = {
  4. name : 'alert',
  5. version : '5.5.3',
  6. settings : {
  7. callback : function () {}
  8. },
  9. init : function (scope, method, options) {
  10. this.bindings(method, options);
  11. },
  12. events : function () {
  13. var self = this,
  14. S = this.S;
  15. $(this.scope).off('.alert').on('click.fndtn.alert', '[' + this.attr_name() + '] .close', function (e) {
  16. var alertBox = S(this).closest('[' + self.attr_name() + ']'),
  17. settings = alertBox.data(self.attr_name(true) + '-init') || self.settings;
  18. e.preventDefault();
  19. if (Modernizr.csstransitions) {
  20. alertBox.addClass('alert-close');
  21. alertBox.on('transitionend webkitTransitionEnd oTransitionEnd', function (e) {
  22. S(this).trigger('close.fndtn.alert').remove();
  23. settings.callback();
  24. });
  25. } else {
  26. alertBox.fadeOut(300, function () {
  27. S(this).trigger('close.fndtn.alert').remove();
  28. settings.callback();
  29. });
  30. }
  31. });
  32. },
  33. reflow : function () {}
  34. };
  35. }(jQuery, window, window.document));