Bootstrap, Chosen gems. New settings
This commit is contained in:
@@ -39,18 +39,11 @@ class window.Ajax
|
||||
|
||||
if m = path.match /\/artist\/(.+)\//
|
||||
_search.loadArtistData m[1]
|
||||
else if path.match /\/settings\//
|
||||
_settings.loadSettingsPage()
|
||||
else
|
||||
this.showSpinner()
|
||||
_session.query path, {}, (response) ->
|
||||
_page.render response
|
||||
_ajax.hideSpinner()
|
||||
if _session.getUser().id?
|
||||
$('.authorized-action').show()
|
||||
else
|
||||
$('.authorized-action').hide()
|
||||
false
|
||||
false
|
||||
|
||||
$(window).bind 'hashchange', ->
|
||||
|
||||
@@ -3,6 +3,9 @@
|
||||
//= require jquery/jquery.autocomplete
|
||||
//= require jquery/jplayer/jquery.jplayer.min
|
||||
|
||||
//= require bootstrap-modal
|
||||
//= require chosen-jquery
|
||||
|
||||
//= require vksearch/vkontakte_search
|
||||
|
||||
//= require session
|
||||
|
||||
@@ -15,6 +15,7 @@ class window.Session
|
||||
log "Setting user ..."
|
||||
@user = user
|
||||
log "Hello, #{if user.name? then user.name else "%username%"}!"
|
||||
$('#username').html (if @user.name? then @user.name else '%username%')
|
||||
false
|
||||
|
||||
getUser: ->
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
class window.Settings
|
||||
|
||||
loadSettingsPage: ->
|
||||
unless _session.getUser().id?
|
||||
_ajax.go('/')
|
||||
false
|
||||
_session.secureLoad '/settings/', (data) ->
|
||||
false
|
||||
_ajax.setTitle 'Settings'
|
||||
false
|
||||
|
||||
getAccountInfo: (callback) ->
|
||||
_session.query '/user/update/', {}, callback
|
||||
false
|
||||
@@ -22,45 +13,69 @@ class window.Settings
|
||||
if window.lastfm_popup.closed
|
||||
_session.query '/user/auth', {}, (ar) ->
|
||||
_session.setUser ar.user
|
||||
$('#lastfm_username').val(ar.user.lastfm_username)
|
||||
$('.lastfm-connect').hide()
|
||||
if _session.user.lastfm_username not in ["", null]
|
||||
$('#settings .lastfm-off').hide()
|
||||
$('#settings .lastfm-on').show()
|
||||
$('#settings .lastfm-login').text _session.user.lastfm_username
|
||||
false
|
||||
else
|
||||
setTimeout _settings.updateLastfmLogin, 100
|
||||
false
|
||||
|
||||
setFormFields: ->
|
||||
$('#settings input[name="name"]').val _session.user.name
|
||||
$('#settings select[name="lang"] option[value="'+_session.user.lang+'"]').attr("selected", true)
|
||||
$('select#lang').chosen()
|
||||
if _session.user.lastfm_username not in ["", null]
|
||||
$('#settings .lastfm-off').hide()
|
||||
$('#settings .lastfm-on').show()
|
||||
$('#settings .lastfm-login').text _session.user.lastfm_username
|
||||
else
|
||||
$('#settings .lastfm-on').hide()
|
||||
$('#settings .lastfm-off').show()
|
||||
false
|
||||
|
||||
updateSettings: ->
|
||||
this.saveAccountInfo {
|
||||
params:
|
||||
name: $('#settings input[name="name"]').val()
|
||||
lang: $('#settings select[name="lang"]').val()
|
||||
}, (ar) ->
|
||||
_session.setUser ar.user
|
||||
$("#settings").modal 'hide'
|
||||
|
||||
|
||||
$('#preferences').live 'click', ->
|
||||
_ajax.go('/settings/');
|
||||
if _session.getUser().id?
|
||||
$("#settings").modal 'show'
|
||||
_settings.setFormFields()
|
||||
false
|
||||
|
||||
$('#settings-tabs li').live 'click', ->
|
||||
if not $(this).hasClass 'active'
|
||||
$('#settings-tabs li').removeClass 'active'
|
||||
$(this).addClass 'active'
|
||||
$('#settings-forms > div').hide()
|
||||
$('#settings-forms > .'+ $(this).find('a').attr('data-tab')).show()
|
||||
$("#settings a.close-btn").live 'click', ->
|
||||
$("#settings").modal 'hide'
|
||||
false
|
||||
|
||||
$('#settings a.save-btn').live 'click', ->
|
||||
_settings.updateSettings()
|
||||
false
|
||||
|
||||
$('.lastfm-connect').live 'click', ->
|
||||
window.lastfm_popup = window.open _session.getUser().lastfm_login_url, "lastfm_popup", "status=1,width=960,height=585"
|
||||
setTimeout _settings.updateLastfmLogin, 100
|
||||
false
|
||||
|
||||
$('#settings-forms form').live 'submit', ->
|
||||
params = {}
|
||||
$(this).find('input, select').each ->
|
||||
if $(this).attr('name')
|
||||
if $(this).attr('type') is 'checkbox'
|
||||
params[$(this).attr('name')] = ($(this).attr('checked') is 'checked')
|
||||
else
|
||||
params[$(this).attr('name')] = $(this).val()
|
||||
_session.query '/user/update/', { params: params }
|
||||
|
||||
$('.lastfm-disconnect').live 'click', ->
|
||||
_settings.saveAccountInfo {
|
||||
params:
|
||||
lastfm_username: ""
|
||||
lastfm_token: ""
|
||||
}, (ar) ->
|
||||
_session.setUser ar.user
|
||||
$('#settings .lastfm-on').hide()
|
||||
$('#settings .lastfm-off').show()
|
||||
false
|
||||
false
|
||||
|
||||
$('#settings-forms input[type$="submit"]').live 'mouseup', ->
|
||||
$(this).parent().parent().parent().submit();
|
||||
false
|
||||
|
||||
$('#settings-forms input[type$="checkbox"]').live 'click', (e) ->
|
||||
sorry
|
||||
$ ->
|
||||
$("#settings").modal keyboard: true, backdrop: true
|
||||
false
|
||||
@@ -24,12 +24,10 @@ class window.Vkontakte
|
||||
_session = new Session(response.session)
|
||||
_session.query '/user/auth', {}, (ar) ->
|
||||
log "Authenticating user ..."
|
||||
if ar.newbie
|
||||
if ar.newbie or ar.user.name == ""
|
||||
VK.Api.call 'getVariable', key: 1281, (r) ->
|
||||
_session.query '/user/update', params: { name: r.response }, (ar2) ->
|
||||
_session.setUser ar2.user
|
||||
$('#username')
|
||||
.html (if _session.getUser().name then _session.getUser().name else '%username%')
|
||||
window._session = _session
|
||||
_ajax.detectPage()
|
||||
_session.displayAuthorizedContent()
|
||||
@@ -42,9 +40,6 @@ class window.Vkontakte
|
||||
false
|
||||
else
|
||||
_session.setUser ar.user
|
||||
|
||||
$('#username')
|
||||
.html (if _session.getUser().name then _session.getUser().name else '%username%')
|
||||
_session.displayAuthorizedContent()
|
||||
window._session = _session
|
||||
_ajax.detectPage()
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*
|
||||
|
||||
*= require bootstrap.min
|
||||
*= require bootstrap
|
||||
*= require chosen
|
||||
|
||||
*= require header
|
||||
*= require common
|
||||
@@ -8,8 +9,6 @@
|
||||
|
||||
*= require albums
|
||||
*= require player
|
||||
* require pulldown
|
||||
* require pulldown
|
||||
*= require search
|
||||
*= require settings
|
||||
* require textpage
|
||||
|
||||
@@ -19,4 +19,18 @@
|
||||
box-shadow: none !important;
|
||||
margin-top: 2px !important;
|
||||
}
|
||||
}
|
||||
|
||||
#settings {
|
||||
display: none;
|
||||
}
|
||||
|
||||
select#lang {
|
||||
width: 280px;
|
||||
}
|
||||
|
||||
a.label {
|
||||
color: #fff;
|
||||
text-decoration: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
@@ -28,7 +28,7 @@ class UserController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
allowed_params = [:name, :email, :lang, :show]
|
||||
allowed_params = [:name, :email, :lang, :show, :lastfm_username, :lastfm_token]
|
||||
|
||||
user = User.find_by_vkid(params[:mid])
|
||||
unless params[:params].nil?
|
||||
@@ -87,7 +87,7 @@ private
|
||||
lastfm_username: user.lastfm_username,
|
||||
lastfm_login_url: ('http://www.last.fm/api/auth?api_key=' << LastFM.api_key <<
|
||||
'&cb=http://' << request.host << ':' << request.port.to_s << '/lastfm/connect/?sid=' <<
|
||||
user.session.key if user.lastfm_username.nil?)
|
||||
user.session.key if user.lastfm_username.nil? or user.lastfm_username == "")
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
@@ -84,3 +84,4 @@
|
||||
= image_tag "loader.gif"
|
||||
#vk_api_transport
|
||||
#jplayer
|
||||
= render "user/settings"
|
||||
|
||||
@@ -1,71 +1,36 @@
|
||||
%h1= I18n.t 'settings.title'
|
||||
%ul.tabs#settings-tabs
|
||||
%li.active
|
||||
%a{ :href => "#", :'data-tab' => 'account' }= I18n.t 'settings.tab.account'
|
||||
%li
|
||||
%a{ :href => "#", :'data-tab' => 'site' }= I18n.t 'settings.tab.site'
|
||||
%li
|
||||
%a{ :href => "#", :'data-tab' => 'music' }= I18n.t 'settings.tab.music'
|
||||
%li
|
||||
%a{ :href => "#", :'data-tab' => 'lastfm' }= I18n.t 'settings.tab.lastfm'
|
||||
|
||||
.forms#settings-forms
|
||||
.form.account
|
||||
%form{ :action => "/", :method => 'post' }
|
||||
%fieldset
|
||||
.clearfix
|
||||
%label{ :for => "name" }= I18n.t 'settings.username'
|
||||
.input
|
||||
%input.xlarge#name{ :name => "name", :size => 30, :type => "text", :value => @user.name }
|
||||
.clearfix
|
||||
%label{ :for => "email" }= I18n.t 'settings.email'
|
||||
.input
|
||||
%input.xlarge#email{ :name => "email", :size => 30, :type => "text", :value => @user.email }
|
||||
.actions
|
||||
%input.btn.primary{ :type => "submit", :value => I18n.t('settings.save') }
|
||||
.form.site
|
||||
%form
|
||||
%fieldset
|
||||
.clearfix
|
||||
%label{ :for => "lang" }= I18n.t 'settings.lang.title'
|
||||
.input
|
||||
%select.medium#lang{ :name => "lang" }
|
||||
%option{ :value => "en", :selected => (@user.lang == 'en') }= I18n.t 'settings.lang.en'
|
||||
%option{ :value => "ru", :selected => (@user.lang == 'ru') }= I18n.t 'settings.lang.ru'
|
||||
.actions
|
||||
%input.btn.primary{ :type => "submit", :value => I18n.t('settings.save') }
|
||||
.form.music
|
||||
%form
|
||||
%fieldset
|
||||
.clearfix
|
||||
%label{ :for => "album_types" }= I18n.t 'settings.music.title'
|
||||
.input
|
||||
%ul.inputs-list
|
||||
%li
|
||||
%label{ :for => "show_album" }
|
||||
%input#show_album{ :name => "show[album]", :type => "checkbox", :checked => @user.music.include?(:album) }
|
||||
%span= I18n.t 'settings.music.albums'
|
||||
%li
|
||||
%label{ :for => "show_single" }
|
||||
%input#show_single{ :name => "show[single]", :type => "checkbox", :checked => @user.music.include?(:single) }
|
||||
%span= I18n.t 'settings.music.singles'
|
||||
%li
|
||||
%label.disabled{ :for => "show_live" }
|
||||
%input#show_live{ :name => "show[live]", :type => "checkbox", :disabled => "disabled", :checked => @user.music.include?(:live) }
|
||||
%span= I18n.t 'settings.music.live'
|
||||
%li
|
||||
%label.disabled{ :for => "show_bootleg" }
|
||||
%input#show_bootleg{ :name => "show[bootleg]", :type => "checkbox", :disabled => "disabled", :checked => @user.music.include?(:bootleg) }
|
||||
%span= I18n.t 'settings.music.bootlegs'
|
||||
.actions
|
||||
%input.btn.primary{ :type => "submit", :value => I18n.t('settings.save') }
|
||||
.form.lastfm
|
||||
%form
|
||||
%fieldset
|
||||
.clearfix
|
||||
%label{ :for => "lastfm_username" }= I18n.t 'settings.username'
|
||||
.input
|
||||
%input.borderless#lastfm_username{ :type => "text", :readonly => "readonly", :value => (@user.lastfm_username || I18n.t('settings.not_connected')) }
|
||||
- unless @user.lastfm_username
|
||||
%span.help-inline
|
||||
%input.btn.lastfm-connect{ :type => "submit", :value => I18n.t('settings.connect') }
|
||||
.modal#settings
|
||||
.modal-header
|
||||
%a.close.close-btn ×
|
||||
%h3= t('settings.title')
|
||||
.modal-body
|
||||
.forms#settings-forms
|
||||
.form.account
|
||||
%form{ :action => "/", :method => 'post' }
|
||||
%fieldset
|
||||
.clearfix
|
||||
%label{ :for => "name" }= I18n.t 'settings.username'
|
||||
.input
|
||||
%input.xlarge#name{ :name => "name", :size => 30, :type => "text", :value => "" }
|
||||
.clearfix
|
||||
%label{ :for => "lang" }= I18n.t 'settings.lang.title'
|
||||
.input
|
||||
%select.large#lang{ name: "lang" }
|
||||
%option{ :value => "en" }= I18n.t 'settings.lang.en'
|
||||
%option{ :value => "ru" }= I18n.t 'settings.lang.ru'
|
||||
.clearfix.lastfm-on
|
||||
%label= I18n.t 'settings.lastfm'
|
||||
.input
|
||||
%ul.inputs-list
|
||||
%li
|
||||
= t('settings.logged_in_as')
|
||||
%span.label.notice.lastfm-login
|
||||
%a.label.important.lastfm-disconnect= t('settings.disconnect')
|
||||
.clearfix.lastfm-off
|
||||
%label= I18n.t 'settings.lastfm'
|
||||
.input
|
||||
%ul.inputs-list
|
||||
%li
|
||||
%a.label.success.lastfm-connect= t('settings.connect')
|
||||
.modal-footer
|
||||
%a.save-btn.btn.primary= t('settings.save')
|
||||
%a.close-btn.btn.secondary= t('settings.cancel')
|
||||
|
||||
Reference in New Issue
Block a user