mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
ENHANCEMENT Removed UniqueField.js dependency to CMS-related statusMessage() javascript class, and using jQuery even triggers instead
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@92540 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
0b25cb9e14
commit
28109df438
@ -25,6 +25,7 @@ class UniqueTextField extends TextField {
|
|||||||
|
|
||||||
function Field() {
|
function Field() {
|
||||||
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
Requirements::add_i18n_javascript(SAPPHIRE_DIR . '/javascript/lang');
|
||||||
|
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/jquery/jquery.js");
|
||||||
Requirements::javascript(SAPPHIRE_DIR . "/javascript/UniqueFields.js");
|
Requirements::javascript(SAPPHIRE_DIR . "/javascript/UniqueFields.js");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -6,12 +6,13 @@ UniqueFormField.prototype = {
|
|||||||
|
|
||||||
if( this.restrictedValues[suggested] || suggested == null ) {
|
if( this.restrictedValues[suggested] || suggested == null ) {
|
||||||
suggested = this.suggestNewValue();
|
suggested = this.suggestNewValue();
|
||||||
statusMessage(ss.i18n.sprintf(
|
var message = i18n.sprintf(
|
||||||
ss.i18n._t('UNIQUEFIELD.SUGGESTED', "Changed value to '%s' : %s"),
|
ss.i18n._t('UNIQUEFIELD.SUGGESTED', "Changed value to '%s' : %s"),
|
||||||
suggested,
|
suggested,
|
||||||
this.restrictedMessage
|
this.restrictedMessage
|
||||||
));
|
);
|
||||||
this.value = suggested;
|
jQuery(this).trigger('validate', {message: message, suggested: suggested});
|
||||||
|
this.value = suggested;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
suggestNewValue: function() {
|
suggestNewValue: function() {
|
||||||
@ -108,11 +109,13 @@ UniqueRestrictedTextField.prototype = {
|
|||||||
message = this.charMessage;
|
message = this.charMessage;
|
||||||
|
|
||||||
suggested = this.suggestNewValue();
|
suggested = this.suggestNewValue();
|
||||||
statusMessage(ss.i18n.sprintf(
|
var message = ss.i18n.sprintf(
|
||||||
ss.i18n._t('UNIQUEFIELD.SUGGESTED', "Changed value to '%s' : %s"),
|
ss.i18n._t('UNIQUEFIELD.SUGGESTED', "Changed value to '%s' : %s"),
|
||||||
suggested,
|
suggested,
|
||||||
message
|
message
|
||||||
));
|
);
|
||||||
|
|
||||||
|
jQuery(this).trigger('validate', {message: message, suggested: suggested});
|
||||||
}
|
}
|
||||||
|
|
||||||
this.value = suggested;
|
this.value = suggested;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user