2013-10-29 09:04:42 +01:00
|
|
|
$(function()
|
|
|
|
{
|
2013-11-05 09:17:44 +01:00
|
|
|
$('body').bind('dom-update', function()
|
2013-10-29 09:04:42 +01:00
|
|
|
{
|
2013-11-05 09:17:44 +01:00
|
|
|
$('.post a.toggle-tag').click(function(e)
|
|
|
|
{
|
|
|
|
if(e.isPropagationStopped())
|
|
|
|
return;
|
2013-10-29 09:04:42 +01:00
|
|
|
|
2013-11-05 09:17:44 +01:00
|
|
|
e.preventDefault();
|
|
|
|
e.stopPropagation();
|
2013-10-29 09:04:42 +01:00
|
|
|
|
2013-11-05 09:17:44 +01:00
|
|
|
var aDom = $(this);
|
|
|
|
if (aDom.hasClass('inactive'))
|
|
|
|
return;
|
|
|
|
aDom.addClass('inactive');
|
2013-10-29 09:04:42 +01:00
|
|
|
|
2013-11-05 09:17:44 +01:00
|
|
|
var url = $(this).attr('href') + '?json';
|
2013-11-23 09:51:57 +01:00
|
|
|
$.get(url, {submit: 1}).always(function(data)
|
2013-10-29 09:04:42 +01:00
|
|
|
{
|
2013-11-05 09:17:44 +01:00
|
|
|
if (data['success'])
|
|
|
|
{
|
|
|
|
aDom.removeClass('inactive');
|
|
|
|
aDom.parents('.post').toggleClass('tagged');
|
|
|
|
aDom.text(aDom.parents('.post').hasClass('tagged')
|
|
|
|
? aDom.attr('data-text-tagged')
|
|
|
|
: aDom.attr('data-text-untagged'));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-11-23 09:51:57 +01:00
|
|
|
alert(data['message'] ? data['message'] : 'Fatal error');
|
2013-11-05 09:17:44 +01:00
|
|
|
aDom.removeClass('inactive');
|
|
|
|
}
|
|
|
|
});
|
2013-10-29 09:04:42 +01:00
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|