1
0
Fork 0
oldhaven/public/js/beathaven/layout.js

66 lines
1.8 KiB
JavaScript
Raw Normal View History

2011-06-14 16:05:12 +00:00
$(function(){
2011-06-17 19:26:03 +00:00
if (document.location.host != 'beathaven.org' && document.location.host != 'localhost') {
2011-06-20 14:26:07 +00:00
document.location.href = 'http://beathaven.org/'+ document.location.hash;
2011-06-17 19:26:03 +00:00
}
2011-06-14 16:05:12 +00:00
beathaven.init();
$(window).resize(beathaven.adjustSizes)
2011-06-16 00:19:40 +00:00
window.setTimeout(beathaven.checkRedrawScrollbar, 500);
2011-06-14 16:05:12 +00:00
})
var beathaven = {
2011-06-16 00:19:40 +00:00
last_height: false,
2011-06-14 16:05:12 +00:00
init: function () {
this.drawInterface();
this.adjustSizes();
2011-06-17 15:13:47 +00:00
Ajax.detectPage();
2011-06-14 16:05:12 +00:00
},
2011-06-16 00:19:40 +00:00
2011-06-14 16:05:12 +00:00
drawInterface: function() {
},
2011-06-16 00:19:40 +00:00
2011-06-14 16:05:12 +00:00
adjustSizes: function() {
$('#data-container').height($(window).height() - $('#header-container').height());
2011-06-15 01:42:50 +00:00
$('#data-container').width($(window).width() - $('#player').width()).scrollbar();
2011-06-14 16:05:12 +00:00
$('#player-container').height($(window).height());
$('#playlist').height($(window).height() - $('#player').height() - $('#player-container .additional-controls').height());
$('#playlist').scrollbar();
2011-06-16 00:19:40 +00:00
},
checkRedrawScrollbar: function() {
var focused_id = false;
if (typeof document.activeElement.id !== 'undefined') {
focused_id = document.activeElement.id;
}
2011-06-16 00:19:40 +00:00
var outer_height = $('#data-container > div').outerHeight();
if (outer_height > 300 && outer_height != beathaven.last_height) {
beathaven.last_height = outer_height;
beathaven.redrawScrollbar();
}
if (focused_id) {
document.getElementById(focused_id).focus();
focused_id = false;
}
2011-06-16 00:19:40 +00:00
window.setTimeout(beathaven.checkRedrawScrollbar, 500);
},
redrawScrollbar: function() {
$('#data-container').html($('#data-container').find('.inner').first());
$('#data-container').scrollbar();
2011-06-14 16:05:12 +00:00
}
}
String.prototype.htmlsafe = function() {
var replaces = [
["\\", "\\\\"],
["\"", """],
["<", "&lt;"],
[">", "&gt;"]
];
var str = this;
for (var i = 0; i < replaces.length; i++) {
str = str.replace(replaces[i][0], replaces[i][1]);
}
return str;
2011-06-14 16:05:12 +00:00
}