remove some annoying 'missing username/password/e-mail' messages

This commit is contained in:
rolux 2011-11-07 09:58:37 +00:00
parent 94a9a59718
commit 3bed914023
3 changed files with 31 additions and 25 deletions

View file

@ -204,12 +204,7 @@ pandora.ui.accountForm = function(action, value) {
id: 'code', id: 'code',
label: 'Code', label: 'Code',
labelWidth: 120, labelWidth: 120,
validate: function(value, callback) { validate: pandora.validateCode,
callback({
message: 'Missing code',
valid: value.length > 0
});
},
width: 320 width: 320
}); });
} else if (type == 'email') { } else if (type == 'email') {
@ -257,12 +252,7 @@ pandora.ui.accountForm = function(action, value) {
label: 'Password', label: 'Password',
labelWidth: 120, labelWidth: 120,
type: 'password', type: 'password',
validate: function(value, callback) { validate: pandora.validatePassword,
callback({
message: 'Missing password',
valid: value.length > 0
});
},
width: 320 width: 320
}); });
} else if (type == 'username') { } else if (type == 'username') {
@ -295,7 +285,8 @@ pandora.ui.accountForm = function(action, value) {
? pandora.autovalidateUsername : pandora.autovalidateEmail, ? pandora.autovalidateUsername : pandora.autovalidateEmail,
validate: pandora.validateUser(selected, true), validate: pandora.validateUser(selected, true),
value: '' value: ''
}).focus(); }).focusInput();
//setTimeout(that.submit, 250);
pandora.$ui.accountDialog.disableButton('submitReset'); pandora.$ui.accountDialog.disableButton('submitReset');
} }
}), }),

View file

@ -38,11 +38,18 @@ pandora.autovalidateUsername = function(value, blur, callback) {
callback({valid: !!value.length, value: value}); callback({valid: !!value.length, value: value});
}; };
pandora.validateCode = function(value, callback) {
callback({
message: '',
// message: 'Missing code',
valid: value.length > 0
});
};
pandora.validateNewEmail = function(value, callback) { pandora.validateNewEmail = function(value, callback) {
value == pandora.user.email ? callback({ value == pandora.user.email ? callback({
message: '', message: '',
valid: true, valid: true
value: value
}) : Ox.isValidEmail(value) ? pandora.api.findUser({ }) : Ox.isValidEmail(value) ? pandora.api.findUser({
key: 'email', key: 'email',
value: value, value: value,
@ -50,21 +57,28 @@ pandora.validateNewEmail = function(value, callback) {
}, function(result) { }, function(result) {
callback({ callback({
message: 'E-mail address already exists', message: 'E-mail address already exists',
valid: !result.data.users.length, valid: !result.data.users.length
value: value
}); });
}) : callback({ }) : callback({
message: (!value.length ? 'Missing' : 'Invalid') + ' e-mail address', message: value.length ? 'Invalid e-mail address' : '',
// message: (!value.length ? 'Missing' : 'Invalid') + ' e-mail address',
valid: false, valid: false,
value: value
}); });
}; };
pandora.validateNewPassword = function(value, callback) { pandora.validateNewPassword = function(value, callback) {
callback({ callback({
message: 'Missing password', message: '',
valid: value.length > 0, // message: 'Missing password',
value: value valid: value.length > 0
});
};
pandora.validatePassword = function(value, callback) {
callback({
message: '',
// message: 'Missing password',
valid: value.length > 0
}); });
}; };
@ -79,7 +93,6 @@ pandora.validateUser = function(key, existing) {
operator: '==' operator: '=='
}, function(result) { }, function(result) {
var valid = existing == !!result.data.users.length; var valid = existing == !!result.data.users.length;
//Ox.Log('', existing, result.data.users)
callback({ callback({
message: existing ? message: existing ?
'Unknown ' + string : 'Unknown ' + string :
@ -87,7 +100,8 @@ pandora.validateUser = function(key, existing) {
valid: valid valid: valid
}); });
}) : callback({ }) : callback({
message: (!value.length ? 'Missing' : 'Invalid') + ' ' + string, message: value.length ? 'Invalid ' + string : '',
// message: (!value.length ? 'Missing' : 'Invalid') + ' ' + string,
valid: false valid: false
}); });
}; };

View file

@ -64,9 +64,10 @@ pandora.ui.siteDialog = function(section) {
$dialog.options({ $dialog.options({
title: Ox.getObjectById(tabs, data.selected).title title: Ox.getObjectById(tabs, data.selected).title
}); });
pandora.URL.replace('/' + data.selected);
//fixme: this should be using URL.push / UI.set //fixme: this should be using URL.push / UI.set
//but that currenlty causes another dialog to be opened //but that currenlty causes another dialog to be opened
history.pushState({}, '', '/' + data.selected); //history.pushState({}, '', '/' + data.selected);
} }
}); });
var $dialog = Ox.Dialog({ var $dialog = Ox.Dialog({