From c2b70b7bc5ee5fcd4b33a4ce7ead2de848e6766c Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 22 Sep 2008 22:50:13 +0000 Subject: [PATCH] Replaced alert()s in UniqueFields.js with statusMessage()s, to be less obnoxious git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@62865 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- javascript/UniqueFields.js | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/javascript/UniqueFields.js b/javascript/UniqueFields.js index 6653a816f..7649a3a29 100755 --- a/javascript/UniqueFields.js +++ b/javascript/UniqueFields.js @@ -4,13 +4,11 @@ UniqueFormField.prototype = { // check that the value is not in use, and matches the pattern var suggested = this.value; - while( this.restrictedValues[suggested] || suggested == null ) { - alert(this.restrictedMessage); - - suggested = prompt('The following might be a suitable URL segment for the page. Alternatively, you can modify it.', this.suggestNewValue() ); + if( this.restrictedValues[suggested] || suggested == null ) { + suggested = this.suggestNewValue(); + statusMessage("Changed value to " + suggested + ". " + this.restrictedMessage); + this.value = suggested; } - - this.value = suggested; }, suggestNewValue: function() { var parts = this.value.match( /(.*)(\d+)$/ ); @@ -107,17 +105,19 @@ UniqueRestrictedTextField.prototype = { var suggestedValue = this.restrictedValues[suggested]; } - while( suggested == null || suggested.length == 0 || suggestedValue || suggested.match( this.charRegex ) ) { + if( suggested == null || suggested.length == 0 || suggestedValue || suggested.match( this.charRegex ) ) { + var message; if( suggested == null ) - alert('You will need to enter a new value for this field'); + message = 'You will need to enter a new value for this field'; else if( suggested.length == 0 ) - alert('This field cannot be left empty'); + message = 'This field cannot be left empty'; else if( suggestedValue ) - alert(this.restrictedMessage); + message = this.restrictedMessage; else - alert(this.charMessage); - - suggested = prompt('The following might be a suitable URL segment for the page. Alternatively, you can modify it.', this.suggestNewValue() ); + message = this.charMessage; + + suggested = this.suggestNewValue(); + statusMessage("Changed value to " + suggested + ". " + message); } this.value = suggested;