2016-06-07 17:15:55 +00:00
|
|
|
var basePath = "/";
|
|
|
|
|
2015-09-19 13:25:35 +00:00
|
|
|
$(document).ready(function() {
|
2016-06-07 17:15:55 +00:00
|
|
|
basePath += window.location.pathname.split('/')[0];
|
|
|
|
|
2016-02-07 09:09:22 +00:00
|
|
|
// Log out the user sending bad credentials to the server
|
|
|
|
$("#logout").click(function(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
$.ajax({
|
|
|
|
type: "GET",
|
2016-06-07 17:15:55 +00:00
|
|
|
url: basePath + "",
|
2016-02-07 09:09:22 +00:00
|
|
|
async: false,
|
|
|
|
username: "username",
|
|
|
|
password: "password",
|
|
|
|
headers: {
|
|
|
|
"Authorization": "Basic xxx"
|
|
|
|
}
|
|
|
|
}).fail(function() {
|
|
|
|
window.location = "/";
|
|
|
|
});
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2015-09-20 10:03:17 +00:00
|
|
|
$(document).pjax('a[data-pjax]', '#content');
|
2015-09-19 13:25:35 +00:00
|
|
|
});
|
|
|
|
|
2016-02-08 08:24:12 +00:00
|
|
|
$(document).on('ready pjax:end', function() {
|
|
|
|
$('#content').off();
|
|
|
|
|
2016-02-06 16:08:48 +00:00
|
|
|
// Update the title
|
|
|
|
document.title = document.getElementById('site-title').innerHTML;
|
|
|
|
|
2016-02-07 09:01:17 +00:00
|
|
|
//TODO: navbar titles changing effect when changing page
|
|
|
|
|
2016-02-01 22:30:29 +00:00
|
|
|
// Auto Grow Textarea
|
2016-02-07 09:34:28 +00:00
|
|
|
function autoGrow() {
|
|
|
|
this.style.height = '5px';
|
|
|
|
this.style.height = this.scrollHeight + 'px';
|
2016-02-01 22:30:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$("textarea").each(autoGrow);
|
|
|
|
$('textarea').keyup(autoGrow);
|
|
|
|
$(window).resize(function() {
|
|
|
|
$("textarea").each(autoGrow);
|
2015-10-24 09:54:10 +00:00
|
|
|
});
|
2015-09-19 13:25:35 +00:00
|
|
|
|
2015-09-20 13:43:41 +00:00
|
|
|
if ($('main').hasClass('browse')) {
|
2016-02-06 16:08:48 +00:00
|
|
|
$(document).trigger("page:browse");
|
2015-09-20 13:43:41 +00:00
|
|
|
}
|
|
|
|
|
2015-09-19 13:25:35 +00:00
|
|
|
if ($(".editor")[0]) {
|
2016-02-06 16:08:48 +00:00
|
|
|
$(document).trigger("page:editor");
|
2015-09-19 13:25:35 +00:00
|
|
|
}
|
2016-02-06 16:08:48 +00:00
|
|
|
|
|
|
|
return false;
|
2016-01-31 22:14:17 +00:00
|
|
|
});
|