Skip to content

Commit

Permalink
AJAX Notify/Unnotify was not setting the proper value for the quick r…
Browse files Browse the repository at this point in the history
…eply - fixes #1819

Signed-off-by: emanuele <emanuele45@gmail.com>
  • Loading branch information
emanuele45 committed Sep 16, 2014
1 parent 9914ec3 commit f418a9a
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions themes/default/scripts/script_elk.js
Expand Up @@ -27,8 +27,9 @@ function elk_codefix()
*
* @param {string} btn string representing this, generally the anchor link tag <a class="" href="" onclick="">
* @param {string} confirmation_msg_variable var name of the text sting to display in the "are you sure" box
* @param {function} onSuccessCallback optional, a callback executed on successfully execute the AJAX call
*/
function toggleButtonAJAX(btn, confirmation_msg_variable)
function toggleButtonAJAX(btn, confirmation_msg_variable, onSuccessCallback)
{
$.ajax({
type: 'GET',
Expand Down Expand Up @@ -75,6 +76,9 @@ function toggleButtonAJAX(btn, confirmation_msg_variable)
if (oElement.getElementsByTagName('url').length !== 0)
window.location.href = oElement.getElementsByTagName('url')[0].firstChild.nodeValue;
}

if (typeof (onSuccessCallback) !== 'undefined')
onSuccessCallback(btn, request, oElement.getElementsByTagName('error'));
})
.fail(function() {
// ajax failure code
Expand Down Expand Up @@ -149,7 +153,20 @@ function notifyButton(btn)
if (typeof (notification_topic_notice) !== 'undefined' && !confirm(notification_topic_notice))
return false;

return toggleButtonAJAX(btn, 'notification_topic_notice');
return toggleButtonAJAX(btn, 'notification_topic_notice', function(btn, request, errors) {
var toggle = 0;

if (errors.length > 0)
return;

// This is a "turn notifications on"
if (btn.href.indexOf('sa=on') !== -1)
toggle = 1;
else
toggle = 0;

$("input[name='notify']").val(toggle);
});
}

/**
Expand Down

0 comments on commit f418a9a

Please sign in to comment.