Form submit ability
This commit is contained in:
parent
442995dbc9
commit
2f31a6fd65
|
@ -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
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -28,21 +28,6 @@ class window.Page
|
|||
, 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/'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -8,16 +18,6 @@ class window.Settings
|
|||
_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) ->
|
||||
|
@ -45,20 +45,14 @@ $('.lastfm-connect') .live 'click', ->
|
|||
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%')
|
||||
$('#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
|
|
@ -9,6 +9,7 @@
|
|||
}
|
||||
|
||||
.popover-wrapper {
|
||||
display: none;
|
||||
position: fixed;
|
||||
left: 50%;
|
||||
margin-left: -280px;
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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') }
|
Loading…
Reference in New Issue