mindreframer-riemann-dash 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. data/.gitignore +8 -0
  2. data/Gemfile +7 -0
  3. data/Gemfile.lock +52 -0
  4. data/LICENSE +21 -0
  5. data/README.markdown +52 -0
  6. data/Rakefile.rb +11 -0
  7. data/bin/riemann-dash +7 -0
  8. data/example/config.rb +17 -0
  9. data/lib/riemann/dash.rb +5 -0
  10. data/lib/riemann/dash/app.rb +32 -0
  11. data/lib/riemann/dash/config.rb +154 -0
  12. data/lib/riemann/dash/controller/css.rb +5 -0
  13. data/lib/riemann/dash/controller/index.rb +20 -0
  14. data/lib/riemann/dash/public/clock.js +45 -0
  15. data/lib/riemann/dash/public/dash.js +287 -0
  16. data/lib/riemann/dash/public/format.js +24 -0
  17. data/lib/riemann/dash/public/jquery-1.7.2.min.js +4 -0
  18. data/lib/riemann/dash/public/jquery-ui-1.9.0.custom.min.js +6 -0
  19. data/lib/riemann/dash/public/jquery.json-2.2.min.js +31 -0
  20. data/lib/riemann/dash/public/jquery.quickfit.js +144 -0
  21. data/lib/riemann/dash/public/jquery.simplemodal.1.4.3.min.js +26 -0
  22. data/lib/riemann/dash/public/keys.js +46 -0
  23. data/lib/riemann/dash/public/mustache.js +597 -0
  24. data/lib/riemann/dash/public/persistence.js +30 -0
  25. data/lib/riemann/dash/public/profile.js +33 -0
  26. data/lib/riemann/dash/public/subs.js +164 -0
  27. data/lib/riemann/dash/public/toastr.css +174 -0
  28. data/lib/riemann/dash/public/toastr.js +207 -0
  29. data/lib/riemann/dash/public/toolbar.js +217 -0
  30. data/lib/riemann/dash/public/underscore-min.js +5 -0
  31. data/lib/riemann/dash/public/util.js +34 -0
  32. data/lib/riemann/dash/public/vendor/smoothie.js +374 -0
  33. data/lib/riemann/dash/public/view.js +704 -0
  34. data/lib/riemann/dash/public/views/gauge.js +76 -0
  35. data/lib/riemann/dash/public/views/grid.js +279 -0
  36. data/lib/riemann/dash/public/views/help.js +28 -0
  37. data/lib/riemann/dash/public/views/timeseries.js +107 -0
  38. data/lib/riemann/dash/public/views/title.js +35 -0
  39. data/lib/riemann/dash/public/x.png +0 -0
  40. data/lib/riemann/dash/rack/static.rb +16 -0
  41. data/lib/riemann/dash/version.rb +4 -0
  42. data/lib/riemann/dash/views/css.scss +393 -0
  43. data/lib/riemann/dash/views/index.erubis +203 -0
  44. data/lib/riemann/dash/views/layout.erubis +21 -0
  45. data/riemann-dash.gemspec +28 -0
  46. data/sh/c +1 -0
  47. data/sh/env.rb +2 -0
  48. data/sh/test +1 -0
  49. data/test/config_test.rb +106 -0
  50. data/test/fixtures/config/basic_config.rb +2 -0
  51. data/test/fixtures/config/ws_config.rb +1 -0
  52. data/test/fixtures/ws_config/dummy_config.json +1 -0
  53. data/test/fixtures/ws_config/pretty_printed_config.json +6 -0
  54. data/test/test_helper.rb +10 -0
  55. metadata +202 -0
@@ -0,0 +1,30 @@
1
+ // Provides persistent storage for dashboard configuration.
2
+ var persistence = (function() {
3
+ // Saves configuration to persistent store. Calls success() or error() when
4
+ // complete.
5
+ var save = function(config, success, error) {
6
+ jQuery.ajax('/config', {
7
+ type: 'POST',
8
+ success: success,
9
+ error: error,
10
+ contentType: 'application/json',
11
+ data: JSON.stringify(config),
12
+ dataType: 'json'
13
+ });
14
+ };
15
+
16
+ // Returns configuration from persistent store.
17
+ var load = function(success, error) {
18
+ jQuery.ajax('/config', {
19
+ type: 'GET',
20
+ success: success,
21
+ error: error,
22
+ dataType: 'json'
23
+ });
24
+ };
25
+
26
+ return {
27
+ save: save,
28
+ load: load
29
+ }
30
+ })();
@@ -0,0 +1,33 @@
1
+ var profile = (function() {
2
+ // Instrumentation for how much time we spend doing things. With 0 args,
3
+ // returns current busy fraction. With a start and stop time in milliseconds,
4
+ // updates the current busy fraction.
5
+
6
+ // Returns a load meter with a sampling period in ms.
7
+ var load = function(period) {
8
+ // Start of the sample interval
9
+ var interval = 0;
10
+
11
+ // Fraction of time busy
12
+ var load = 0;
13
+ var acc = 0;
14
+
15
+ return function(t1, t2) {
16
+ if (t1 === undefined) {
17
+ return load;
18
+ }
19
+
20
+ if (interval < t2) {
21
+ interval = (Math.floor(t2 / period) * period) + period;
22
+ load = acc / period;
23
+ acc = 0;
24
+ }
25
+
26
+ acc += (t2 - t1);
27
+ }
28
+ };
29
+
30
+ return {
31
+ load: load
32
+ };
33
+ })();
@@ -0,0 +1,164 @@
1
+ var subs = (function() {
2
+ // What server shall we connect to by default?
3
+ var server;
4
+
5
+ // Subscription ID counter.
6
+ var id_counter = -1;
7
+
8
+ // Subscriptions
9
+ var subs = {};
10
+
11
+ // Switch to turn on/off event processing
12
+ var active = true;
13
+
14
+ // Error queue for notification
15
+ var errorQueue = [];
16
+
17
+ // Instrumentation
18
+ var load1 = profile.load(1000);
19
+ var load5 = profile.load(5000);
20
+
21
+ // Get a new subscription ID.
22
+ var newId = function() {
23
+ return id_counter += 1;
24
+ }
25
+
26
+ // Close a subscription's websocket channel.
27
+ var close = function(sub) {
28
+ if (sub.ws == null) {
29
+ return sub;
30
+ }
31
+ sub.ws.close();
32
+ sub.ws == null;
33
+ return sub;
34
+ }
35
+
36
+ // Closes a subscription and deletes it from the subscription manager.
37
+ var unsubscribe = function(sub) {
38
+ delete subs[sub.id];
39
+ close(sub);
40
+ }
41
+
42
+ // Unsubscribe from all subscriptions.
43
+ var unsubscribeAll = function() {
44
+ _.each(subs, unsubscribe);
45
+ }
46
+
47
+ // Open a subscription's websocket channel.
48
+ var open = function(sub) {
49
+ if (sub.ws != null && sub.ws.readyState != WebSocket.CLOSED) {
50
+ return sub;
51
+ }
52
+
53
+ var f = sub.f;
54
+ var queryString = "query=" + encodeURI(sub.query);
55
+ var uri = "ws://" + server + "/index?subscribe=true&" + queryString;
56
+ sub.ws = new WebSocket(uri);
57
+ var $ws = $(sub.ws);
58
+
59
+ $ws.bind('open', function() {
60
+ console.log("Socket opened", sub.query);
61
+ });
62
+
63
+ $ws.bind('close', function(e) {
64
+ console.log("Socket closed", sub.query);
65
+ sub.ws = null;
66
+ });
67
+
68
+ $ws.bind('error', function(e) {
69
+ console.log("Socket error", sub.query);
70
+ errorQueue.push(e);
71
+ sub.ws.close();
72
+ });
73
+
74
+ $ws.bind('message', function(e) {
75
+ t1 = Date.now();
76
+ if (active) {
77
+ f(JSON.parse(e.originalEvent.data));
78
+ }
79
+ load1(t1, Date.now());
80
+ load5(t1, Date.now());
81
+ });
82
+
83
+ return sub;
84
+ }
85
+
86
+ // Add a subscription. Returns a subscription object. Subscriptions are
87
+ // opened immediately.
88
+ var subscribe = function(query, f) {
89
+ var sub = {
90
+ id: newId(),
91
+ query: query,
92
+ f: f,
93
+ ws: null
94
+ }
95
+ subs[sub.id] = sub;
96
+ open(sub);
97
+ return sub;
98
+ }
99
+
100
+ // Reconnect all inactive subs.
101
+ var converge = function() {
102
+ var closed = _.filter(subs, function(sub) {
103
+ return (sub.ws == null || sub.ws.readyState == WebSocket.CLOSED);
104
+ });
105
+ if (_.isEmpty(closed)) {
106
+ // Done here.
107
+ return;
108
+ }
109
+
110
+ // Display reconnection notice
111
+ toastr.warning(_.size(closed) + " lost connections");
112
+
113
+ // Reopen
114
+ _.each(closed, function(sub) {
115
+ open(sub);
116
+ });
117
+ }
118
+
119
+ var notifyErrors = function() {
120
+ if (errorQueue.length == 0) {
121
+ return;
122
+ }
123
+ toastr.warning(errorQueue.length + " socket errors");
124
+ errorQueue.length = 0;
125
+ converge();
126
+ }
127
+
128
+ // Periodically notify of errors.
129
+ window.setInterval(notifyErrors, 100);
130
+
131
+ // Periodically converge.
132
+ setInterval(converge, 6000);
133
+
134
+ // When terminating, close all connections.
135
+ $(window).unload(unsubscribeAll);
136
+
137
+ return {
138
+ subscribe: subscribe,
139
+ unsubscribe: unsubscribe,
140
+ unsubscribeAll: unsubscribeAll,
141
+ converge: converge,
142
+ load1: load1,
143
+ load5: load5,
144
+ subs: function() { return subs; },
145
+ enable: function() { active = true; console.log("Subs enabled."); },
146
+ disable: function() { active = false; console.log("Subs disabled."); },
147
+ toggle: function() {
148
+ active = ! active;
149
+ if (active) {
150
+ console.log("Subs enabled.");
151
+ } else {
152
+ console.log("Subs disabled.");
153
+ }
154
+ },
155
+ server: function(s) {
156
+ if (s === undefined) {
157
+ return server;
158
+ } else {
159
+ server = s;
160
+ return s;
161
+ }
162
+ }
163
+ };
164
+ })();
@@ -0,0 +1,174 @@
1
+ .toast-title
2
+ {
3
+ font-weight: bold;
4
+ }
5
+
6
+ .toast-message
7
+ {
8
+ -ms-word-wrap: break-word;
9
+ word-wrap: break-word;
10
+ }
11
+
12
+ .toast-message a,
13
+ .toast-message label
14
+ {
15
+ color: #FFF;
16
+ }
17
+
18
+ .toast-message a:hover
19
+ {
20
+ color: #CCC;
21
+ text-decoration: none;
22
+ }
23
+
24
+ .toast-top-left
25
+ {
26
+ left: 12px;
27
+ top: 12px;
28
+ }
29
+
30
+ .toast-bottom-right
31
+ {
32
+ bottom: 12px;
33
+ right: 12px;
34
+ }
35
+
36
+ .toast-bottom-left
37
+ {
38
+ bottom: 12px;
39
+ left: 12px;
40
+ }
41
+
42
+ #toast-container
43
+ {
44
+ position: fixed;
45
+ z-index: 9999;
46
+ }
47
+
48
+ #toast-container > div
49
+ {
50
+ background-position: 15px center;
51
+ background-repeat: no-repeat;
52
+ -moz-border-radius: 3px 3px 3px 3px;
53
+ -webkit-border-radius: 3px 3px 3px 3px;
54
+ border-radius: 3px 3px 3px 3px;
55
+ -moz-box-shadow: 0 0 12px #999999;
56
+ -webkit-box-shadow: 0 0 12px #999999;
57
+ box-shadow: 0 0 12px #999999;
58
+ color: #FFFFFF;
59
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";
60
+ filter: alpha(opacity=80);
61
+ margin: 0 0 6px;
62
+ opacity: 0.8;
63
+ padding: 15px 15px 15px 50px;
64
+ width: 300px;
65
+ }
66
+
67
+ .toast
68
+ {
69
+ background-color: #030303;
70
+ }
71
+
72
+ .toast-success
73
+ {
74
+ background-color: #51A351;
75
+ }
76
+
77
+ .toast-error
78
+ {
79
+ background-color: #BD362F;
80
+ }
81
+
82
+ .toast-info
83
+ {
84
+ background-color: #2F96B4;
85
+ }
86
+
87
+ .toast-warning
88
+ {
89
+ background-color: #F89406;
90
+ }
91
+
92
+ .toast-top-right
93
+ {
94
+ right: 12px;
95
+ top: 12px;
96
+ }
97
+
98
+ #toast-container > :hover
99
+ {
100
+ -moz-box-shadow: 0 0 12px #000000;
101
+ -webkit-box-shadow: 0 0 12px #000000;
102
+ box-shadow: 0 0 12px #000000;
103
+ cursor: pointer;
104
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";
105
+ filter: alpha(opacity=100);
106
+ opacity: 1;
107
+ }
108
+
109
+ #toast-container > .toast-info
110
+ {
111
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGwSURBVEhLtZa9SgNBEMc9sUxxRcoUKSzSWIhXpFMhhYWFhaBg4yPYiWCXZxBLERsLRS3EQkEfwCKdjWJAwSKCgoKCcudv4O5YLrt7EzgXhiU3/4+b2ckmwVjJSpKkQ6wAi4gwhT+z3wRBcEz0yjSseUTrcRyfsHsXmD0AmbHOC9Ii8VImnuXBPglHpQ5wwSVM7sNnTG7Za4JwDdCjxyAiH3nyA2mtaTJufiDZ5dCaqlItILh1NHatfN5skvjx9Z38m69CgzuXmZgVrPIGE763Jx9qKsRozWYw6xOHdER+nn2KkO+Bb+UV5CBN6WC6QtBgbRVozrahAbmm6HtUsgtPC19tFdxXZYBOfkbmFJ1VaHA1VAHjd0pp70oTZzvR+EVrx2Ygfdsq6eu55BHYR8hlcki+n+kERUFG8BrA0BwjeAv2M8WLQBtcy+SD6fNsmnB3AlBLrgTtVW1c2QN4bVWLATaIS60J2Du5y1TiJgjSBvFVZgTmwCU+dAZFoPxGEEs8nyHC9Bwe2GvEJv2WXZb0vjdyFT4Cxk3e/kIqlOGoVLwwPevpYHT+00T+hWwXDf4AJAOUqWcDhbwAAAAASUVORK5CYII=") !important;
112
+ }
113
+
114
+ #toast-container > .toast-error
115
+ {
116
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAHOSURBVEhLrZa/SgNBEMZzh0WKCClSCKaIYOED+AAKeQQLG8HWztLCImBrYadgIdY+gIKNYkBFSwu7CAoqCgkkoGBI/E28PdbLZmeDLgzZzcx83/zZ2SSXC1j9fr+I1Hq93g2yxH4iwM1vkoBWAdxCmpzTxfkN2RcyZNaHFIkSo10+8kgxkXIURV5HGxTmFuc75B2RfQkpxHG8aAgaAFa0tAHqYFfQ7Iwe2yhODk8+J4C7yAoRTWI3w/4klGRgR4lO7Rpn9+gvMyWp+uxFh8+H+ARlgN1nJuJuQAYvNkEnwGFck18Er4q3egEc/oO+mhLdKgRyhdNFiacC0rlOCbhNVz4H9FnAYgDBvU3QIioZlJFLJtsoHYRDfiZoUyIxqCtRpVlANq0EU4dApjrtgezPFad5S19Wgjkc0hNVnuF4HjVA6C7QrSIbylB+oZe3aHgBsqlNqKYH48jXyJKMuAbiyVJ8KzaB3eRc0pg9VwQ4niFryI68qiOi3AbjwdsfnAtk0bCjTLJKr6mrD9g8iq/S/B81hguOMlQTnVyG40wAcjnmgsCNESDrjme7wfftP4P7SP4N3CJZdvzoNyGq2c/HWOXJGsvVg+RA/k2MC/wN6I2YA2Pt8GkAAAAASUVORK5CYII=") !important;
117
+ }
118
+
119
+ #toast-container > .toast-success
120
+ {
121
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAADsSURBVEhLY2AYBfQMgf///3P8+/evAIgvA/FsIF+BavYDDWMBGroaSMMBiE8VC7AZDrIFaMFnii3AZTjUgsUUWUDA8OdAH6iQbQEhw4HyGsPEcKBXBIC4ARhex4G4BsjmweU1soIFaGg/WtoFZRIZdEvIMhxkCCjXIVsATV6gFGACs4Rsw0EGgIIH3QJYJgHSARQZDrWAB+jawzgs+Q2UO49D7jnRSRGoEFRILcdmEMWGI0cm0JJ2QpYA1RDvcmzJEWhABhD/pqrL0S0CWuABKgnRki9lLseS7g2AlqwHWQSKH4oKLrILpRGhEQCw2LiRUIa4lwAAAABJRU5ErkJggg==") !important;
122
+ }
123
+
124
+ #toast-container > .toast-warning
125
+ {
126
+ background-image: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAGYSURBVEhL5ZSvTsNQFMbXZGICMYGYmJhAQIJAICYQPAACiSDB8AiICQQJT4CqQEwgJvYASAQCiZiYmJhAIBATCARJy+9rTsldd8sKu1M0+dLb057v6/lbq/2rK0mS/TRNj9cWNAKPYIJII7gIxCcQ51cvqID+GIEX8ASG4B1bK5gIZFeQfoJdEXOfgX4QAQg7kH2A65yQ87lyxb27sggkAzAuFhbbg1K2kgCkB1bVwyIR9m2L7PRPIhDUIXgGtyKw575yz3lTNs6X4JXnjV+LKM/m3MydnTbtOKIjtz6VhCBq4vSm3ncdrD2lk0VgUXSVKjVDJXJzijW1RQdsU7F77He8u68koNZTz8Oz5yGa6J3H3lZ0xYgXBK2QymlWWA+RWnYhskLBv2vmE+hBMCtbA7KX5drWyRT/2JsqZ2IvfB9Y4bWDNMFbJRFmC9E74SoS0CqulwjkC0+5bpcV1CZ8NMej4pjy0U+doDQsGyo1hzVJttIjhQ7GnBtRFN1UarUlH8F3xict+HY07rEzoUGPlWcjRFRr4/gChZgc3ZL2d8oAAAAASUVORK5CYII=") !important;
127
+ }
128
+
129
+ /*Responsive Design*/
130
+
131
+ @media all and (max-width: 240px)
132
+ {
133
+ #toast-container > div
134
+ {
135
+ padding: 8px 8px 8px 50px;
136
+ width: 108px;
137
+ }
138
+ }
139
+
140
+ @media all and (min-width: 241px) and (max-width: 320px)
141
+ {
142
+ #toast-container > div
143
+ {
144
+ padding: 8px 8px 8px 50px;
145
+ width: 128px;
146
+ }
147
+ }
148
+
149
+ @media all and (min-width: 321px) and (max-width: 480px)
150
+ {
151
+ #toast-container > div
152
+ {
153
+ padding: 8px 8px 8px 50px;
154
+ width: 192px;
155
+ }
156
+ }
157
+
158
+ @media all and (min-width: 481px) and (max-width: 768px)
159
+ {
160
+ #toast-container > div
161
+ {
162
+ padding: 15px 15px 15px 50px;
163
+ width: 300px;
164
+ }
165
+ }
166
+
167
+ @media all and (min-width: 769px)
168
+ {
169
+ #toast-container > div
170
+ {
171
+ padding: 15px 15px 15px 50px;
172
+ width: 300px;
173
+ }
174
+ }
@@ -0,0 +1,207 @@
1
+ // By: Hans Fjällemark and John Papa
2
+ // https://github.com/CodeSeven/toastr
3
+ //
4
+ // Modified to support css styling instead of inline styling
5
+ // Inspired by https://github.com/Srirangan/notifer.js/
6
+
7
+ ; (function (define) {
8
+ define(['jquery'], function ($) {
9
+ var toastr = (function () {
10
+ var
11
+ defaults = {
12
+ tapToDismiss: true,
13
+ toastClass: 'toast',
14
+ containerId: 'toast-container',
15
+ debug: false,
16
+ fadeIn: 300,
17
+ fadeOut: 1000,
18
+ extendedTimeOut: 1000,
19
+ iconClasses: {
20
+ error: 'toast-error',
21
+ info: 'toast-info',
22
+ success: 'toast-success',
23
+ warning: 'toast-warning'
24
+ },
25
+ iconClass: 'toast-info',
26
+ positionClass: 'toast-top-right',
27
+ timeOut: 5000, // Set timeOut to 0 to make it sticky
28
+ titleClass: 'toast-title',
29
+ messageClass: 'toast-message'
30
+ },
31
+
32
+ error = function (message, title, optionsOverride) {
33
+ return notify({
34
+ iconClass: getOptions().iconClasses.error,
35
+ message: message,
36
+ optionsOverride: optionsOverride,
37
+ title: title
38
+ });
39
+ },
40
+
41
+ getContainer = function (options) {
42
+ var $container = $('#' + options.containerId);
43
+ if ($container.length) {
44
+ return $container;
45
+ }
46
+ $container = $('<div/>')
47
+ .attr('id', options.containerId)
48
+ .addClass(options.positionClass);
49
+ $container.appendTo($('body'));
50
+ return $container;
51
+ },
52
+
53
+ getOptions = function () {
54
+ return $.extend({}, defaults, toastr.options);
55
+ },
56
+
57
+ info = function (message, title, optionsOverride) {
58
+ return notify({
59
+ iconClass: getOptions().iconClasses.info,
60
+ message: message,
61
+ optionsOverride: optionsOverride,
62
+ title: title
63
+ });
64
+ },
65
+
66
+ notify = function (map) {
67
+ var
68
+ options = getOptions(),
69
+ iconClass = map.iconClass || options.iconClass;
70
+
71
+ if (typeof (map.optionsOverride) !== 'undefined') {
72
+ options = $.extend(options, map.optionsOverride);
73
+ iconClass = map.optionsOverride.iconClass || iconClass;
74
+ }
75
+
76
+ var
77
+ intervalId = null,
78
+ $container = getContainer(options),
79
+ $toastElement = $('<div/>'),
80
+ $titleElement = $('<div/>'),
81
+ $messageElement = $('<div/>'),
82
+ response = { options: options, map: map };
83
+
84
+ if (map.iconClass) {
85
+ $toastElement.addClass(options.toastClass).addClass(iconClass);
86
+ }
87
+
88
+ if (map.title) {
89
+ $titleElement.append(map.title).addClass(options.titleClass);
90
+ $toastElement.append($titleElement);
91
+ }
92
+
93
+ if (map.message) {
94
+ $messageElement.append(map.message).addClass(options.messageClass);
95
+ $toastElement.append($messageElement);
96
+ }
97
+
98
+ var fadeAway = function () {
99
+ if ($(':focus', $toastElement).length > 0) {
100
+ return;
101
+ }
102
+ var fade = function (callback) {
103
+ return $toastElement.fadeOut(options.fadeOut, callback);
104
+ };
105
+ var removeToast = function () {
106
+ if ($toastElement.is(':visible')) {
107
+ return;
108
+ }
109
+ $toastElement.remove();
110
+ if ($container.children().length === 0) {
111
+ $container.remove();
112
+ }
113
+ };
114
+ fade(removeToast);
115
+ };
116
+ var delayedFadeAway = function () {
117
+ if (options.timeOut > 0 || options.extendedTimeOut > 0) {
118
+ intervalId = setTimeout(fadeAway, options.extendedTimeOut);
119
+ }
120
+ };
121
+ var stickAround = function () {
122
+ clearTimeout(intervalId);
123
+ $toastElement.stop(true, true).fadeIn(options.fadeIn);
124
+ };
125
+ $toastElement.hide();
126
+ $container.prepend($toastElement);
127
+ $toastElement.fadeIn(options.fadeIn);
128
+ if (options.timeOut > 0) {
129
+ intervalId = setTimeout(fadeAway, options.timeOut);
130
+ }
131
+
132
+ $toastElement.hover(stickAround, delayedFadeAway);
133
+ if (!options.onclick && options.tapToDismiss) {
134
+ $toastElement.click(fadeAway);
135
+ }
136
+
137
+ if (options.onclick) {
138
+ $toastElement.click(function () {
139
+ options.onclick() && fadeAway();
140
+ });
141
+ }
142
+
143
+ if (options.debug && console) {
144
+ console.log(response);
145
+ }
146
+ return $toastElement;
147
+ },
148
+
149
+ success = function (message, title, optionsOverride) {
150
+ return notify({
151
+ iconClass: getOptions().iconClasses.success,
152
+ message: message,
153
+ optionsOverride: optionsOverride,
154
+ title: title
155
+ });
156
+ },
157
+
158
+ warning = function (message, title, optionsOverride) {
159
+ return notify({
160
+ iconClass: getOptions().iconClasses.warning,
161
+ message: message,
162
+ optionsOverride: optionsOverride,
163
+ title: title
164
+ });
165
+ },
166
+
167
+ clear = function ($toastElement) {
168
+ var options = getOptions();
169
+ var $container = $('#' + options.containerId);
170
+ if ($toastElement && $(':focus', $toastElement).length === 0) {
171
+ var removeToast = function () {
172
+ if ($toastElement.is(':visible')) {
173
+ return;
174
+ }
175
+ $toastElement.remove();
176
+ if ($container.children().length === 0) {
177
+ $container.remove();
178
+ }
179
+ };
180
+ $toastElement.fadeOut(options.fadeOut, removeToast);
181
+ return;
182
+ }
183
+ if ($container.length) {
184
+ $container.fadeOut(options.fadeOut, function () {
185
+ $container.remove();
186
+ });
187
+ }
188
+ };
189
+ return {
190
+ clear: clear,
191
+ error: error,
192
+ info: info,
193
+ options: {},
194
+ success: success,
195
+ version: '1.1.2',
196
+ warning: warning
197
+ };
198
+ })();
199
+ return toastr;
200
+ });
201
+ }(typeof define === 'function' && define.amd ? define : function (deps, factory) {
202
+ if (typeof module !== 'undefined' && module.exports) { //Node
203
+ module.exports = factory(require(deps[0]));
204
+ } else {
205
+ window['toastr'] = factory(window['jQuery']);
206
+ }
207
+ }));