forked from 0x2620/pandora
improve accountDialog
This commit is contained in:
parent
50e15ad3b0
commit
414b930a92
1 changed files with 10 additions and 1 deletions
|
@ -8,6 +8,9 @@ pandora.ui.accountDialog = function(action) {
|
||||||
width: 432
|
width: 432
|
||||||
}, pandora.ui.accountDialogOptions(action)))
|
}, pandora.ui.accountDialogOptions(action)))
|
||||||
.bindEvent({
|
.bindEvent({
|
||||||
|
open: function() {
|
||||||
|
pandora.$ui.accountForm.find('input')[0].focus();
|
||||||
|
},
|
||||||
resize: function(data) {
|
resize: function(data) {
|
||||||
var width = data.width - 32;
|
var width = data.width - 32;
|
||||||
pandora.$ui.accountForm.items.forEach(function(item) {
|
pandora.$ui.accountForm.items.forEach(function(item) {
|
||||||
|
@ -68,6 +71,7 @@ pandora.ui.accountDialogOptions = function(action, value) {
|
||||||
title: buttonTitle[type] + '...'
|
title: buttonTitle[type] + '...'
|
||||||
}).bindEvent('click', function() {
|
}).bindEvent('click', function() {
|
||||||
pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(type));
|
pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions(type));
|
||||||
|
pandora.$ui.accountForm.find('input')[0].focus();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,12 +136,14 @@ pandora.ui.accountForm = function(action, value) {
|
||||||
id: 'accountForm' + Ox.toTitleCase(action),
|
id: 'accountForm' + Ox.toTitleCase(action),
|
||||||
items: $items,
|
items: $items,
|
||||||
submit: function(data, callback) {
|
submit: function(data, callback) {
|
||||||
|
pandora.$ui.accountDialog.disableButtons();
|
||||||
if (action == 'signin') {
|
if (action == 'signin') {
|
||||||
pandora.api.signin(data, function(result) {
|
pandora.api.signin(data, function(result) {
|
||||||
if (!result.data.errors) {
|
if (!result.data.errors) {
|
||||||
pandora.$ui.accountDialog.close();
|
pandora.$ui.accountDialog.close();
|
||||||
pandora.signin(result.data);
|
pandora.signin(result.data);
|
||||||
} else {
|
} else {
|
||||||
|
pandora.$ui.accountDialog.enableButtons();
|
||||||
callback([{id: 'password', message: 'Incorrect password'}]);
|
callback([{id: 'password', message: 'Incorrect password'}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -148,6 +154,7 @@ pandora.ui.accountForm = function(action, value) {
|
||||||
pandora.signin(result.data);
|
pandora.signin(result.data);
|
||||||
pandora.ui.accountWelcomeDialog().open();
|
pandora.ui.accountWelcomeDialog().open();
|
||||||
} else {
|
} else {
|
||||||
|
pandora.$ui.accountDialog.enableButtons();
|
||||||
callback([{id: 'password', message: result.data.errors.toString()}]); // fixme
|
callback([{id: 'password', message: result.data.errors.toString()}]); // fixme
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -160,6 +167,7 @@ pandora.ui.accountForm = function(action, value) {
|
||||||
if (!result.data.errors) {
|
if (!result.data.errors) {
|
||||||
pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions('resetAndSignin', result.data.username));
|
pandora.$ui.accountDialog.options(pandora.ui.accountDialogOptions('resetAndSignin', result.data.username));
|
||||||
} else {
|
} else {
|
||||||
|
pandora.$ui.accountDialog.enableButtons();
|
||||||
callback([{id: 'usernameOrEmail', message: 'Unknown ' + (key == 'username' ? 'username' : 'e-mail address')}])
|
callback([{id: 'usernameOrEmail', message: 'Unknown ' + (key == 'username' ? 'username' : 'e-mail address')}])
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -169,6 +177,7 @@ pandora.ui.accountForm = function(action, value) {
|
||||||
pandora.$ui.accountDialog.close();
|
pandora.$ui.accountDialog.close();
|
||||||
pandora.signin(result.data);
|
pandora.signin(result.data);
|
||||||
} else {
|
} else {
|
||||||
|
pandora.$ui.accountDialog.enableButtons();
|
||||||
callback([{id: 'code', message: 'Incorrect code'}]);
|
callback([{id: 'code', message: 'Incorrect code'}]);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -248,7 +257,7 @@ pandora.ui.accountForm = function(action, value) {
|
||||||
type: 'password',
|
type: 'password',
|
||||||
validate: function(value, callback) {
|
validate: function(value, callback) {
|
||||||
callback({
|
callback({
|
||||||
message: 'Missing Password',
|
message: 'Missing password',
|
||||||
valid: value.length > 0
|
valid: value.length > 0
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue