1
0
Fork 0
oldhaven/public/javascripts/coffee/beathaven.js

96 lines
3.2 KiB
JavaScript
Raw Normal View History

2011-06-27 18:41:36 +00:00
/* DO NOT MODIFY. This file was compiled Mon, 27 Jun 2011 17:49:39 GMT from
* /Users/chez/Sites/beathaven/app/coffeescripts/beathaven.coffee
*/
(function() {
var BeatHaven;
$(function() {
var ajax, beathaven, l, pages, player, search, session, settings, vkontakte, _ref;
l = document.location;
if ((_ref = l.host) !== 'beathaven.org' && _ref !== 'localhost') {
l.href = 'http://beathaven.org/' + l.hash;
}
beathaven = new BeatHaven();
vkontakte = new Vkontakte(l.host === 'beathaven.org' ? 2335068 : 2383163);
session = new Session();
ajax = new Ajax();
player = new Player();
search = new Search();
pages = new Pages();
settings = new Settings();
beathaven.init();
vkontakte.init();
$(window).resize(function() {
return beathaven.adjustSizes();
});
return window.setTimeout(function() {
return beathaven.checkRedrawScrollbar();
}, 500);
});
BeatHaven = (function() {
function BeatHaven() {}
BeatHaven.prototype.last_height = false;
BeatHaven.prototype.init = function() {
this.drawInterface();
this.adjustSizes();
return ajax.detectPage();
};
BeatHaven.prototype.adjustSizes = function() {
$('.data-container').height($(window).height() - $('.header-container').height());
$('.data-container').width($(window).width() - $('.player').width());
$('.player-container').height($(window).height());
$('.playlist').height($(window).height() - $('.player').height() - $('.player-container .additional-controls').height());
$('.data-container').scrollbar();
return $('.playlist').scrollbar();
};
BeatHaven.prototype.checkRedrawScrollbar = function() {
var focused_id, outer_height;
focused_id = false;
if (document.activeElement.id != null) {
focused_id = document.activeElement.id;
}
outer_height = $('.data-container > div').outerHeight();
if (outer_height > 300 && outer_height !== this.last_height) {
this.last_height = outer_height;
this.redrawScrollbar();
}
if (focused_id) {
document.getElementById(focused_id).focus();
focused_id = false;
}
return window.setTimeout(function() {
return beathaven.checkRedrawScrollbar();
}, 500);
};
BeatHaven.prototype.redrawScrollbar = function() {
$('.data-container').html($('.data-container').find('.inner').first());
return $('.data-container').scrollbar();
};
return BeatHaven;
})();
String.prototype.htmlsafe = function() {
var item, replaces, str, _i, _len;
replaces = [["\\", "\\\\"], ["\"", "&quot;"], ["<", "&lt;"], [">", "&gt;"]];
str = this;
for (_i = 0, _len = replaces.length; _i < _len; _i++) {
item = replaces[_i];
str = str.replace(item[0], item[1]);
}
return str;
};
String.prototype.trim = function() {
var str;
str = this;
while (str.indexOf(' ') !== -1) {
str = str.replace(' ', ' ');
}
if (str.charAt(0) === ' ') {
str = str.substring(1);
}
if (str.charAt(str.length - 1) === ' ') {
str = str.substring(0, str.length - 1);
}
return str;
};
}).call(this);