diff --git a/public_html/media/js/core.js b/public_html/media/js/core.js
index b70a091c..33bf8b10 100644
--- a/public_html/media/js/core.js
+++ b/public_html/media/js/core.js
@@ -39,13 +39,9 @@ $(function()
$.get(url, function(data)
{
if (data['success'])
- {
window.location.reload();
- }
else
- {
alert(data['message']);
- }
});
});
});
@@ -88,6 +84,8 @@ $(function()
{
if (aDom.hasAttr('data-redirect-url'))
window.location.href = aDom.attr('data-redirect-url');
+ else if (aDom.data('callback'))
+ aDom.data('callback')();
else
window.location.reload();
}
@@ -115,16 +113,13 @@ $(function()
});
});
});
- $('body').trigger('dom-update');
});
//modify DOM on small viewports
-$(window).resize(function()
+function processSidebar()
{
- if ($('body').width() == $('body').data('last-width'))
- return;
$('#inner-content .unit').addClass('bottom-unit');
if ($('body').width() < 600)
{
@@ -139,10 +134,15 @@ $(window).resize(function()
$('#sidebar .unit').removeClass('bottom-unit').addClass('left-unit');
}
$('body').data('last-width', $('body').width());
-});
+}
$(function()
{
- $(window).resize();
+ $(window).resize(function()
+ {
+ if ($('body').width() == $('body').data('last-width'))
+ return;
+ });
+ $('body').bind('dom-update', processSidebar);
});
@@ -242,3 +242,9 @@ $(function()
Mousetrap.bind('d', function() { var url = $('.paginator:visible .next:not(.disabled) a').attr('href'); if (typeof url !== 'undefined') window.location.href = url; }, 'keyup');
Mousetrap.bind('p', function() { $('.post a').eq(0).focus(); return false; }, 'keyup');
});
+
+
+$(function()
+{
+ $('body').trigger('dom-update');
+});
diff --git a/public_html/media/js/post-view.js b/public_html/media/js/post-view.js
index 805f6685..579508e5 100644
--- a/public_html/media/js/post-view.js
+++ b/public_html/media/js/post-view.js
@@ -1,4 +1,4 @@
-$(function()
+function onDomUpdate()
{
$('li.edit a').click(function(e)
{
@@ -30,6 +30,30 @@ $(function()
});
});
+ $('.comments.unit a.simple-action').data('callback', function()
+ {
+ $.get(window.location.href, function(data)
+ {
+ $('.comments.unit').replaceWith($(data).find('.comments.unit'));
+ $('body').trigger('dom-update');
+ });
+ });
+
+ $('#sidebar a.simple-action').data('callback', function()
+ {
+ $.get(window.location.href, function(data)
+ {
+ $('#sidebar').replaceWith($(data).find('#sidebar'));
+ $('body').trigger('dom-update');
+ });
+ });
+}
+
+$(function()
+{
+ $('body').bind('dom-update', onDomUpdate);
+ onDomUpdate();
+
$('form.edit-post').submit(function(e)
{
e.preventDefault();
@@ -104,13 +128,18 @@ $(function()
if (preview)
{
formDom.find('.preview').html(data['textPreview']).show();
- formDom.find(':input').attr('readonly', false);
- formDom.removeClass('inactive');
}
else
{
- window.location.reload();
+ $.get(window.location.href, function(data)
+ {
+ $('.comments.unit').replaceWith($(data).find('.comments.unit'));
+ $('body').trigger('dom-update');
+ });
+ formDom.find('textarea').val('');
}
+ formDom.find(':input').attr('readonly', false);
+ formDom.removeClass('inactive');
}
else
{