Fixed issue with masstag in endless scrolling mode
This commit is contained in:
parent
b093a090eb
commit
09b5a38c95
3 changed files with 107 additions and 84 deletions
|
@ -1,3 +1,4 @@
|
|||
//core functionalities, prototypes
|
||||
$.fn.hasAttr = function(name)
|
||||
{
|
||||
return this.attr(name) !== undefined;
|
||||
|
@ -20,6 +21,9 @@ if ($.when.all === undefined)
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//safety trigger
|
||||
$(function()
|
||||
{
|
||||
$('.safety a').click(function(e)
|
||||
|
@ -44,67 +48,78 @@ $(function()
|
|||
}
|
||||
});
|
||||
});
|
||||
|
||||
function confirmEvent(e)
|
||||
{
|
||||
if (!confirm($(this).attr('data-confirm-text')))
|
||||
{
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
$('form[data-confirm-text]').submit(confirmEvent);
|
||||
$('a[data-confirm-text]').click(confirmEvent);
|
||||
|
||||
$('a.simple-action').click(function(e)
|
||||
{
|
||||
if(e.isPropagationStopped())
|
||||
return;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var aDom = $(this);
|
||||
if (aDom.hasClass('inactive'))
|
||||
return;
|
||||
aDom.addClass('inactive');
|
||||
|
||||
var url = $(this).attr('href') + '?json';
|
||||
$.get(url, {submit: 1}, function(data)
|
||||
{
|
||||
if (data['success'])
|
||||
{
|
||||
if (aDom.hasAttr('data-redirect-url'))
|
||||
window.location.href = aDom.attr('data-redirect-url');
|
||||
else
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(data['errorMessage']);
|
||||
aDom.removeClass('inactive');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//attach data from submit buttons to forms before .submit() gets called
|
||||
$(':submit').each(function()
|
||||
{
|
||||
$(this).click(function()
|
||||
{
|
||||
var form = $(this).closest('form');
|
||||
form.find('.faux-submit').remove();
|
||||
var input = $('<input class="faux-submit" type="hidden"/>').attr({
|
||||
name: $(this).attr('name'),
|
||||
value: $(this).val()
|
||||
});
|
||||
form.append(input);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
//basic event listeners
|
||||
$(function()
|
||||
{
|
||||
$('body').bind('dom-update', function()
|
||||
{
|
||||
function confirmEvent(e)
|
||||
{
|
||||
if (!confirm($(this).attr('data-confirm-text')))
|
||||
{
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
}
|
||||
}
|
||||
|
||||
$('form[data-confirm-text]').submit(confirmEvent);
|
||||
$('a[data-confirm-text]').click(confirmEvent);
|
||||
|
||||
$('a.simple-action').click(function(e)
|
||||
{
|
||||
if(e.isPropagationStopped())
|
||||
return;
|
||||
|
||||
e.preventDefault();
|
||||
|
||||
var aDom = $(this);
|
||||
if (aDom.hasClass('inactive'))
|
||||
return;
|
||||
aDom.addClass('inactive');
|
||||
|
||||
var url = $(this).attr('href') + '?json';
|
||||
$.get(url, {submit: 1}, function(data)
|
||||
{
|
||||
if (data['success'])
|
||||
{
|
||||
if (aDom.hasAttr('data-redirect-url'))
|
||||
window.location.href = aDom.attr('data-redirect-url');
|
||||
else
|
||||
window.location.reload();
|
||||
}
|
||||
else
|
||||
{
|
||||
alert(data['errorMessage']);
|
||||
aDom.removeClass('inactive');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
//attach data from submit buttons to forms before .submit() gets called
|
||||
$(':submit').each(function()
|
||||
{
|
||||
$(this).click(function()
|
||||
{
|
||||
var form = $(this).closest('form');
|
||||
form.find('.faux-submit').remove();
|
||||
var input = $('<input class="faux-submit" type="hidden"/>').attr({
|
||||
name: $(this).attr('name'),
|
||||
value: $(this).val()
|
||||
});
|
||||
form.append(input);
|
||||
});
|
||||
});
|
||||
});
|
||||
$('body').trigger('dom-update');
|
||||
});
|
||||
|
||||
|
||||
|
||||
//modify DOM on small viewports
|
||||
$(window).resize(function()
|
||||
{
|
||||
|
@ -131,6 +146,7 @@ $(function()
|
|||
});
|
||||
|
||||
|
||||
|
||||
//autocomplete
|
||||
function split(val)
|
||||
{
|
||||
|
@ -214,6 +230,9 @@ function getTagItOptions()
|
|||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
//hotkeys
|
||||
$(function()
|
||||
{
|
||||
Mousetrap.bind('q', function() { $('#top-nav input').focus(); return false; }, 'keyup');
|
||||
|
|
|
@ -1,34 +1,37 @@
|
|||
$(function()
|
||||
{
|
||||
$('.post a.toggle-tag').click(function(e)
|
||||
$('body').bind('dom-update', function()
|
||||
{
|
||||
if(e.isPropagationStopped())
|
||||
return;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var aDom = $(this);
|
||||
if (aDom.hasClass('inactive'))
|
||||
return;
|
||||
aDom.addClass('inactive');
|
||||
|
||||
var url = $(this).attr('href') + '?json';
|
||||
$.get(url, {submit: 1}, function(data)
|
||||
$('.post a.toggle-tag').click(function(e)
|
||||
{
|
||||
if (data['success'])
|
||||
if(e.isPropagationStopped())
|
||||
return;
|
||||
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
|
||||
var aDom = $(this);
|
||||
if (aDom.hasClass('inactive'))
|
||||
return;
|
||||
aDom.addClass('inactive');
|
||||
|
||||
var url = $(this).attr('href') + '?json';
|
||||
$.get(url, {submit: 1}, function(data)
|
||||
{
|
||||
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
|
||||
{
|
||||
alert(data['errorMessage']);
|
||||
aDom.removeClass('inactive');
|
||||
}
|
||||
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
|
||||
{
|
||||
alert(data['errorMessage']);
|
||||
aDom.removeClass('inactive');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -18,6 +18,7 @@ function scrolled()
|
|||
var nextPage = dom.find('.paginator .next:not(.disabled) a').attr('href');
|
||||
$(document).data('page-next', nextPage);
|
||||
$('.paginator-content').append($(response).find('.paginator-content').children().css({opacity: 0}).animate({opacity: 1}, 'slow'));
|
||||
$('body').trigger('dom-update');
|
||||
scrolled();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue