minor: Rename $mute to $container.

The name doesn't even make sense for the specific
case, and we want to generalize this widget.
This commit is contained in:
Steve Howell
2018-12-20 16:20:14 +00:00
committed by Tim Abbott
parent 079dfadf1a
commit 51438281c7

View File

@@ -27,17 +27,17 @@ exports.notify_with_undo_option = (function () {
var meta = { var meta = {
hide_me_time: null, hide_me_time: null,
alert_hover_state: false, alert_hover_state: false,
$mute: null, $container: null,
}; };
var animate = { var animate = {
fadeOut: function () { fadeOut: function () {
if (meta.$mute) { if (meta.$container) {
meta.$mute.fadeOut(500).removeClass("show"); meta.$container.fadeOut(500).removeClass("show");
} }
}, },
fadeIn: function () { fadeIn: function () {
if (meta.$mute) { if (meta.$container) {
meta.$mute.fadeIn(500).addClass("show"); meta.$container.fadeIn(500).addClass("show");
} }
}, },
}; };
@@ -58,14 +58,14 @@ exports.notify_with_undo_option = (function () {
exports.unmute(stream_id, topic); exports.unmute(stream_id, topic);
}; };
if (!meta.$mute) { if (!meta.$container) {
meta.$mute = $("#unmute_muted_topic_notification"); meta.$container = $("#unmute_muted_topic_notification");
$exit.click(function () { $exit.click(function () {
animate.fadeOut(); animate.fadeOut();
}); });
meta.$mute.find("#unmute").click(function () { meta.$container.find("#unmute").click(function () {
// it should reference the meta variable and not get stuck with // it should reference the meta variable and not get stuck with
// a pass-by-value of stream, topic. // a pass-by-value of stream, topic.
meta.undo(); meta.undo();
@@ -76,18 +76,18 @@ exports.notify_with_undo_option = (function () {
// add a four second delay before closing up. // add a four second delay before closing up.
meta.hide_me_time = new Date().getTime() + 4000; meta.hide_me_time = new Date().getTime() + 4000;
meta.$mute.find(".stream").text(stream_name); meta.$container.find(".stream").text(stream_name);
meta.$mute.find(".topic").text(topic); meta.$container.find(".topic").text(topic);
animate.fadeIn(); animate.fadeIn();
// if the user mouses over the notification, don't hide it. // if the user mouses over the notification, don't hide it.
meta.$mute.mouseenter(function () { meta.$container.mouseenter(function () {
meta.alert_hover_state = true; meta.alert_hover_state = true;
}); });
// once the user's mouse leaves the notification, restart the countdown. // once the user's mouse leaves the notification, restart the countdown.
meta.$mute.mouseleave(function () { meta.$container.mouseleave(function () {
meta.alert_hover_state = false; meta.alert_hover_state = false;
// add at least 2000ms but if more than that exists just keep the // add at least 2000ms but if more than that exists just keep the
// current amount. // current amount.
@@ -97,9 +97,9 @@ exports.notify_with_undo_option = (function () {
}()); }());
exports.dismiss_mute_confirmation = function () { exports.dismiss_mute_confirmation = function () {
var $mute = $("#unmute_muted_topic_notification"); var $container = $("#unmute_muted_topic_notification");
if ($mute) { if ($container) {
$mute.fadeOut(500).removeClass("show"); $container.fadeOut(500).removeClass("show");
} }
}; };