You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.2 KiB

пре 6 година
  1. /*jslint unparam: true, browser: true, indent: 2 */
  2. ;(function ($, window, document, undefined) {
  3. 'use strict';
  4. Foundation.libs.alerts = {
  5. name : 'alerts',
  6. version : '4.2.2',
  7. settings : {
  8. speed: 300, // fade out speed
  9. callback: function (){}
  10. },
  11. init : function (scope, method, options) {
  12. this.scope = scope || this.scope;
  13. if (typeof method === 'object') {
  14. $.extend(true, this.settings, method);
  15. }
  16. if (typeof method !== 'string') {
  17. if (!this.settings.init) { this.events(); }
  18. return this.settings.init;
  19. } else {
  20. return this[method].call(this, options);
  21. }
  22. },
  23. events : function () {
  24. var self = this;
  25. $(this.scope).on('click.fndtn.alerts', '[data-alert] a.close', function (e) {
  26. e.preventDefault();
  27. $(this).closest("[data-alert]").fadeOut(self.speed, function () {
  28. $(this).remove();
  29. self.settings.callback();
  30. });
  31. });
  32. this.settings.init = true;
  33. },
  34. off : function () {
  35. $(this.scope).off('.fndtn.alerts');
  36. },
  37. reflow : function () {}
  38. };
  39. }(Foundation.zj, this, this.document));