diff --git a/app/assets/javascripts/ajax.coffee b/app/assets/javascripts/ajax.coffee
index b06e98b..b761c90 100644
--- a/app/assets/javascripts/ajax.coffee
+++ b/app/assets/javascripts/ajax.coffee
@@ -3,9 +3,10 @@ class window.Ajax
referer: false
loadSettingsPage: ->
- $.get '/templates/settings.html', (data) ->
+ $.get '/settings/', (data) ->
_ajax.setArchor '/settings/'
- _page.renderSettings _beathaven.localizeHTML $(data)
+ _page.renderSettings data
+ false
false
load404Page: ->
@@ -37,7 +38,7 @@ class window.Ajax
if m = _ajax.getAnchor().match /\/artist\/(.+)\//
_search.loadArtistData m[1]
else if _ajax.getAnchor() == '' or _ajax.getAnchor().match /\/search\//
- _ajax.loadSearchPage();
+ #_ajax.loadSearchPage();
else if _ajax.getAnchor().match /\/settings\//
_ajax.loadSettingsPage()
else if _ajax.getAnchor().match /\/about\//
diff --git a/app/assets/javascripts/beathaven.coffee b/app/assets/javascripts/beathaven.coffee
index 03e98df..702803d 100644
--- a/app/assets/javascripts/beathaven.coffee
+++ b/app/assets/javascripts/beathaven.coffee
@@ -37,7 +37,6 @@ class window.BeatHaven
window._settings = new Settings()
this.setupAutocomplete()
- window._ajax.detectPage()
false
diff --git a/app/assets/javascripts/page.coffee b/app/assets/javascripts/page.coffee
index 80b7797..6efdfe3 100644
--- a/app/assets/javascripts/page.coffee
+++ b/app/assets/javascripts/page.coffee
@@ -3,48 +3,56 @@ class window.Page
print: (html) ->
$('#content').html(html)
false
-
- renderArtist: (data) ->
- $('#content').html(data)
-
- yaCounter7596904.hit _ajax.getAnchor(), data.artist.name, _ajax.referer
- _ajax.setTitle data.artist.name
- false
-
- renderSearch: (data) ->
- $('.pulldown').html data
- setTimeout ->
- $('.search_field').first().bh_autocomplete
- serviceUrl: '/artist/autocomplete' # Страница для обработки запросов автозаполнения
- minChars: 2 # Минимальная длина запроса для срабатывания автозаполнения
- delimiter: /(,|;)\s*/ # Разделитель для нескольких запросов, символ или регулярное выражение
- maxHeight: 400 # Максимальная высота списка подсказок, в пикселях
- width: 415 # Ширина списка
- zIndex: 9999 # z-index списка
- deferRequestBy: 500 # Задержка запроса (мсек)
- onSelect: ->
- _ajax.loadArtistData $('.search_field').first().val()
- $('.search_field').first().focus()
- , 1
- false
-
- renderSettings: (data) ->
- unless _session.getUser().id?
- _ajax.go('/search/')
- return false
- $('.data-container').css background: 'none'
- $('.data-container .inner').html data
- yaCounter7596904.hit _ajax.getAnchor(), 'Settings', _ajax.referer
- _ajax.setTitle 'Settings'
- $('.settings-container .tabs .tab').first().trigger 'click'
- false
-
- renderTextpage: (data) ->
- $('.data-container').css background: 'url(/images/concrete_wall_2.png) 0 -30px repeat'
- $('.data-container .inner').html data
- _beathaven.redrawScrollbar()
- false
+
+ renderArtist: (data) ->
+ $('#content').html(data)
+
+ yaCounter7596904.hit _ajax.getAnchor(), data.artist.name, _ajax.referer
+ _ajax.setTitle data.artist.name
+ false
+
+ renderSearch: (data) ->
+ $('.pulldown').html data
+ setTimeout ->
+ $('.search_field').first().bh_autocomplete
+ serviceUrl: '/artist/autocomplete' # Страница для обработки запросов автозаполнения
+ minChars: 2 # Минимальная длина запроса для срабатывания автозаполнения
+ delimiter: /(,|;)\s*/ # Разделитель для нескольких запросов, символ или регулярное выражение
+ maxHeight: 400 # Максимальная высота списка подсказок, в пикселях
+ width: 415 # Ширина списка
+ zIndex: 9999 # z-index списка
+ deferRequestBy: 500 # Задержка запроса (мсек)
+ onSelect: ->
+ _ajax.loadArtistData $('.search_field').first().val()
+ $('.search_field').first().focus()
+ , 1
+ false
+
+ renderSettings: (data) ->
+ unless _session.getUser().id?
+ #_ajax.go('/')
+ false
+ $('#content').html data
+ #yaCounter7596904.hit _ajax.getAnchor(), 'Settings', _ajax.referer
+ _ajax.setTitle 'Settings'
+ false
+
+ renderTextpage: (data) ->
+ $('.data-container').css background: 'url(/images/concrete_wall_2.png) 0 -30px repeat'
+ $('.data-container .inner').html data
+ _beathaven.redrawScrollbar()
+ false
-$('.about').live 'click', ->
- _ajax.go '/about/'
- false
\ No newline at end of file
+$ ->
+ $('.about').live 'click', ->
+ _ajax.go '/about/'
+ false
+ $('body').live 'click', ->
+ $('.dropdown-toggle, .menu').parent('li').removeClass('open')
+ false
+ $('.dropdown-toggle, .menu').live 'click', ->
+ $(this).parent('li').toggleClass('open')
+ false
+ $('.dropdown-toggle li, .menu li').live 'click', ->
+ $(this).parent('li').toggleClass('open')
+ false
\ No newline at end of file
diff --git a/app/assets/javascripts/session.coffee b/app/assets/javascripts/session.coffee
index 22c8a53..140e372 100644
--- a/app/assets/javascripts/session.coffee
+++ b/app/assets/javascripts/session.coffee
@@ -1,32 +1,32 @@
class window.Session
-
- vk_params: null
- user: null
-
- constructor: (params) ->
- attrs = ['expire', 'mid', 'secret', 'sid', 'sig']
- _params = {}
- for key in attrs
- if params[key]?
- _params[key] = params[key]
- @vk_params = _params
-
- setUser: (user) ->
- @user = user
- _beathaven.lang = @user.lang || 'ru'
- _beathaven.localizeHTML()
- false
-
- getUser: ->
- @user
-
- query: (url, params, callback) ->
- q_params = $.extend {}, @vk_params, params
- $.post url, q_params, callback
- false
-
- reloadSession: ->
- _session.query '/user/auth', {}, (ar) ->
- _session.setUser ar.user
- false
- false
+
+ vk_params: null
+ user: null
+
+ constructor: (params) ->
+ attrs = ['expire', 'mid', 'secret', 'sid', 'sig']
+ _params = {}
+ for key in attrs
+ if params[key]?
+ _params[key] = params[key]
+ @vk_params = _params
+
+ setUser: (user) ->
+ @user = user
+ _beathaven.lang = @user.lang || 'ru'
+ _beathaven.localizeHTML()
+ false
+
+ getUser: ->
+ @user
+
+ query: (url, params, callback) ->
+ q_params = $.extend {}, @vk_params, params
+ $.post url, q_params, callback
+ false
+
+ reloadSession: ->
+ _session.query '/user/auth', {}, (ar) ->
+ _session.setUser ar.user
+ false
+ false
diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee
index 89a89f7..87a3c47 100644
--- a/app/assets/javascripts/settings.coffee
+++ b/app/assets/javascripts/settings.coffee
@@ -1,64 +1,64 @@
class window.Settings
-
- getAccountInfo: (callback) ->
- _session.query '/user/update/', {}, callback
- false
-
- saveAccountInfo: (params, callback) ->
- _session.query '/user/update', params, callback
- false
-
- loadFormData: (form) ->
- if form == 'account'
- $('.settings-container .form input[name$="username"]').val _session.getUser().name
- $('.settings-container .form input[name$="email"]').val _session.getUser().email
- $('.settings-container .form select').val _session.getUser().lang
- else if form == 'lastfm'
- if _session.getUser().lastfm_username
- $('.form-container input[name$="username"]').first().val _session.getUser().lastfm_username
- false
-
- updateLastfmLogin: ->
- if window.lastfm_popup.closed
- _session.query '/user/auth', {}, (ar) ->
- _session.setUser ar.user
- _settings.loadFormData 'lastfm'
- else
- setTimeout _settings.updateLastfmLogin, 100
- false
+
+ getAccountInfo: (callback) ->
+ _session.query '/user/update/', {}, callback
+ false
+
+ saveAccountInfo: (params, callback) ->
+ _session.query '/user/update', params, callback
+ false
+
+ loadFormData: (form) ->
+ if form == 'account'
+ $('.settings-container .form input[name$="username"]').val _session.getUser().name
+ $('.settings-container .form input[name$="email"]').val _session.getUser().email
+ $('.settings-container .form select').val _session.getUser().lang
+ else if form == 'lastfm'
+ if _session.getUser().lastfm_username
+ $('.form-container input[name$="username"]').first().val _session.getUser().lastfm_username
+ false
+
+ updateLastfmLogin: ->
+ if window.lastfm_popup.closed
+ _session.query '/user/auth', {}, (ar) ->
+ _session.setUser ar.user
+ _settings.loadFormData 'lastfm'
+ else
+ setTimeout _settings.updateLastfmLogin, 100
+ false
-$('.settings') .live 'click', ->
- _ajax.go('/settings/');
- false
+$('#preferences') .live 'click', ->
+ _ajax.go('/settings/');
+ false
$('.settings-container .tabs .tab').live 'click', ->
- if not $(this).hasClass 'active'
- $('.settings-container .tabs .tab').removeClass 'active'
- $(this).addClass 'active'
- $('.form-container').html $('.forms .'+ $(this).attr 'data-fieldset').html()
- _settings.loadFormData $(this).attr 'data-fieldset'
- false
+ if not $(this).hasClass 'active'
+ $('.settings-container .tabs .tab').removeClass 'active'
+ $(this).addClass 'active'
+ $('.form-container').html $('.forms .'+ $(this).attr 'data-fieldset').html()
+ _settings.loadFormData $(this).attr 'data-fieldset'
+ false
$('.lastfm-connect') .live 'click', ->
- window.lastfm_popup = window.open _session.getUser().lastfm_login_url
- setTimeout _settings.updateLastfmLogin, 100
- false
-
+ window.lastfm_popup = window.open _session.getUser().lastfm_login_url
+ setTimeout _settings.updateLastfmLogin, 100
+ false
+
$('.settings-container .form input, .settings-container .form select').live 'blur', ->
- active_tab = $('.settings-container .tabs .tab.active').attr 'data-fieldset'
- if active_tab == 'account'
- params =
- username: $('.settings-container .form input[name$="username"]').first().val()
- email: $('.settings-container .form input[name$="email"]').first().val()
- lang: $('.settings-container .form select').first().val()
- lang_changed = params.lang != _session.getUser().lang
- if lang_changed
- if not confirm _beathaven.ls 'WINDOW_LANG_RELOAD', params.lang
- $('.settings-container .form select').val _session.getUser().lang
- _settings.saveAccountInfo params, ->
- if lang_changed
- window.location.reload()
- $('.header-container .hello .greating span').text (if params.username.length > 0 then params.username else '%username%')
- false
- false
\ No newline at end of file
+ active_tab = $('.settings-container .tabs .tab.active').attr 'data-fieldset'
+ if active_tab == 'account'
+ params =
+ username: $('.settings-container .form input[name$="username"]').first().val()
+ email: $('.settings-container .form input[name$="email"]').first().val()
+ lang: $('.settings-container .form select').first().val()
+ lang_changed = params.lang != _session.getUser().lang
+ if lang_changed
+ if not confirm _beathaven.ls 'WINDOW_LANG_RELOAD', params.lang
+ $('.settings-container .form select').val _session.getUser().lang
+ _settings.saveAccountInfo params, ->
+ if lang_changed
+ window.location.reload()
+ $('.header-container .hello .greating span').text (if params.username.length > 0 then params.username else '%username%')
+ false
+ false
\ No newline at end of file
diff --git a/app/assets/javascripts/vkontakte.coffee b/app/assets/javascripts/vkontakte.coffee
index 0b8c829..5f35324 100644
--- a/app/assets/javascripts/vkontakte.coffee
+++ b/app/assets/javascripts/vkontakte.coffee
@@ -32,17 +32,16 @@ class window.Vkontakte
VK.Api.call 'getVariable', key: 1281, (r) ->
_session.query '/user/update', name: r.response, (ar2) ->
_session.setUser ar2.user
- $('.header-container .hello .greating')
- .html _beathaven.ls('HELLO')+', ' +(if _session.getUser().name then _session.getUser().name else '%username%')+ '!'
+ $('#username')
+ .html (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 _beathaven.ls('HELLO')+', ' +(if _session.getUser().name then _session.getUser().name else '%username%')+ '!'
+ $('#username')
+ .html (if _session.getUser().name then _session.getUser().name else '%username%')
window._session = _session
_ajax.detectPage()
$('.fullscreen').hide();
diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb
index 935de11..8638eaf 100644
--- a/app/controllers/user_controller.rb
+++ b/app/controllers/user_controller.rb
@@ -32,6 +32,10 @@ class UserController < ApplicationController
render :json => @res
end
+ def settings
+ render :partial => 'settings'
+ end
+
def update
return unless authorized?
@res = {}
diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml
index 26d1e4a..dba23ec 100644
--- a/app/views/layouts/application.html.haml
+++ b/app/views/layouts/application.html.haml
@@ -27,13 +27,13 @@
= image_tag "artist_loader.gif"
%ul.nav.secondary-nav
%li.dropdown
- %a.dropdown-toggle{ :href => "#" } chez
+ %a.dropdown-toggle#username{ :href => "#" } %username%
%ul.dropdown-menu
%li
- %a{ :href => "#" } Preferences
+ %a#preferences{ :href => "#" } Preferences
%li.divider
%li
- %a{ :href => "#" } Logout
+ %a#logout{ :href => "#" } Logout
.popover-wrapper
.popover.below#autocomplete-container
diff --git a/app/views/user/_settings.html.haml b/app/views/user/_settings.html.haml
new file mode 100644
index 0000000..dcb0132
--- /dev/null
+++ b/app/views/user/_settings.html.haml
@@ -0,0 +1,65 @@
+%h1 Settings
+%ul.tabs
+ %li.active
+ %a{ :href => "#" } Account
+ %li
+ %a{ :href => "#" } Site
+ %li
+ %a{ :href => "#" } Music
+ %li
+ %a{ :href => "#" } Last.fm
+
+.forms
+ .form.account
+ %form
+ %fieldset
+ .clearfix
+ %label{ :for => "input-username" } Username
+ .input
+ %input.xlarge#input-username{ :name => "input-username", :size => 30, :type => "text" }
+ .clearfix
+ %label{ :for => "input-email" } Email
+ .input
+ %input.xlarge#input-email{ :name => "input-email", :size => 30, :type => "text" }
+ .form.site
+ %form
+ %fieldset
+ .clearfix
+ %label{ :for => "select-lang" } Language
+ .input
+ %select.medium#select-lang{ :name => "select-lang" }
+ %option English
+ %option Русский
+ .form.music
+ %form
+ %fieldset
+ .clearfix
+ %label{ :for => "select-lang" } Show
+ .input
+ %ul.inputs-list
+ %li
+ %label.disabled
+ %input{ :name => "show-album", :type => "checkbox", :checked => "checked", :disabled => "disabled" }
+ %span Albums
+ %li
+ %label
+ %input{ :name => "show-single", :type => "checkbox" }
+ %span Singles
+ %li
+ %label
+ %input{ :name => "show-live", :type => "checkbox" }
+ %span Live shows
+ %li
+ %label
+ %input{ :name => "show-bootleg", :type => "checkbox" }
+ %span Bootlegs
+ .form.lastfm
+ %form
+ %fieldset
+ .clearfix
+ %label{ :for => "input-username" } Username
+ .input
+ .input-append
+ %input#input-username{ :name => "input-username", :type => "text", :size => 30 }
+ %label.add-on
+ %input{ :type => "checkbox" }
\ No newline at end of file
diff --git a/config/routes.rb b/config/routes.rb
index 920585a..dc0b6a1 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -66,6 +66,8 @@ Beathaven::Application.routes.draw do
match 'lastfm/listening' => 'last_fm#listening'
match 'lastfm/scrobble' => 'last_fm#scrobble'
+ match 'settings' => 'user#settings'
+
match 'artist/autocomplete' => 'artist#autocomplete'
match 'artist/(:name)/' => 'artist#data', :constraints => { :name => /[^\/]*/ }
end