PageSourceSearch

https://www.pinglighting.com/js/jquery/plugins/growl/jquery.growl.js

js pinglighting.com collected 2026-10-06 18:27:37 UTC 5,945 bytes, 218 lines download raw bytes

1// Generated by CoffeeScript 1.6.3
2/*
3jQuery Growl
4Copyright 2013 Kevin Sylvestre
51.1.4
6*/
7
8
9(function() {
10  "use strict";
11  var $, Animation, Growl,
12    __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
13
14  $ = jQuery;
15
16  Animation = (function() {
17    function Animation() {}
18
19    Animation.transitions = {
20      "webkitTransition": "webkitTransitionEnd",
21      "mozTransition": "mozTransitionEnd",
22      "oTransition": "oTransitionEnd",
23      "transition": "transitionend"
24    };
25
26    Animation.transition = function($el) {
27      var el, result, type, _ref;
28      el = $el[0];
29      _ref = this.transitions;
30      for (type in _ref) {
31        result = _ref[type];
32        if (el.style[type] != null) {
33          return result;
34        }
35      }
36    };
37
38    return Animation;
39
40  })();
41
42  Growl = (function() {
43    Growl.settings = {
44      namespace: 'growl',
45      duration: 3200,
46      close: "×",
47      location: "default",
48      style: "default",
49      size: "medium"
50    };
51
52    Growl.growl = function(settings) {
53      if (settings == null) {
54        settings = {};
55      }
56      this.initialize();
57      return new Growl(settings);
58    };
59
60    Growl.initialize = function() {
61      return $("body:not(:has(#growls))").append('<div id="growls" />');
62    };
63
64    function Growl(settings) {
65      if (settings == null) {
66        settings = {};
67      }
68      this.html = __bind(this.html, this);
69      this.$growl = __bind(this.$growl, this);
70      this.$growls = __bind(this.$growls, this);
71      this.animate = __bind(this.animate, this);
72      this.remove = __bind(this.remove, this);
73      this.dismiss = __bind(this.dismiss, this);
74      this.present = __bind(this.present, this);
75      this.close = __bind(this.close, this);
76      this.cycle = __bind(this.cycle, this);
77      this.unbind = __bind(this.unbind, this);
78      this.bind = __bind(this.bind, this);
79      this.render = __bind(this.render, this);
80      this.settings = $.extend({}, Growl.settings, settings);
81      this.$growls().attr('class', this.settings.location);
82      this.render();
83    }
84
85    Growl.prototype.render = function() {
86      var $growl;
87      $growl = this.$growl();
88      this.$growls().append($growl);
89      this.cycle($growl);
90    };
91
92    Growl.prototype.bind = function($growl) {
93      if ($growl == null) {
94        $growl = this.$growl();
95      }
96      return $growl.find("." + this.settings.namespace + "-close").on("click", this.close);
97    };
98
99    Growl.prototype.unbind = function($growl) {
100      if ($growl == null) {
101        $growl = this.$growl();
102      }
103      return $growl.find("." + (this.settings.namespace - close)).off("click", this.close);
104    };
105
106    Growl.prototype.cycle = function($growl) {
107      if ($growl == null) {
108        $growl = this.$growl();
109      }
110      return $growl.queue(this.present).delay(this.settings.duration).queue(this.dismiss).queue(this.remove);
111    };
112
113    Growl.prototype.close = function(event) {
114      var $growl;
115      event.preventDefault();
116      event.stopPropagation();
117      $growl = this.$growl();
118      return $growl.stop().queue(this.dismiss).queue(this.remove);
119    };
120
121    Growl.prototype.present = function(callback) {
122      var $growl;
123      $growl = this.$growl();
124      this.bind($growl);
125      return this.animate($growl, "" + this.settings.namespace + "-incoming", 'out', callback);
126    };
127
128    Growl.prototype.dismiss = function(callback) {
129      var $growl;
130      $growl = this.$growl();
131      this.unbind($growl);
132      return this.animate($growl, "" + this.settings.namespace + "-outgoing", 'in', callback);
133    };
134
135    Growl.prototype.remove = function(callback) {
136      this.$growl().remove();
137      return callback();
138    };
139
140    Growl.prototype.animate = function($element, name, direction, callback) {
141      var transition;
142      if (direction == null) {
143        direction = 'in';
144      }
145      transition = Animation.transition($element);
146      $element[direction === 'in' ? 'removeClass' : 'addClass'](name);
147      $element.offset().position;
148      $element[direction === 'in' ? 'addClass' : 'removeClass'](name);
149      if (callback == null) {
150        return;
151      }
152      if (transition != null) {
153        $element.one(transition, callback);
154      } else {
155        callback();
156      }
157    };
158
159    Growl.prototype.$growls = function() {
160      return this.$_growls != null ? this.$_growls : this.$_growls = $('#growls');
161    };
162
163    Growl.prototype.$growl = function() {
164      return this.$_growl != null ? this.$_growl : this.$_growl = $(this.html());
165    };
166
167    Growl.prototype.html = function() {
168      return "<div class='" + this.settings.namespace + " " + this.settings.namespace + "-" + this.settings.style + " " + this.settings.namespace + "-" + this.settings.size + "'>\n  <div class='" + this.settings.namespace + "-close'>" + this.settings.close + "</div>\n  <div class='" + this.settings.namespace + "-title'>" + this.settings.title + "</div>\n  <div class='" + this.settings.namespace + "-message'>" + this.settings.message + "</div>\n</div>";
169    };
170
171    return Growl;
172
173  })();
174
175  $.growl = function(options) {
176    if (options == null) {
177      options = {};
178    }
179    return Growl.growl(options);
180  };
181
182  $.growl.error = function(options) {
183    var settings;
184    if (options == null) {
185      options = {};
186    }
187    settings = {
188      title: "Error!",
189      style: "error"
190    };
191    return $.growl($.extend(settings, options));
192  };
193
194  $.growl.notice = function(options) {
195    var settings;
196    if (options == null) {
197      options = {};
198    }
199    settings = {
200      title: "Notice!",
201      style: "notice"
202    };
203    return $.growl($.extend(settings, options));
204  };
205
206  $.growl.warning = function(options) {
207    var settings;
208    if (options == null) {
209      options = {};
210    }
211    settings = {
212      title: "Warning!",
213      style: "warning"
214    };
215    return $.growl($.extend(settings, options));
216  };
217
218}).call(this);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.