Integrating Drupal and Openlayers in IE

viraj.kanwade - April 28, 2009 - 04:15

Hi,

We are developing a website (http://www.indiabiodiversity.org) which uses Drupal and Openlayers.

Everything works fine on FF 3.

But when we try to run the site in IE, we get JS exceptions.

======8<=======8<=====8<=======8<===
Drupal.behaviors.tableDrag = function(context) {
for (var base in Drupal.settings.tableDrag) {
==>> if (!$('#' + base + '.tabledrag-processed', context).size()) { <<=== issue on this line
======8<=======8<=====8<=======8<===

If we disable our OpenLayers module, it works fine.

After some debugging we figured out that the issue is Drupal uses jQuery while OpenLayers uses Prototype.

So the use of "$" is causing the issue.

We replaced "$" with "jQuery" in Drupal code and it works fine.

Is there another fix for this issue?

Is it possible that this be added as coding standard that while using jQuery functions use jQuery instead of $?

Can it be changed in the next version of Drupal?

Thanks.
Regards,
Viraj

Patch

viraj.kanwade - April 28, 2009 - 04:40

Index: ahah.js
===================================================================
--- ahah.js (revision 1322)
+++ ahah.js (working copy)
@@ -17,15 +17,15 @@
*/
Drupal.behaviors.ahah = function(context) {
for (var base in Drupal.settings.ahah) {
- if (!$('#'+ base + '.ahah-processed').size()) {
+ if (!jQuery('#'+ base + '.ahah-processed').size()) {
var element_settings = Drupal.settings.ahah[base];

- $(element_settings.selector).each(function() {
+ jQuery(element_settings.selector).each(function() {
element_settings.element = this;
var ahah = new Drupal.ahah(base, element_settings);
});

- $('#'+ base).addClass('ahah-processed');
+ jQuery('#'+ base).addClass('ahah-processed');
}
}
};
@@ -63,7 +63,7 @@
}

// Record the form action and target, needed for iFrame file uploads.
- var form = $(this.element).parents('form');
+ var form = jQuery(this.element).parents('form');
this.form_action = form.attr('action');
this.form_target = form.attr('target');
this.form_encattr = form.attr('encattr');
@@ -95,18 +95,18 @@
};

// Bind the ajaxSubmit function to the element event.
- $(element_settings.element).bind(element_settings.event, function() {
- $(element_settings.element).parents('form').ajaxSubmit(options);
+ jQuery(element_settings.element).bind(element_settings.event, function() {
+ jQuery(element_settings.element).parents('form').ajaxSubmit(options);
return false;
});
// If necessary, enable keyboard submission so that AHAH behaviors
// can be triggered through keyboard input as well as e.g. a mousedown
// action.
if (element_settings.keypress) {
- $(element_settings.element).keypress(function(event) {
+ jQuery(element_settings.element).keypress(function(event) {
// Detect enter key.
if (event.keyCode == 13) {
- $(element_settings.element).trigger(element_settings.event);
+ jQuery(element_settings.element).trigger(element_settings.event);
return false;
}
});
@@ -118,7 +118,7 @@
*/
Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) {
// Disable the element that received the change.
- $(this.element).addClass('progress-disabled').attr('disabled', true);
+ jQuery(this.element).addClass('progress-disabled').attr('disabled', true);

// Insert progressbar or throbber.
if (this.progress.type == 'bar') {
@@ -129,16 +129,16 @@
if (this.progress.url) {
progressBar.startMonitoring(this.progress.url, this.progress.interval || 1500);
}
- this.progress.element = $(progressBar.element).addClass('ahah-progress ahah-progress-bar');
+ this.progress.element = jQuery(progressBar.element).addClass('ahah-progress ahah-progress-bar');
this.progress.object = progressBar;
- $(this.element).after(this.progress.element);
+ jQuery(this.element).after(this.progress.element);
}
else if (this.progress.type == 'throbber') {
- this.progress.element = $(' ');
+ this.progress.element = jQuery(' ');
if (this.progress.message) {
- $('.throbber', this.progress.element).after('' + this.progress.message + '')
+ jQuery('.throbber', this.progress.element).after('' + this.progress.message + '')
}
- $(this.element).after(this.progress.element);
+ jQuery(this.element).after(this.progress.element);
}
};

@@ -146,11 +146,11 @@
* Handler for the form redirection completion.
*/
Drupal.ahah.prototype.success = function (response, status) {
- var wrapper = $(this.wrapper);
- var form = $(this.element).parents('form');
- // Manually insert HTML into the jQuery object, using $() directly crashes
+ var wrapper = jQuery(this.wrapper);
+ var form = jQuery(this.element).parents('form');
+ // Manually insert HTML into the jQuery object, using jQuery() directly crashes
// Safari with long string lengths. http://dev.jquery.com/ticket/1152
- var new_content = $('').html(response.data);
+ var new_content = jQuery('').html(response.data);

// Restore the previous action and target to the form.
form.attr('action', this.form_action);
@@ -159,12 +159,12 @@

// Remove the progress element.
if (this.progress.element) {
- $(this.progress.element).remove();
+ jQuery(this.progress.element).remove();
}
if (this.progress.object) {
this.progress.object.stopMonitoring();
}
- $(this.element).removeClass('progress-disabled').attr('disabled', false);
+ jQuery(this.element).removeClass('progress-disabled').attr('disabled', false);

// Add the new content to the page.
Drupal.freezeHeight();
@@ -183,13 +183,13 @@
// Determine what effect use and what content will receive the effect, then
// show the new content. For browser compatibility, Safari is excluded from
// using effects on table rows.
- if (($.browser.safari && $("tr.ahah-new-content", new_content).size() > 0)) {
+ if (($.browser.safari && jQuery("tr.ahah-new-content", new_content).size() > 0)) {
new_content.show();
}
- else if ($('.ahah-new-content', new_content).size() > 0) {
- $('.ahah-new-content', new_content).hide();
+ else if (jQuery('.ahah-new-content', new_content).size() > 0) {
+ jQuery('.ahah-new-content', new_content).hide();
new_content.show();
- $(".ahah-new-content", new_content)[this.showEffect](this.showSpeed);
+ jQuery(".ahah-new-content", new_content)[this.showEffect](this.showSpeed);
}
else if (this.showEffect != 'show') {
new_content[this.showEffect](this.showSpeed);
@@ -210,16 +210,16 @@
Drupal.ahah.prototype.error = function (response, uri) {
alert(Drupal.ahahError(response, uri));
// Resore the previous action and target to the form.
- $(this.element).parent('form').attr( { action: this.form_action, target: this.form_target} );
+ jQuery(this.element).parent('form').attr( { action: this.form_action, target: this.form_target} );
// Remove the progress element.
if (this.progress.element) {
- $(this.progress.element).remove();
+ jQuery(this.progress.element).remove();
}
if (this.progress.object) {
this.progress.object.stopMonitoring();
}
// Undo hide.
- $(this.wrapper).show();
+ jQuery(this.wrapper).show();
// Re-enable the element.
- $(this.element).removeClass('progess-disabled').attr('disabled', false);
+ jQuery(this.element).removeClass('progess-disabled').attr('disabled', false);
};
Index: autocomplete.js
===================================================================
--- autocomplete.js (revision 1322)
+++ autocomplete.js (working copy)
@@ -5,16 +5,16 @@
*/
Drupal.behaviors.autocomplete = function (context) {
var acdb = [];
- $('input.autocomplete:not(.autocomplete-processed)', context).each(function () {
+ jQuery('input.autocomplete:not(.autocomplete-processed)', context).each(function () {
var uri = this.value;
if (!acdb[uri]) {
acdb[uri] = new Drupal.ACDB(uri);
}
- var input = $('#' + this.id.substr(0, this.id.length - 13))
+ var input = jQuery('#' + this.id.substr(0, this.id.length - 13))
.attr('autocomplete', 'OFF')[0];
- $(input.form).submit(Drupal.autocompleteSubmit);
+ jQuery(input.form).submit(Drupal.autocompleteSubmit);
new Drupal.jsAC(input, acdb[uri]);
- $(this).addClass('autocomplete-processed');
+ jQuery(this).addClass('autocomplete-processed');
});
};

@@ -23,7 +23,7 @@
* and closes the suggestions popup when doing so.
*/
Drupal.autocompleteSubmit = function () {
- return $('#autocomplete').each(function () {
+ return jQuery('#autocomplete').each(function () {
this.owner.hidePopup();
}).size() == 0;
};
@@ -36,7 +36,7 @@
this.input = input;
this.db = db;

- $(this.input)
+ jQuery(this.input)
.keydown(function (event) { return ac.onkeydown(this, event); })
.keyup(function (event) { ac.onkeyup(this, event); })
.blur(function () { ac.hidePopup(); ac.db.cancel(); });
@@ -114,7 +114,7 @@
this.highlight(this.selected.nextSibling);
}
else {
- var lis = $('li', this.popup);
+ var lis = jQuery('li', this.popup);
if (lis.size() > 0) {
this.highlight(lis.get(0));
}
@@ -135,9 +135,9 @@
*/
Drupal.jsAC.prototype.highlight = function (node) {
if (this.selected) {
- $(this.selected).removeClass('selected');
+ jQuery(this.selected).removeClass('selected');
}
- $(node).addClass('selected');
+ jQuery(node).addClass('selected');
this.selected = node;
};

@@ -145,7 +145,7 @@
* Unhighlights a suggestion
*/
Drupal.jsAC.prototype.unhighlight = function (node) {
- $(node).removeClass('selected');
+ jQuery(node).removeClass('selected');
this.selected = false;
};

@@ -161,7 +161,7 @@
var popup = this.popup;
if (popup) {
this.popup = null;
- $(popup).fadeOut('fast', function() { $(popup).remove(); });
+ jQuery(popup).fadeOut('fast', function() { jQuery(popup).remove(); });
}
this.selected = false;
};
@@ -172,18 +172,18 @@
Drupal.jsAC.prototype.populatePopup = function () {
// Show popup
if (this.popup) {
- $(this.popup).remove();
+ jQuery(this.popup).remove();
}
this.selected = false;
this.popup = document.createElement('div');
this.popup.id = 'autocomplete';
this.popup.owner = this;
- $(this.popup).css({
+ jQuery(this.popup).css({
marginTop: this.input.offsetHeight +'px',
width: (this.input.offsetWidth - 4) +'px',
display: 'none'
});
- $(this.input).before(this.popup);
+ jQuery(this.input).before(this.popup);

// Do search
this.db.owner = this;
@@ -204,22 +204,22 @@
var ac = this;
for (key in matches) {
var li = document.createElement('li');
- $(li)
+ jQuery(li)
.html(''+ matches[key] +'')
.mousedown(function () { ac.select(this); })
.mouseover(function () { ac.highlight(this); })
.mouseout(function () { ac.unhighlight(this); });
li.autocompleteValue = key;
- $(ul).append(li);
+ jQuery(ul).append(li);
}

// Show popup with matches, if any
if (this.popup) {
if (ul.childNodes.length > 0) {
- $(this.popup).empty().append(ul).show();
+ jQuery(this.popup).empty().append(ul).show();
}
else {
- $(this.popup).css({visibility: 'hidden'});
+ jQuery(this.popup).css({visibility: 'hidden'});
this.hidePopup();
}
}
@@ -228,12 +228,12 @@
Drupal.jsAC.prototype.setStatus = function (status) {
switch (status) {
case 'begin':
- $(this.input).addClass('throbbing');
+ jQuery(this.input).addClass('throbbing');
break;
case 'cancel':
case 'error':
case 'found':
- $(this.input).removeClass('throbbing');
+ jQuery(this.input).removeClass('throbbing');
break;
}
};
Index: collapse.js
===================================================================
--- collapse.js (revision 1322)
+++ collapse.js (working copy)
@@ -4,11 +4,11 @@
* Toggle the visibility of a fieldset using smooth animations
*/
Drupal.toggleFieldset = function(fieldset) {
- if ($(fieldset).is('.collapsed')) {
+ if (jQuery(fieldset).is('.collapsed')) {
// Action div containers are processed separately because of a IE bug
// that alters the default submit button behavior.
- var content = $('> div:not(.action)', fieldset);
- $(fieldset).removeClass('collapsed');
+ var content = jQuery('> div:not(.action)', fieldset);
+ jQuery(fieldset).removeClass('collapsed');
content.hide();
content.slideDown( {
duration: 'fast',
@@ -16,7 +16,7 @@
complete: function() {
Drupal.collapseScrollIntoView(this.parentNode);
this.parentNode.animating = false;
- $('div.action', fieldset).show();
+ jQuery('div.action', fieldset).show();
},
step: function() {
// Scroll the fieldset into view
@@ -25,9 +25,9 @@
});
}
else {
- $('div.action', fieldset).hide();
- var content = $('> div:not(.action)', fieldset).slideUp('fast', function() {
- $(this.parentNode).addClass('collapsed');
+ jQuery('div.action', fieldset).hide();
+ var content = jQuery('> div:not(.action)', fieldset).slideUp('fast', function() {
+ jQuery(this.parentNode).addClass('collapsed');
this.parentNode.animating = false;
});
}
@@ -37,9 +37,9 @@
* Scroll a given fieldset into view as much as possible.
*/
Drupal.collapseScrollIntoView = function (node) {
- var h = self.innerHeight || document.documentElement.clientHeight || $('body')[0].clientHeight || 0;
- var offset = self.pageYOffset || document.documentElement.scrollTop || $('body')[0].scrollTop || 0;
- var posY = $(node).offset().top;
+ var h = self.innerHeight || document.documentElement.clientHeight || jQuery('body')[0].clientHeight || 0;
+ var offset = self.pageYOffset || document.documentElement.scrollTop || jQuery('body')[0].scrollTop || 0;
+ var posY = jQuery(node).offset().top;
var fudge = 55;
if (posY + node.offsetHeight + fudge > h + offset) {
if (node.offsetHeight > h) {
@@ -51,18 +51,18 @@
};

Drupal.behaviors.collapse = function (context) {
- $('fieldset.collapsible > legend:not(.collapse-processed)', context).each(function() {
- var fieldset = $(this.parentNode);
+ jQuery('fieldset.collapsible > legend:not(.collapse-processed)', context).each(function() {
+ var fieldset = jQuery(this.parentNode);
// Expand if there are errors inside
- if ($('input.error, textarea.error, select.error', fieldset).size() > 0) {
+ if (jQuery('input.error, textarea.error, select.error', fieldset).size() > 0) {
fieldset.removeClass('collapsed');
}

// Turn the legend into a clickable link and wrap the contents of the fieldset
// in a div for easier animation
var text = this.innerHTML;
- $(this).empty().append($(''+ text +'').click(function() {
- var fieldset = $(this).parents('fieldset:first')[0];
+ jQuery(this).empty().append(jQuery(''+ text +'').click(function() {
+ var fieldset = jQuery(this).parents('fieldset:first')[0];
// Don't animate multiple times
if (!fieldset.animating) {
fieldset.animating = true;
@@ -70,7 +70,7 @@
}
return false;
}))
- .after($('')
+ .after(jQuery('')
.append(fieldset.children(':not(legend):not(.action)')))
.addClass('collapse-processed');
});
Index: tabledrag.js
===================================================================
--- tabledrag.js (revision 1322)
+++ tabledrag.js (working copy)
@@ -13,16 +13,16 @@
*/
Drupal.behaviors.tableDrag = function(context) {
for (var base in Drupal.settings.tableDrag) {
- if (!$('#' + base + '.tabledrag-processed', context).size()) {
+ if (!jQuery('#' + base + '.tabledrag-processed', context).size()) {
var tableSettings = Drupal.settings.tableDrag[base];

- $('#' + base).filter(':not(.tabledrag-processed)').each(function() {
+ jQuery('#' + base).filter(':not(.tabledrag-processed)').each(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, tableSettings);
});

- $('#' + base).addClass('tabledrag-processed');
+ jQuery('#' + base).addClass('tabledrag-processed');
}
}
};
@@ -47,7 +47,7 @@
this.oldY = 0; // Used to determine up or down direction from last mouse move.
this.changed = false; // Whether anything in the entire table has changed.
this.maxDepth = 0; // Maximum amount of allowed parenting.
- this.rtl = $(this.table).css('direction') == 'rtl' ? -1 : 1; // Direction of the table.
+ this.rtl = jQuery(this.table).css('direction') == 'rtl' ? -1 : 1; // Direction of the table.

// Configure the scroll settings.
this.scrollSettings = { amount: 4, interval: 50, trigger: 70 };
@@ -76,21 +76,21 @@
// manually append 2 indentations in the first draggable row, measure
// the offset, then remove.
var indent = Drupal.theme('tableDragIndentation');
- var testCell = $('tr.draggable:first td:first', table).prepend(indent).prepend(indent);
- this.indentAmount = $('.indentation', testCell).get(1).offsetLeft - $('.indentation', testCell).get(0).offsetLeft;
- $('.indentation', testCell).slice(0, 2).remove();
+ var testCell = jQuery('tr.draggable:first td:first', table).prepend(indent).prepend(indent);
+ this.indentAmount = jQuery('.indentation', testCell).get(1).offsetLeft - jQuery('.indentation', testCell).get(0).offsetLeft;
+ jQuery('.indentation', testCell).slice(0, 2).remove();
}

// Make each applicable row draggable.
- $('tr.draggable', table).each(function() { self.makeDraggable(this); });
+ jQuery('tr.draggable', table).each(function() { self.makeDraggable(this); });

// Hide columns containing affected form elements.
this.hideColumns();

// Add mouse bindings to the document. The self variable is passed along
// as event handlers do not have direct access to the tableDrag object.
- $(document).bind('mousemove', function(event) { return self.dragRow(event, self); });
- $(document).bind('mouseup', function(event) { return self.dropRow(event, self); });
+ jQuery(document).bind('mousemove', function(event) { return self.dragRow(event, self); });
+ jQuery(document).bind('mouseup', function(event) { return self.dropRow(event, self); });
};

/**
@@ -101,7 +101,7 @@
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 = jQuery('.' + this.tableSettings[group][d]['target'] + ':first', this.table);
if (field.size() && this.tableSettings[group][d]['hidden']) {
var hidden = this.tableSettings[group][d]['hidden'];
var cell = field.parents('td:first');
@@ -112,10 +112,10 @@
// Hide the column containing this field.
if (hidden && cell[0] && cell.css('display') != 'none') {
// Add 1 to our indexes. The nth-child selector is 1 based, not 0 based.
- var columnIndex = $('td', cell.parent()).index(cell.get(0)) + 1;
- var headerIndex = $('td:not(:hidden)', cell.parent()).index(cell.get(0)) + 1;
- $('tr', this.table).each(function(){
- var row = $(this);
+ var columnIndex = jQuery('td', cell.parent()).index(cell.get(0)) + 1;
+ var headerIndex = jQuery('td:not(:hidden)', cell.parent()).index(cell.get(0)) + 1;
+ jQuery('tr', this.table).each(function(){
+ var row = jQuery(this);
var parentTag = row.parent().get(0).tagName.toLowerCase();
var index = (parentTag == 'thead') ? headerIndex : columnIndex;

@@ -146,7 +146,7 @@
* Find the target used within a particular row and group.
*/
Drupal.tableDrag.prototype.rowSettings = function(group, row) {
- var field = $('.' + group, row);
+ var field = jQuery('.' + group, row);
for (delta in this.tableSettings[group]) {
var targetClass = this.tableSettings[group][delta]['target'];
if (field.is('.' + targetClass)) {
@@ -167,21 +167,21 @@
var self = this;

// Create the handle.
- var handle = $(' ').attr('title', Drupal.t('Drag to re-order'));
+ var handle = jQuery(' ').attr('title', Drupal.t('Drag to re-order'));
// Insert the handle after indentations (if any).
- if ($('td:first .indentation:last', item).after(handle).size()) {
+ if (jQuery('td:first .indentation:last', item).after(handle).size()) {
// Update the total width of indentation in this entire table.
- self.indentCount = Math.max($('.indentation', item).size(), self.indentCount);
+ self.indentCount = Math.max(jQuery('.indentation', item).size(), self.indentCount);
}
else {
- $('td:first', item).prepend(handle);
+ jQuery('td:first', item).prepend(handle);
}

// Add hover action for the handle.
handle.hover(function() {
- self.dragObject == null ? $(this).addClass('tabledrag-handle-hover') : null;
+ self.dragObject == null ? jQuery(this).addClass('tabledrag-handle-hover') : null;
}, function() {
- self.dragObject == null ? $(this).removeClass('tabledrag-handle-hover') : null;
+ self.dragObject == null ? jQuery(this).removeClass('tabledrag-handle-hover') : null;
});

// Add the mousedown action for the handle.
@@ -196,7 +196,7 @@

// If there's a lingering row object from the keyboard, remove its focus.
if (self.rowObject) {
- $('a.tabledrag-handle', self.rowObject.element).blur();
+ jQuery('a.tabledrag-handle', self.rowObject.element).blur();
}

// Create a new rowObject for manipulation of this row.
@@ -207,18 +207,18 @@
self.table.bottomY = self.table.topY + self.table.offsetHeight;

// Add classes to the handle and row.
- $(this).addClass('tabledrag-handle-hover');
- $(item).addClass('drag');
+ jQuery(this).addClass('tabledrag-handle-hover');
+ jQuery(item).addClass('drag');

// Set the document to use the move cursor during drag.
- $('body').addClass('drag');
+ jQuery('body').addClass('drag');
if (self.oldRowElement) {
- $(self.oldRowElement).removeClass('drag-previous');
+ jQuery(self.oldRowElement).removeClass('drag-previous');
}

// Hack for IE6 that flickers uncontrollably if select lists are moved.
if (navigator.userAgent.indexOf('MSIE 6.') != -1) {
- $('select', this.table).css('display', 'none');
+ jQuery('select', this.table).css('display', 'none');
}

// Hack for Konqueror, prevent the blur handler from firing.
@@ -237,13 +237,13 @@

// Similar to the hover event, add a class when the handle is focused.
handle.focus(function() {
- $(this).addClass('tabledrag-handle-hover');
+ jQuery(this).addClass('tabledrag-handle-hover');
self.safeBlur = true;
});

// Remove the handle class on blur and fire the same function as a mouseup.
handle.blur(function(event) {
- $(this).removeClass('tabledrag-handle-hover');
+ jQuery(this).removeClass('tabledrag-handle-hover');
if (self.rowObject && self.safeBlur) {
self.dropRow(event, self);
}
@@ -265,21 +265,21 @@
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 = jQuery(self.rowObject.element).prev('tr').get(0);
+ while (previousRow && jQuery(previousRow).is(':hidden')) {
+ previousRow = jQuery(previousRow).prev('tr').get(0);
}
if (previousRow) {
self.safeBlur = false; // Do not allow the onBlur cleanup.
self.rowObject.direction = 'up';
keyChange = true;

- if ($(item).is('.tabledrag-root')) {
+ if (jQuery(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 && jQuery('.indentation', previousRow).size()) {
+ previousRow = jQuery(previousRow).prev('tr').get(0);
+ groupHeight += jQuery(previousRow).is(':hidden') ? 0 : previousRow.offsetHeight;
}
if (previousRow) {
self.rowObject.swap('before', previousRow);
@@ -287,7 +287,7 @@
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 || jQuery(previousRow).is('.draggable')) {
// Swap with the previous row (unless previous row is the first one
// and undraggable).
self.rowObject.swap('before', previousRow);
@@ -305,22 +305,22 @@
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 = jQuery(self.rowObject.group).filter(':last').next('tr').get(0);
+ while (nextRow && jQuery(nextRow).is(':hidden')) {
+ nextRow = jQuery(nextRow).next('tr').get(0);
}
if (nextRow) {
self.safeBlur = false; // Do not allow the onBlur cleanup.
self.rowObject.direction = 'down';
keyChange = true;

- if ($(item).is('.tabledrag-root')) {
+ if (jQuery(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);
if (nextGroup) {
- $(nextGroup.group).each(function () {groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight});
- nextGroupRow = $(nextGroup.group).filter(':last').get(0);
+ jQuery(nextGroup.group).each(function () {groupHeight += jQuery(this).is(':hidden') ? 0 : this.offsetHeight});
+ nextGroupRow = jQuery(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));
@@ -339,9 +339,9 @@
}

if (self.rowObject && self.rowObject.changed == true) {
- $(item).addClass('drag');
+ jQuery(item).addClass('drag');
if (self.oldRowElement) {
- $(self.oldRowElement).removeClass('drag-previous');
+ jQuery(self.oldRowElement).removeClass('drag-previous');
}
self.oldRowElement = item;
self.restripeTable();
@@ -448,7 +448,7 @@

self.rowObject.markChanged();
if (self.changed == false) {
- $(Drupal.theme('tableDragChangedWarning')).insertAfter(self.table).hide().fadeIn('slow');
+ jQuery(Drupal.theme('tableDragChangedWarning')).insertAfter(self.table).hide().fadeIn('slow');
self.changed = true;
}
}
@@ -457,9 +457,9 @@
self.rowObject.removeIndentClasses();
}
if (self.oldRowElement) {
- $(self.oldRowElement).removeClass('drag-previous');
+ jQuery(self.oldRowElement).removeClass('drag-previous');
}
- $(droppedRow).removeClass('drag').addClass('drag-previous');
+ jQuery(droppedRow).removeClass('drag').addClass('drag-previous');
self.oldRowElement = droppedRow;
self.onDrop();
self.rowObject = null;
@@ -467,15 +467,15 @@

// Functionality specific only to mouseup event.
if (self.dragObject != null) {
- $('.tabledrag-handle', droppedRow).removeClass('tabledrag-handle-hover');
+ jQuery('.tabledrag-handle', droppedRow).removeClass('tabledrag-handle-hover');

self.dragObject = null;
- $('body').removeClass('drag');
+ jQuery('body').removeClass('drag');
clearInterval(self.scrollInterval);

// Hack for IE6 that flickers uncontrollably if select lists are moved.
if (navigator.userAgent.indexOf('MSIE 6.') != -1) {
- $('select', this.table).css('display', 'block');
+ jQuery('select', this.table).css('display', 'block');
}
}
};
@@ -571,8 +571,8 @@
// 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 (jQuery(row).is(':hidden') && jQuery(row).prev('tr').is(':hidden')) {
+ row = jQuery(row).prev('tr').get(0);
}
return row;
}
@@ -613,12 +613,12 @@
}
// 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 = jQuery(changedRow).prev('tr').get(0);
+ var nextRow = jQuery(changedRow).next('tr').get(0);
var sourceRow = changedRow;
- if ($(previousRow).is('.draggable') && $('.' + group, previousRow).length) {
+ if (jQuery(previousRow).is('.draggable') && jQuery('.' + group, previousRow).length) {
if (this.indentEnabled) {
- if ($('.indentations', previousRow).size() == $('.indentations', changedRow)) {
+ if (jQuery('.indentations', previousRow).size() == jQuery('.indentations', changedRow)) {
sourceRow = previousRow;
}
}
@@ -626,9 +626,9 @@
sourceRow = previousRow;
}
}
- else if ($(nextRow).is('.draggable') && $('.' + group, nextRow).length) {
+ else if (jQuery(nextRow).is('.draggable') && jQuery('.' + group, nextRow).length) {
if (this.indentEnabled) {
- if ($('.indentations', nextRow).size() == $('.indentations', changedRow)) {
+ if (jQuery('.indentations', nextRow).size() == jQuery('.indentations', changedRow)) {
sourceRow = nextRow;
}
}
@@ -640,8 +640,8 @@
// 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) {
+ var previousRow = jQuery(changedRow).prev('tr');
+ while (previousRow.length && jQuery('.indentation', previousRow).length >= this.rowObject.indents) {
previousRow = previousRow.prev('tr');
}
// If we found a row.
@@ -654,9 +654,9 @@
// Use the first row in the table as source, because it's garanteed to
// be at the root level. Find the first item, then compare this row
// against it as a sibling.
- sourceRow = $('tr.draggable:first').get(0);
+ sourceRow = jQuery('tr.draggable:first').get(0);
if (sourceRow == this.rowObject.element) {
- sourceRow = $(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0);
+ sourceRow = jQuery(this.rowObject.group[this.rowObject.group.length - 1]).next('tr.draggable').get(0);
}
var useSibling = true;
}
@@ -675,16 +675,16 @@
}

var targetClass = '.' + rowSettings.target;
- var targetElement = $(targetClass, changedRow).get(0);
+ var targetElement = jQuery(targetClass, changedRow).get(0);

// Check if a target element exists in this row.
if (targetElement) {
var sourceClass = '.' + rowSettings.source;
- var sourceElement = $(sourceClass, sourceRow).get(0);
+ var sourceElement = jQuery(sourceClass, sourceRow).get(0);
switch (rowSettings.action) {
case 'depth':
// Get the depth of the target row.
- targetElement.value = $('.indentation', $(sourceElement).parents('tr:first')).size();
+ targetElement.value = jQuery('.indentation', jQuery(sourceElement).parents('tr:first')).size();
break;
case 'match':
// Update the value.
@@ -692,15 +692,15 @@
break;
case 'order':
var siblings = this.rowObject.findSiblings(rowSettings);
- if ($(targetElement).is('select')) {
+ if (jQuery(targetElement).is('select')) {
// Get a list of acceptable values.
var values = new Array();
- $('option', targetElement).each(function() {
+ jQuery('option', targetElement).each(function() {
values.push(this.value);
});
var maxVal = values[values.length - 1];
// Populate the values in the siblings.
- $(targetClass, siblings).each(function() {
+ jQuery(targetClass, siblings).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();
@@ -712,8 +712,8 @@
}
else {
// Assume a numeric input field.
- var weight = parseInt($(targetClass, siblings[0]).val()) || 0;
- $(targetClass, siblings).each(function() {
+ var weight = parseInt(jQuery(targetClass, siblings[0]).val()) || 0;
+ jQuery(targetClass, siblings).each(function() {
this.value = weight;
weight++;
});
@@ -729,8 +729,8 @@
* may have had.
*/
Drupal.tableDrag.prototype.copyDragClasses = function(sourceRow, targetRow, group) {
- var sourceElement = $('.' + group, sourceRow);
- var targetElement = $('.' + group, targetRow);
+ var sourceElement = jQuery('.' + group, sourceRow);
+ var targetElement = jQuery('.' + group, targetRow);
if (sourceElement.length && targetElement.length) {
targetElement[0].className = sourceElement[0].className;
}
@@ -775,7 +775,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.
- $('tr.draggable', this.table)
+ jQuery('tr.draggable', this.table)
.filter(':odd').filter('.odd')
.removeClass('odd').addClass('even')
.end().end()
@@ -815,20 +815,20 @@
this.element = tableRow;
this.method = method;
this.group = new Array(tableRow);
- this.groupDepth = $('.indentation', tableRow).size();
+ this.groupDepth = jQuery('.indentation', tableRow).size();
this.changed = false;
- this.table = $(tableRow).parents('table:first').get(0);
+ this.table = jQuery(tableRow).parents('table:first').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 = jQuery('.indentation', tableRow).size();
this.children = this.findChildren(addClasses);
this.group = $.merge(this.group, this.children);
// Find the depth of this entire group.
for (var n = 0; n < this.group.length; n++) {
- this.groupDepth = Math.max($('.indentation', this.group[n]).size(), this.groupDepth);
+ this.groupDepth = Math.max(jQuery('.indentation', this.group[n]).size(), this.groupDepth);
}
}
};
@@ -841,25 +841,25 @@
*/
Drupal.tableDrag.prototype.row.prototype.findChildren = function(addClasses) {
var parentIndentation = this.indents;
- var currentRow = $(this.element, this.table).next('tr.draggable');
+ var currentRow = jQuery(this.element, this.table).next('tr.draggable');
var rows = new Array();
var child = 0;
while (currentRow.length) {
- var rowIndentation = $('.indentation', currentRow).length;
+ var rowIndentation = jQuery('.indentation', currentRow).length;
// A greater indentation indicates this is a child.
if (rowIndentation > parentIndentation) {
child++;
rows.push(currentRow[0]);
if (addClasses) {
- $('.indentation', currentRow).each(function(indentNum) {
+ jQuery('.indentation', currentRow).each(function(indentNum) {
if (child == 1 && (indentNum == parentIndentation)) {
- $(this).addClass('tree-child-first');
+ jQuery(this).addClass('tree-child-first');
}
if (indentNum == parentIndentation) {
- $(this).addClass('tree-child');
+ jQuery(this).addClass('tree-child');
}
else if (indentNum > parentIndentation) {
- $(this).addClass('tree-child-horizontal');
+ jQuery(this).addClass('tree-child-horizontal');
}
});
}
@@ -870,7 +870,7 @@
currentRow = currentRow.next('tr.draggable');
}
if (addClasses && rows.length) {
- $('.indentation:nth-child(' + (parentIndentation + 1) + ')', rows[rows.length - 1]).addClass('tree-child-last');
+ jQuery('.indentation:nth-child(' + (parentIndentation + 1) + ')', rows[rows.length - 1]).addClass('tree-child-last');
}
return rows;
};
@@ -886,10 +886,10 @@
var prevRow, nextRow;
if (this.direction == 'down') {
prevRow = row;
- nextRow = $(row).next('tr').get(0);
+ nextRow = jQuery(row).next('tr').get(0);
}
else {
- prevRow = $(row).prev('tr').get(0);
+ prevRow = jQuery(row).prev('tr').get(0);
nextRow = row;
}
this.interval = this.validIndentInterval(prevRow, nextRow);
@@ -901,7 +901,7 @@
}

// 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 && jQuery(row).is(':not(.draggable)')) {
return false;
}

@@ -917,7 +917,7 @@
* DOM element what will be swapped with the row group.
*/
Drupal.tableDrag.prototype.row.prototype.swap = function(position, row) {
- $(row)[position](this.group);
+ jQuery(row)[position](this.group);
this.changed = true;
this.onSwap(row);
};
@@ -938,16 +938,16 @@

// Minimum indentation:
// Do not orphan the next row.
- minIndent = nextRow ? $('.indentation', nextRow).size() : 0;
+ minIndent = nextRow ? jQuery('.indentation', nextRow).size() : 0;

// Maximum indentation:
- if (!prevRow || $(this.element).is('.tabledrag-root')) {
+ if (!prevRow || jQuery(this.element).is('.tabledrag-root')) {
// Do not indent the first row in the table or 'root' rows..
maxIndent = 0;
}
else {
// Do not go deeper than as a child of the previous row.
- maxIndent = $('.indentation', prevRow).size() + ($(prevRow).is('.tabledrag-leaf') ? 0 : 1);
+ maxIndent = jQuery('.indentation', prevRow).size() + (jQuery(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));
@@ -968,8 +968,8 @@
Drupal.tableDrag.prototype.row.prototype.indent = function(indentDiff) {
// 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);
+ prevRow = jQuery(this.element).prev('tr').get(0);
+ nextRow = jQuery(this.group).filter(':last').next('tr').get(0);
this.interval = this.validIndentInterval(prevRow, nextRow);
}

@@ -982,11 +982,11 @@
for (var n = 1; n <= Math.abs(indentDiff); n++) {
// Add or remove indentations.
if (indentDiff < 0) {
- $('.indentation:first', this.group).remove();
+ jQuery('.indentation:first', this.group).remove();
this.indents--;
}
else {
- $('td:first', this.group).prepend(Drupal.theme('tableDragIndentation'));
+ jQuery('td:first', this.group).prepend(Drupal.theme('tableDragIndentation'));
this.indents++;
}
}
@@ -1012,14 +1012,14 @@
var directions = new Array('prev', 'next');
var rowIndentation = this.indents;
for (var d in directions) {
- var checkRow = $(this.element)[directions[d]]();
+ var checkRow = jQuery(this.element)[directions[d]]();
while (checkRow.length) {
// Check that the sibling contains a similar target field.
- if ($('.' + rowSettings.target, checkRow)) {
+ if (jQuery('.' + rowSettings.target, checkRow)) {
// Either add immediately if this is a flat table, or check to ensure
// that this row has the same level of indentaiton.
if (this.indentEnabled) {
- var checkRowIndentation = $('.indentation', checkRow).length
+ var checkRowIndentation = jQuery('.indentation', checkRow).length
}

if (!(this.indentEnabled) || (checkRowIndentation == rowIndentation)) {
@@ -1033,7 +1033,7 @@
else {
break;
}
- checkRow = $(checkRow)[directions[d]]();
+ checkRow = jQuery(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.
@@ -1050,7 +1050,7 @@
*/
Drupal.tableDrag.prototype.row.prototype.removeIndentClasses = function() {
for (n in this.children) {
- $('.indentation', this.children[n])
+ jQuery('.indentation', this.children[n])
.removeClass('tree-child')
.removeClass('tree-child-first')
.removeClass('tree-child-last')
@@ -1063,8 +1063,8 @@
*/
Drupal.tableDrag.prototype.row.prototype.markChanged = function() {
var marker = Drupal.theme('tableDragChangedMarker');
- var cell = $('td:first', this.element);
- if ($('span.tabledrag-changed', cell).length == 0) {
+ var cell = jQuery('td:first', this.element);
+ if (jQuery('span.tabledrag-changed', cell).length == 0) {
cell.append(marker);
}
};
Index: teaser.js
===================================================================
--- teaser.js (revision 1322)
+++ teaser.js (working copy)
@@ -11,16 +11,16 @@
return;
}

- $('textarea.teaser:not(.teaser-processed)', context).each(function() {
- var teaser = $(this).addClass('teaser-processed');
+ jQuery('textarea.teaser:not(.teaser-processed)', context).each(function() {
+ var teaser = jQuery(this).addClass('teaser-processed');

// Move teaser textarea before body, and remove its form-item wrapper.
- var body = $('#'+ Drupal.settings.teaser[this.id]);
- var checkbox = $('#'+ Drupal.settings.teaserCheckbox[this.id]).parent();
- var checked = $(checkbox).children('input').attr('checked') ? true : false;
+ var body = jQuery('#'+ Drupal.settings.teaser[this.id]);
+ var checkbox = jQuery('#'+ Drupal.settings.teaserCheckbox[this.id]).parent();
+ var checked = jQuery(checkbox).children('input').attr('checked') ? true : false;
var parent = teaser[0].parentNode;
- $(body).before(teaser);
- $(parent).remove();
+ jQuery(body).before(teaser);
+ jQuery(parent).remove();

function trim(text) {
return text.replace(/^\s+/g, '').replace(/\s+$/g, '');
@@ -33,17 +33,17 @@
}
// Empty, hide and disable teaser.
teaser[0].value = '';
- $(teaser).attr('disabled', 'disabled');
- $(teaser).parent().slideUp('fast');
+ jQuery(teaser).attr('disabled', 'disabled');
+ jQuery(teaser).parent().slideUp('fast');
// Change label.
- $(this).val(Drupal.t('Split summary at cursor'));
+ jQuery(this).val(Drupal.t('Split summary at cursor'));
// Hide separate teaser checkbox.
- $(checkbox).hide();
+ jQuery(checkbox).hide();
// Force a hidden checkbox to be checked (to ensure that the body is
// correctly processed on form submit when teaser/body are in joined
// state), and remember the current checked status.
- checked = $(checkbox).children('input').attr('checked') ? true : false;
- $(checkbox).children('input').attr('checked', true);
+ checked = jQuery(checkbox).children('input').attr('checked') ? true : false;
+ jQuery(checkbox).children('input').attr('checked', true);
}

// Split the teaser from the body.
@@ -57,30 +57,30 @@
teaser[0].value = trim(text.slice(0, split));
body[0].value = trim(text.slice(split));
// Reveal and enable teaser
- $(teaser).attr('disabled', '');
- $(teaser).parent().slideDown('fast');
+ jQuery(teaser).attr('disabled', '');
+ jQuery(teaser).parent().slideDown('fast');
// Change label
- $(this).val(Drupal.t('Join summary'));
+ jQuery(this).val(Drupal.t('Join summary'));
// Show separate teaser checkbox, restore checked value.
- $(checkbox).show().children('input').attr('checked', checked);
+ jQuery(checkbox).show().children('input').attr('checked', checked);
}

// Add split/join button.
- var button = $('');
- var include = $('#'+ this.id.substring(0, this.id.length - 2) +'include');
- $(include).parent().parent().before(button);
+ var button = jQuery('');
+ var include = jQuery('#'+ this.id.substring(0, this.id.length - 2) +'include');
+ jQuery(include).parent().parent().before(button);

// Extract the teaser from the body, if set. Otherwise, stay in joined mode.
var text = body.val().split('', 2);
if (text.length == 2) {
teaser[0].value = trim(text[0]);
body[0].value = trim(text[1]);
- $(teaser).attr('disabled', '');
- $('input', button).val(Drupal.t('Join summary')).toggle(join_teaser, split_teaser);
+ jQuery(teaser).attr('disabled', '');
+ jQuery('input', button).val(Drupal.t('Join summary')).toggle(join_teaser, split_teaser);
}
else {
- $('input', button).val(Drupal.t('Split summary at cursor')).toggle(split_teaser, join_teaser);
- $(checkbox).hide().children('input').attr('checked', true);
+ jQuery('input', button).val(Drupal.t('Split summary at cursor')).toggle(split_teaser, join_teaser);
+ jQuery(checkbox).hide().children('input').attr('checked', true);
}

// Make sure that textarea.js has done its magic to ensure proper visibility state.
@@ -88,8 +88,8 @@
Drupal.behaviors.textarea(teaser.parentNode);
}
// Set initial visibility
- if ($(teaser).is('[@disabled]')) {
- $(teaser).parent().hide();
+ if (jQuery(teaser).is('[@disabled]')) {
+ jQuery(teaser).parent().hide();
}

});
Index: textarea.js
===================================================================
--- textarea.js (revision 1322)
+++ textarea.js (working copy)
@@ -1,25 +1,25 @@
// $Id: textarea.js,v 1.22 2008/01/17 19:31:56 goba Exp $

Drupal.behaviors.textarea = function(context) {
- $('textarea.resizable:not(.textarea-processed)', context).each(function() {
+ jQuery('textarea.resizable:not(.textarea-processed)', context).each(function() {
// Avoid non-processed teasers.
- if ($(this).is(('textarea.teaser:not(.teaser-processed)'))) {
+ if (jQuery(this).is(('textarea.teaser:not(.teaser-processed)'))) {
return false;
}
- var textarea = $(this).addClass('textarea-processed'), staticOffset = null;
+ var textarea = jQuery(this).addClass('textarea-processed'), staticOffset = null;

// When wrapping the text area, work around an IE margin bug. See:
// http://jaspan.com/ie-inherited-margin-bug-form-elements-and-haslayout
- $(this).wrap('')
- .parent().append($('').mousedown(startDrag));
+ jQuery(this).wrap('')
+ .parent().append(jQuery('').mousedown(startDrag));

- var grippie = $('div.grippie', $(this).parent())[0];
- grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px';
+ var grippie = jQuery('div.grippie', jQuery(this).parent())[0];
+ grippie.style.marginRight = (grippie.offsetWidth - jQuery(this)[0].offsetWidth) +'px';

function startDrag(e) {
staticOffset = textarea.height() - e.pageY;
textarea.css('opacity', 0.25);
- $(document).mousemove(performDrag).mouseup(endDrag);
+ jQuery(document).mousemove(performDrag).mouseup(endDrag);
return false;
}

@@ -29,7 +29,7 @@
}

function endDrag(e) {
- $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag);
+ jQuery(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag);
textarea.css('opacity', 1);
}
});

Human knowledge belongs to the world!

 
 

Drupal is a registered trademark of Dries Buytaert.