diff --git a/static/js/pandora/account.js b/static/js/pandora/account.js index 294eaa596..8c141f064 100644 --- a/static/js/pandora/account.js +++ b/static/js/pandora/account.js @@ -204,12 +204,7 @@ pandora.ui.accountForm = function(action, value) { id: 'code', label: 'Code', labelWidth: 120, - validate: function(value, callback) { - callback({ - message: 'Missing code', - valid: value.length > 0 - }); - }, + validate: pandora.validateCode, width: 320 }); } else if (type == 'email') { @@ -257,12 +252,7 @@ pandora.ui.accountForm = function(action, value) { label: 'Password', labelWidth: 120, type: 'password', - validate: function(value, callback) { - callback({ - message: 'Missing password', - valid: value.length > 0 - }); - }, + validate: pandora.validatePassword, width: 320 }); } else if (type == 'username') { @@ -295,7 +285,8 @@ pandora.ui.accountForm = function(action, value) { ? pandora.autovalidateUsername : pandora.autovalidateEmail, validate: pandora.validateUser(selected, true), value: '' - }).focus(); + }).focusInput(); + //setTimeout(that.submit, 250); pandora.$ui.accountDialog.disableButton('submitReset'); } }), diff --git a/static/js/pandora/autovalidate.js b/static/js/pandora/autovalidate.js index 38a11bad8..ed91e80bb 100644 --- a/static/js/pandora/autovalidate.js +++ b/static/js/pandora/autovalidate.js @@ -38,11 +38,18 @@ pandora.autovalidateUsername = function(value, blur, callback) { 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) { value == pandora.user.email ? callback({ message: '', - valid: true, - value: value + valid: true }) : Ox.isValidEmail(value) ? pandora.api.findUser({ key: 'email', value: value, @@ -50,21 +57,28 @@ pandora.validateNewEmail = function(value, callback) { }, function(result) { callback({ message: 'E-mail address already exists', - valid: !result.data.users.length, - value: value + valid: !result.data.users.length }); }) : 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, - value: value }); }; pandora.validateNewPassword = function(value, callback) { callback({ - message: 'Missing password', - valid: value.length > 0, - value: value + message: '', + // message: 'Missing password', + 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: '==' }, function(result) { var valid = existing == !!result.data.users.length; - //Ox.Log('', existing, result.data.users) callback({ message: existing ? 'Unknown ' + string : @@ -87,7 +100,8 @@ pandora.validateUser = function(key, existing) { valid: valid }); }) : callback({ - message: (!value.length ? 'Missing' : 'Invalid') + ' ' + string, + message: value.length ? 'Invalid ' + string : '', + // message: (!value.length ? 'Missing' : 'Invalid') + ' ' + string, valid: false }); }; diff --git a/static/js/pandora/siteDialog.js b/static/js/pandora/siteDialog.js index 738d82b55..018c2de46 100644 --- a/static/js/pandora/siteDialog.js +++ b/static/js/pandora/siteDialog.js @@ -64,9 +64,10 @@ pandora.ui.siteDialog = function(section) { $dialog.options({ title: Ox.getObjectById(tabs, data.selected).title }); + pandora.URL.replace('/' + data.selected); //fixme: this should be using URL.push / UI.set //but that currenlty causes another dialog to be opened - history.pushState({}, '', '/' + data.selected); + //history.pushState({}, '', '/' + data.selected); } }); var $dialog = Ox.Dialog({