summaryrefslogtreecommitdiff
path: root/modules/field_ui/field_ui.js
diff options
context:
space:
mode:
Diffstat (limited to 'modules/field_ui/field_ui.js')
-rw-r--r--modules/field_ui/field_ui.js19
1 files changed, 13 insertions, 6 deletions
diff --git a/modules/field_ui/field_ui.js b/modules/field_ui/field_ui.js
index 0a41c4c6f..1017937b6 100644
--- a/modules/field_ui/field_ui.js
+++ b/modules/field_ui/field_ui.js
@@ -28,7 +28,7 @@ Drupal.fieldUIFieldOverview = {
// 'Field type' select updates its 'Widget' select.
$('.field-type-select', table).each(function () {
- this.targetSelect = $('.widget-type-select', $(this).parents('tr').eq(0));
+ this.targetSelect = $('.widget-type-select', $(this).closest('tr'));
$(this).bind('change keyup', function () {
var selectedFieldType = this.options[this.selectedIndex].value;
@@ -43,8 +43,13 @@ Drupal.fieldUIFieldOverview = {
// 'Existing field' select updates its 'Widget' select and 'Label' textfield.
$('.field-select', table).each(function () {
- this.targetSelect = $('.widget-type-select', $(this).parents('tr').eq(0));
- this.targetTextfield = $('.label-textfield', $(this).parents('tr').eq(0));
+ this.targetSelect = $('.widget-type-select', $(this).closest('tr'));
+ this.targetTextfield = $('.label-textfield', $(this).closest('tr'));
+ this.targetTextfield
+ .data('field_ui_edited', false)
+ .bind('keyup', function (e) {
+ $(this).data('field_ui_edited', $(this).val() != '');
+ });
$(this).bind('change keyup', function (e, updateText) {
var updateText = (typeof updateText == 'undefined' ? true : updateText);
@@ -54,8 +59,10 @@ Drupal.fieldUIFieldOverview = {
var options = (selectedFieldType && (selectedFieldType in widgetTypes) ? widgetTypes[selectedFieldType] : []);
this.targetSelect.fieldUIPopulateOptions(options, selectedFieldWidget);
- if (updateText) {
- $(this.targetTextfield).attr('value', (selectedField in fields ? fields[selectedField].label : ''));
+ // Only overwrite the "Label" input if it has not been manually
+ // changed, or if it is empty.
+ if (updateText && !this.targetTextfield.data('field_ui_edited')) {
+ this.targetTextfield.val(selectedField in fields ? fields[selectedField].label : '');
}
});
@@ -133,7 +140,7 @@ Drupal.fieldUIOverview = {
*/
onChange: function () {
var $trigger = $(this);
- var row = $trigger.parents('tr:first').get(0);
+ var row = $trigger.closest('tr').get(0);
var rowHandler = $(row).data('fieldUIRowHandler');
var refreshRows = {};