PageSourceSearch

https://www.allclients.com/js/jquery.growl.js

js allclients.com collected 2026-09-25 15:25:25 UTC 8,505 bytes, 254 lines download raw bytes

1// 6-18-2025 3:00pm - Robust Growl Clearing
2
3// Remove all growl notifications from the DOM immediately
4window.clearAllGrowls = function () {
5    $('#growls').remove();
6    // Recreate the growls container if needed
7    $('body').append('<div id="growls"></div>');
8};
9
10(function () {
11    "use strict";
12    var $, Animation, Growl,
13        __bind = function (fn, me) { return function () { return fn.apply(me, arguments); }; };
14
15    $ = jQuery;
16
17    Animation = (function () {
18        function Animation() { }
19
20        Animation.transitions = {
21            "webkitTransition": "webkitTransitionEnd",
22            "mozTransition": "mozTransitionEnd",
23            "oTransition": "oTransitionEnd",
24            "transition": "transitionend"
25        };
26
27        Animation.transition = function ($el) {
28            var el, result, type, _ref;
29            el = $el[0];
30            _ref = this.transitions;
31            for (type in _ref) {
32                result = _ref[type];
33                if (el.style[type] != null) {
34                    return result;
35                }
36            }
37        };
38
39        return Animation;
40
41    })();
42
43    Growl = (function () {
44        Growl.settings = {
45            namespace: 'growl',
46            duration: 3200,
47            close: "&#215;",
48            location: "default",
49            style: "default",
50            size: "medium"
51        };
52
53        Growl.growl = function (settings) {
54            if (settings == null) {
55                settings = {};
56            }
57            // Remove all existing growls before showing a new one
58            if (window.clearAllGrowls) window.clearAllGrowls();
59            this.initialize();
60            return new Growl(settings);
61        };
62
63        Growl.initialize = function () {
64            return $("body:not(:has(#growls))").append('<div id="growls" />');
65        };
66
67        function Growl(settings) {
68            if (settings == null) {
69                settings = {};
70            }
71            this.html = __bind(this.html, this);
72            this.$growl = __bind(this.$growl, this);
73            this.$growls = __bind(this.$growls, this);
74            this.animate = __bind(this.animate, this);
75            this.remove = __bind(this.remove, this);
76            this.dismiss = __bind(this.dismiss, this);
77            this.present = __bind(this.present, this);
78            this.cycle = __bind(this.cycle, this);
79            this.close = __bind(this.close, this);
80            this.unbind = __bind(this.unbind, this);
81            this.bind = __bind(this.bind, this);
82            this.render = __bind(this.render, this);
83            this.settings = $.extend({}, Growl.settings, settings);
84            this._$growl = null; // Track the current growl element
85            this.$growls().attr('class', this.settings.location);
86            this.render();
87
88            // --- FORCE REMOVAL after duration ---
89            if (!this.settings["static"]) {
90                var self = this;
91                setTimeout(function () {
92                    if (self._$growl && $.contains(document, self._$growl[0])) {
93                        self._$growl.remove();
94                    }
95                }, this.settings.duration + 1000); // +1000ms to allow for animation
96            }
97        }
98
99
100        Growl.prototype.render = function () {
101            var $growl = this.$growl();
102            this.$growls().append($growl);
103            if (this.settings["static"] === true) {
104                this.present();
105            } else {
106                this.cycle();
107            }
108        };
109
110        Growl.prototype.bind = function ($growl) {
111            if ($growl == null) {
112                $growl = this.$growl();
113            }
114            return $growl.on("contextmenu", this.close)
115                .find("." + this.settings.namespace + "-close").on("click", this.close);
116        };
117
118        Growl.prototype.unbind = function ($growl) {
119            if ($growl == null) {
120                $growl = this.$growl();
121            }
122            return $growl.off("contextmenu", this.close)
123                .find("." + this.settings.namespace + "-close").off("click", this.close);
124        };
125
126        Growl.prototype.close = function (event) {
127            var $growl;
128            event.preventDefault();
129            event.stopPropagation();
130            $growl = this.$growl();
131            return $growl.stop().queue((next) => {
132                this.dismiss(() => {
133                    this.remove(next);
134                });
135            });
136        };
137
138        Growl.prototype.cycle = function () {
139            var $growl = this.$growl();
140            var self = this;
141            $growl.queue("fx", function (next) { self.present(next); });
142            $growl.delay(this.settings.duration, "fx");
143            $growl.queue("fx", function (next) { self.dismiss(next); });
144            $growl.queue("fx", function (next) { self.remove(next); });
145            $growl.dequeue("fx");
146            return $growl;
147        };
148
149        Growl.prototype.present = function (callback) {
150            var $growl = this.$growl();
151            this.bind($growl);
152            this.animate($growl, "" + this.settings.namespace + "-incoming", 'out', function () {
153                if (typeof callback === "function") callback();
154            });
155        };
156
157        Growl.prototype.dismiss = function (callback) {
158            var $growl = this.$growl();
159            this.unbind($growl);
160            this.animate($growl, "" + this.settings.namespace + "-outgoing", 'in', function () {
161                if (typeof callback === "function") callback();
162            });
163        };
164
165        Growl.prototype.remove = function (callback) {
166            var $growl = this.$growl();
167            $growl.remove();
168            if (typeof callback === "function") callback();
169        };
170
171        Growl.prototype.animate = function ($element, name, direction, callback) {
172            var transition;
173            if (direction == null) {
174                direction = 'in';
175            }
176            transition = Animation.transition($element);
177            $element[direction === 'in' ? 'removeClass' : 'addClass'](name);
178            $element.offset().position;
179            $element[direction === 'in' ? 'addClass' : 'removeClass'](name);
180            if (callback == null) {
181                return;
182            }
183            if (transition != null) {
184                $element.one(transition, callback);
185            } else {
186                callback();
187            }
188        };
189
190        Growl.prototype.$growls = function () {
191            return this.$_growls != null ? this.$_growls : this.$_growls = $('#growls');
192        };
193
194        // Always create a new growl element if needed
195        Growl.prototype.$growl = function () {
196            if (this._$growl && $.contains(document, this._$growl[0])) {
197                return this._$growl;
198            }
199            this._$growl = $(this.html());
200            return this._$growl;
201        };
202
203        Growl.prototype.html = function () {
204            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>";
205        };
206
207        return Growl;
208
209    })();
210
211    $.growl = function (options) {
212        if (options == null) {
213            options = {};
214        }
215        return Growl.growl(options);
216    };
217
218    $.growl.error = function (options) {
219        var settings;
220        if (options == null) {
221            options = {};
222        }
223        settings = {
224            title: "Error!",
225            style: "error"
226        };
227        return $.growl($.extend(settings, options));
228    };
229
230    $.growl.notice = function (options) {
231        var settings;
232        if (options == null) {
233            options = {};
234        }
235        settings = {
236            title: "Notice!",
237            style: "notice"
238        };
239        return $.growl($.extend(settings, options));
240    };
241
242    $.growl.warning = function (options) {
243        var settings;
244        if (options == null) {
245            options = {};
246        }
247        settings = {
248            title: "Warning!",
249            style: "warning"
250        };
251        return $.growl($.extend(settings, options));
252    };
253
254}).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.