diff --git a/core/misc/ajax.js b/core/misc/ajax.js
index ec9958d..adb650f 100644
--- a/core/misc/ajax.js
+++ b/core/misc/ajax.js
@@ -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 5e85be4..282bcbc 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);
@@ -122,7 +122,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.size() > 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 259b84e..053ea40 100644
--- a/core/misc/form.js
+++ b/core/misc/form.js
@@ -65,7 +65,7 @@ Drupal.behaviors.fillUserInfoFromCookie = {
$('form.user-info-from-cookie').once('user-info-from-cookie', function () {
var formContext = this;
$.each(['name', 'mail', 'homepage'], function () {
- var $element = $('[name=' + this + ']', formContext);
+ var $element = $(formContext).find('[name=' + this + ']');
var cookie = $.cookie('Drupal.visitor.' + this);
if ($element.length && cookie) {
$element.val(cookie);
diff --git a/core/misc/machine-name.js b/core/misc/machine-name.js
index 996cf84..03eaec7 100644
--- a/core/misc/machine-name.js
+++ b/core/misc/machine-name.js
@@ -23,9 +23,10 @@ Drupal.behaviors.machineName = {
attach: function (context, settings) {
var self = this;
$.each(settings.machineName, 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/tabledrag.js b/core/misc/tabledrag.js
index 61e64bf..5219890 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,16 @@ 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;
+ this.indentAmount = testCell.find('.indentation').get(1).offsetLeft - testCell.find('.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 +120,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.size() && this.tableSettings[group][d].hidden) {
var hidden = this.tableSettings[group][d].hidden;
var cell = field.closest('td');
@@ -134,8 +136,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 +187,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.
@@ -208,12 +211,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.
@@ -249,17 +253,18 @@ 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);
+ if ($item.find('td:first .indentation:last').length) {
+ $item.find('td:first .indentation:last').after(handle);
// Update the total width of indentation in this entire table.
- self.indentCount = Math.max($('.indentation', item).size(), self.indentCount);
+ self.indentCount = Math.max($item.find('.indentation').size(), self.indentCount);
}
else {
- $('td:first', item).prepend(handle);
+ $item.find('td:first').prepend(handle);
}
// Add hover action for the handle.
@@ -281,7 +286,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.
@@ -345,9 +350,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');
+ var previousRow = $previousRow.get(0);
+ while (previousRow && $previousRow.is(':hidden')) {
+ $previousRow = $(previousRow).prev('tr');
+ previousRow = $previousRow.get(0);
}
if (previousRow) {
self.safeBlur = false; // Do not allow the onBlur cleanup.
@@ -357,9 +364,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).size()) {
- previousRow = $(previousRow).prev('tr').get(0);
- groupHeight += $(previousRow).is(':hidden') ? 0 : previousRow.offsetHeight;
+ while (previousRow && $previousRow.find('.indentation').size()) {
+ $previousRow = $(previousRow).prev('tr');
+ previousRow = $previousRow.get(0);
+ groupHeight += $previousRow.is(':hidden') ? 0 : previousRow.offsetHeight;
}
if (previousRow) {
self.rowObject.swap('before', previousRow);
@@ -367,7 +375,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);
@@ -385,9 +393,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');
+ var nextRow = $nextRow.get(0);
+ while (nextRow && $nextRow.is(':hidden')) {
+ $nextRow = $(nextRow).next('tr');
+ nextRow = $nextRow.get(0);
}
if (nextRow) {
self.safeBlur = false; // Do not allow the onBlur cleanup.
@@ -397,12 +407,12 @@ Drupal.tableDrag.prototype.makeDraggable = function (item) {
if ($(item).is('.tabledrag-root')) {
// Swap with the next group (necessarily a top-level one).
var groupHeight = 0;
- nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false);
+ var nextGroup = new self.row(nextRow, 'keyboard', self.indentEnabled, self.maxDepth, false);
if (nextGroup) {
$(nextGroup.group).each(function () {
groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight;
});
- nextGroupRow = $(nextGroup.group).filter(':last').get(0);
+ var nextGroupRow = $(nextGroup.group).filter(':last').get(0);
self.rowObject.swap('after', nextGroupRow);
// No need to check for indentation, 0 is the only valid one.
window.scrollBy(0, parseInt(groupHeight, 10));
@@ -512,6 +522,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.
@@ -541,7 +552,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;
@@ -549,7 +560,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');
@@ -593,8 +604,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.
@@ -631,8 +643,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');
+ row = $row.get(0);
}
return row;
}
@@ -666,6 +679,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') {
@@ -673,12 +687,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');
+ var previousRow = $previousRow.get(0);
+ var $nextRow = $changedRow.next('tr');
+ 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).size() == $('.indentations', changedRow)) {
+ if ($previousRow.find('.indentations').size() == $changedRow.find('.indentations')) {
sourceRow = previousRow;
}
}
@@ -686,9 +702,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).size() == $('.indentations', changedRow)) {
+ if ($nextRow.find('.indentations').size() == $changedRow.find('.indentations')) {
sourceRow = nextRow;
}
}
@@ -700,13 +716,16 @@ 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');
+ // TODO clean that up, It wasn't coherent compared to the rest of the function.
+ 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.
@@ -735,7 +754,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) {
@@ -744,7 +763,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')).size();
+ targetElement.value = $(sourceElement).closest('tr').find('.indentation').size();
break;
case 'match':
// Update the value.
@@ -755,12 +774,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();
@@ -772,8 +791,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++;
});
@@ -789,8 +808,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;
}
@@ -836,7 +855,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');
@@ -871,18 +890,20 @@ 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).size();
+ this.groupDepth = $tableRow.find('.indentation').size();
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).size();
+ this.indents = $tableRow.find('.indentation').size();
this.children = this.findChildren(addClasses);
this.group = $.merge(this.group, this.children);
// Find the depth of this entire group.
@@ -904,13 +925,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');
}
@@ -929,7 +950,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;
};
@@ -941,14 +962,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);
@@ -960,7 +982,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;
}
@@ -995,14 +1017,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).size() : 0;
+ minIndent = nextRow ? $(nextRow).find('.indentation').size() : 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,
@@ -1011,7 +1034,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).size() + ($(prevRow).is('.tabledrag-leaf') ? 0 : 1);
+ maxIndent = $prevRow.find('.indentation').size() + ($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));
@@ -1030,10 +1053,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) {
prevRow = $(this.element).prev('tr').get(0);
- nextRow = $(this.group).filter(':last').next('tr').get(0);
+ nextRow = $group.filter(':last').next('tr').get(0);
this.interval = this.validIndentInterval(prevRow, nextRow);
}
@@ -1046,11 +1070,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++;
}
}
@@ -1079,11 +1103,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)) {
@@ -1097,7 +1121,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.
@@ -1114,7 +1138,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')
@@ -1127,8 +1151,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 63de30c..a1c065f 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');
// Clone the table header so it inherits original jQuery properties. Hide
diff --git a/core/misc/tableselect.js b/core/misc/tableselect.js
index d83da2c..0092849 100644
--- a/core/misc/tableselect.js
+++ b/core/misc/tableselect.js
@@ -8,22 +8,23 @@ Drupal.behaviors.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).size() == 0) {
+ if ($(this).find('td input:checkbox').size() == 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) {
- $('th.select-all input:checkbox', table).each(function () {
+ $table.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 () {
@@ -37,7 +38,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);
@@ -50,7 +51,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;
@@ -62,15 +63,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)[ state ? 'addClass' : 'removeClass' ]('selected');
- $('input:checkbox', i).each(function () {
+ $i[ state ? 'addClass' : 'removeClass' ]('selected');
+ $i.find('input:checkbox').each(function () {
this.checked = state;
});
diff --git a/core/misc/textarea.js b/core/misc/textarea.js
index 0ab5e71..81c4d22 100644
--- a/core/misc/textarea.js
+++ b/core/misc/textarea.js
@@ -2,7 +2,7 @@
Drupal.behaviors.textarea = {
attach: function (context, settings) {
- $('.form-textarea-wrapper.resizable', context).once('textarea', function () {
+ $(context).find('.form-textarea-wrapper.resizable').once('textarea', function () {
var staticOffset = null;
var textarea = $(this).addClass('resizable-textarea').find('textarea');
var grippie = $('').mousedown(startDrag);
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 82dcd2c..e9c0d74 100644
--- a/core/misc/vertical-tabs.js
+++ b/core/misc/vertical-tabs.js
@@ -14,47 +14,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 6d2c33f..5527323 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,12 +84,13 @@ 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 not, alert the user and keep the block in its old region setting.
@@ -97,8 +99,8 @@ Drupal.behaviors.blockDrag = {
// 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');
}
});
@@ -145,20 +147,21 @@ Drupal.behaviors.blockDrag = {
var checkEmptyRegions = function (table, rowObject) {
$('tr.region-message', table).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').size() == 0) {
- $(this).removeClass('region-populated').addClass('region-empty');
+ if ($this.next('tr').is(':not(.draggable)') || $this.next('tr').size() == 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 5b953f1..d617806 100644
--- a/core/modules/book/book.js
+++ b/core/modules/book/book.js
@@ -3,7 +3,7 @@
Drupal.behaviors.bookFieldsetSummaries = {
attach: function (context) {
- $('fieldset.book-form', context).drupalSetSummary(function (context) {
+ $(context).find('fieldset.book-form').drupalSetSummary(function (context) {
var val = $('.form-item-book-bid select').val();
if (val === '0') {
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..d4e8e56 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) {
+ var $context = $(context);
+ $context.find('fieldset.comment-node-settings-form').drupalSetSummary(function (context) {
return Drupal.checkPlain($('.form-item-comment input:checked', context).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 ebe5091..5481cd0 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-links-wrapper', context).once('contextual-links', function () {
+ $(context).find('div.contextual-links-wrapper').once('contextual-links', function () {
var $wrapper = $(this);
var $region = $wrapper.closest('.contextual-links-region');
var $links = $wrapper.find('ul.contextual-links');
diff --git a/core/modules/dashboard/dashboard.js b/core/modules/dashboard/dashboard.js
index ca2a3b5..b4b8ec5 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('.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..72667b1 100644
--- a/core/modules/field/modules/text/text.js
+++ b/core/modules/field/modules/text/text.js
@@ -6,7 +6,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/file/file.js b/core/modules/file/file.js
index 37419fd..f27a132 100644
--- a/core/modules/file/file.js
+++ b/core/modules/file/file.js
@@ -18,14 +18,14 @@ Drupal.behaviors.fileValidateAutoAttach = {
if (settings.file && settings.file.elements) {
$.each(settings.file.elements, function(selector) {
var extensions = settings.file.elements[selector];
- $(selector, context).bind('change', {extensions: extensions}, Drupal.file.validateExtension);
+ $(context).find(selector).bind('change', {extensions: extensions}, Drupal.file.validateExtension);
});
}
},
detach: function (context, settings) {
if (settings.file && settings.file.elements) {
$.each(settings.file.elements, function(selector) {
- $(selector, context).unbind('change', Drupal.file.validateExtension);
+ $(context).find(selector).unbind('change', Drupal.file.validateExtension);
});
}
}
@@ -36,12 +36,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);
}
};
@@ -50,10 +52,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 15bc2e7..fedac11 100644
--- a/core/modules/menu/menu.admin.js
+++ b/core/modules/menu/menu.admin.js
@@ -18,7 +18,7 @@
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 40c1bfe..b36ac21 100644
--- a/core/modules/menu/menu.js
+++ b/core/modules/menu/menu.js
@@ -19,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..d44d171 100644
--- a/core/modules/node/node.js
+++ b/core/modules/node/node.js
@@ -3,36 +3,40 @@
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 fdc97fa..e51f181 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 e78e383..a936492 100644
--- a/core/modules/overlay/overlay-child.js
+++ b/core/modules/overlay/overlay-child.js
@@ -60,14 +60,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');
});
}
};
@@ -108,7 +108,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..4445af3 100644
--- a/core/modules/path/path.js
+++ b/core/modules/path/path.js
@@ -3,7 +3,7 @@
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 0d0e9f4..3e2180a 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++;
}
@@ -76,11 +76,12 @@ Drupal.behaviors.shortcutDrag = {
};
function rowStatusChange(rowObject) {
+ var $rowElement = $(rowObject.element);
// 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 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 5446d28..860aab9 100644
--- a/core/modules/system/system.js
+++ b/core/modules/system/system.js
@@ -102,7 +102,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 = settings.lookup + (settings.lookup.match(/\?q=/) ? '&format=' : '?format=') + encodeURIComponent(input.val());
$.getJSON(url, function (data) {
@@ -119,15 +119,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 cc9cdf7..0436c86 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).size();
+ var rows = table.find('tr').size();
// 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 5b61634..1abde0b 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 44c00f3..e6c7edc 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 = '