2011-06-21 20:44:19 +00:00
|
|
|
var Settings = {
|
|
|
|
|
2011-06-21 23:29:18 +00:00
|
|
|
getAccountInfo: function(callback) {
|
|
|
|
Session.query('/user/update', {}, callback);
|
|
|
|
},
|
|
|
|
|
|
|
|
saveAccountInfo: function(params, callback) {
|
|
|
|
Session.query('/user/update', params, callback);
|
|
|
|
},
|
|
|
|
|
|
|
|
loadFormData: function(form) {
|
|
|
|
if (form == 'account') {
|
|
|
|
this.getAccountInfo(function(data){
|
|
|
|
$('.settings-container .form input[name$="username"]').val(data.username);
|
|
|
|
$('.settings-container .form input[name$="email"]').val(data.email);
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2011-06-21 20:44:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
$('.settings').live('click', function() {
|
|
|
|
Ajax.loadSettingsPage();
|
2011-06-21 23:29:18 +00:00
|
|
|
});
|
|
|
|
|
2011-06-21 21:51:20 +00:00
|
|
|
$('.settings-container .tabs .tab').live('click', function(){
|
|
|
|
if (!$(this).hasClass('active')) {
|
|
|
|
$('.settings-container .tabs .tab').removeClass('active');
|
|
|
|
$(this).addClass('active');
|
2011-06-21 23:29:18 +00:00
|
|
|
$('.form-container').html($('.forms .'+ $(this).attr('data-fieldset')).html());
|
|
|
|
Settings.loadFormData($(this).attr('data-fieldset'));
|
2011-06-21 21:51:20 +00:00
|
|
|
}
|
2011-06-21 23:29:18 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
$('.settings-container .form input').live('blur', function(){
|
|
|
|
params = {
|
|
|
|
'username': $('.settings-container .form input[name$="username"]').first().val(),
|
|
|
|
'email': $('.settings-container .form input[name$="email"]').first().val(),
|
|
|
|
};
|
|
|
|
Settings.saveAccountInfo(params, function(){
|
2011-06-22 04:52:56 +00:00
|
|
|
$('#header-container .hello .greating').text('Hi there, '+ (params.username.length > 0 ? params.username : '%username%') +'!');
|
2011-06-21 23:29:18 +00:00
|
|
|
});
|
2011-06-21 20:44:19 +00:00
|
|
|
})
|