Fix notification id collision
This commit is contained in:
parent
bf672bdec3
commit
34ec05d4b4
2 changed files with 13 additions and 12 deletions
|
@ -49,7 +49,7 @@ class Wrapper
|
||||||
@sendInner message # Pass message to inner frame
|
@sendInner message # Pass message to inner frame
|
||||||
else if cmd == "notification" # Display notification
|
else if cmd == "notification" # Display notification
|
||||||
type = message.params[0]
|
type = message.params[0]
|
||||||
id = "notification-#{message.id}"
|
id = "notification-ws-#{message.id}"
|
||||||
if "-" in message.params[0] # - in first param: message id defined
|
if "-" in message.params[0] # - in first param: message id defined
|
||||||
[id, type] = message.params[0].split("-")
|
[id, type] = message.params[0].split("-")
|
||||||
@notifications.add(id, type, message.params[1], message.params[2])
|
@notifications.add(id, type, message.params[1], message.params[2])
|
||||||
|
|
|
@ -684,11 +684,11 @@ jQuery.extend( jQuery.easing,
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
var Notifications,
|
var Notifications,
|
||||||
__slice = [].slice;
|
slice = [].slice;
|
||||||
|
|
||||||
Notifications = (function() {
|
Notifications = (function() {
|
||||||
function Notifications(_at_elem) {
|
function Notifications(elem1) {
|
||||||
this.elem = _at_elem;
|
this.elem = elem1;
|
||||||
this;
|
this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -707,14 +707,14 @@ jQuery.extend( jQuery.easing,
|
||||||
};
|
};
|
||||||
|
|
||||||
Notifications.prototype.add = function(id, type, body, timeout) {
|
Notifications.prototype.add = function(id, type, body, timeout) {
|
||||||
var elem, width, _i, _len, _ref;
|
var elem, i, len, ref, width;
|
||||||
if (timeout == null) {
|
if (timeout == null) {
|
||||||
timeout = 0;
|
timeout = 0;
|
||||||
}
|
}
|
||||||
id = id.replace(/[^A-Za-z0-9]/g, "");
|
id = id.replace(/[^A-Za-z0-9]/g, "");
|
||||||
_ref = $(".notification-" + id);
|
ref = $(".notification-" + id);
|
||||||
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
|
for (i = 0, len = ref.length; i < len; i++) {
|
||||||
elem = _ref[_i];
|
elem = ref[i];
|
||||||
this.close($(elem));
|
this.close($(elem));
|
||||||
}
|
}
|
||||||
elem = $(".notification.template", this.elem).clone().removeClass("template");
|
elem = $(".notification.template", this.elem).clone().removeClass("template");
|
||||||
|
@ -791,8 +791,8 @@ jQuery.extend( jQuery.easing,
|
||||||
|
|
||||||
Notifications.prototype.log = function() {
|
Notifications.prototype.log = function() {
|
||||||
var args;
|
var args;
|
||||||
args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
|
args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
|
||||||
return console.log.apply(console, ["[Notifications]"].concat(__slice.call(args)));
|
return console.log.apply(console, ["[Notifications]"].concat(slice.call(args)));
|
||||||
};
|
};
|
||||||
|
|
||||||
return Notifications;
|
return Notifications;
|
||||||
|
@ -804,6 +804,7 @@ jQuery.extend( jQuery.easing,
|
||||||
}).call(this);
|
}).call(this);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* ---- src/Ui/media/Wrapper.coffee ---- */
|
/* ---- src/Ui/media/Wrapper.coffee ---- */
|
||||||
|
|
||||||
|
|
||||||
|
@ -880,7 +881,7 @@ jQuery.extend( jQuery.easing,
|
||||||
}
|
}
|
||||||
} else if (cmd === "notification") {
|
} else if (cmd === "notification") {
|
||||||
type = message.params[0];
|
type = message.params[0];
|
||||||
id = "notification-" + message.id;
|
id = "notification-ws-" + message.id;
|
||||||
if (indexOf.call(message.params[0], "-") >= 0) {
|
if (indexOf.call(message.params[0], "-") >= 0) {
|
||||||
ref = message.params[0].split("-"), id = ref[0], type = ref[1];
|
ref = message.params[0].split("-"), id = ref[0], type = ref[1];
|
||||||
}
|
}
|
||||||
|
@ -1550,4 +1551,4 @@ jQuery.extend( jQuery.easing,
|
||||||
|
|
||||||
window.wrapper = new Wrapper(ws_url);
|
window.wrapper = new Wrapper(ws_url);
|
||||||
|
|
||||||
}).call(this);
|
}).call(this);
|
Loading…
Reference in a new issue