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
This commit is contained in:
Sam Minnee 2008-09-22 22:50:13 +00:00
parent be90ef6573
commit c2b70b7bc5

View File

@ -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;