1
0
Fork 0

Auth bug fixed

This commit is contained in:
magnolia-fan 2011-07-02 18:10:59 +04:00
parent f331533a29
commit f92693d847
4 changed files with 25 additions and 18 deletions

View File

@ -10,7 +10,7 @@ _settings = null
$ ->
l = document.location
if l.host not in ['beathaven.org', 'local.beathaven.org']
if l.host not in ['beathaven.org', 'dev.beathaven.org']
l.href = 'http://beathaven.org/'+ l.hash
_beathaven = new BeatHaven()
@ -18,6 +18,7 @@ $ ->
$(window).resize ->
_beathaven.adjustSizes()
_beathaven.redrawScrollbar()
false
window.setTimeout ->
_beathaven.checkRedrawScrollbar()
@ -65,9 +66,9 @@ class BeatHaven
if document.activeElement.id?
focused_id = document.activeElement.id;
outer_height = $('.data-container > div').outerHeight()
if outer_height > 300 and outer_height != @last_height
@last_height = outer_height
this.redrawScrollbar()
if outer_height > 300 and outer_height != _beathaven.last_height
_beathaven.last_height = outer_height
_beathaven.redrawScrollbar()
if focused_id
document.getElementById(focused_id).focus()
focused_id = false
@ -82,15 +83,17 @@ class BeatHaven
$('.data-container').scrollbar()
false
localizeHTML: (obj) ->
localizeHTML: (obj, lang) ->
unless obj?
obj = $('body')
unless lang?
lang = _beathaven.lang
$(obj).find('[data-ls]').each ->
if _locale[$(this).attr 'data-ls']? and _locale[$(this).attr 'data-ls'][_beathaven.lang]?
if _locale[$(this).attr 'data-ls']? and _locale[$(this).attr 'data-ls'][lang]?
if this.nodeName is 'INPUT'
$(this).val _locale[$(this).attr 'data-ls'][_beathaven.lang]
$(this).val _locale[$(this).attr 'data-ls'][lang]
else
$(this).text _locale[$(this).attr 'data-ls'][_beathaven.lang]
$(this).text _locale[$(this).attr 'data-ls'][lang]
return obj
ls: (id, lang) ->

View File

@ -13,7 +13,7 @@ class Session
setUser: (user) ->
@user = user
_beathaven.lang = @user.lang
_beathaven.lang = @user.lang || 'ru'
_beathaven.localizeHTML()
false

View File

@ -10,13 +10,14 @@ _settings = null;
$(function() {
var l, _ref;
l = document.location;
if ((_ref = l.host) !== 'beathaven.org' && _ref !== 'local.beathaven.org') {
if ((_ref = l.host) !== 'beathaven.org' && _ref !== 'dev.beathaven.org') {
l.href = 'http://beathaven.org/' + l.hash;
}
_beathaven = new BeatHaven();
_beathaven.init();
$(window).resize(function() {
_beathaven.adjustSizes();
_beathaven.redrawScrollbar();
return false;
});
return window.setTimeout(function() {
@ -57,9 +58,9 @@ BeatHaven = (function() {
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 (outer_height > 300 && outer_height !== _beathaven.last_height) {
_beathaven.last_height = outer_height;
_beathaven.redrawScrollbar();
}
if (focused_id) {
document.getElementById(focused_id).focus();
@ -76,16 +77,19 @@ BeatHaven = (function() {
$('.data-container').scrollbar();
return false;
};
BeatHaven.prototype.localizeHTML = function(obj) {
BeatHaven.prototype.localizeHTML = function(obj, lang) {
if (obj == null) {
obj = $('body');
}
if (lang == null) {
lang = _beathaven.lang;
}
$(obj).find('[data-ls]').each(function() {
if ((_locale[$(this).attr('data-ls')] != null) && (_locale[$(this).attr('data-ls')][_beathaven.lang] != null)) {
if ((_locale[$(this).attr('data-ls')] != null) && (_locale[$(this).attr('data-ls')][lang] != null)) {
if (this.nodeName === 'INPUT') {
return $(this).val(_locale[$(this).attr('data-ls')][_beathaven.lang]);
return $(this).val(_locale[$(this).attr('data-ls')][lang]);
} else {
return $(this).text(_locale[$(this).attr('data-ls')][_beathaven.lang]);
return $(this).text(_locale[$(this).attr('data-ls')][lang]);
}
}
});

View File

@ -16,7 +16,7 @@ Session = (function() {
}
Session.prototype.setUser = function(user) {
this.user = user;
_beathaven.lang = this.user.lang;
_beathaven.lang = this.user.lang || 'ru';
_beathaven.localizeHTML();
return false;
};