diff --git a/app/assets/javascripts/ajax.coffee b/app/assets/javascripts/ajax.coffee index a24b7d2..90babf0 100644 --- a/app/assets/javascripts/ajax.coffee +++ b/app/assets/javascripts/ajax.coffee @@ -2,13 +2,6 @@ class window.Ajax referer: false - loadSettingsPage: -> - _session.query '/settings/', {}, (data) -> - _ajax.setArchor '/settings/' - _page.renderSettings data - false - false - load404Page: -> $.get '/404.html', (data) -> $('.data-container .inner').html data @@ -40,7 +33,7 @@ class window.Ajax else if _ajax.getAnchor() == '' or _ajax.getAnchor().match /\/search\// #_ajax.loadSearchPage(); else if _ajax.getAnchor().match /\/settings\// - _ajax.loadSettingsPage() + _settings.loadSettingsPage() else if _ajax.getAnchor().match /\/about\// _ajax.loadAboutPage() else @@ -48,5 +41,5 @@ class window.Ajax false $(window).bind 'hashchange', -> - #_ajax.detectPage() + _ajax.detectPage() false diff --git a/app/assets/javascripts/jquery/jquery.autocomplete.js b/app/assets/javascripts/jquery/jquery.autocomplete.js index ee29683..9a08412 100644 --- a/app/assets/javascripts/jquery/jquery.autocomplete.js +++ b/app/assets/javascripts/jquery/jquery.autocomplete.js @@ -264,6 +264,7 @@ this.enabled = false; this.selectedIndex = -1; this.container.hide(); + $('.popover-wrapper').hide(); }, suggest: function() { @@ -292,6 +293,7 @@ } this.enabled = true; this.container.show(); + $('.popover-wrapper').show(); }, processResponse: function(text) { diff --git a/app/assets/javascripts/page.coffee b/app/assets/javascripts/page.coffee index 6efdfe3..1f3b5dc 100644 --- a/app/assets/javascripts/page.coffee +++ b/app/assets/javascripts/page.coffee @@ -27,21 +27,6 @@ class window.Page $('.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', -> diff --git a/app/assets/javascripts/session.coffee b/app/assets/javascripts/session.coffee index 140e372..60e7904 100644 --- a/app/assets/javascripts/session.coffee +++ b/app/assets/javascripts/session.coffee @@ -25,6 +25,11 @@ class window.Session $.post url, q_params, callback false + secureLoad: (url, callback) -> + q_params = $.extend {}, @vk_params + $('#content').load url, q_params, callback + false + reloadSession: -> _session.query '/user/auth', {}, (ar) -> _session.setUser ar.user diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee index 65226e1..d3c449a 100644 --- a/app/assets/javascripts/settings.coffee +++ b/app/assets/javascripts/settings.coffee @@ -1,5 +1,15 @@ class window.Settings + loadSettingsPage: -> + unless _session.getUser().id? + _ajax.go('/') + false + _session.secureLoad '/settings/', (data) -> + false + #yaCounter7596904.hit _ajax.getAnchor(), 'Settings', _ajax.referer + _ajax.setTitle 'Settings' + false + getAccountInfo: (callback) -> _session.query '/user/update/', {}, callback false @@ -7,16 +17,6 @@ class window.Settings 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 @@ -28,7 +28,7 @@ class window.Settings false -$('#preferences') .live 'click', -> +$('#preferences').live 'click', -> _ajax.go('/settings/'); false @@ -40,25 +40,19 @@ $('#settings-tabs li').live 'click', -> $('#settings-forms > .'+ $(this).find('a').attr('data-tab')).show() false -$('.lastfm-connect') .live 'click', -> +$('.lastfm-connect').live 'click', -> 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 + +$('#settings-forms form').live 'submit', -> + params = {} + $(this).find('input, select').each -> + if $(this).attr('name') + params[$(this).attr('name')] = $(this).val() + console.log(params) + false + +$('#settings-forms input[type$="submit"]').live 'mouseup', -> + $(this).parent().parent().parent().submit(); + false diff --git a/app/assets/stylesheets/misc.scss b/app/assets/stylesheets/misc.scss index 3375ba3..00c4e04 100644 --- a/app/assets/stylesheets/misc.scss +++ b/app/assets/stylesheets/misc.scss @@ -9,6 +9,7 @@ } .popover-wrapper { + display: none; position: fixed; left: 50%; margin-left: -280px; diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 9b072b6..5f52f2e 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -43,6 +43,10 @@ class UserController < ApplicationController @res = {} user = User.find_by_vkid(params[:mid]) + + render :json => request + return + unless params[:username].nil? or params[:email].nil? user.name = params[:username] user.email = params[:email] diff --git a/app/views/user/_settings.html.haml b/app/views/user/_settings.html.haml index c30f3d1..9e5cbc3 100644 --- a/app/views/user/_settings.html.haml +++ b/app/views/user/_settings.html.haml @@ -11,7 +11,7 @@ .forms#settings-forms .form.account - %form + %form{ :action => "/", :method => 'post' } %fieldset .clearfix %label{ :for => "name" }= I18n.t 'settings.username' @@ -42,20 +42,20 @@ .input %ul.inputs-list %li - %label.disabled - %input{ :name => "show_album", :type => "checkbox", :checked => "checked", :disabled => "disabled" } + %label{ :for => "show_album" } + %input#show_album{ :name => "show[album]", :type => "checkbox", :checked => "checked" } %span= I18n.t 'settings.music.albums' %li - %label - %input{ :name => "show_single", :type => "checkbox", :disabled => "disabled" } + %label{ :for => "show_single" } + %input#show_single{ :name => "show[single]", :type => "checkbox" } %span= I18n.t 'settings.music.singles' %li - %label - %input{ :name => "show_live", :type => "checkbox", :disabled => "disabled" } + %label.disabled{ :for => "show_live" } + %input#show_live{ :name => "show[live]", :type => "checkbox", :disabled => "disabled" } %span= I18n.t 'settings.music.live' %li - %label - %input{ :name => "show_bootleg", :type => "checkbox", :disabled => "disabled" } + %label.disabled{ :for => "show_bootleg" } + %input#show_bootleg{ :name => "show[bootleg]", :type => "checkbox", :disabled => "disabled" } %span= I18n.t 'settings.music.bootlegs' .actions %input.btn.primary{ :type => "submit", :value => I18n.t('settings.save') } @@ -68,5 +68,3 @@ %input.borderless#lastfm_username{ :type => "text", :readonly => "readonly", :value => (@user.lastfm_username || I18n.t('settings.not_connected')) } %span.help-inline %input.btn{ :type => "submit", :value => I18n.t('settings.connect') } - .actions - %input.btn.primary{ :type => "submit", :value => I18n.t('settings.save') } \ No newline at end of file