From 124e9e481ee29a22fceffb4dfa250ffbacf5aed8 Mon Sep 17 00:00:00 2001 From: magnolia-fan Date: Thu, 30 Jun 2011 06:05:57 +0400 Subject: [PATCH] Init spinner --- app/coffeescripts/beathaven.coffee | 2 -- app/coffeescripts/pages.coffee | 2 +- app/coffeescripts/vkontakte.coffee | 17 ++++++++++++++--- app/views/layouts/application.html.erb | 5 +++++ public/javascripts/coffee/beathaven.js | 3 +-- public/javascripts/coffee/pages.js | 2 +- public/javascripts/coffee/vkontakte.js | 23 +++++++++++++++++------ public/stylesheets/_sass/misc.scss | 18 +++++++++++++++++- public/stylesheets/misc.css | 17 +++++++++++++++-- 9 files changed, 71 insertions(+), 18 deletions(-) diff --git a/app/coffeescripts/beathaven.coffee b/app/coffeescripts/beathaven.coffee index 7a2f18b..ce7274c 100644 --- a/app/coffeescripts/beathaven.coffee +++ b/app/coffeescripts/beathaven.coffee @@ -44,8 +44,6 @@ class BeatHaven _pages = new Pages() _settings = new Settings() - - _ajax.detectPage() adjustSizes: -> $('.data-container').height $(window).height() - $('.header-container').height() diff --git a/app/coffeescripts/pages.coffee b/app/coffeescripts/pages.coffee index 0e56536..b0318e6 100644 --- a/app/coffeescripts/pages.coffee +++ b/app/coffeescripts/pages.coffee @@ -80,7 +80,7 @@ class Pages false renderSettings: (data) -> - unless _session.getUser().name? + unless _session.getUser().id? _ajax.go('/search/') return false $('.data-container').css background: 'none' diff --git a/app/coffeescripts/vkontakte.coffee b/app/coffeescripts/vkontakte.coffee index 8555130..51ae9d0 100644 --- a/app/coffeescripts/vkontakte.coffee +++ b/app/coffeescripts/vkontakte.coffee @@ -37,12 +37,18 @@ class Vkontakte _session.setUser ar2.user $('.header-container .hello .greating') .html 'Tēnā koe, ' +(if _session.getUser().name then _session.getUser().name else '%username%')+ '!' + window._session = _session + _ajax.detectPage() + $('.fullscreen').hide(); else _session.setUser ar.user $('.header-container .hello').show() $('.header-container .hello .greating') .html 'Tēnā koe, ' +(if _session.getUser().name then _session.getUser().name else '%username%')+ '!' + window._session = _session + _ajax.detectPage() + $('.fullscreen').hide(); if response.session.expire? setTimeout -> @@ -54,10 +60,12 @@ class Vkontakte _session.setUser {} $('#vk_login, .auth_notice').css display: 'block' $('.header-container .hello').hide() - window._session = _session + window._session = _session + _ajax.detectPage() + $('.fullscreen').hide(); auth: -> - VK.Auth.login (response) -> + VK.Auth.getLoginStatus (response) -> _vkontakte.authInfo(response) false , 8 @@ -121,7 +129,10 @@ class Vkontakte false $('#vk_login').live 'click', -> - _vkontakte.auth() + VK.Auth.login (response) -> + _vkontakte.authInfo(response) + false + , 8 false $('#vk_logout').live 'click', -> _ajax.go '/search/'; diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index b7f5255..3d22051 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -74,6 +74,11 @@
Don't forget to log in, please. It's simple.
+
+
+ +
+
diff --git a/public/javascripts/coffee/beathaven.js b/public/javascripts/coffee/beathaven.js index d4baf6f..0a004e4 100644 --- a/public/javascripts/coffee/beathaven.js +++ b/public/javascripts/coffee/beathaven.js @@ -35,8 +35,7 @@ BeatHaven = (function() { _player.initJplayer(); _search = new Search(); _pages = new Pages(); - _settings = new Settings(); - return _ajax.detectPage(); + return _settings = new Settings(); }; BeatHaven.prototype.adjustSizes = function() { $('.data-container').height($(window).height() - $('.header-container').height()); diff --git a/public/javascripts/coffee/pages.js b/public/javascripts/coffee/pages.js index 97aad84..cb9acad 100644 --- a/public/javascripts/coffee/pages.js +++ b/public/javascripts/coffee/pages.js @@ -81,7 +81,7 @@ Pages = (function() { return false; }; Pages.prototype.renderSettings = function(data) { - if (_session.getUser().name == null) { + if (_session.getUser().id == null) { _ajax.go('/search/'); return false; } diff --git a/public/javascripts/coffee/vkontakte.js b/public/javascripts/coffee/vkontakte.js index d0286e7..d74a7a1 100644 --- a/public/javascripts/coffee/vkontakte.js +++ b/public/javascripts/coffee/vkontakte.js @@ -42,17 +42,23 @@ Vkontakte = (function() { name: r.response }, function(ar2) { _session.setUser(ar2.user); - return $('.header-container .hello .greating').html('Tēnā koe, ' + (_session.getUser().name ? _session.getUser().name : '%username%') + '!'); + $('.header-container .hello .greating').html('Tēnā koe, ' + (_session.getUser().name ? _session.getUser().name : '%username%') + '!'); + window._session = _session; + _ajax.detectPage(); + return $('.fullscreen').hide(); }); }); } else { _session.setUser(ar.user); } $('.header-container .hello').show(); - return $('.header-container .hello .greating').html('Tēnā koe, ' + (_session.getUser().name ? _session.getUser().name : '%username%') + '!'); + $('.header-container .hello .greating').html('Tēnā koe, ' + (_session.getUser().name ? _session.getUser().name : '%username%') + '!'); + window._session = _session; + _ajax.detectPage(); + return $('.fullscreen').hide(); }); if (response.session.expire != null) { - setTimeout(function() { + return setTimeout(function() { _vkontakte.auth(); return false; }, response.session.expire * 1000 - new Date().getTime() + 1000); @@ -64,11 +70,13 @@ Vkontakte = (function() { display: 'block' }); $('.header-container .hello').hide(); + window._session = _session; + _ajax.detectPage(); + return $('.fullscreen').hide(); } - return window._session = _session; }; Vkontakte.prototype.auth = function() { - VK.Auth.login(function(response) { + VK.Auth.getLoginStatus(function(response) { _vkontakte.authInfo(response); return false; }, 8); @@ -145,7 +153,10 @@ Vkontakte = (function() { return Vkontakte; })(); $('#vk_login').live('click', function() { - _vkontakte.auth(); + VK.Auth.login(function(response) { + _vkontakte.authInfo(response); + return false; + }, 8); return false; }); $('#vk_logout').live('click', function() { diff --git a/public/stylesheets/_sass/misc.scss b/public/stylesheets/_sass/misc.scss index d85b283..99b61c2 100644 --- a/public/stylesheets/_sass/misc.scss +++ b/public/stylesheets/_sass/misc.scss @@ -1,9 +1,25 @@ @import "rounded"; .fullscreen { + position: absolute; + z-index: 9999; + top: 0; + left: 0; width: 100%; height: 100%; + background-color: #ffffff; text-align: center; + + background: rgba(255, 255, 255, 0.9); + filter:progid:DXImageTransform.Microsoft.gradient(startColorstr=#e5ffffff, endColorstr=#e5ffffff); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#e5ffffff, endColorstr=#e5ffffff)"; + + .inner { + position: relative; + top: 50%; + margin-top: -50px; + height: 100px; + } } .button { @@ -119,7 +135,7 @@ background-color: #07F; color: #FFF; top: 32px; - left: 230px; + left: 280px; padding: 8px; border: #05D 1px solid; @include rounded(3); diff --git a/public/stylesheets/misc.css b/public/stylesheets/misc.css index 95ccac6..8f52cc9 100644 --- a/public/stylesheets/misc.css +++ b/public/stylesheets/misc.css @@ -1,7 +1,20 @@ .fullscreen { + position: absolute; + z-index: 9999; + top: 0; + left: 0; width: 100%; height: 100%; - text-align: center; } + background-color: #ffffff; + text-align: center; + background: rgba(255, 255, 255, 0.9); + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#e5ffffff, endColorstr=#e5ffffff); + -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorstr=#e5ffffff, endColorstr=#e5ffffff)"; } + .fullscreen .inner { + position: relative; + top: 50%; + margin-top: -50px; + height: 100px; } .button { display: inline; @@ -79,7 +92,7 @@ background-color: #07F; color: #FFF; top: 32px; - left: 230px; + left: 280px; padding: 8px; border: #05D 1px solid; border-radius: 3px;