- Patch #1400310 by nod_: Fixed Use of .parents() is really .closest().
parent
4b92841794
commit
f5563bf877
core
modules
block
field_ui
file
filter
shortcut
simpletest
|
@ -536,7 +536,7 @@ Drupal.ajax.prototype.commands = {
|
||||||
// Attach all JavaScript behaviors to the new content, if it was successfully
|
// Attach all JavaScript behaviors to the new content, if it was successfully
|
||||||
// added to the page, this if statement allows #ajax['wrapper'] to be
|
// added to the page, this if statement allows #ajax['wrapper'] to be
|
||||||
// optional.
|
// optional.
|
||||||
if (new_content.parents('html').length > 0) {
|
if ($('html').find(new_content).length > 0) {
|
||||||
// Apply any settings from the returned JSON if available.
|
// Apply any settings from the returned JSON if available.
|
||||||
var settings = response.settings || ajax.settings || Drupal.settings;
|
var settings = response.settings || ajax.settings || Drupal.settings;
|
||||||
Drupal.attachBehaviors(new_content, settings);
|
Drupal.attachBehaviors(new_content, settings);
|
||||||
|
|
|
@ -26,7 +26,7 @@ Drupal.behaviors.machineName = {
|
||||||
var $source = $(source_id, context).addClass('machine-name-source');
|
var $source = $(source_id, context).addClass('machine-name-source');
|
||||||
var $target = $(options.target, context).addClass('machine-name-target');
|
var $target = $(options.target, context).addClass('machine-name-target');
|
||||||
var $suffix = $(options.suffix, context);
|
var $suffix = $(options.suffix, context);
|
||||||
var $wrapper = $target.parents('.form-item:first');
|
var $wrapper = $target.closest('.form-item');
|
||||||
// All elements have to exist.
|
// All elements have to exist.
|
||||||
if (!$source.length || !$target.length || !$suffix.length || !$wrapper.length) {
|
if (!$source.length || !$target.length || !$suffix.length || !$wrapper.length) {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -125,7 +125,7 @@ Drupal.tableDrag.prototype.initColumns = function () {
|
||||||
var field = $('.' + this.tableSettings[group][d].target + ':first', this.table);
|
var field = $('.' + this.tableSettings[group][d].target + ':first', this.table);
|
||||||
if (field.size() && this.tableSettings[group][d].hidden) {
|
if (field.size() && this.tableSettings[group][d].hidden) {
|
||||||
var hidden = this.tableSettings[group][d].hidden;
|
var hidden = this.tableSettings[group][d].hidden;
|
||||||
var cell = field.parents('td:first');
|
var cell = field.closest('td');
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -744,7 +744,7 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
|
||||||
switch (rowSettings.action) {
|
switch (rowSettings.action) {
|
||||||
case 'depth':
|
case 'depth':
|
||||||
// Get the depth of the target row.
|
// Get the depth of the target row.
|
||||||
targetElement.value = $('.indentation', $(sourceElement).parents('tr:first')).size();
|
targetElement.value = $('.indentation', $(sourceElement).closest('tr')).size();
|
||||||
break;
|
break;
|
||||||
case 'match':
|
case 'match':
|
||||||
// Update the value.
|
// Update the value.
|
||||||
|
@ -876,7 +876,7 @@ Drupal.tableDrag.prototype.row = function (tableRow, method, indentEnabled, maxD
|
||||||
this.group = [tableRow];
|
this.group = [tableRow];
|
||||||
this.groupDepth = $('.indentation', tableRow).size();
|
this.groupDepth = $('.indentation', tableRow).size();
|
||||||
this.changed = false;
|
this.changed = false;
|
||||||
this.table = $(tableRow).parents('table:first').get(0);
|
this.table = $(tableRow).closest('table').get(0);
|
||||||
this.indentEnabled = indentEnabled;
|
this.indentEnabled = indentEnabled;
|
||||||
this.maxDepth = maxDepth;
|
this.maxDepth = maxDepth;
|
||||||
this.direction = ''; // Direction the row is being moved.
|
this.direction = ''; // Direction the row is being moved.
|
||||||
|
|
|
@ -29,7 +29,7 @@ Drupal.tableSelect = function () {
|
||||||
checkboxes.each(function () {
|
checkboxes.each(function () {
|
||||||
this.checked = event.target.checked;
|
this.checked = event.target.checked;
|
||||||
// Either add or remove the selected class based on the state of the check all checkbox.
|
// Either add or remove the selected class based on the state of the check all checkbox.
|
||||||
$(this).parents('tr:first')[ this.checked ? 'addClass' : 'removeClass' ]('selected');
|
$(this).closest('tr').toggleClass('selected', this.checked);
|
||||||
});
|
});
|
||||||
// Update the title and the state of the check all box.
|
// Update the title and the state of the check all box.
|
||||||
updateSelectAll(event.target.checked);
|
updateSelectAll(event.target.checked);
|
||||||
|
@ -39,14 +39,14 @@ Drupal.tableSelect = function () {
|
||||||
// For each of the checkboxes within the table that are not disabled.
|
// For each of the checkboxes within the table that are not disabled.
|
||||||
checkboxes = $('td input:checkbox:enabled', table).click(function (e) {
|
checkboxes = $('td input:checkbox:enabled', table).click(function (e) {
|
||||||
// Either add or remove the selected class based on the state of the check all checkbox.
|
// Either add or remove the selected class based on the state of the check all checkbox.
|
||||||
$(this).parents('tr:first')[ this.checked ? 'addClass' : 'removeClass' ]('selected');
|
$(this).closest('tr').toggleClass('selected', this.checked);
|
||||||
|
|
||||||
// If this is a shift click, we need to highlight everything in the range.
|
// If this is a shift click, we need to highlight everything in the range.
|
||||||
// Also make sure that we are actually checking checkboxes over a range and
|
// Also make sure that we are actually checking checkboxes over a range and
|
||||||
// that a checkbox has been checked or unchecked before.
|
// that a checkbox has been checked or unchecked before.
|
||||||
if (e.shiftKey && lastChecked && lastChecked != e.target) {
|
if (e.shiftKey && lastChecked && lastChecked != e.target) {
|
||||||
// We use the checkbox's parent TR to do our range searching.
|
// We use the checkbox's parent TR to do our range searching.
|
||||||
Drupal.tableSelectRange($(e.target).parents('tr')[0], $(lastChecked).parents('tr')[0], e.target.checked);
|
Drupal.tableSelectRange($(e.target).closest('tr')[0], $(lastChecked).closest('tr')[0], e.target.checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If all checkboxes are checked, make sure the select-all one is checked too, otherwise keep unchecked.
|
// If all checkboxes are checked, make sure the select-all one is checked too, otherwise keep unchecked.
|
||||||
|
|
|
@ -113,7 +113,7 @@ Drupal.behaviors.blockDrag = {
|
||||||
$('select.block-region-select', context).once('block-region-select', function () {
|
$('select.block-region-select', context).once('block-region-select', function () {
|
||||||
$(this).change(function (event) {
|
$(this).change(function (event) {
|
||||||
// Make our new row and select field.
|
// Make our new row and select field.
|
||||||
var row = $(this).parents('tr:first');
|
var row = $(this).closest('tr');
|
||||||
var select = $(this);
|
var select = $(this);
|
||||||
tableDrag.rowObject = new tableDrag.row(row);
|
tableDrag.rowObject = new tableDrag.row(row);
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@ Drupal.fieldUIFieldOverview = {
|
||||||
|
|
||||||
// 'Field type' select updates its 'Widget' select.
|
// 'Field type' select updates its 'Widget' select.
|
||||||
$('.field-type-select', table).each(function () {
|
$('.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 () {
|
$(this).bind('change keyup', function () {
|
||||||
var selectedFieldType = this.options[this.selectedIndex].value;
|
var selectedFieldType = this.options[this.selectedIndex].value;
|
||||||
|
@ -43,8 +43,8 @@ Drupal.fieldUIFieldOverview = {
|
||||||
|
|
||||||
// 'Existing field' select updates its 'Widget' select and 'Label' textfield.
|
// 'Existing field' select updates its 'Widget' select and 'Label' textfield.
|
||||||
$('.field-select', table).each(function () {
|
$('.field-select', table).each(function () {
|
||||||
this.targetSelect = $('.widget-type-select', $(this).parents('tr').eq(0));
|
this.targetSelect = $('.widget-type-select', $(this).closest('tr'));
|
||||||
this.targetTextfield = $('.label-textfield', $(this).parents('tr').eq(0));
|
this.targetTextfield = $('.label-textfield', $(this).closest('tr'));
|
||||||
this.targetTextfield
|
this.targetTextfield
|
||||||
.data('field_ui_edited', false)
|
.data('field_ui_edited', false)
|
||||||
.bind('keyup', function (e) {
|
.bind('keyup', function (e) {
|
||||||
|
@ -140,7 +140,7 @@ Drupal.fieldUIOverview = {
|
||||||
*/
|
*/
|
||||||
onChange: function () {
|
onChange: function () {
|
||||||
var $trigger = $(this);
|
var $trigger = $(this);
|
||||||
var row = $trigger.parents('tr:first').get(0);
|
var row = $trigger.closest('tr').get(0);
|
||||||
var rowHandler = $(row).data('fieldUIRowHandler');
|
var rowHandler = $(row).data('fieldUIRowHandler');
|
||||||
|
|
||||||
var refreshRows = {};
|
var refreshRows = {};
|
||||||
|
|
|
@ -77,7 +77,7 @@ Drupal.file = Drupal.file || {
|
||||||
'%filename': this.value,
|
'%filename': this.value,
|
||||||
'%extensions': extensionPattern.replace(/\|/g, ', ')
|
'%extensions': extensionPattern.replace(/\|/g, ', ')
|
||||||
});
|
});
|
||||||
$(this).parents('div.form-managed-file').prepend('<div class="messages error file-upload-js-error">' + error + '</div>');
|
$(this).closest('div.form-managed-file').prepend('<div class="messages error file-upload-js-error">' + error + '</div>');
|
||||||
this.value = '';
|
this.value = '';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -96,8 +96,8 @@ Drupal.file = Drupal.file || {
|
||||||
|
|
||||||
// Check if we're working with an "Upload" button.
|
// Check if we're working with an "Upload" button.
|
||||||
var $enabledFields = [];
|
var $enabledFields = [];
|
||||||
if ($(this).parents('div.form-managed-file').size() > 0) {
|
if ($(this).closest('div.form-managed-file').size() > 0) {
|
||||||
$enabledFields = $(this).parents('div.form-managed-file').find('input.form-file');
|
$enabledFields = $(this).closest('div.form-managed-file').find('input.form-file');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Temporarily disable upload fields other than the one we're currently
|
// Temporarily disable upload fields other than the one we're currently
|
||||||
|
@ -119,7 +119,7 @@ Drupal.file = Drupal.file || {
|
||||||
*/
|
*/
|
||||||
progressBar: function (event) {
|
progressBar: function (event) {
|
||||||
var clickedButton = this;
|
var clickedButton = this;
|
||||||
var $progressId = $(clickedButton).parents('div.form-managed-file').find('input.file-progress');
|
var $progressId = $(clickedButton).closest('div.form-managed-file').find('input.file-progress');
|
||||||
if ($progressId.size()) {
|
if ($progressId.size()) {
|
||||||
var originalName = $progressId.attr('name');
|
var originalName = $progressId.attr('name');
|
||||||
|
|
||||||
|
@ -133,7 +133,7 @@ Drupal.file = Drupal.file || {
|
||||||
}
|
}
|
||||||
// Show the progress bar if the upload takes longer than half a second.
|
// Show the progress bar if the upload takes longer than half a second.
|
||||||
setTimeout(function () {
|
setTimeout(function () {
|
||||||
$(clickedButton).parents('div.form-managed-file').find('div.ajax-progress-bar').slideDown();
|
$(clickedButton).closest('div.form-managed-file').find('div.ajax-progress-bar').slideDown();
|
||||||
}, 500);
|
}, 500);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,9 +7,9 @@ Drupal.behaviors.filterGuidelines = {
|
||||||
attach: function (context) {
|
attach: function (context) {
|
||||||
$('.filter-guidelines', context).once('filter-guidelines')
|
$('.filter-guidelines', context).once('filter-guidelines')
|
||||||
.find(':header').hide()
|
.find(':header').hide()
|
||||||
.parents('.filter-wrapper').find('select.filter-list')
|
.closest('.filter-wrapper').find('select.filter-list')
|
||||||
.bind('change', function () {
|
.bind('change', function () {
|
||||||
$(this).parents('.filter-wrapper')
|
$(this).closest('.filter-wrapper')
|
||||||
.find('.filter-guidelines-item').hide()
|
.find('.filter-guidelines-item').hide()
|
||||||
.siblings('.filter-guidelines-' + this.value).show();
|
.siblings('.filter-guidelines-' + this.value).show();
|
||||||
})
|
})
|
||||||
|
|
|
@ -103,7 +103,7 @@ Drupal.behaviors.shortcutDrag = {
|
||||||
Drupal.behaviors.newSet = {
|
Drupal.behaviors.newSet = {
|
||||||
attach: function (context, settings) {
|
attach: function (context, settings) {
|
||||||
var selectDefault = function() {
|
var selectDefault = function() {
|
||||||
$($(this).parents('div.form-item').get(1)).find('> label > input').attr('checked', 'checked');
|
$(this).closest('form').find('.form-item-set .form-type-radio:last input').attr('checked', 'checked');
|
||||||
};
|
};
|
||||||
$('div.form-item-new input').focus(selectDefault).keyup(selectDefault);
|
$('div.form-item-new input').focus(selectDefault).keyup(selectDefault);
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,7 +14,7 @@ Drupal.behaviors.simpleTestMenuCollapse = {
|
||||||
|
|
||||||
// Adds group toggling functionality to arrow images.
|
// Adds group toggling functionality to arrow images.
|
||||||
$('div.simpletest-image').click(function () {
|
$('div.simpletest-image').click(function () {
|
||||||
var trs = $(this).parents('tbody').children('.' + settings.simpleTest[this.id].testClass);
|
var trs = $(this).closest('tbody').children('.' + settings.simpleTest[this.id].testClass);
|
||||||
var direction = settings.simpleTest[this.id].imageDirection;
|
var direction = settings.simpleTest[this.id].imageDirection;
|
||||||
var row = direction ? trs.size() - 1 : 0;
|
var row = direction ? trs.size() - 1 : 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue