Commit eab6f127 authored by catch's avatar catch

Issue #1419968 by nod_, cosmicdreams, droplet, tim.plunkett: Replace...

Issue #1419968 by nod_, cosmicdreams, droplet, tim.plunkett: Replace $('selector', domelement) with $(domelement).find('selector').
parent d0c4f999
......@@ -374,7 +374,7 @@ Drupal.ajax.prototype.beforeSend = function (xmlhttprequest, options) {
else if (this.progress.type == 'throbber') {
this.progress.element = $('<div class="ajax-progress ajax-progress-throbber"><div class="throbber">&nbsp;</div></div>');
if (this.progress.message) {
$('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>');
this.progress.element.find('.throbber').after('<div class="message">' + this.progress.message + '</div>');
}
$(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');
......
......@@ -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));
}
......
......@@ -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.
......
......@@ -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');
$('<span class="fieldset-legend-prefix element-invisible"></span>')
.append($fieldset.hasClass('collapsed') ? Drupal.t('Show') : Drupal.t('Hide'))
......
......@@ -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);
......
......@@ -26,12 +26,13 @@ Drupal.behaviors.machineName = {
*/
attach: function (context, settings) {
var self = this;
var $context = $(context);
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 $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) {
......
......@@ -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) {
......
......@@ -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();
}
}
});
......
This diff is collapsed.
......@@ -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;
......
......@@ -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 <th> with class select-all, and insert the check all checkbox.
$('th.select-all', table).prepend($('<input type="checkbox" class="form-checkbox" />').attr('title', strings.selectAll)).click(function (event) {
$table.find('th.select-all').prepend($('<input type="checkbox" class="form-checkbox" />').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;
});
......
......@@ -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,
......
(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 = $('<ul class="vertical-tabs-list"></ul>');
$(this).wrap('<div class="vertical-tabs clearfix"></div>').before(tab_list);
$this.wrap('<div class="vertical-tabs clearfix"></div>').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) {
......
......@@ -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');
}
});
};
......
......@@ -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();
......
......@@ -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('<div id="placeholder"></div>').addClass('color-processed');
form.prepend('<div id="placeholder"></div>').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]);
......
......@@ -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];
}
......
......@@ -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(', '));
......
......@@ -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');
......
......@@ -10,7 +10,7 @@
*/
Drupal.behaviors.dashboard = {
attach: function (context, settings) {
$('#dashboard', context).once(function () {
$(context).find('#dashboard').once(function () {
$(this).prepend('<div class="customize clearfix"><ul class="action-links"><li><a href="#">' + Drupal.t('Customize dashboard') + '</a></li></ul><div class="canvas"></div></div>');
$('.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')) {