diff options
author | webchick <webchick@24967.no-reply.drupal.org> | 2011-06-08 21:16:28 -0700 |
---|---|---|
committer | webchick <webchick@24967.no-reply.drupal.org> | 2011-06-08 21:16:28 -0700 |
commit | 8458100467704359fe0447dbdca0410deda67d75 (patch) | |
tree | af835030dc0b99879c01a1e2bd89f1da836938e6 /misc | |
parent | d01ac03790e3e5e34cabb611409041c1b565fae8 (diff) | |
download | brdo-8458100467704359fe0447dbdca0410deda67d75.tar.gz brdo-8458100467704359fe0447dbdca0410deda67d75.tar.bz2 |
Issue #1149188 by fago: Fixed machine_name.js does not respect maxlength of target field.
Diffstat (limited to 'misc')
-rw-r--r-- | misc/machine-name.js | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/misc/machine-name.js b/misc/machine-name.js index 00a648a1b..2691c3b73 100644 --- a/misc/machine-name.js +++ b/misc/machine-name.js @@ -35,6 +35,8 @@ Drupal.behaviors.machineName = { if ($target.hasClass('error')) { return; } + // Figure out the maximum length for the machine name. + options.maxlength = $target.attr('maxlength'); // Hide the form item container of the machine name form element. $wrapper.hide(); // Determine the initial machine name value. Unless the machine name form @@ -103,13 +105,14 @@ Drupal.behaviors.machineName = { * disallowed characters in the machine name; e.g., '[^a-z0-9]+'. * - replace: A character to replace disallowed characters with; e.g., '_' * or '-'. + * - maxlength: The maximum length of the machine name. * * @return * The transliterated source string. */ transliterate: function (source, settings) { var rx = new RegExp(settings.replace_pattern, 'g'); - return source.toLowerCase().replace(rx, settings.replace); + return source.toLowerCase().replace(rx, settings.replace).substr(0, settings.maxlength); } }; |