VRFS-1287 VRFS-1340 fix issues with weird behavior of Okay and Cancel buttons in notifications

This commit is contained in:
Brian Smith 2014-03-08 01:37:25 -05:00
parent 9c2b10dd5f
commit 00a447037a
3 changed files with 35 additions and 20 deletions

View File

@ -711,7 +711,7 @@
if (notifyQueue.length === 0) {
firstNotification = true;
setNotificationInfo(message, descriptor);
setNotificationInfo(message, descriptor, $notify);
}
notifyQueue.push({message: message, descriptor: descriptor});
@ -733,11 +733,13 @@
if (notifyDetails !== undefined) {
setNotificationInfo(notifyDetails.message, notifyDetails.descriptor);
}
notifyDetails = {};
}
});
};
function setNotificationInfo(message, descriptor) {
function setNotificationInfo(message, descriptor, notificationSelector) {
var $notify = $('[layout="notify"]');
$('h2', $notify).text(message.title);
$('p', $notify).empty();
@ -763,19 +765,20 @@
$('div.detail', $notify).hide();
}
$('#ok-button', $notify).unbind('click');
$('#cancel-button', $notify).unbind('click');
if (descriptor) {
if (descriptor.ok_text) {
$('#ok-button', $notify).html(descriptor.ok_text);
}
else {
$('#ok-button', $notify).html("OKAY");
}
if (descriptor.ok_callback !== undefined) {
$('#ok-button', $notify).unbind('click');
$('#ok-button', $notify).click(function () {
}
$('#ok-button', $notify).click(function () {
if (descriptor.ok_callback !== undefined) {
if (descriptor.ok_callback_args) {
logger.debug("descriptor.ok_callback_args=" + descriptor.ok_callback_args);
descriptor.ok_callback(descriptor.ok_callback_args);
return false;
}
@ -783,8 +786,11 @@
descriptor.ok_callback();
return false;
}
});
}
}
else {
notificationSelector.hide();
}
});
if (descriptor.cancel_text) {
$('#cancel-button', $notify).html(descriptor.cancel_text);
@ -797,12 +803,10 @@
$('#cancel-button', $notify).html("CANCEL");
}
}
if (descriptor.cancel_callback !== undefined) {
$('#cancel-button', $notify).unbind('click');
$('#cancel-button', $notify).click(function () {
$('#cancel-button', $notify).click(function () {
if (descriptor.cancel_callback !== undefined) {
if (descriptor.cancel_callback_args) {
logger.debug("descriptor.cancel_callback_args=" + descriptor.cancel_callback_args);
descriptor.cancel_callback(descriptor.cancel_callback_args);
return false;
}
@ -810,12 +814,23 @@
descriptor.cancel_callback();
return false;
}
});
}
}
else {
notificationSelector.hide();
}
});
}
// by default OKAY and CANCEL should just hide the notification
else {
$('#ok-button', $notify).html("OKAY");
$('#ok-button', $notify).click(function () {
notificationSelector.hide();
});
$('#cancel-button', $notify).html("CANCEL");
$('#cancel-button', $notify).click(function () {
notificationSelector.hide();
});
}
}

View File

@ -515,8 +515,8 @@
function acceptFriendRequest(args) {
rest.acceptFriendRequest({
status : 'accept',
friend_request_id : args.friend_request_id
status: 'accept',
friend_request_id: args.friend_request_id
}).done(function(response) {
deleteNotification(args.notification_id); // delete notification corresponding to this friend request
initializeFriendsPanel(); // refresh friends panel when request is accepted

View File

@ -201,7 +201,7 @@
<li session-id="{sessionId}" notification-id="{notificationId}">
<div class="avatar-small"><img src="{avatar_url}" /></div>
<div class="note-text">
{text}&nbsp;&nbsp;
{text}<br/>
<em>{date}</em>
<div class="note-delete">
<a>