Statistics
| Branch: | Tag: | Revision:

root / snf-cyclades-app / synnefo / ui / new_ui / ui / javascripts / foundation / foundation.alerts.js @ 65635b1b

History | View | Annotate | Download (1.1 kB)

1
/*jslint unparam: true, browser: true, indent: 2 */
2

    
3
;(function ($, window, document, undefined) {
4
  'use strict';
5

    
6
  Foundation.libs.alerts = {
7
    name : 'alerts',
8

    
9
    version : '4.0.0',
10

    
11
    settings : {
12
      speed: 300, // fade out speed
13
      callback: function (){}
14
    },
15

    
16
    init : function (scope, method, options) {
17
      this.scope = scope || this.scope;
18

    
19
      if (typeof method === 'object') {
20
        $.extend(true, this.settings, method);
21
      }
22

    
23
      if (typeof method != 'string') {
24
        if (!this.settings.init) this.events();
25

    
26
        return this.settings.init;
27
      } else {
28
        return this[method].call(this, options);
29
      }
30
    },
31

    
32
    events : function () {
33
      var self = this;
34

    
35
      $(this.scope).on('click.fndtn.alerts', '[data-alert] a.close', function (e) {
36
        e.preventDefault();
37
        $(this).closest("[data-alert]").fadeOut(self.speed, function () {
38
          $(this).remove();
39
          self.settings.callback();
40
        });
41
      });
42

    
43
      this.settings.init = true;
44
    },
45

    
46
    off : function () {
47
      $(this.scope).off('.fndtn.alerts');
48
    }
49
  };
50
}(Foundation.zj, this, this.document));