');
}
$(this.element).after(this.progress.element);
}
@@ -524,10 +524,10 @@ Drupal.ajax.prototype.commands = {
// Determine which effect to use and what content will receive the
// effect, then show the new content.
- if ($('.ajax-new-content', new_content).length > 0) {
- $('.ajax-new-content', new_content).hide();
+ if (new_content.find('.ajax-new-content').length > 0) {
+ new_content.find('.ajax-new-content').hide();
new_content.show();
- $('.ajax-new-content', new_content)[effect.showEffect](effect.showSpeed);
+ new_content.find('.ajax-new-content')[effect.showEffect](effect.showSpeed);
}
else if (effect.showEffect != 'show') {
new_content[effect.showEffect](effect.showSpeed);
@@ -612,7 +612,7 @@ Drupal.ajax.prototype.commands = {
// :even and :odd are reversed because jQuery counts from 0 and
// we count from 1, so we're out of sync.
// Match immediate children of the parent element to allow nesting.
- $('> tbody > tr:visible, > tr:visible', $(response.selector))
+ $(response.selector).find('> tbody > tr:visible, > tr:visible')
.removeClass('odd even')
.filter(':even').addClass('odd').end()
.filter(':odd').addClass('even');
diff --git a/core/misc/autocomplete.js b/core/misc/autocomplete.js
index 122f05d..a4f6335 100644
--- a/core/misc/autocomplete.js
+++ b/core/misc/autocomplete.js
@@ -6,7 +6,7 @@
Drupal.behaviors.autocomplete = {
attach: function (context, settings) {
var acdb = [];
- $('input.autocomplete', context).once('autocomplete', function () {
+ $(context).find('input.autocomplete').once('autocomplete', function () {
var uri = this.value;
if (!acdb[uri]) {
acdb[uri] = new Drupal.ACDB(uri);
@@ -125,7 +125,7 @@ Drupal.jsAC.prototype.selectDown = function () {
this.highlight(this.selected.nextSibling);
}
else if (this.popup) {
- var lis = $('li', this.popup);
+ var lis = $(this.popup).find('li');
if (lis.length > 0) {
this.highlight(lis.get(0));
}
diff --git a/core/misc/batch.js b/core/misc/batch.js
index fee71a5..6d28b69 100644
--- a/core/misc/batch.js
+++ b/core/misc/batch.js
@@ -5,7 +5,7 @@
*/
Drupal.behaviors.batch = {
attach: function (context, settings) {
- $('#progress', context).once('batch', function () {
+ $(context).find('#progress').once('batch', function () {
var holder = $(this);
// Success: redirect to the summary.
diff --git a/core/misc/collapse.js b/core/misc/collapse.js
index 1a98dc0..28281a1 100644
--- a/core/misc/collapse.js
+++ b/core/misc/collapse.js
@@ -6,7 +6,7 @@
Drupal.toggleFieldset = function (fieldset) {
var $fieldset = $(fieldset);
if ($fieldset.is('.collapsed')) {
- var $content = $('> .fieldset-wrapper', fieldset).hide();
+ var $content = $fieldset.find('> .fieldset-wrapper').hide();
$fieldset
.removeClass('collapsed')
.trigger({ type: 'collapsed', value: false })
@@ -26,7 +26,7 @@ Drupal.toggleFieldset = function (fieldset) {
}
else {
$fieldset.trigger({ type: 'collapsed', value: true });
- $('> .fieldset-wrapper', fieldset).slideUp('fast', function () {
+ $fieldset.find('> .fieldset-wrapper').slideUp('fast', function () {
$fieldset
.addClass('collapsed')
.find('> legend span.fieldset-legend-prefix').html(Drupal.t('Show'));
@@ -55,12 +55,12 @@ Drupal.collapseScrollIntoView = function (node) {
Drupal.behaviors.collapse = {
attach: function (context, settings) {
- $('fieldset.collapsible', context).once('collapse', function () {
+ $(context).find('fieldset.collapsible').once('collapse', function () {
var $fieldset = $(this);
// Expand fieldset if there are errors inside, or if it contains an
// element that is targeted by the uri fragment identifier.
var anchor = location.hash && location.hash != '#' ? ', ' + location.hash : '';
- if ($('.error' + anchor, $fieldset).length) {
+ if ($fieldset.find('.error' + anchor).length) {
$fieldset.removeClass('collapsed');
}
@@ -74,7 +74,7 @@ Drupal.behaviors.collapse = {
// Turn the legend into a clickable link, but retain span.fieldset-legend
// for CSS positioning.
- var $legend = $('> legend .fieldset-legend', this);
+ var $legend = $fieldset.find('> legend .fieldset-legend');
$('')
.append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide'))
diff --git a/core/misc/form.js b/core/misc/form.js
index ed7d4b3..4dc5b8c 100644
--- a/core/misc/form.js
+++ b/core/misc/form.js
@@ -65,9 +65,10 @@ Drupal.behaviors.fillUserInfoFromCookie = {
var userInfo = ['name', 'mail', 'homepage'];
$('form.user-info-from-cookie').once('user-info-from-cookie', function () {
var formContext = this;
+ var $formContext = $(this);
var i, il, $element, cookie;
for (i = 0, il = userInfo.length; i < il; i += 1) {
- $element = $('[name=' + userInfo[i] + ']', formContext);
+ $element = $formContext.find('[name=' + userInfo[i] + ']');
cookie = $.cookie('Drupal.visitor.' + userInfo[i]);
if ($element.length && cookie) {
$element.val(cookie);
diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js
index 4982798..bd3f4a5 100644
--- a/core/misc/machine-name.js
+++ b/core/misc/machine-name.js
@@ -29,9 +29,10 @@ Drupal.behaviors.machineName = {
for (var i in settings.machineName) {
if (settings.machineName.hasOwnProperty(i)) {
(function (source_id, options) {
- var $source = $(source_id, context).addClass('machine-name-source');
- var $target = $(options.target, context).addClass('machine-name-target');
- var $suffix = $(options.suffix, context);
+ var $context = $(context);
+ var $source = $context.find(source_id).addClass('machine-name-source');
+ var $target = $context.find(options.target).addClass('machine-name-target');
+ var $suffix = $context.find(options.suffix);
var $wrapper = $target.closest('.form-item');
// All elements have to exist.
if (!$source.length || !$target.length || !$suffix.length || !$wrapper.length) {
diff --git a/core/misc/progress.js b/core/misc/progress.js
index 822666a..b0e125c 100644
--- a/core/misc/progress.js
+++ b/core/misc/progress.js
@@ -30,8 +30,8 @@ Drupal.progressBar = function (id, updateCallback, method, errorCallback) {
*/
Drupal.progressBar.prototype.setProgress = function (percentage, message) {
if (percentage >= 0 && percentage <= 100) {
- $('div.filled', this.element).css('width', percentage + '%');
- $('div.percentage', this.element).html(percentage + '%');
+ $(this.element).find('div.filled').css('width', percentage + '%');
+ $(this.element).find('div.percentage').html(percentage + '%');
}
$('div.message', this.element).html(message);
if (this.updateCallback) {
diff --git a/core/misc/states.js b/core/misc/states.js
index 3c17efc..30b63ba 100644
--- a/core/misc/states.js
+++ b/core/misc/states.js
@@ -527,7 +527,7 @@ $(document).bind('state:checked', function(e) {
$(document).bind('state:collapsed', function(e) {
if (e.trigger) {
if ($(e.target).is('.collapsed') !== e.value) {
- $('> legend a', e.target).click();
+ $(e.target).find$('> legend a').click();
}
}
});
diff --git a/core/misc/tabledrag.js b/core/misc/tabledrag.js
index 95c886a..16800e0 100644
--- a/core/misc/tabledrag.js
+++ b/core/misc/tabledrag.js
@@ -14,7 +14,7 @@
Drupal.behaviors.tableDrag = {
attach: function (context, settings) {
for (var base in settings.tableDrag) {
- $('#' + base, context).once('tabledrag', function () {
+ $(context).find('#' + base).once('tabledrag', function () {
// Create the new tableDrag instance. Save in the Drupal variable
// to allow other scripts access to the object.
Drupal.tableDrag[base] = new Drupal.tableDrag(this, settings.tableDrag[base]);
@@ -33,6 +33,7 @@ Drupal.behaviors.tableDrag = {
*/
Drupal.tableDrag = function (table, tableSettings) {
var self = this;
+ var $table = $(table);
// Required object variables.
this.table = table;
@@ -74,16 +75,17 @@ Drupal.tableDrag = function (table, tableSettings) {
var indent = Drupal.theme('tableDragIndentation');
var testRow = $('
').addClass('draggable').appendTo(table);
var testCell = $('
').appendTo(testRow).prepend(indent).prepend(indent);
- this.indentAmount = $('.indentation', testCell).get(1).offsetLeft - $('.indentation', testCell).get(0).offsetLeft;
+ var $indentation = testCell.find('.indentation');
+ this.indentAmount = $indentation.get(1).offsetLeft - $indentation.get(0).offsetLeft;
testRow.remove();
}
// Make each applicable row draggable.
// Match immediate children of the parent element to allow nesting.
- $('> tr.draggable, > tbody > tr.draggable', table).each(function () { self.makeDraggable(this); });
+ $table.find('> tr.draggable, > tbody > tr.draggable').each(function () { self.makeDraggable(this); });
// Add a link before the table for users to show or hide weight columns.
- $(table).before($('')
+ $table.before($('')
.attr('title', Drupal.t('Re-order rows by numerical weight instead of dragging.'))
.click(function () {
if ($.cookie('Drupal.tableDrag.showWeight') == 1) {
@@ -119,10 +121,11 @@ Drupal.tableDrag = function (table, tableSettings) {
* 'Drupal.tableDrag.showWeight' cookie.
*/
Drupal.tableDrag.prototype.initColumns = function () {
+ var $table = $(this.table);
for (var group in this.tableSettings) {
// Find the first field in this group.
for (var d in this.tableSettings[group]) {
- var field = $('.' + this.tableSettings[group][d].target + ':first', this.table);
+ var field = $table.find('.' + this.tableSettings[group][d].target + ':first');
if (field.length && this.tableSettings[group][d].hidden) {
var hidden = this.tableSettings[group][d].hidden;
var cell = field.closest('td');
@@ -134,8 +137,8 @@ Drupal.tableDrag.prototype.initColumns = function () {
if (hidden && cell[0]) {
// Add 1 to our indexes. The nth-child selector is 1 based, not 0 based.
// Match immediate children of the parent element to allow nesting.
- var columnIndex = $('> td', cell.parent()).index(cell.get(0)) + 1;
- $('> thead > tr, > tbody > tr, > tr', this.table).each(function () {
+ var columnIndex = cell.parent().find('> td').index(cell.get(0)) + 1;
+ $table.find('> thead > tr, > tbody > tr, > tr').each(function () {
// Get the columnIndex and adjust for any colspans in this row.
var index = columnIndex;
var cells = $(this).children();
@@ -185,12 +188,13 @@ Drupal.tableDrag.prototype.initColumns = function () {
* Undo showColumns().
*/
Drupal.tableDrag.prototype.hideColumns = function () {
+ var $tables = $('table.tabledrag-processed');
// Hide weight/parent cells and headers.
- $('.tabledrag-hide', 'table.tabledrag-processed').css('display', 'none');
+ $tables.find('.tabledrag-hide').css('display', 'none');
// Show TableDrag handles.
- $('.tabledrag-handle', 'table.tabledrag-processed').css('display', '');
+ $tables.find('.tabledrag-handle').css('display', '');
// Reduce the colspan of any effected multi-span columns.
- $('.tabledrag-has-colspan', 'table.tabledrag-processed').each(function () {
+ $tables.find('.tabledrag-has-colspan').each(function () {
this.colSpan = this.colSpan - 1;
});
// Change link text.
@@ -210,12 +214,13 @@ Drupal.tableDrag.prototype.hideColumns = function () {
* Undo hideColumns().
*/
Drupal.tableDrag.prototype.showColumns = function () {
+ var $tables = $('table.tabledrag-processed');
// Show weight/parent cells and headers.
- $('.tabledrag-hide', 'table.tabledrag-processed').css('display', '');
+ $tables.find('.tabledrag-hide').css('display', '');
// Hide TableDrag handles.
- $('.tabledrag-handle', 'table.tabledrag-processed').css('display', 'none');
+ $tables.find('.tabledrag-handle').css('display', 'none');
// Increase the colspan for any columns where it was previously reduced.
- $('.tabledrag-has-colspan', 'table.tabledrag-processed').each(function () {
+ $tables.find('.tabledrag-has-colspan').each(function () {
this.colSpan = this.colSpan + 1;
});
// Change link text.
@@ -234,7 +239,7 @@ Drupal.tableDrag.prototype.showColumns = function () {
* Find the target used within a particular row and group.
*/
Drupal.tableDrag.prototype.rowSettings = function (group, row) {
- var field = $('.' + group, row);
+ var field = $(row).find('.' + group);
for (var delta in this.tableSettings[group]) {
var targetClass = this.tableSettings[group][delta].target;
if (field.is('.' + targetClass)) {
@@ -253,17 +258,19 @@ Drupal.tableDrag.prototype.rowSettings = function (group, row) {
*/
Drupal.tableDrag.prototype.makeDraggable = function (item) {
var self = this;
+ var $item = $(item);
// Create the handle.
var handle = $('
').attr('title', Drupal.t('Drag to re-order'));
// Insert the handle after indentations (if any).
- if ($('td:first .indentation:last', item).length) {
- $('td:first .indentation:last', item).after(handle);
+ var $indentationLast = $item.find('td:first .indentation:last');
+ if ($indentationLast.length) {
+ $indentationLast.after(handle);
// Update the total width of indentation in this entire table.
- self.indentCount = Math.max($('.indentation', item).length, self.indentCount);
+ self.indentCount = Math.max($item.find('.indentation').length, self.indentCount);
}
else {
- $('td:first', item).prepend(handle);
+ $item.find('td:first').prepend(handle);
}
// Add hover action for the handle.
@@ -285,7 +292,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
// If there's a lingering row object from the keyboard, remove its focus.
if (self.rowObject) {
- $('a.tabledrag-handle', self.rowObject.element).blur();
+ $(self.rowObject.element).find('a.tabledrag-handle').blur();
}
// Create a new rowObject for manipulation of this row.
@@ -349,9 +356,11 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
break;
case 38: // Up arrow.
case 63232: // Safari up arrow.
- var previousRow = $(self.rowObject.element).prev('tr').get(0);
- while (previousRow && $(previousRow).is(':hidden')) {
- previousRow = $(previousRow).prev('tr').get(0);
+ var $previousRow = $(self.rowObject.element).prev('tr').eq(0);
+ var previousRow = $previousRow.get(0);
+ while (previousRow && $previousRow.is(':hidden')) {
+ $previousRow = $(previousRow).prev('tr').eq(0);
+ previousRow = $previousRow.get(0);
}
if (previousRow) {
self.safeBlur = false; // Do not allow the onBlur cleanup.
@@ -361,9 +370,10 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
if ($(item).is('.tabledrag-root')) {
// Swap with the previous top-level row.
var groupHeight = 0;
- while (previousRow && $('.indentation', previousRow).length) {
- previousRow = $(previousRow).prev('tr').get(0);
- groupHeight += $(previousRow).is(':hidden') ? 0 : previousRow.offsetHeight;
+ while (previousRow && $previousRow.find('.indentation').length) {
+ $previousRow = $(previousRow).prev('tr').eq(0);
+ previousRow = $previousRow.get(0);
+ groupHeight += $previousRow.is(':hidden') ? 0 : previousRow.offsetHeight;
}
if (previousRow) {
self.rowObject.swap('before', previousRow);
@@ -371,7 +381,7 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
window.scrollBy(0, -groupHeight);
}
}
- else if (self.table.tBodies[0].rows[0] != previousRow || $(previousRow).is('.draggable')) {
+ else if (self.table.tBodies[0].rows[0] != previousRow || $previousRow.is('.draggable')) {
// Swap with the previous row (unless previous row is the first one
// and undraggable).
self.rowObject.swap('before', previousRow);
@@ -389,9 +399,11 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
break;
case 40: // Down arrow.
case 63233: // Safari down arrow.
- var nextRow = $(self.rowObject.group).filter(':last').next('tr').get(0);
- while (nextRow && $(nextRow).is(':hidden')) {
- nextRow = $(nextRow).next('tr').get(0);
+ var $nextRow = $(self.rowObject.group).filter(':last').next('tr').eq(0);
+ var nextRow = $nextRow.get(0);
+ while (nextRow && $nextRow.is(':hidden')) {
+ $nextRow = $(nextRow).next('tr').eq(0);
+ nextRow = $nextRow.get(0);
}
if (nextRow) {
self.safeBlur = false; // Do not allow the onBlur cleanup.
@@ -516,6 +528,7 @@ Drupal.tableDrag.prototype.dropRow = function (event, self) {
// Drop row functionality shared between mouseup and blur events.
if (self.rowObject != null) {
var droppedRow = self.rowObject.element;
+ var $droppedRow = $(droppedRow);
// The row is already in the right place so we just release it.
if (self.rowObject.changed == true) {
// Update the fields in the dropped row.
@@ -545,7 +558,7 @@ Drupal.tableDrag.prototype.dropRow = function (event, self) {
if (self.oldRowElement) {
$(self.oldRowElement).removeClass('drag-previous');
}
- $(droppedRow).removeClass('drag').addClass('drag-previous');
+ $droppedRow.removeClass('drag').addClass('drag-previous');
self.oldRowElement = droppedRow;
self.onDrop();
self.rowObject = null;
@@ -553,7 +566,7 @@ Drupal.tableDrag.prototype.dropRow = function (event, self) {
// Functionality specific only to mouseup event.
if (self.dragObject != null) {
- $('.tabledrag-handle', droppedRow).removeClass('tabledrag-handle-hover');
+ $droppedRow.find('.tabledrag-handle').removeClass('tabledrag-handle-hover');
self.dragObject = null;
$('body').removeClass('drag');
@@ -597,8 +610,9 @@ Drupal.tableDrag.prototype.findDropTargetRow = function (x, y) {
var rows = $(this.table.tBodies[0].rows).not(':hidden');
for (var n = 0; n < rows.length; n++) {
var row = rows[n];
+ var $row = $(row);
var indentDiff = 0;
- var rowY = $(row).offset().top;
+ var rowY = $row.offset().top;
// Because Safari does not report offsetHeight on table rows, but does on
// table cells, grab the firstChild of the row and use that instead.
// http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari.
@@ -635,8 +649,9 @@ Drupal.tableDrag.prototype.findDropTargetRow = function (x, y) {
// We may have found the row the mouse just passed over, but it doesn't
// take into account hidden rows. Skip backwards until we find a draggable
// row.
- while ($(row).is(':hidden') && $(row).prev('tr').is(':hidden')) {
- row = $(row).prev('tr').get(0);
+ while ($row.is(':hidden') && $row.prev('tr').is(':hidden')) {
+ $row = $row.prev('tr').eq(0);
+ row = $row.get(0);
}
return row;
}
@@ -670,6 +685,7 @@ Drupal.tableDrag.prototype.updateFields = function (changedRow) {
*/
Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
var rowSettings = this.rowSettings(group, changedRow);
+ var $changedRow = $(changedRow);
// Set the row as its own target.
if (rowSettings.relationship == 'self' || rowSettings.relationship == 'group') {
@@ -677,12 +693,14 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
}
// Siblings are easy, check previous and next rows.
else if (rowSettings.relationship == 'sibling') {
- var previousRow = $(changedRow).prev('tr').get(0);
- var nextRow = $(changedRow).next('tr').get(0);
+ var $previousRow = $changedRow.prev('tr').eq(0);
+ var previousRow = $previousRow.get(0);
+ var $nextRow = $changedRow.next('tr').eq(0);
+ var nextRow = $nextRow.get(0);
var sourceRow = changedRow;
- if ($(previousRow).is('.draggable') && $('.' + group, previousRow).length) {
+ if ($previousRow.is('.draggable') && $previousRow.find('.' + group).length) {
if (this.indentEnabled) {
- if ($('.indentations', previousRow).length == $('.indentations', changedRow)) {
+ if ($previousRow.find('.indentations').length == $changedRow.find('.indentations')) {
sourceRow = previousRow;
}
}
@@ -690,9 +708,9 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
sourceRow = previousRow;
}
}
- else if ($(nextRow).is('.draggable') && $('.' + group, nextRow).length) {
+ else if ($nextRow.is('.draggable') && $nextRow.find('.' + group).length) {
if (this.indentEnabled) {
- if ($('.indentations', nextRow).length == $('.indentations', changedRow)) {
+ if ($nextRow.find('.indentations').length == $changedRow.find('.indentations')) {
sourceRow = nextRow;
}
}
@@ -704,13 +722,15 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
// Parents, look up the tree until we find a field not in this group.
// Go up as many parents as indentations in the changed row.
else if (rowSettings.relationship == 'parent') {
- var previousRow = $(changedRow).prev('tr');
- while (previousRow.length && $('.indentation', previousRow).length >= this.rowObject.indents) {
- previousRow = previousRow.prev('tr');
+ var $previousRow = $changedRow.prev('tr');
+ var previousRow = $previousRow;
+ while ($previousRow.length && $previousRow.find('.indentation').length >= this.rowObject.indents) {
+ $previousRow = $previousRow.prev('tr');
+ previousRow = $previousRow;
}
// If we found a row.
- if (previousRow.length) {
- sourceRow = previousRow[0];
+ if ($previousRow.length) {
+ sourceRow = $previousRow.get(0);
}
// Otherwise we went all the way to the left of the table without finding
// a parent, meaning this item has been placed at the root level.
@@ -739,7 +759,7 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
}
var targetClass = '.' + rowSettings.target;
- var targetElement = $(targetClass, changedRow).get(0);
+ var targetElement = $changedRow.find(targetClass).get(0);
// Check if a target element exists in this row.
if (targetElement) {
@@ -748,7 +768,7 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
switch (rowSettings.action) {
case 'depth':
// Get the depth of the target row.
- targetElement.value = $('.indentation', $(sourceElement).closest('tr')).length;
+ targetElement.value = $(sourceElement).closest('tr').find('.indentation').length;
break;
case 'match':
// Update the value.
@@ -759,12 +779,12 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
if ($(targetElement).is('select')) {
// Get a list of acceptable values.
var values = [];
- $('option', targetElement).each(function () {
+ $(targetElement).find('option').each(function () {
values.push(this.value);
});
var maxVal = values[values.length - 1];
// Populate the values in the siblings.
- $(targetClass, siblings).each(function () {
+ $(siblings).find(targetClass).each(function () {
// If there are more items than possible values, assign the maximum value to the row.
if (values.length > 0) {
this.value = values.shift();
@@ -776,8 +796,8 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
}
else {
// Assume a numeric input field.
- var weight = parseInt($(targetClass, siblings[0]).val(), 10) || 0;
- $(targetClass, siblings).each(function () {
+ var weight = parseInt($(siblings[0]).find(targetClass).val(), 10) || 0;
+ $(siblings).find(targetClass).each(function () {
this.value = weight;
weight++;
});
@@ -793,8 +813,8 @@ Drupal.tableDrag.prototype.updateField = function (changedRow, group) {
* may have had.
*/
Drupal.tableDrag.prototype.copyDragClasses = function (sourceRow, targetRow, group) {
- var sourceElement = $('.' + group, sourceRow);
- var targetElement = $('.' + group, targetRow);
+ var sourceElement = $(sourceRow).find('.' + group);
+ var targetElement = $(targetRow).find('.' + group);
if (sourceElement.length && targetElement.length) {
targetElement[0].className = sourceElement[0].className;
}
@@ -840,7 +860,7 @@ Drupal.tableDrag.prototype.restripeTable = function () {
// :even and :odd are reversed because jQuery counts from 0 and
// we count from 1, so we're out of sync.
// Match immediate children of the parent element to allow nesting.
- $('> tbody > tr.draggable:visible, > tr.draggable:visible', this.table)
+ $(this.table).find('> tbody > tr.draggable:visible, > tr.draggable:visible')
.removeClass('odd even')
.filter(':odd').addClass('even').end()
.filter(':even').addClass('odd');
@@ -875,23 +895,25 @@ Drupal.tableDrag.prototype.onDrop = function () {
* Whether we want to add classes to this row to indicate child relationships.
*/
Drupal.tableDrag.prototype.row = function (tableRow, method, indentEnabled, maxDepth, addClasses) {
+ var $tableRow = $(tableRow);
+
this.element = tableRow;
this.method = method;
this.group = [tableRow];
- this.groupDepth = $('.indentation', tableRow).length;
+ this.groupDepth = $tableRow.find('.indentation').length;
this.changed = false;
- this.table = $(tableRow).closest('table').get(0);
+ this.table = $tableRow.closest('table').get(0);
this.indentEnabled = indentEnabled;
this.maxDepth = maxDepth;
this.direction = ''; // Direction the row is being moved.
if (this.indentEnabled) {
- this.indents = $('.indentation', tableRow).length;
+ this.indents = $tableRow.find('.indentation').length;
this.children = this.findChildren(addClasses);
this.group = $.merge(this.group, this.children);
// Find the depth of this entire group.
for (var n = 0; n < this.group.length; n++) {
- this.groupDepth = Math.max($('.indentation', this.group[n]).length, this.groupDepth);
+ this.groupDepth = Math.max($(this.group[n]).find('.indentation').length, this.groupDepth);
}
}
};
@@ -908,13 +930,13 @@ Drupal.tableDrag.prototype.row.prototype.findChildren = function (addClasses) {
var rows = [];
var child = 0;
while (currentRow.length) {
- var rowIndentation = $('.indentation', currentRow).length;
+ var rowIndentation = currentRow.find('.indentation').length;
// A greater indentation indicates this is a child.
if (rowIndentation > parentIndentation) {
child++;
rows.push(currentRow[0]);
if (addClasses) {
- $('.indentation', currentRow).each(function (indentNum) {
+ currentRow.find('.indentation').each(function (indentNum) {
if (child == 1 && (indentNum == parentIndentation)) {
$(this).addClass('tree-child-first');
}
@@ -933,7 +955,7 @@ Drupal.tableDrag.prototype.row.prototype.findChildren = function (addClasses) {
currentRow = currentRow.next('tr.draggable');
}
if (addClasses && rows.length) {
- $('.indentation:nth-child(' + (parentIndentation + 1) + ')', rows[rows.length - 1]).addClass('tree-child-last');
+ $(rows[rows.length - 1]).find('.indentation:nth-child(' + (parentIndentation + 1) + ')').addClass('tree-child-last');
}
return rows;
};
@@ -945,14 +967,15 @@ Drupal.tableDrag.prototype.row.prototype.findChildren = function (addClasses) {
* DOM object for the row being considered for swapping.
*/
Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) {
+ var $row = $(row);
if (this.indentEnabled) {
var prevRow, nextRow;
if (this.direction == 'down') {
prevRow = row;
- nextRow = $(row).next('tr').get(0);
+ nextRow = $row.next('tr').get(0);
}
else {
- prevRow = $(row).prev('tr').get(0);
+ prevRow = $row.prev('tr').get(0);
nextRow = row;
}
this.interval = this.validIndentInterval(prevRow, nextRow);
@@ -964,7 +987,7 @@ Drupal.tableDrag.prototype.row.prototype.isValidSwap = function (row) {
}
// Do not let an un-draggable first row have anything put before it.
- if (this.table.tBodies[0].rows[0] == row && $(row).is(':not(.draggable)')) {
+ if (this.table.tBodies[0].rows[0] == row && $row.is(':not(.draggable)')) {
return false;
}
@@ -999,14 +1022,15 @@ Drupal.tableDrag.prototype.row.prototype.swap = function (position, row) {
* (or null for last position in the table).
*/
Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) {
+ var $prevRow = $(prevRow);
var minIndent, maxIndent;
// Minimum indentation:
// Do not orphan the next row.
- minIndent = nextRow ? $('.indentation', nextRow).length : 0;
+ minIndent = nextRow ? $(nextRow).find('.indentation').length : 0;
// Maximum indentation:
- if (!prevRow || $(prevRow).is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) {
+ if (!prevRow || $prevRow.is(':not(.draggable)') || $(this.element).is('.tabledrag-root')) {
// Do not indent:
// - the first row in the table,
// - rows dragged below a non-draggable row,
@@ -1015,7 +1039,7 @@ Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow
}
else {
// Do not go deeper than as a child of the previous row.
- maxIndent = $('.indentation', prevRow).length + ($(prevRow).is('.tabledrag-leaf') ? 0 : 1);
+ maxIndent = $prevRow.find('.indentation').length + ($prevRow.is('.tabledrag-leaf') ? 0 : 1);
// Limit by the maximum allowed depth for the table.
if (this.maxDepth) {
maxIndent = Math.min(maxIndent, this.maxDepth - (this.groupDepth - this.indents));
@@ -1034,10 +1058,11 @@ Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow
* indentation level for the row.
*/
Drupal.tableDrag.prototype.row.prototype.indent = function (indentDiff) {
+ var $group = $(this.group);
// Determine the valid indentations interval if not available yet.
if (!this.interval) {
var prevRow = $(this.element).prev('tr').get(0);
- var nextRow = $(this.group).filter(':last').next('tr').get(0);
+ var nextRow = $group.filter(':last').next('tr').get(0);
this.interval = this.validIndentInterval(prevRow, nextRow);
}
@@ -1050,11 +1075,11 @@ Drupal.tableDrag.prototype.row.prototype.indent = function (indentDiff) {
for (var n = 1; n <= Math.abs(indentDiff); n++) {
// Add or remove indentations.
if (indentDiff < 0) {
- $('.indentation:first', this.group).remove();
+ $group.find('.indentation:first').remove();
this.indents--;
}
else {
- $('td:first', this.group).prepend(Drupal.theme('tableDragIndentation'));
+ $group.find('td:first').prepend(Drupal.theme('tableDragIndentation'));
this.indents++;
}
}
@@ -1083,11 +1108,11 @@ Drupal.tableDrag.prototype.row.prototype.findSiblings = function (rowSettings) {
var checkRow = $(this.element)[directions[d]]();
while (checkRow.length) {
// Check that the sibling contains a similar target field.
- if ($('.' + rowSettings.target, checkRow)) {
+ if (checkRow.find('.' + rowSettings.target)) {
// Either add immediately if this is a flat table, or check to ensure
// that this row has the same level of indentation.
if (this.indentEnabled) {
- var checkRowIndentation = $('.indentation', checkRow).length;
+ var checkRowIndentation = checkRow.find('.indentation').length;
}
if (!(this.indentEnabled) || (checkRowIndentation == rowIndentation)) {
@@ -1101,7 +1126,7 @@ Drupal.tableDrag.prototype.row.prototype.findSiblings = function (rowSettings) {
else {
break;
}
- checkRow = $(checkRow)[directions[d]]();
+ checkRow = checkRow[directions[d]]();
}
// Since siblings are added in reverse order for previous, reverse the
// completed list of previous siblings. Add the current row and continue.
@@ -1118,7 +1143,7 @@ Drupal.tableDrag.prototype.row.prototype.findSiblings = function (rowSettings) {
*/
Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
for (var n in this.children) {
- $('.indentation', this.children[n])
+ $(this.children[n]).find('.indentation')
.removeClass('tree-child')
.removeClass('tree-child-first')
.removeClass('tree-child-last')
@@ -1131,8 +1156,8 @@ Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function () {
*/
Drupal.tableDrag.prototype.row.prototype.markChanged = function () {
var marker = Drupal.theme('tableDragChangedMarker');
- var cell = $('td:first', this.element);
- if ($('abbr.tabledrag-changed', cell).length == 0) {
+ var cell = $(this.element).find('td:first');
+ if (cell.find('abbr.tabledrag-changed').length == 0) {
cell.append(marker);
}
};
diff --git a/core/misc/tableheader.js b/core/misc/tableheader.js
index dce64b9..aa1c8bb 100644
--- a/core/misc/tableheader.js
+++ b/core/misc/tableheader.js
@@ -9,7 +9,7 @@ Drupal.behaviors.tableHeader = {
return;
}
- $('table.sticky-enabled', context).once('tableheader', function () {
+ $(context).find('table.sticky-enabled').once('tableheader', function () {
$(this).data("drupal-tableheader", new Drupal.tableHeader(this));
});
}
@@ -23,9 +23,10 @@ Drupal.behaviors.tableHeader = {
*/
Drupal.tableHeader = function (table) {
var self = this;
+ var $table = $(table);
- this.originalTable = $(table);
- this.originalHeader = $(table).children('thead');
+ this.originalTable = $table;
+ this.originalHeader = $table.children('thead');
this.originalHeaderCells = this.originalHeader.find('> tr > th');
this.displayWeight = null;
diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js
index fee63a9..b7011e0 100644
--- a/core/misc/tableselect.js
+++ b/core/misc/tableselect.js
@@ -3,29 +3,30 @@
Drupal.behaviors.tableSelect = {
attach: function (context, settings) {
// Select the inner-most table in case of nested tables.
- $('th.select-all', context).closest('table').once('table-select', Drupal.tableSelect);
+ $(context).find('th.select-all').closest('table').once('table-select', Drupal.tableSelect);
}
};
Drupal.tableSelect = function () {
// Do not add a "Select all" checkbox if there are no rows with checkboxes in the table
- if ($('td input:checkbox', this).length == 0) {
+ if ($(this).find('td input:checkbox').length == 0) {
return;
}
// Keep track of the table, which checkbox is checked and alias the settings.
var table = this, checkboxes, lastChecked;
+ var $table = $(table);
var strings = { 'selectAll': Drupal.t('Select all rows in this table'), 'selectNone': Drupal.t('Deselect all rows in this table') };
var updateSelectAll = function (state) {
// Update table's select-all checkbox (and sticky header's if available).
- $(table).prev('table.sticky-header').andSelf().find('th.select-all input:checkbox').each(function() {
+ $table.prev('table.sticky-header').andSelf().find('th.select-all input:checkbox').each(function() {
$(this).attr('title', state ? strings.selectNone : strings.selectAll);
this.checked = state;
});
};
// Find all
with class select-all, and insert the check all checkbox.
- $('th.select-all', table).prepend($('').attr('title', strings.selectAll)).click(function (event) {
+ $table.find('th.select-all').prepend($('').attr('title', strings.selectAll)).click(function (event) {
if ($(event.target).is('input:checkbox')) {
// Loop through all checkboxes and set their state to the select all checkbox' state.
checkboxes.each(function () {
@@ -39,7 +40,7 @@ Drupal.tableSelect = function () {
});
// For each of the checkboxes within the table that are not disabled.
- checkboxes = $('td input:checkbox:enabled', table).click(function (e) {
+ checkboxes = $table.find('td input:checkbox:enabled').click(function (e) {
// Either add or remove the selected class based on the state of the check all checkbox.
$(this).closest('tr').toggleClass('selected', this.checked);
@@ -52,7 +53,7 @@ Drupal.tableSelect = function () {
}
// If all checkboxes are checked, make sure the select-all one is checked too, otherwise keep unchecked.
- updateSelectAll((checkboxes.length == $(checkboxes).filter(':checked').length));
+ updateSelectAll((checkboxes.length == checkboxes.filter(':checked').length));
// Keep track of the last checked checkbox.
lastChecked = e.target;
@@ -64,15 +65,15 @@ Drupal.tableSelectRange = function (from, to, state) {
var mode = from.rowIndex > to.rowIndex ? 'previousSibling' : 'nextSibling';
// Traverse through the sibling nodes.
- for (var i = from[mode]; i; i = i[mode]) {
+ for (var i = from[mode], $i; i; i = i[mode]) {
// Make sure that we're only dealing with elements.
if (i.nodeType != 1) {
continue;
}
-
+ $i = $(i);
// Either add or remove the selected class based on the state of the target checkbox.
- $(i).toggleClass('selected', state);
- $('input:checkbox', i).each(function () {
+ $i.toggleClass('selected', state);
+ $i.find('input:checkbox').each(function () {
this.checked = state;
});
diff --git a/core/misc/timezone.js b/core/misc/timezone.js
index 5449730..62b7d4b 100644
--- a/core/misc/timezone.js
+++ b/core/misc/timezone.js
@@ -5,7 +5,7 @@
*/
Drupal.behaviors.setTimezone = {
attach: function (context, settings) {
- $('select.timezone-detect', context).once('timezone', function () {
+ $(context).find('select.timezone-detect').once('timezone', function () {
var dateString = Date();
// In some client environments, date strings include a time zone
// abbreviation, between 3 and 5 letters enclosed in parentheses,
diff --git a/core/misc/vertical-tabs.js b/core/misc/vertical-tabs.js
index 14d0660..65e5683 100644
--- a/core/misc/vertical-tabs.js
+++ b/core/misc/vertical-tabs.js
@@ -1,4 +1,3 @@
-
(function ($) {
/**
@@ -14,47 +13,50 @@
*/
Drupal.behaviors.verticalTabs = {
attach: function (context) {
- $('.vertical-tabs-panes', context).once('vertical-tabs', function () {
- var focusID = $(':hidden.vertical-tabs-active-tab', this).val();
+ $(context).find('.vertical-tabs-panes').once('vertical-tabs', function () {
+ var $this = $(this);
+ var focusID = $this.find(':hidden.vertical-tabs-active-tab').val();
var tab_focus;
// Check if there are some fieldsets that can be converted to vertical-tabs
- var $fieldsets = $('> fieldset', this);
+ var $fieldsets = $this.find('> fieldset');
if ($fieldsets.length == 0) {
return;
}
// Create the tab column.
var tab_list = $('
');
- $(this).wrap('').before(tab_list);
+ $this.wrap('').before(tab_list);
// Transform each fieldset into a tab.
$fieldsets.each(function () {
+ var $this = $(this);
var vertical_tab = new Drupal.verticalTab({
- title: $('> legend', this).text(),
- fieldset: $(this)
+ title: $this.find('> legend').text(),
+ fieldset: $this
});
tab_list.append(vertical_tab.item);
- $(this)
+ $this
.removeClass('collapsible collapsed')
.addClass('vertical-tabs-pane')
.data('verticalTab', vertical_tab);
if (this.id == focusID) {
- tab_focus = $(this);
+ tab_focus = $this;
}
});
- $('> li:first', tab_list).addClass('first');
- $('> li:last', tab_list).addClass('last');
+ $(tab_list).find('> li:first').addClass('first');
+ $(tab_list).find('> li:last').addClass('last');
if (!tab_focus) {
// If the current URL has a fragment and one of the tabs contains an
// element that matches the URL fragment, activate that tab.
- if (window.location.hash && $(window.location.hash, this).length) {
- tab_focus = $(window.location.hash, this).closest('.vertical-tabs-pane');
+ var $locationHash = $this.find(window.location.hash);
+ if (window.location.hash && $locationHash.length) {
+ tab_focus = $locationHash.closest('.vertical-tabs-pane');
}
else {
- tab_focus = $('> .vertical-tabs-pane:first', this);
+ tab_focus = $this.find('> .vertical-tabs-pane:first');
}
}
if (tab_focus.length) {
diff --git a/core/modules/block/block.js b/core/modules/block/block.js
index 72b5673..7dd3c9b 100644
--- a/core/modules/block/block.js
+++ b/core/modules/block/block.js
@@ -12,8 +12,9 @@ Drupal.behaviors.blockSettingsSummary = {
return;
}
- $('fieldset#edit-path', context).drupalSetSummary(function (context) {
- if (!$('textarea[name="pages"]', context).val()) {
+ var $context = $(context);
+ $context.find('fieldset#edit-path').drupalSetSummary(function (context) {
+ if (!$(context).find('textarea[name="pages"]').val()) {
return Drupal.t('Not restricted');
}
else {
@@ -21,9 +22,9 @@ Drupal.behaviors.blockSettingsSummary = {
}
});
- $('fieldset#edit-node-type', context).drupalSetSummary(function (context) {
+ $context.find('fieldset#edit-node-type').drupalSetSummary(function (context) {
var vals = [];
- $('input[type="checkbox"]:checked', context).each(function () {
+ $(context).find('input[type="checkbox"]:checked').each(function () {
vals.push($.trim($(this).next('label').text()));
});
if (!vals.length) {
@@ -32,9 +33,9 @@ Drupal.behaviors.blockSettingsSummary = {
return vals.join(', ');
});
- $('fieldset#edit-role', context).drupalSetSummary(function (context) {
+ $context.find('fieldset#edit-role').drupalSetSummary(function (context) {
var vals = [];
- $('input[type="checkbox"]:checked', context).each(function () {
+ $(context).find('input[type="checkbox"]:checked').each(function () {
vals.push($.trim($(this).next('label').text()));
});
if (!vals.length) {
@@ -43,8 +44,8 @@ Drupal.behaviors.blockSettingsSummary = {
return vals.join(', ');
});
- $('fieldset#edit-user', context).drupalSetSummary(function (context) {
- var $radio = $('input[name="custom"]:checked', context);
+ $context.find('fieldset#edit-user').drupalSetSummary(function (context) {
+ var $radio = $(context).find('input[name="custom"]:checked');
if ($radio.val() == 0) {
return Drupal.t('Not customizable');
}
@@ -83,22 +84,23 @@ Drupal.behaviors.blockDrag = {
// Add a handler so when a row is dropped, update fields dropped into new regions.
tableDrag.onDrop = function () {
- dragObject = this;
+ var dragObject = this;
+ var $rowElement = $(dragObject.rowObject.element);
// Use "region-message" row instead of "region" row because
// "region-{region_name}-message" is less prone to regexp match errors.
- var regionRow = $(dragObject.rowObject.element).prevAll('tr.region-message').get(0);
+ var regionRow = $rowElement.prevAll('tr.region-message').get(0);
var regionName = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
- var regionField = $('select.block-region-select', dragObject.rowObject.element);
+ var regionField = $rowElement.find('select.block-region-select');
// Check whether the newly picked region is available for this block.
- if ($('option[value=' + regionName + ']', regionField).length == 0) {
+ if (regionField.find('option[value=' + regionName + ']').length == 0) {
// If not, alert the user and keep the block in its old region setting.
alert(Drupal.t('The block cannot be placed in this region.'));
// Simulate that there was a selected element change, so the row is put
// back to from where the user tried to drag it.
regionField.change();
}
- else if ($(dragObject.rowObject.element).prev('tr').is('.region-message')) {
- var weightField = $('select.block-weight', dragObject.rowObject.element);
+ else if ($rowElement.prev('tr').is('.region-message')) {
+ var weightField = $rowElement.find('select.block-weight');
var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2');
if (!regionField.is('.block-region-' + regionName)) {
@@ -110,7 +112,7 @@ Drupal.behaviors.blockDrag = {
};
// Add the behavior to each region select list.
- $('select.block-region-select', context).once('block-region-select', function () {
+ $(context).find('select.block-region-select').once('block-region-select', function () {
$(this).change(function (event) {
// Make our new row and select field.
var row = $(this).closest('tr');
@@ -118,7 +120,7 @@ Drupal.behaviors.blockDrag = {
tableDrag.rowObject = new tableDrag.row(row);
// Find the correct region and insert the row as the first in the region.
- $('tr.region-message', table).each(function () {
+ table.find('tr.region-message').each(function () {
if ($(this).is('.region-' + select[0].value + '-message')) {
// Add the new row and remove the old one.
$(this).after(row);
@@ -132,7 +134,7 @@ Drupal.behaviors.blockDrag = {
tableDrag.restripeTable();
tableDrag.rowObject.markChanged();
tableDrag.oldRowElement = row;
- $(row).addClass('drag-previous');
+ row.addClass('drag-previous');
}
});
@@ -144,21 +146,22 @@ Drupal.behaviors.blockDrag = {
});
var checkEmptyRegions = function (table, rowObject) {
- $('tr.region-message', table).each(function () {
+ table.find('tr.region-message').each(function () {
+ var $this = $(this);
// If the dragged row is in this region, but above the message row, swap it down one space.
- if ($(this).prev('tr').get(0) == rowObject.element) {
+ if ($this.prev('tr').get(0) == rowObject.element) {
// Prevent a recursion problem when using the keyboard to move rows up.
if ((rowObject.method != 'keyboard' || rowObject.direction == 'down')) {
rowObject.swap('after', this);
}
}
// This region has become empty.
- if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').length == 0) {
- $(this).removeClass('region-populated').addClass('region-empty');
+ if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').length == 0) {
+ $this.removeClass('region-populated').addClass('region-empty');
}
// This region has become populated.
- else if ($(this).is('.region-empty')) {
- $(this).removeClass('region-empty').addClass('region-populated');
+ else if ($this.is('.region-empty')) {
+ $this.removeClass('region-empty').addClass('region-populated');
}
});
};
diff --git a/core/modules/book/book.js b/core/modules/book/book.js
index 075f33b..e6ab4fa 100644
--- a/core/modules/book/book.js
+++ b/core/modules/book/book.js
@@ -2,7 +2,7 @@
Drupal.behaviors.bookFieldsetSummaries = {
attach: function (context) {
- $('fieldset.book-outline-form', context).drupalSetSummary(function (context) {
+ $(context).find('fieldset.book-outline-form').drupalSetSummary(function (context) {
var $select = $('.form-item-book-bid select');
var val = $select.val();
diff --git a/core/modules/color/color.js b/core/modules/color/color.js
index ae0019e..6ed789a 100644
--- a/core/modules/color/color.js
+++ b/core/modules/color/color.js
@@ -9,7 +9,7 @@ Drupal.behaviors.color = {
attach: function (context, settings) {
var i, j, colors, field_name;
// This behavior attaches by ID, so is only valid once on a page.
- var form = $('#system-theme-settings .color-form', context).once('color');
+ var form = $(context).find('#system-theme-settings .color-form').once('color');
if (form.length == 0) {
return;
}
@@ -19,7 +19,7 @@ Drupal.behaviors.color = {
var focused = null;
// Add Farbtastic.
- $(form).prepend('').addClass('color-processed');
+ form.prepend('').addClass('color-processed');
var farb = $.farbtastic('#placeholder');
// Decode reference colors to HSL.
@@ -49,7 +49,7 @@ Drupal.behaviors.color = {
}
// Set up colorScheme selector.
- $('#edit-scheme', form).change(function () {
+ form.find('#edit-scheme').change(function () {
var schemes = settings.color.schemes, colorScheme = this.options[this.selectedIndex].value;
if (colorScheme != '' && schemes[colorScheme]) {
// Get colors of active scheme.
@@ -159,7 +159,7 @@ Drupal.behaviors.color = {
* Resets the color scheme selector.
*/
function resetScheme() {
- $('#edit-scheme', form).each(function () {
+ form.find('#edit-scheme').each(function () {
this.selectedIndex = this.options.length - 1;
});
}
@@ -183,7 +183,7 @@ Drupal.behaviors.color = {
}
// Initialize color fields.
- $('#palette input.form-text', form)
+ form.find('#palette input.form-text')
.each(function () {
// Extract palette field name
this.key = this.id.substring(13);
@@ -229,7 +229,7 @@ Drupal.behaviors.color = {
})
.focus(focus);
- $('#palette label', form);
+ form.find('#palette label');
// Focus first color.
focus.call(inputs[0]);
diff --git a/core/modules/color/preview.js b/core/modules/color/preview.js
index 67eef0b..69c3897 100644
--- a/core/modules/color/preview.js
+++ b/core/modules/color/preview.js
@@ -7,17 +7,17 @@
Drupal.color = {
callback: function(context, settings, form, farb, height, width) {
// Solid background.
- $('#preview', form).css('backgroundColor', $('#palette input[name="palette[base]"]', form).val());
+ form.find('#preview').css('backgroundColor', form.find('#palette input[name="palette[base]"]').val());
// Text preview
- $('#text', form).css('color', $('#palette input[name="palette[text]"]', form).val());
- $('#text a, #text h2', form).css('color', $('#palette input[name="palette[link]"]', form).val());
+ form.find('#text').css('color', form.find('#palette input[name="palette[text]"]').val());
+ form.find('#text a, #text h2').css('color', form.find('#palette input[name="palette[link]"]').val());
// Set up gradients if there are some.
var color_start, color_end;
for (i in settings.gradients) {
- color_start = farb.unpack($('#palette input[name="palette[' + settings.gradients[i]['colors'][0] + ']"]', form).val());
- color_end = farb.unpack($('#palette input[name="palette[' + settings.gradients[i]['colors'][1] + ']"]', form).val());
+ color_start = farb.unpack(form.find('#palette input[name="palette[' + settings.gradients[i]['colors'][0] + ']"]').val());
+ color_end = farb.unpack(form.find('#palette input[name="palette[' + settings.gradients[i]['colors'][1] + ']"]').val());
if (color_start && color_end) {
var delta = [];
for (j in color_start) {
@@ -25,7 +25,7 @@
}
var accum = color_start;
// Render gradient lines.
- $('#gradient-' + i + ' > div', form).each(function () {
+ form.find('#gradient-' + i + ' > div').each(function () {
for (j in accum) {
accum[j] += delta[j];
}
diff --git a/core/modules/comment/comment-node-form.js b/core/modules/comment/comment-node-form.js
index e46f05e..51ea492 100644
--- a/core/modules/comment/comment-node-form.js
+++ b/core/modules/comment/comment-node-form.js
@@ -7,25 +7,27 @@
Drupal.behaviors.commentFieldsetSummaries = {
attach: function (context) {
- $('fieldset.comment-node-settings-form', context).drupalSetSummary(function (context) {
- return Drupal.checkPlain($('.form-item-comment input:checked', context).next('label').text());
+ var $context = $(context);
+ $context.find('fieldset.comment-node-settings-form').drupalSetSummary(function (context) {
+ return Drupal.checkPlain($(context).find('.form-item-comment input:checked').next('label').text());
});
// Provide the summary for the node type form.
- $('fieldset.comment-node-type-settings-form', context).drupalSetSummary(function(context) {
+ $context.find('fieldset.comment-node-type-settings-form').drupalSetSummary(function(context) {
+ var $context = $(context);
var vals = [];
// Default comment setting.
- vals.push($(".form-item-comment select option:selected", context).text());
+ vals.push($context.find(".form-item-comment select option:selected").text());
// Threading.
- var threading = $(".form-item-comment-default-mode input:checked", context).next('label').text();
+ var threading = $(context).find(".form-item-comment-default-mode input:checked").next('label').text();
if (threading) {
vals.push(threading);
}
// Comments per page.
- var number = $(".form-item-comment-default-per-page select option:selected", context).val();
+ var number = $context.find(".form-item-comment-default-per-page select option:selected").val();
vals.push(Drupal.t('@number comments per page', {'@number': number}));
return Drupal.checkPlain(vals.join(', '));
diff --git a/core/modules/contextual/contextual.js b/core/modules/contextual/contextual.js
index 2744acb..afc9583 100644
--- a/core/modules/contextual/contextual.js
+++ b/core/modules/contextual/contextual.js
@@ -12,7 +12,7 @@ Drupal.contextualLinks = Drupal.contextualLinks || {};
*/
Drupal.behaviors.contextualLinks = {
attach: function (context) {
- $('div.contextual', context).once('contextual-links', function () {
+ $(context).find('div.contextual-links-wrapper').once('contextual-links', function () {
var $wrapper = $(this);
var $region = $wrapper.closest('.contextual-region');
var $links = $wrapper.find('ul');
diff --git a/core/modules/dashboard/dashboard.js b/core/modules/dashboard/dashboard.js
index 385da08..f3b9e6a 100644
--- a/core/modules/dashboard/dashboard.js
+++ b/core/modules/dashboard/dashboard.js
@@ -10,7 +10,7 @@
*/
Drupal.behaviors.dashboard = {
attach: function (context, settings) {
- $('#dashboard', context).once(function () {
+ $(context).find('#dashboard').once(function () {
$(this).prepend('
');
$('.customize .action-links a', this).click(Drupal.behaviors.dashboard.enterCustomizeMode);
});
@@ -22,9 +22,10 @@ Drupal.behaviors.dashboard = {
addPlaceholders: function() {
$('#dashboard .dashboard-region .region').each(function () {
+ var $this = $(this);
var empty_text = "";
// If the region is empty
- if ($('.block', this).length == 0) {
+ if ($this.find('.block').length == 0) {
// Check if we are in customize mode and grab the correct empty text
if ($('#dashboard').hasClass('customize-mode')) {
empty_text = Drupal.settings.dashboard.emptyRegionTextActive;
@@ -32,13 +33,13 @@ Drupal.behaviors.dashboard = {
empty_text = Drupal.settings.dashboard.emptyRegionTextInactive;
}
// We need a placeholder.
- if ($('.placeholder', this).length == 0) {
- $(this).append('');
+ if ($this.find('.placeholder').length == 0) {
+ $this.append('');
}
- $('.placeholder', this).html(empty_text);
+ $this.find('.placeholder').html(empty_text);
}
else {
- $('.placeholder', this).remove();
+ $this.find('.placeholder').remove();
}
});
},
diff --git a/core/modules/field/modules/text/text.js b/core/modules/field/modules/text/text.js
index f3ae894..8527355 100644
--- a/core/modules/field/modules/text/text.js
+++ b/core/modules/field/modules/text/text.js
@@ -1,4 +1,3 @@
-
(function ($) {
/**
@@ -6,7 +5,7 @@
*/
Drupal.behaviors.textSummary = {
attach: function (context, settings) {
- $('.text-summary', context).once('text-summary', function () {
+ $(context).find('.text-summary').once('text-summary', function () {
var $widget = $(this).closest('div.field-type-text-with-summary');
var $summaries = $widget.find('div.text-summary-wrapper');
diff --git a/core/modules/field_ui/field_ui.js b/core/modules/field_ui/field_ui.js
index 1442fe7..6de5c15 100644
--- a/core/modules/field_ui/field_ui.js
+++ b/core/modules/field_ui/field_ui.js
@@ -7,7 +7,7 @@
Drupal.behaviors.fieldUIFieldOverview = {
attach: function (context, settings) {
- $('table#field-overview', context).once('field-overview', function () {
+ $(context).find('table#field-overview').once('field-overview', function () {
Drupal.fieldUIFieldOverview.attachUpdateSelects(this, settings);
});
}
@@ -20,17 +20,19 @@ Drupal.fieldUIFieldOverview = {
attachUpdateSelects: function(table, settings) {
var widgetTypes = settings.fieldWidgetTypes;
var fields = settings.fields;
+ var $table = $(table);
// Store the default text of widget selects.
- $('.widget-type-select', table).each(function () {
+ $table.find('.widget-type-select').each(function () {
this.initialValue = this.options[0].text;
});
// 'Field type' select updates its 'Widget' select.
- $('.field-type-select', table).each(function () {
- this.targetSelect = $('.widget-type-select', $(this).closest('tr'));
+ $table.find('.field-type-select').each(function () {
+ var $this = $(this);
+ this.targetSelect = $this.closest('tr').find('.widget-type-select');
- $(this).bind('change keyup', function () {
+ $this.bind('change keyup', function () {
var selectedFieldType = this.options[this.selectedIndex].value;
var options = (selectedFieldType in widgetTypes ? widgetTypes[selectedFieldType] : []);
this.targetSelect.fieldUIPopulateOptions(options);
@@ -38,20 +40,22 @@ Drupal.fieldUIFieldOverview = {
// Trigger change on initial pageload to get the right widget options
// when field type comes pre-selected (on failed validation).
- $(this).trigger('change', false);
+ $this.trigger('change', false);
});
// 'Existing field' select updates its 'Widget' select and 'Label' textfield.
- $('.field-select', table).each(function () {
- this.targetSelect = $('.widget-type-select', $(this).closest('tr'));
- this.targetTextfield = $('.label-textfield', $(this).closest('tr'));
+ $table.find('.field-select').each(function () {
+ var $this = $(this);
+ var $tr = $this.closest('tr');
+ this.targetSelect = $tr.find('.widget-type-select');
+ this.targetTextfield = $tr.find('.label-textfield');
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) {
+ $this.bind('change keyup', function (e, updateText) {
var updateText = (typeof updateText == 'undefined' ? true : updateText);
var selectedField = this.options[this.selectedIndex].value;
var selectedFieldType = (selectedField in fields ? fields[selectedField].type : null);
@@ -68,7 +72,7 @@ Drupal.fieldUIFieldOverview = {
// Trigger change on initial pageload to get the right widget options
// and label when field type comes pre-selected (on failed validation).
- $(this).trigger('change', false);
+ $this.trigger('change', false);
});
}
};
@@ -103,7 +107,7 @@ jQuery.fn.fieldUIPopulateOptions = function (options, selected) {
Drupal.behaviors.fieldUIDisplayOverview = {
attach: function (context, settings) {
- $('table#field-display-overview', context).once('field-display-overview', function() {
+ $(context).find('table#field-display-overview').once('field-display-overview', function() {
Drupal.fieldUIOverview.attach(this, settings.fieldUIRowsData, Drupal.fieldUIDisplayOverview);
});
}
@@ -121,7 +125,7 @@ Drupal.fieldUIOverview = {
tableDrag.row.prototype.onSwap = this.onSwap;
// Create row handlers.
- $('tr.draggable', table).each(function () {
+ $(table).find('tr.draggable').each(function () {
// Extract server-side data for the row.
var row = this;
if (row.id in rowsData) {
@@ -140,8 +144,8 @@ Drupal.fieldUIOverview = {
*/
onChange: function () {
var $trigger = $(this);
- var row = $trigger.closest('tr').get(0);
- var rowHandler = $(row).data('fieldUIRowHandler');
+ var $row = $trigger.closest('tr');
+ var rowHandler = $row.data('fieldUIRowHandler');
var refreshRows = {};
refreshRows[rowHandler.name] = $trigger.get(0);
@@ -150,7 +154,7 @@ Drupal.fieldUIOverview = {
var region = rowHandler.getRegion();
if (region != rowHandler.region) {
// Remove parenting.
- $('select.field-parent', row).val('');
+ $row.find('select.field-parent').val('');
// Let the row handler deal with the region change.
$.extend(refreshRows, rowHandler.regionChange(region));
// Update the row region.
@@ -167,14 +171,15 @@ Drupal.fieldUIOverview = {
onDrop: function () {
var dragObject = this;
var row = dragObject.rowObject.element;
- var rowHandler = $(row).data('fieldUIRowHandler');
+ var $row = $(row);
+ var rowHandler = $row.data('fieldUIRowHandler');
if (rowHandler !== undefined) {
- var regionRow = $(row).prevAll('tr.region-message').get(0);
+ var regionRow = $row.prevAll('tr.region-message').get(0);
var region = regionRow.className.replace(/([^ ]+[ ]+)*region-([^ ]+)-message([ ]+[^ ]+)*/, '$2');
if (region != rowHandler.region) {
// Let the row handler deal with the region change.
- refreshRows = rowHandler.regionChange(region);
+ var refreshRows = rowHandler.regionChange(region);
// Update the row region.
rowHandler.region = region;
// Ajax-update the rows.
@@ -195,22 +200,23 @@ Drupal.fieldUIOverview = {
*/
onSwap: function (draggedRow) {
var rowObject = this;
- $('tr.region-message', rowObject.table).each(function () {
+ $(rowObject.table).find('tr.region-message').each(function () {
+ var $this = $(this);
// If the dragged row is in this region, but above the message row, swap
// it down one space.
- if ($(this).prev('tr').get(0) == rowObject.group[rowObject.group.length - 1]) {
+ if ($this.prev('tr').get(0) == rowObject.group[rowObject.group.length - 1]) {
// Prevent a recursion problem when using the keyboard to move rows up.
if ((rowObject.method != 'keyboard' || rowObject.direction == 'down')) {
rowObject.swap('after', this);
}
}
// This region has become empty.
- if ($(this).next('tr').is(':not(.draggable)') || $(this).next('tr').length == 0) {
- $(this).removeClass('region-populated').addClass('region-empty');
+ if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').length == 0) {
+ $this.removeClass('region-populated').addClass('region-empty');
}
// This region has become populated.
- else if ($(this).is('.region-empty')) {
- $(this).removeClass('region-empty').addClass('region-populated');
+ else if ($this.is('.region-empty')) {
+ $this.removeClass('region-empty').addClass('region-populated');
}
});
},
@@ -281,7 +287,7 @@ Drupal.fieldUIDisplayOverview.field = function (row, data) {
this.tableDrag = data.tableDrag;
// Attach change listener to the 'formatter type' select.
- this.$formatSelect = $('select.field-formatter-type', row);
+ this.$formatSelect = $(row).find('select.field-formatter-type');
this.$formatSelect.change(Drupal.fieldUIOverview.onChange);
return this;
diff --git a/core/modules/file/file.js b/core/modules/file/file.js
index c66362c..a934afe 100644
--- a/core/modules/file/file.js
+++ b/core/modules/file/file.js
@@ -14,25 +14,27 @@
*/
Drupal.behaviors.fileValidateAutoAttach = {
attach: function (context, settings) {
+ var $context = $(context);
var validateExtension = Drupal.file.validateExtension;
var selector, elements;
if (settings.file && settings.file.elements) {
elements = settings.file.elements;
for (selector in elements) {
if (elements.hasOwnProperty(selector)) {
- $(selector, context).bind('change', {extensions: elements[selector]}, validateExtension);
+ $context.find(selector).bind('change', {extensions: elements[selector]}, validateExtension);
}
}
}
},
detach: function (context, settings) {
+ var $context = $(context);
var validateExtension = Drupal.file.validateExtension;
var selector, elements;
if (settings.file && settings.file.elements) {
elements = settings.file.elements;
for (selector in elements) {
if (elements.hasOwnProperty(selector)) {
- $(selector, context).unbind('change', validateExtension);
+ $context.find(selector).unbind('change', validateExtension);
}
}
}
@@ -44,12 +46,14 @@ Drupal.behaviors.fileValidateAutoAttach = {
*/
Drupal.behaviors.fileButtons = {
attach: function (context) {
- $('input.form-submit', context).bind('mousedown', Drupal.file.disableFields);
- $('div.form-managed-file input.form-submit', context).bind('mousedown', Drupal.file.progressBar);
+ var $context = $(context);
+ $context.find('input.form-submit').bind('mousedown', Drupal.file.disableFields);
+ $context.find('div.form-managed-file input.form-submit').bind('mousedown', Drupal.file.progressBar);
},
detach: function (context) {
- $('input.form-submit', context).unbind('mousedown', Drupal.file.disableFields);
- $('div.form-managed-file input.form-submit', context).unbind('mousedown', Drupal.file.progressBar);
+ var $context = $(context);
+ $context.find('input.form-submit').unbind('mousedown', Drupal.file.disableFields);
+ $context.find('div.form-managed-file input.form-submit').unbind('mousedown', Drupal.file.progressBar);
}
};
@@ -58,10 +62,10 @@ Drupal.behaviors.fileButtons = {
*/
Drupal.behaviors.filePreviewLinks = {
attach: function (context) {
- $('div.form-managed-file .file a, .file-widget .file a', context).bind('click',Drupal.file.openInNewWindow);
+ $(context).find('div.form-managed-file .file a, .file-widget .file a').bind('click',Drupal.file.openInNewWindow);
},
detach: function (context){
- $('div.form-managed-file .file a, .file-widget .file a', context).unbind('click', Drupal.file.openInNewWindow);
+ $(context).find('div.form-managed-file .file a, .file-widget .file a').unbind('click', Drupal.file.openInNewWindow);
}
};
diff --git a/core/modules/filter/filter.admin.js b/core/modules/filter/filter.admin.js
index 3bc6233..43cda26 100644
--- a/core/modules/filter/filter.admin.js
+++ b/core/modules/filter/filter.admin.js
@@ -2,12 +2,13 @@
Drupal.behaviors.filterStatus = {
attach: function (context, settings) {
- $('#filters-status-wrapper input.form-checkbox', context).once('filter-status', function () {
+ var $context = $(context);
+ $context.find('#filters-status-wrapper input.form-checkbox').once('filter-status', function () {
var $checkbox = $(this);
// Retrieve the tabledrag row belonging to this filter.
- var $row = $('#' + $checkbox.attr('id').replace(/-status$/, '-weight'), context).closest('tr');
+ var $row = $context.find('#' + $checkbox.attr('id').replace(/-status$/, '-weight')).closest('tr');
// Retrieve the vertical tab belonging to this filter.
- var tab = $('#' + $checkbox.attr('id').replace(/-status$/, '-settings'), context).data('verticalTab');
+ var tab = $context.find('#' + $checkbox.attr('id').replace(/-status$/, '-settings')).data('verticalTab');
// Bind click handler to this checkbox to conditionally show and hide the
// filter's tableDrag row and vertical tab pane.
diff --git a/core/modules/filter/filter.js b/core/modules/filter/filter.js
index c286159..db5f42a 100644
--- a/core/modules/filter/filter.js
+++ b/core/modules/filter/filter.js
@@ -5,7 +5,7 @@
*/
Drupal.behaviors.filterGuidelines = {
attach: function (context) {
- $('.filter-guidelines', context).once('filter-guidelines')
+ $(context).find('.filter-guidelines').once('filter-guidelines')
.find(':header').hide()
.closest('.filter-wrapper').find('select.filter-list')
.bind('change', function () {
diff --git a/core/modules/menu/menu.admin.js b/core/modules/menu/menu.admin.js
index 4fa094e..4e5bf07 100644
--- a/core/modules/menu/menu.admin.js
+++ b/core/modules/menu/menu.admin.js
@@ -17,7 +17,7 @@ Drupal.behaviors.menuChangeParentItems = {
Drupal.menu_update_parent_list = function () {
var values = [];
- $('input:checked', $('fieldset#edit-menu')).each(function () {
+ $('fieldset#edit-menu').find('input:checked').each(function () {
// Get the names of all checked menus.
values.push(Drupal.checkPlain($.trim($(this).val())));
});
diff --git a/core/modules/menu/menu.js b/core/modules/menu/menu.js
index ff4ef1e..f315e7a 100644
--- a/core/modules/menu/menu.js
+++ b/core/modules/menu/menu.js
@@ -2,9 +2,10 @@
Drupal.behaviors.menuFieldsetSummaries = {
attach: function (context) {
- $('fieldset.menu-link-form', context).drupalSetSummary(function (context) {
- if ($('.form-item-menu-enabled input', context).is(':checked')) {
- return Drupal.checkPlain($('.form-item-menu-link-title input', context).val());
+ $(context).find('fieldset.menu-link-form').drupalSetSummary(function (context) {
+ var $context = $(context);
+ if ($context.find('.form-item-menu-enabled input').is(':checked')) {
+ return Drupal.checkPlain($context.find('.form-item-menu-link-title input').val());
}
else {
return Drupal.t('Not in menu');
@@ -18,12 +19,14 @@ Drupal.behaviors.menuFieldsetSummaries = {
*/
Drupal.behaviors.menuLinkAutomaticTitle = {
attach: function (context) {
- $('fieldset.menu-link-form', context).each(function () {
+ var $context = $(context);
+ $context.find('fieldset.menu-link-form').each(function () {
+ var $this = $(this);
// Try to find menu settings widget elements as well as a 'title' field in
// the form, but play nicely with user permissions and form alterations.
- var $checkbox = $('.form-item-menu-enabled input', this);
- var $link_title = $('.form-item-menu-link-title input', context);
- var $title = $(this).closest('form').find('.form-item-title input');
+ var $checkbox = $this.find('.form-item-menu-enabled input');
+ var $link_title = $context.find('.form-item-menu-link-title input');
+ var $title = $this.closest('form').find('.form-item-title input');
// Bail out if we do not have all required fields.
if (!($checkbox.length && $link_title.length && $title.length)) {
return;
diff --git a/core/modules/node/content_types.js b/core/modules/node/content_types.js
index 0031c32..43cfa37 100644
--- a/core/modules/node/content_types.js
+++ b/core/modules/node/content_types.js
@@ -2,28 +2,30 @@
Drupal.behaviors.contentTypes = {
attach: function (context) {
+ var $context = $(context);
// Provide the vertical tab summaries.
- $('fieldset#edit-submission', context).drupalSetSummary(function(context) {
+ $context.find('fieldset#edit-submission').drupalSetSummary(function(context) {
var vals = [];
- vals.push(Drupal.checkPlain($('#edit-title-label', context).val()) || Drupal.t('Requires a title'));
+ vals.push(Drupal.checkPlain($(context).find('#edit-title-label').val()) || Drupal.t('Requires a title'));
return vals.join(', ');
});
- $('fieldset#edit-workflow', context).drupalSetSummary(function(context) {
+ $context.find('fieldset#edit-workflow').drupalSetSummary(function(context) {
var vals = [];
- $("input[name^='node_options']:checked", context).parent().each(function() {
+ $(context).find("input[name^='node_options']:checked").parent().each(function() {
vals.push(Drupal.checkPlain($(this).text()));
});
- if (!$('#edit-node-options-status', context).is(':checked')) {
+ if (!$(context).find('#edit-node-options-status').is(':checked')) {
vals.unshift(Drupal.t('Not published'));
}
return vals.join(', ');
});
- $('fieldset#edit-display', context).drupalSetSummary(function(context) {
+ $context.find('fieldset#edit-display').drupalSetSummary(function(context) {
var vals = [];
- $('input:checked', context).next('label').each(function() {
+ var $context = $(context);
+ $context.find('input:checked').next('label').each(function() {
vals.push(Drupal.checkPlain($(this).text()));
});
- if (!$('#edit-node-submitted', context).is(':checked')) {
+ if (!$context.find('#edit-node-submitted').is(':checked')) {
vals.unshift(Drupal.t("Don't display post information"));
}
return vals.join(', ');
diff --git a/core/modules/node/node.js b/core/modules/node/node.js
index ebf68eb..8990164 100644
--- a/core/modules/node/node.js
+++ b/core/modules/node/node.js
@@ -1,38 +1,41 @@
-
(function ($) {
Drupal.behaviors.nodeFieldsetSummaries = {
attach: function (context) {
- $('fieldset.node-form-revision-information', context).drupalSetSummary(function (context) {
- var revisionCheckbox = $('.form-item-revision input', context);
+ var $context = $(context);
+ $context.find('fieldset.node-form-revision-information').drupalSetSummary(function (context) {
+ var $context = $(context);
+ var revisionCheckbox = $context.find('.form-item-revision input');
// Return 'New revision' if the 'Create new revision' checkbox is checked,
// or if the checkbox doesn't exist, but the revision log does. For users
// without the "Administer content" permission the checkbox won't appear,
// but the revision log will if the content type is set to auto-revision.
- if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $('.form-item-log textarea', context).length)) {
+ if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $context.find('.form-item-log textarea').length)) {
return Drupal.t('New revision');
}
return Drupal.t('No revision');
});
- $('fieldset.node-form-author', context).drupalSetSummary(function (context) {
- var name = $('.form-item-name input', context).val() || Drupal.settings.anonymous,
- date = $('.form-item-date input', context).val();
+ $context.find('fieldset.node-form-author').drupalSetSummary(function (context) {
+ var $context = $(context);
+ var name = $context.find('.form-item-name input').val() || Drupal.settings.anonymous,
+ date = $context.find('.form-item-date input').val();
return date ?
Drupal.t('By @name on @date', { '@name': name, '@date': date }) :
Drupal.t('By @name', { '@name': name });
});
- $('fieldset.node-form-options', context).drupalSetSummary(function (context) {
+ $context.find('fieldset.node-form-options').drupalSetSummary(function (context) {
+ var $context = $(context);
var vals = [];
- $('input:checked', context).parent().each(function () {
+ $context.find('input:checked').parent().each(function () {
vals.push(Drupal.checkPlain($.trim($(this).text())));
});
- if (!$('.form-item-status input', context).is(':checked')) {
+ if (!$context.find('.form-item-status input').is(':checked')) {
vals.unshift(Drupal.t('Not published'));
}
return vals.join(', ');
diff --git a/core/modules/openid/openid.js b/core/modules/openid/openid.js
index 4a09e5a..0e673f3 100644
--- a/core/modules/openid/openid.js
+++ b/core/modules/openid/openid.js
@@ -2,6 +2,7 @@
Drupal.behaviors.openid = {
attach: function (context) {
+ var $context = $(context);
var loginElements = $('.form-item-name, .form-item-pass, li.openid-link');
var openidElements = $('.form-item-openid-identifier, li.user-link');
var cookie = $.cookie('Drupal.visitor.openid_identifier');
@@ -19,7 +20,7 @@ Drupal.behaviors.openid = {
}
}
- $('li.openid-link:not(.openid-processed)', context)
+ $context.find('li.openid-link:not(.openid-processed)')
.addClass('openid-processed')
.click(function () {
loginElements.hide();
@@ -31,7 +32,7 @@ Drupal.behaviors.openid = {
$('#edit-openid-identifier')[0].focus();
return false;
});
- $('li.user-link:not(.openid-processed)', context)
+ $context.find('li.user-link:not(.openid-processed)')
.addClass('openid-processed')
.click(function () {
openidElements.hide();
diff --git a/core/modules/overlay/overlay-child.js b/core/modules/overlay/overlay-child.js
index 9096db7..ff111d8 100644
--- a/core/modules/overlay/overlay-child.js
+++ b/core/modules/overlay/overlay-child.js
@@ -59,14 +59,14 @@ Drupal.behaviors.overlayChild = {
// There are two links within the message that informs people about the
// overlay and how to disable it. Make sure both links are visible when
// either one has focus and add a class to the wrapper for styling purposes.
- $('#overlay-disable-message', context)
+ $(context).find('#overlay-disable-message')
.focusin(function () {
- $(this).addClass('overlay-disable-message-focused');
- $('a.element-focusable', this).removeClass('element-invisible');
+ $(this).addClass('overlay-disable-message-focused')
+ .find('a.element-focusable').removeClass('element-invisible');
})
.focusout(function () {
- $(this).removeClass('overlay-disable-message-focused');
- $('a.element-focusable', this).addClass('element-invisible');
+ $(this).removeClass('overlay-disable-message-focused')
+ .find('a.element-focusable').addClass('element-invisible');
});
}
};
@@ -110,7 +110,7 @@ Drupal.overlayChild.behaviors.addClickHandler = function (context, settings) {
* action attribute get a ?render=overlay suffix.
*/
Drupal.overlayChild.behaviors.parseForms = function (context, settings) {
- $('form', context).once('overlay', function () {
+ $(context).find('form').once('overlay', function () {
// Obtain the action attribute of the form.
var action = $(this).attr('action');
// Keep internal forms in the overlay.
diff --git a/core/modules/path/path.js b/core/modules/path/path.js
index fcc0acc..46f8168 100644
--- a/core/modules/path/path.js
+++ b/core/modules/path/path.js
@@ -1,9 +1,8 @@
-
(function ($) {
Drupal.behaviors.pathFieldsetSummaries = {
attach: function (context) {
- $('fieldset.path-form', context).drupalSetSummary(function (context) {
+ $(context).find('fieldset.path-form').drupalSetSummary(function (context) {
var path = $('.form-item-path-alias input').val();
return path ?
diff --git a/core/modules/shortcut/shortcut.admin.js b/core/modules/shortcut/shortcut.admin.js
index 5554e5a..2647f34 100644
--- a/core/modules/shortcut/shortcut.admin.js
+++ b/core/modules/shortcut/shortcut.admin.js
@@ -13,7 +13,7 @@ Drupal.behaviors.shortcutDrag = {
visibleLength = 0,
slots = 0,
tableDrag = Drupal.tableDrag.shortcuts;
- $('> tbody > tr, > tr', table)
+ table.find('> tbody > tr, > tr')
.filter(':visible')
.filter(':odd').filter('.odd')
.removeClass('odd').addClass('even')
@@ -31,9 +31,9 @@ Drupal.behaviors.shortcutDrag = {
// Add a handler for when a row is swapped.
tableDrag.row.prototype.onSwap = function (swappedRow) {
- var disabledIndex = $(table).find('tr').index($(table).find('tr.shortcut-status-disabled')) - slots - 2,
+ var disabledIndex = table.find('tr').index(table.find('tr.shortcut-status-disabled')) - slots - 2,
count = 0;
- $(table).find('tr.shortcut-status-enabled').nextAll(':not(.shortcut-slot-empty)').each(function(index) {
+ table.find('tr.shortcut-status-enabled').nextAll(':not(.shortcut-slot-empty)').each(function(index) {
if (index < disabledIndex) {
count++;
}
@@ -78,9 +78,10 @@ Drupal.behaviors.shortcutDrag = {
tableDrag.rowStatusChange = function (rowObject) {
// Use "status-message" row instead of "status" row because
// "status-{status_name}-message" is less prone to regexp match errors.
- var statusRow = $(rowObject.element).prevAll('tr.shortcut-status').get(0);
+ var $rowElement = $(rowObject.element);
+ var statusRow = $rowElement.prevAll('tr.shortcut-status').get(0);
var statusName = statusRow.className.replace(/([^ ]+[ ]+)*shortcut-status-([^ ]+)([ ]+[^ ]+)*/, '$2');
- var statusField = $('select.shortcut-status-select', rowObject.element);
+ var statusField = $rowElement.find('select.shortcut-status-select');
statusField.val(statusName);
};
@@ -88,7 +89,7 @@ Drupal.behaviors.shortcutDrag = {
// :even and :odd are reversed because jQuery counts from 0 and
// we count from 1, so we're out of sync.
// Match immediate children of the parent element to allow nesting.
- $('> tbody > tr:visible, > tr:visible', this.table)
+ $(this.table).find('> tbody > tr:visible, > tr:visible')
.filter(':odd').filter('.odd')
.removeClass('odd').addClass('even')
.end().end()
diff --git a/core/modules/system/system.js b/core/modules/system/system.js
index f4bdc6d..b577140 100644
--- a/core/modules/system/system.js
+++ b/core/modules/system/system.js
@@ -103,7 +103,7 @@ Drupal.behaviors.dateTime = {
var suffix = source + '-suffix';
// Attach keyup handler to custom format inputs.
- $('input' + source, context).once('date-time').keyup(function () {
+ $(context).find('input' + source).once('date-time').keyup(function () {
var input = $(this);
var url = fieldSettings.lookup + (fieldSettings.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
$.getJSON(url, function (data) {
@@ -122,15 +122,16 @@ Drupal.behaviors.dateTime = {
*/
Drupal.behaviors.pageCache = {
attach: function (context, settings) {
- $('#edit-cache-0', context).change(function () {
+ var $context = $(context);
+ $context.find('#edit-cache-0').change(function () {
$('#page-compression-wrapper').hide();
$('#cache-error').hide();
});
- $('#edit-cache-1', context).change(function () {
+ $context.find('#edit-cache-1').change(function () {
$('#page-compression-wrapper').show();
$('#cache-error').hide();
});
- $('#edit-cache-2', context).change(function () {
+ $context.find('#edit-cache-2').change(function () {
$('#page-compression-wrapper').show();
$('#cache-error').show();
});
diff --git a/core/modules/taxonomy/taxonomy.js b/core/modules/taxonomy/taxonomy.js
index 1a0c790..035dc29 100644
--- a/core/modules/taxonomy/taxonomy.js
+++ b/core/modules/taxonomy/taxonomy.js
@@ -8,15 +8,15 @@
*/
Drupal.behaviors.termDrag = {
attach: function (context, settings) {
- var table = $('#taxonomy', context);
+ var table = $(context).find('#taxonomy');
var tableDrag = Drupal.tableDrag.taxonomy; // Get the blocks tableDrag object.
- var rows = $('tr', table).length;
+ var rows = table.find('tr').length;
// When a row is swapped, keep previous and next page classes set.
tableDrag.row.prototype.onSwap = function (swappedRow) {
- $('tr.taxonomy-term-preview', table).removeClass('taxonomy-term-preview');
- $('tr.taxonomy-term-divider-top', table).removeClass('taxonomy-term-divider-top');
- $('tr.taxonomy-term-divider-bottom', table).removeClass('taxonomy-term-divider-bottom');
+ table.find('tr.taxonomy-term-preview').removeClass('taxonomy-term-preview');
+ table.find('tr.taxonomy-term-divider-top').removeClass('taxonomy-term-divider-top');
+ table.find('tr.taxonomy-term-divider-bottom').removeClass('taxonomy-term-divider-bottom');
if (settings.taxonomy.backStep) {
for (var n = 0; n < settings.taxonomy.backStep; n++) {
diff --git a/core/modules/toolbar/toolbar.js b/core/modules/toolbar/toolbar.js
index d50f205..d345284 100644
--- a/core/modules/toolbar/toolbar.js
+++ b/core/modules/toolbar/toolbar.js
@@ -7,12 +7,12 @@ Drupal.toolbar = Drupal.toolbar || {};
*/
Drupal.behaviors.toolbar = {
attach: function(context) {
-
+ var $context = $(context);
// Set the initial state of the toolbar.
- $('#toolbar', context).once('toolbar', Drupal.toolbar.init);
+ $context.find('#toolbar').once('toolbar', Drupal.toolbar.init);
// Toggling toolbar drawer.
- $('#toolbar a.toggle', context).once('toolbar-toggle').click(function(e) {
+ $context.find('#toolbar a.toggle').once('toolbar-toggle').click(function(e) {
Drupal.toolbar.toggle();
// Allow resize event handlers to recalculate sizes/positions.
$(window).triggerHandler('resize');
diff --git a/core/modules/user/user.js b/core/modules/user/user.js
index 042668d..20d3e45 100644
--- a/core/modules/user/user.js
+++ b/core/modules/user/user.js
@@ -7,7 +7,7 @@
Drupal.behaviors.password = {
attach: function (context, settings) {
var translate = settings.password;
- $('input.password-field', context).once('password', function () {
+ $(context).find('input.password-field').once('password', function () {
var passwordInput = $(this);
var innerWrapper = $(this).parent();
var outerWrapper = $(this).parent().parent();
@@ -16,16 +16,16 @@ Drupal.behaviors.password = {
innerWrapper.addClass('password-parent');
// Add the password confirmation layer.
- $('input.password-confirm', outerWrapper).parent().prepend('
' + translate['confirmTitle'] + '
').addClass('confirm-parent');
- var confirmInput = $('input.password-confirm', outerWrapper);
- var confirmResult = $('div.password-confirm', outerWrapper);
- var confirmChild = $('span', confirmResult);
+ outerWrapper.find('input.password-confirm').parent().prepend('
' + translate['confirmTitle'] + '
').addClass('confirm-parent');
+ var confirmInput = outerWrapper.find('input.password-confirm');
+ var confirmResult = outerWrapper.find('div.password-confirm');
+ var confirmChild = confirmResult.find('span');
// Add the description box.
var passwordMeter = '