diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/form.js | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/misc/form.js b/misc/form.js index ca572cf38..4b48d3bb0 100644 --- a/misc/form.js +++ b/misc/form.js @@ -68,7 +68,6 @@ Drupal.behaviors.multiselectSelector = { } }; - /** * Automatically display the guidelines of the selected text format. */ @@ -86,4 +85,22 @@ Drupal.behaviors.filterGuidelines = { } }; +/** + * Prepopulate form fields with information from the visitor cookie. + */ +Drupal.behaviors.fillUserInfoFromCookie = { + attach: function (context, settings) { + $('form.user-info-from-cookie').once('user-info-from-cookie', function () { + var formContext = this; + $.each(['name', 'mail', 'homepage'], function () { + var $element = $('[name=' + this + ']', formContext); + var cookie = $.cookie('Drupal.visitor.' + this); + if ($element.length && cookie) { + $element.val(cookie); + } + }); + }); + } +}; + })(jQuery); |