Skip to content

Commit b5eda67

Browse files
author
Scott Greenfield
committed
Improved code per suggestions of ehynds. Moved queued notifications example to index.htm to show that it works with the other examples. Updated minified JavaScript to reflect the changes.
1 parent 539951e commit b5eda67

File tree

4 files changed

+25
-62
lines changed

4 files changed

+25
-62
lines changed

index.htm

+17
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
container.notify("widget").find("input").bind("click", function(){
7878
container.notify("create", 1, { title:'Another Notification!', text:'The quick brown fox jumped over the lazy dog.' });
7979
});
80+
81+
// third
82+
var container = $("#container-bottom-right").notify();
83+
$("#queue").click(function(){
84+
container.notify("create", "queueing", {
85+
title:'Queueing', text:'Example of a notification with queuing. For this container, no more than three notifications of this type will be visible at one time.'
86+
}, { queue: 3 });
87+
});
8088
});
8189
</script>
8290

@@ -92,6 +100,7 @@ <h1>jQuery UI Notify Widget</h1>
92100

93101
<form style="margin:20px 0">
94102
<input type="button" id="default" value="Open with default configuration" />
103+
<input type="button" id="queue" value="Or with Queueing" />
95104
<input type="button" id="sticky" value="Create a &quot;sticky&quot; notification" />
96105
<input type="button" id="warning" value="Use icons in your templates" />
97106
<input type="button" id="buttons" value="Or buttons even" />
@@ -152,6 +161,14 @@ <h1>#{title}</h1>
152161
<p>#{text}</p>
153162
</div>
154163
</div>
164+
165+
<!--- third container - bottom-right notifications --->
166+
<div id="container-bottom-right" style="display:none; top:0; right:360px; margin:10px 10px 0 0">
167+
<div id="queueing">
168+
<h1>#{title}</h1>
169+
<p>#{text}</p>
170+
</div>
171+
</div>
155172
</div>
156173

157174
</body>

limit-example.htm

-55
This file was deleted.

src/jquery.notify.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ $.widget("ech.notify", {
4949
tpl = $(tpl).removeClass("ui-notify-message-style").wrap("<div></div>").parent().html();
5050
}
5151

52-
$.ech.notify.openNotifications = $.ech.notify.openNotifications || 0;
52+
this.openNotifications = this.openNotifications || 0;
53+
54+
// return a new notification instance
5355
return new $.ech.notify.instance(this)._create(msg, $.extend({}, this.options, opts), tpl);
5456
}
5557
});
@@ -106,9 +108,8 @@ $.extend($.ech.notify.instance.prototype, {
106108
}
107109

108110
});
109-
110-
if (!this.options.queue) this.parent.element.dequeue('notify');
111-
else if ($.ech.notify.openNotifications <= this.options.queue-1) this.parent.element.dequeue('notify');
111+
112+
if(!this.options.queue || this.parent.openNotifications <= this.options.queue - 1) this.parent.element.dequeue('notify');
112113

113114
return this;
114115
},
@@ -119,7 +120,7 @@ $.extend($.ech.notify.instance.prototype, {
119120
self._trigger("close");
120121
self.isOpen = false;
121122
self.element.remove();
122-
$.ech.notify.openNotifications -= 1;
123+
self.parent.openNotifications -= 1;
123124
self.parent.element.dequeue('notify');
124125
});
125126

@@ -132,7 +133,7 @@ $.extend($.ech.notify.instance.prototype, {
132133

133134
var self = this;
134135

135-
$.ech.notify.openNotifications += 1;
136+
this.parent.openNotifications += 1;
136137

137138
this.element[this.options.stack === 'above' ? 'prependTo' : 'appendTo'](this.parent.element).css({ display:"none", opacity:"" }).fadeIn(this.options.speed, function(){
138139
self._trigger("open");

src/jquery.notify.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)