Removed extra spacing from js/default.js
Signed-off-by: Collin J. Doering <collin.doering@rekahsoft.ca>
This commit is contained in:
parent
b065448a26
commit
c5803970bd
228
js/default.js
228
js/default.js
|
@ -177,132 +177,132 @@ _paq.push(['enableLinkTracking']);
|
|||
return spec;
|
||||
}()),
|
||||
|
||||
page = (function () {
|
||||
// var pageId = '#page-content', navId = '#nav';
|
||||
page = (function () {
|
||||
// var pageId = '#page-content', navId = '#nav';
|
||||
|
||||
function loadPageContent(page_href, virt_href, handlerCallback) {
|
||||
// Track page view with piwik
|
||||
_paq.push(['setDocumentTitle', document.domain + '/' + virt_href]);
|
||||
_paq.push(['trackPageView']);
|
||||
function loadPageContent(page_href, virt_href, handlerCallback) {
|
||||
// Track page view with piwik
|
||||
_paq.push(['setDocumentTitle', document.domain + '/' + virt_href]);
|
||||
_paq.push(['trackPageView']);
|
||||
|
||||
$.ajax({
|
||||
url: page_href,
|
||||
type: 'GET',
|
||||
dataType: 'html',
|
||||
beforeSend: function (xhr, settings) {
|
||||
// Add .loading to #page-content and #nav to facilitate a loading animation
|
||||
$('#page-content, #nav').removeClass('loading-done').addClass('loading');
|
||||
$.ajax({
|
||||
url: page_href,
|
||||
type: 'GET',
|
||||
dataType: 'html',
|
||||
beforeSend: function (xhr, settings) {
|
||||
// Add .loading to #page-content and #nav to facilitate a loading animation
|
||||
$('#page-content, #nav').removeClass('loading-done').addClass('loading');
|
||||
|
||||
// Run current handlers onSuccess callback (if it exists)
|
||||
if (handlerCallback.hasOwnProperty('beforeSend') && typeof handlerCallback.beforeSend === 'function') {
|
||||
handlerCallback.beforeSend(page_href, virt_href);
|
||||
}
|
||||
// Run current handlers onSuccess callback (if it exists)
|
||||
if (handlerCallback.hasOwnProperty('beforeSend') && typeof handlerCallback.beforeSend === 'function') {
|
||||
handlerCallback.beforeSend(page_href, virt_href);
|
||||
}
|
||||
|
||||
console.log('beforeSend a.menuitem');
|
||||
},
|
||||
success: function (dta) {
|
||||
// Remove any status message errors or successes
|
||||
$('#status').slideUp('normal', function () {
|
||||
$('#status').removeClass('error').removeClass('success').children('p.message').remove();
|
||||
});
|
||||
console.log('beforeSend a.menuitem');
|
||||
},
|
||||
success: function (dta) {
|
||||
// Remove any status message errors or successes
|
||||
$('#status').slideUp('normal', function () {
|
||||
$('#status').removeClass('error').removeClass('success').children('p.message').remove();
|
||||
});
|
||||
|
||||
// Stop animations in the nav and page-content and scroll to the top of the page in a set amount of time
|
||||
setTimeout(function () {
|
||||
// Replace old page-content with new page-content
|
||||
dta = $($.parseHTML(dta)).filter('#page-content').html();
|
||||
$('#page-content').html(dta);
|
||||
// Stop animations in the nav and page-content and scroll to the top of the page in a set amount of time
|
||||
setTimeout(function () {
|
||||
// Replace old page-content with new page-content
|
||||
dta = $($.parseHTML(dta)).filter('#page-content').html();
|
||||
$('#page-content').html(dta);
|
||||
|
||||
// Stop page loading
|
||||
$('#page-content, #nav').removeClass('loading');
|
||||
|
||||
// Reload any new maths using MathJax
|
||||
$('#page-content .math').each(function (math_elem) {
|
||||
mj.Hub.Queue(["Typeset", mj.Hub, math_elem[0]]);
|
||||
});
|
||||
|
||||
// Rewrite new URLs within new content inserted into #page-content
|
||||
$('#page-content a').each(function (i) {
|
||||
var href = $(this).attr('href'),
|
||||
external_url_regexp = /https?:\/\/.*/,
|
||||
mailto_regexp = /mailto:.*/,
|
||||
files_regexp = /files\/.*/,
|
||||
images_regexp = /images\/.*/;
|
||||
|
||||
if (!(external_url_regexp.test(href) || mailto_regexp.test(href) || files_regexp.test(href) || images_regexp.test(href))) {
|
||||
$(this).attr('href', "/#" + href);
|
||||
}
|
||||
});
|
||||
|
||||
// Add fullscreen functionality to inline-images and figures
|
||||
$('article.post p > img').click(function () {
|
||||
$(this).get(0).toggleFullScreen();
|
||||
});
|
||||
$('figure').click(function () {
|
||||
$(this).children('img').get(0).toggleFullScreen();
|
||||
});
|
||||
|
||||
// Run current handles onSuccess callback (if it exists)
|
||||
if (handlerCallback.hasOwnProperty('onSuccess') && typeof handlerCallback.onSuccess === 'function') {
|
||||
handlerCallback.onSuccess();
|
||||
}
|
||||
|
||||
// Scroll to top of the page
|
||||
if ($('body').scrollTop() > $('#nav').offset().top - 15) {
|
||||
$('html, body').animate({
|
||||
scrollTop: $('#nav').offset().top - 15
|
||||
}, 'fast');
|
||||
}
|
||||
}, 250);
|
||||
},
|
||||
error: function (xhr, status) {
|
||||
/* Remove .loading from #page-content and #nav to stop the loading
|
||||
* animation. Finally, display an error message in #status.
|
||||
*/
|
||||
// Stop page loading
|
||||
$('#page-content, #nav').removeClass('loading');
|
||||
|
||||
// TODO: instead of immediately displaying error, check if the content is stored in local storage
|
||||
$('#status').prepend('<p class="message">Error retrieving page ' + page_href + '</p>');
|
||||
$('#status').addClass('error').slideDown();
|
||||
|
||||
// Run current handles onError callback (if it exists)
|
||||
if (handlerCallback.hasOwnProperty('onError') && typeof handlerCallback.onError === 'function') {
|
||||
handlerCallback.onError();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init(router) {
|
||||
router.setCallback(loadPageContent);
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#nav-menu a.menuitem').click(function () {
|
||||
$(this).closest('ul').find('li.active').removeClass('active');
|
||||
$(this).closest('li').addClass('active');
|
||||
//$('.navbar-collapse').collapse('hide');
|
||||
});
|
||||
|
||||
$('#status a.close-button').click(function () {
|
||||
$(this).parent().slideUp(function () {
|
||||
$(this).removeClass('error').removeClass('success');
|
||||
$(this).children('p.message').remove();
|
||||
// Reload any new maths using MathJax
|
||||
$('#page-content .math').each(function (math_elem) {
|
||||
mj.Hub.Queue(["Typeset", mj.Hub, math_elem[0]]);
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: use history API in place of $.address.change (from jquery-address)
|
||||
// Callback for when the inital page has completely loaded (including images, etc..)
|
||||
//$.address.change(function (event) {
|
||||
// console.log("Change " + event.value);
|
||||
// router.runRouter(event.value);
|
||||
//}); // TODO
|
||||
// Rewrite new URLs within new content inserted into #page-content
|
||||
$('#page-content a').each(function (i) {
|
||||
var href = $(this).attr('href'),
|
||||
external_url_regexp = /https?:\/\/.*/,
|
||||
mailto_regexp = /mailto:.*/,
|
||||
files_regexp = /files\/.*/,
|
||||
images_regexp = /images\/.*/;
|
||||
|
||||
if (!(external_url_regexp.test(href) || mailto_regexp.test(href) || files_regexp.test(href) || images_regexp.test(href))) {
|
||||
$(this).attr('href', "/#" + href);
|
||||
}
|
||||
});
|
||||
|
||||
// Add fullscreen functionality to inline-images and figures
|
||||
$('article.post p > img').click(function () {
|
||||
$(this).get(0).toggleFullScreen();
|
||||
});
|
||||
$('figure').click(function () {
|
||||
$(this).children('img').get(0).toggleFullScreen();
|
||||
});
|
||||
|
||||
// Run current handles onSuccess callback (if it exists)
|
||||
if (handlerCallback.hasOwnProperty('onSuccess') && typeof handlerCallback.onSuccess === 'function') {
|
||||
handlerCallback.onSuccess();
|
||||
}
|
||||
|
||||
// Scroll to top of the page
|
||||
if ($('body').scrollTop() > $('#nav').offset().top - 15) {
|
||||
$('html, body').animate({
|
||||
scrollTop: $('#nav').offset().top - 15
|
||||
}, 'fast');
|
||||
}
|
||||
}, 250);
|
||||
},
|
||||
error: function (xhr, status) {
|
||||
/* Remove .loading from #page-content and #nav to stop the loading
|
||||
* animation. Finally, display an error message in #status.
|
||||
*/
|
||||
$('#page-content, #nav').removeClass('loading');
|
||||
|
||||
// TODO: instead of immediately displaying error, check if the content is stored in local storage
|
||||
$('#status').prepend('<p class="message">Error retrieving page ' + page_href + '</p>');
|
||||
$('#status').addClass('error').slideDown();
|
||||
|
||||
// Run current handles onError callback (if it exists)
|
||||
if (handlerCallback.hasOwnProperty('onError') && typeof handlerCallback.onError === 'function') {
|
||||
handlerCallback.onError();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function init(router) {
|
||||
router.setCallback(loadPageContent);
|
||||
|
||||
$(document).ready(function () {
|
||||
$('#nav-menu a.menuitem').click(function () {
|
||||
$(this).closest('ul').find('li.active').removeClass('active');
|
||||
$(this).closest('li').addClass('active');
|
||||
//$('.navbar-collapse').collapse('hide');
|
||||
});
|
||||
}
|
||||
|
||||
var spec = {
|
||||
init: init
|
||||
};
|
||||
return spec;
|
||||
}());
|
||||
$('#status a.close-button').click(function () {
|
||||
$(this).parent().slideUp(function () {
|
||||
$(this).removeClass('error').removeClass('success');
|
||||
$(this).children('p.message').remove();
|
||||
});
|
||||
});
|
||||
|
||||
// TODO: use history API in place of $.address.change (from jquery-address)
|
||||
// Callback for when the inital page has completely loaded (including images, etc..)
|
||||
//$.address.change(function (event) {
|
||||
// console.log("Change " + event.value);
|
||||
// router.runRouter(event.value);
|
||||
//}); // TODO
|
||||
});
|
||||
}
|
||||
|
||||
var spec = {
|
||||
init: init
|
||||
};
|
||||
return spec;
|
||||
}());
|
||||
|
||||
page.init(router);
|
||||
}(jQuery, MathJax));
|
||||
|
|
Loading…
Reference in New Issue