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-25 11:59:59 +01:00
|
|
|
var enable = !aDom.parents('.post').hasClass('tagged');
|
2013-11-05 09:17:44 +01:00
|
|
|
var url = $(this).attr('href') + '?json';
|
2013-11-25 11:59:59 +01:00
|
|
|
url = url.replace('_enable_', enable ? '1' : '0');
|
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');
|
2013-11-25 11:59:59 +01:00
|
|
|
aDom.parents('.post').removeClass('tagged');
|
|
|
|
if (enable)
|
|
|
|
aDom.parents('.post').addClass('tagged');
|
|
|
|
aDom.text(enable
|
2013-11-05 09:17:44 +01:00
|
|
|
? 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
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|