foundation.alert.js 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ;(function ($, window, document, undefined) {
  2. 'use strict';
  3. Foundation.libs.alert = {
  4. name : 'alert',
  5. version : '5.2.2',
  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() + '] a.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 ('transitionend' in window || 'webkitTransitionEnd' in window || 'oTransitionEnd' in window) {
  20. alertBox.addClass("alert-close");
  21. alertBox.on('transitionend webkitTransitionEnd oTransitionEnd', function(e) {
  22. S(this).trigger('close').remove();
  23. settings.callback();
  24. });
  25. } else {
  26. alertBox.fadeOut(300, function () {
  27. S(this).trigger('close').remove();
  28. settings.callback();
  29. });
  30. }
  31. });
  32. },
  33. reflow : function () {}
  34. };
  35. }(jQuery, this, this.document));