diff --git a/app/assets/javascripts/ajax.coffee b/app/assets/javascripts/ajax.coffee index b761c90..a24b7d2 100644 --- a/app/assets/javascripts/ajax.coffee +++ b/app/assets/javascripts/ajax.coffee @@ -3,7 +3,7 @@ class window.Ajax referer: false loadSettingsPage: -> - $.get '/settings/', (data) -> + _session.query '/settings/', {}, (data) -> _ajax.setArchor '/settings/' _page.renderSettings data false diff --git a/app/assets/javascripts/settings.coffee b/app/assets/javascripts/settings.coffee index 87a3c47..65226e1 100644 --- a/app/assets/javascripts/settings.coffee +++ b/app/assets/javascripts/settings.coffee @@ -32,12 +32,12 @@ $('#preferences') .live 'click', -> _ajax.go('/settings/'); false -$('.settings-container .tabs .tab').live 'click', -> +$('#settings-tabs li').live 'click', -> if not $(this).hasClass 'active' - $('.settings-container .tabs .tab').removeClass 'active' + $('#settings-tabs li').removeClass 'active' $(this).addClass 'active' - $('.form-container').html $('.forms .'+ $(this).attr 'data-fieldset').html() - _settings.loadFormData $(this).attr 'data-fieldset' + $('#settings-forms > div').hide() + $('#settings-forms > .'+ $(this).find('a').attr('data-tab')).show() false $('.lastfm-connect') .live 'click', -> diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index ac46600..005c435 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -11,7 +11,7 @@ * require pulldown * require pulldown *= require search -* require settings +*= require settings * require textpage diff --git a/app/assets/stylesheets/settings.scss b/app/assets/stylesheets/settings.scss index 372dc23..c11e8a4 100644 --- a/app/assets/stylesheets/settings.scss +++ b/app/assets/stylesheets/settings.scss @@ -1,121 +1,11 @@ -@import "rounded"; - -.settings-container { - margin: 25px; - - .tabs { - height: 26px; - - > div { - float: left; - height: 25px; - } - - .left-space { - width: 15px; - } - - .middle-space { - width: 8px; - } - - .tab { - position: relative; - border-left: #DDD 1px solid; - border-top: #DDD 1px solid; - border-right: #DDD 1px solid; - padding: 0 8px; - line-height: 24px; - margin-top: 2px; - @include rounded(5); - background-color: #FAFAFA; - cursor: pointer; - - &.active { - z-index: 200; - background-color: #FFF; - border-left: #CCC 1px solid; - border-top: #CCC 1px solid; - border-right: #CCC 1px solid; - border-bottom: #FFF 6px solid; - margin-top: -2px; - line-height: 29px; - font-weight: bold; - cursor: default; - } - } - } - - .form-container { - position: relative; - z-index: 100; - height: 500px; - border-top: #CCC 1px solid; - - .form { - position: absolute; - top: 25px; - left: 0; - width: 100%; - - .field { - height: 40px; - margin-bottom: 10px; - clear: both; - - .label{ - float: left; - font-size: 24px; - line-height: 32px; - width: 140px; - padding: 3px 6px; - @include rounded(3); - background-color: #EAEAEA; - margin-right: -10px; - } - - .value { - float: left; - - input[type="text"]{ - font-size: 24px; - padding: 4px; - background-color: #ffffff; - color: #202020; - border: #CCC 1px solid; - @include rounded(3); - width: 300px; - } - - select { - font-size: 24px; - background-color: #ffffff; - color: #202020; - border: #CCC 1px solid; - width: 310px; - height: 38px; - } - } - - .action-button { - float: left; - margin: 6px 0 0 5px; - } - - .saved { - float: left; - } - } - } - - .logout { - position: absolute; - top: 25px; - right: 0; - } - } - - .forms { - display: none; - } +#settings-forms { + .site { + display: none; + } + .music { + display: none; + } + .lastfm { + display: none; + } } \ No newline at end of file diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index 8638eaf..9b072b6 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -33,6 +33,8 @@ class UserController < ApplicationController end def settings + return unless authorized? + @user = User.find_by_vkid(params[:mid]) render :partial => 'settings' end diff --git a/app/views/user/_settings.html.haml b/app/views/user/_settings.html.haml index dcb0132..f589a9f 100644 --- a/app/views/user/_settings.html.haml +++ b/app/views/user/_settings.html.haml @@ -1,65 +1,65 @@ %h1 Settings -%ul.tabs +%ul.tabs#settings-tabs %li.active - %a{ :href => "#" } Account + %a{ :href => "#", :'data-tab' => 'account' } Account %li - %a{ :href => "#" } Site + %a{ :href => "#", :'data-tab' => 'site' } Site %li - %a{ :href => "#" } Music + %a{ :href => "#", :'data-tab' => 'music' } Music %li - %a{ :href => "#" } Last.fm + %a{ :href => "#", :'data-tab' => 'lastfm' } Last.fm -.forms +.forms#settings-forms .form.account %form %fieldset .clearfix - %label{ :for => "input-username" } Username + %label{ :for => "name" } Username .input - %input.xlarge#input-username{ :name => "input-username", :size => 30, :type => "text" } + %input.xlarge#name{ :name => "name", :size => 30, :type => "text", :value => @user.name } .clearfix - %label{ :for => "input-email" } Email + %label{ :for => "email" } Email .input - %input.xlarge#input-email{ :name => "input-email", :size => 30, :type => "text" } + %input.xlarge#email{ :name => "email", :size => 30, :type => "text", :value => @user.email } .form.site %form %fieldset .clearfix - %label{ :for => "select-lang" } Language + %label{ :for => "lang" } Language .input - %select.medium#select-lang{ :name => "select-lang" } - %option English - %option Русский + %select.medium#lang{ :name => "lang" } + %option{ :value => "en", :selected => (@user.lang == 'en') } English + %option{ :value => "ru", :selected => (@user.lang == 'ru') } Русский .form.music %form %fieldset .clearfix - %label{ :for => "select-lang" } Show + %label{ :for => "album_types" } Show .input %ul.inputs-list %li %label.disabled - %input{ :name => "show-album", :type => "checkbox", :checked => "checked", :disabled => "disabled" } + %input{ :name => "show_album", :type => "checkbox", :checked => "checked", :disabled => "disabled" } %span Albums %li %label - %input{ :name => "show-single", :type => "checkbox" } + %input{ :name => "show_single", :type => "checkbox", :disabled => "disabled" } %span Singles %li %label - %input{ :name => "show-live", :type => "checkbox" } + %input{ :name => "show_live", :type => "checkbox", :disabled => "disabled" } %span Live shows %li %label - %input{ :name => "show-bootleg", :type => "checkbox" } + %input{ :name => "show_bootleg", :type => "checkbox", :disabled => "disabled" } %span Bootlegs .form.lastfm %form %fieldset .clearfix - %label{ :for => "input-username" } Username + %label{ :for => "lastfm_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 + %input#lastfm_username{ :name => "lastfm_username", :type => "text", :disabled => "disabled", :value => @user.lastfm_username } + %label.add-on.disabled{ :class => ('active' unless @user.lastfm_key.nil?) } + %input{ :type => "checkbox", :disabled => "disabled", :checked => (!@user.lastfm_key.nil?) } \ No newline at end of file