Index: modules/block/block.js =================================================================== RCS file: /cvs/drupal/drupal/modules/block/block.js,v retrieving revision 1.4 diff -u -r1.4 block.js --- modules/block/block.js 29 Oct 2008 10:01:27 -0000 1.4 +++ modules/block/block.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: block.js,v 1.4 2008/10/29 10:01:27 dries Exp $ +(function($) { /** * Move a block in the blocks table from one region to another via select list. @@ -95,3 +96,5 @@ }; } }; + +})(jQuery); Index: modules/profile/profile.js =================================================================== RCS file: /cvs/drupal/drupal/modules/profile/profile.js,v retrieving revision 1.3 diff -u -r1.3 profile.js --- modules/profile/profile.js 29 Oct 2008 10:01:27 -0000 1.3 +++ modules/profile/profile.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: profile.js,v 1.3 2008/10/29 10:01:27 dries Exp $ +(function($) { /** * Add functionality to the profile drag and drop table. @@ -54,3 +55,5 @@ }; } }; + +})(jQuery); \ No newline at end of file Index: modules/color/color.js =================================================================== RCS file: /cvs/drupal/drupal/modules/color/color.js,v retrieving revision 1.8 diff -u -r1.8 color.js --- modules/color/color.js 29 Oct 2008 10:01:27 -0000 1.8 +++ modules/color/color.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: color.js,v 1.8 2008/10/29 10:01:27 dries Exp $ +(function($) { Drupal.behaviors.color = { attach: function(context) { @@ -251,3 +252,5 @@ preview(); } }; + +})(jQuery); Index: misc/batch.js =================================================================== RCS file: /cvs/drupal/drupal/misc/batch.js,v retrieving revision 1.5 diff -u -r1.5 batch.js --- misc/batch.js 29 Oct 2008 10:01:26 -0000 1.5 +++ misc/batch.js 16 Feb 2009 01:37:12 -0000 @@ -1,4 +1,5 @@ // $Id: batch.js,v 1.5 2008/10/29 10:01:26 dries Exp $ +(function($) { /** * Attaches the batch behavior to progress bars. @@ -38,3 +39,5 @@ }); } }; + +})(jQuery); Index: misc/collapse.js =================================================================== RCS file: /cvs/drupal/drupal/misc/collapse.js,v retrieving revision 1.18 diff -u -r1.18 collapse.js --- misc/collapse.js 29 Oct 2008 10:01:26 -0000 1.18 +++ misc/collapse.js 16 Feb 2009 01:37:12 -0000 @@ -1,4 +1,5 @@ // $Id: collapse.js,v 1.18 2008/10/29 10:01:26 dries Exp $ +(function($) { /** * Toggle the visibility of a fieldset using smooth animations @@ -77,3 +78,5 @@ }); } }; + +})(jQuery); Index: misc/tabledrag.js =================================================================== RCS file: /cvs/drupal/drupal/misc/tabledrag.js,v retrieving revision 1.22 diff -u -r1.22 tabledrag.js --- misc/tabledrag.js 30 Dec 2008 16:43:15 -0000 1.22 +++ misc/tabledrag.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: tabledrag.js,v 1.22 2008/12/30 16:43:15 dries Exp $ +(function($) { /** * Drag and drop table rows with field manipulation. @@ -321,7 +322,9 @@ 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}); + $(nextGroup.group).each(function () { + groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight; + }); nextGroupRow = $(nextGroup.group).filter(':last').get(0); self.rowObject.swap('after', nextGroupRow); // No need to check for indentation, 0 is the only valid one. @@ -957,7 +960,7 @@ } return {'min':minIndent, 'max':maxIndent}; -} +}; /** * Indent a row within the legal bounds of the table. @@ -1021,7 +1024,7 @@ // 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 = $('.indentation', checkRow).length; } if (!(this.indentEnabled) || (checkRowIndentation == rowIndentation)) { @@ -1096,3 +1099,5 @@ Drupal.theme.prototype.tableDragChangedWarning = function () { return '
' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t("Changes made in this table will not be saved until the form is submitted.") + '
'; }; + +})(jQuery); \ No newline at end of file Index: misc/progress.js =================================================================== RCS file: /cvs/drupal/drupal/misc/progress.js,v retrieving revision 1.21 diff -u -r1.21 progress.js --- misc/progress.js 12 Oct 2008 00:29:09 -0000 1.21 +++ misc/progress.js 16 Feb 2009 01:37:12 -0000 @@ -1,4 +1,5 @@ // $Id: progress.js,v 1.21 2008/10/12 00:29:09 webchick Exp $ +(function($) { /** * A progressbar object. Initialized with the given id. Must be inserted into @@ -105,3 +106,5 @@ this.errorCallback(this); } }; + +})(jQuery); Index: misc/teaser.js =================================================================== RCS file: /cvs/drupal/drupal/misc/teaser.js,v retrieving revision 1.14 diff -u -r1.14 teaser.js --- misc/teaser.js 29 Oct 2008 10:01:26 -0000 1.14 +++ misc/teaser.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: teaser.js,v 1.14 2008/10/29 10:01:26 dries Exp $ +(function($) { /** * Auto-attach for teaser behavior. @@ -96,3 +97,5 @@ }); } }; + +})(jQuery); Index: misc/ahah.js =================================================================== RCS file: /cvs/drupal/drupal/misc/ahah.js,v retrieving revision 1.9 diff -u -r1.9 ahah.js --- misc/ahah.js 29 Oct 2008 10:01:26 -0000 1.9 +++ misc/ahah.js 16 Feb 2009 01:37:12 -0000 @@ -1,4 +1,5 @@ // $Id: ahah.js,v 1.9 2008/10/29 10:01:26 dries Exp $ +(function($) { /** * Provides AJAX-like page updating via AHAH (Asynchronous HTML and HTTP). @@ -138,7 +139,7 @@ else if (this.progress.type == 'throbber') { this.progress.element = $('
 
'); if (this.progress.message) { - $('.throbber', this.progress.element).after('
' + this.progress.message + '
') + $('.throbber', this.progress.element).after('
' + this.progress.message + '
'); } $(this.element).after(this.progress.element); } @@ -225,3 +226,5 @@ // Re-enable the element. $(this.element).removeClass('progess-disabled').attr('disabled', false); }; + +})(jQuery); Index: misc/tableselect.js =================================================================== RCS file: /cvs/drupal/drupal/misc/tableselect.js,v retrieving revision 1.9 diff -u -r1.9 tableselect.js --- misc/tableselect.js 29 Oct 2008 10:01:26 -0000 1.9 +++ misc/tableselect.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: tableselect.js,v 1.9 2008/10/29 10:01:26 dries Exp $ +(function($) { Drupal.behaviors.tableSelect = { attach: function(context) { @@ -82,8 +83,10 @@ } } // A faster alternative to doing $(i).filter(to).length. - else if (jQuery.filter(to, [i]).r.length) { + else if ($.filter(to, [i]).r.length) { break; } } }; + +})(jQuery); Index: misc/autocomplete.js =================================================================== RCS file: /cvs/drupal/drupal/misc/autocomplete.js,v retrieving revision 1.25 diff -u -r1.25 autocomplete.js --- misc/autocomplete.js 29 Oct 2008 10:01:26 -0000 1.25 +++ misc/autocomplete.js 16 Feb 2009 01:37:12 -0000 @@ -1,4 +1,5 @@ // $Id: autocomplete.js,v 1.25 2008/10/29 10:01:26 dries Exp $ +(function($) { /** * Attaches the autocomplete behavior to all required fields. @@ -298,3 +299,5 @@ if (this.timer) clearTimeout(this.timer); this.searchString = ''; }; + +})(jQuery); Index: misc/tableheader.js =================================================================== RCS file: /cvs/drupal/drupal/misc/tableheader.js,v retrieving revision 1.20 diff -u -r1.20 tableheader.js --- misc/tableheader.js 30 Dec 2008 16:43:15 -0000 1.20 +++ misc/tableheader.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: tableheader.js,v 1.20 2008/12/30 16:43:15 dries Exp $ +(function($) { Drupal.tableHeaderDoScroll = function() { if (typeof(Drupal.tableHeaderOnScroll)=='function') { @@ -9,7 +10,7 @@ Drupal.behaviors.tableHeader = { attach: function(context) { // This breaks in anything less than IE 7. Prevent it from running. - if (jQuery.browser.msie && parseInt(jQuery.browser.version, 10) < 7) { + if ($.browser.msie && parseInt($.browser.version, 10) < 7) { return; } @@ -113,3 +114,5 @@ $(window).resize(resize); } }; + +})(jQuery); Index: misc/drupal.js =================================================================== RCS file: /cvs/drupal/drupal/misc/drupal.js,v retrieving revision 1.49 diff -u -r1.49 drupal.js --- misc/drupal.js 6 Jan 2009 13:16:09 -0000 1.49 +++ misc/drupal.js 16 Feb 2009 01:37:12 -0000 @@ -2,6 +2,19 @@ var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'locale': {} }; +// Allow other JavaScript libraries to use $. +jQuery.noConflict(); + +// Indicate when other scripts use $ with out wrapping their code. +if ($ === undefined) { + $ = function() { + alert("Please wrap your JavaScript code in (function($) { ... })(jQuery); to be compatible. See http://docs.jquery.com/Using_jQuery_with_Other_Libraries."); + }; +} + + +(function($) { + /** * Set the variable that indicates if JavaScript behaviors should be applied. */ @@ -42,8 +55,8 @@ Drupal.attachBehaviors = function(context) { context = context || document; // Execute all of them. - jQuery.each(Drupal.behaviors, function() { - if (jQuery.isFunction(this.attach)) { + $.each(Drupal.behaviors, function() { + if ($.isFunction(this.attach)) { this.attach(context); } }); @@ -71,8 +84,8 @@ Drupal.detachBehaviors = function(context) { context = context || document; // Execute all of them. - jQuery.each(Drupal.behaviors, function() { - if (jQuery.isFunction(this.detach)) { + $.each(Drupal.behaviors, function() { + if ($.isFunction(this.detach)) { this.detach(context); } }); @@ -286,7 +299,7 @@ */ Drupal.ahahError = function(xmlhttp, uri) { if (xmlhttp.status == 200) { - if (jQuery.trim(xmlhttp.responseText)) { + if ($.trim(xmlhttp.responseText)) { var message = Drupal.t("An error occurred. \n@uri\n@text", {'@uri': uri, '@text': xmlhttp.responseText }); } else { @@ -296,8 +309,8 @@ else { var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status }); } - return message.replace(/\n/g, '
');; -} + return message.replace(/\n/g, '
'); +}; // Global Killswitch on the element. if (Drupal.jsEnabled) { @@ -328,3 +341,5 @@ return '' + Drupal.checkPlain(str) + ''; } }; + +})(jQuery); Index: misc/form.js =================================================================== RCS file: /cvs/drupal/drupal/misc/form.js,v retrieving revision 1.2 diff -u -r1.2 form.js --- misc/form.js 29 Oct 2008 10:01:26 -0000 1.2 +++ misc/form.js 16 Feb 2009 01:37:12 -0000 @@ -1,4 +1,5 @@ // $Id: form.js,v 1.2 2008/10/29 10:01:26 dries Exp $ +(function($) { Drupal.behaviors.multiselectSelector = { attach: function(context) { @@ -10,3 +11,5 @@ }); } }; + +})(jQuery); Index: misc/timezone.js =================================================================== RCS file: /cvs/drupal/drupal/misc/timezone.js,v retrieving revision 1.2 diff -u -r1.2 timezone.js --- misc/timezone.js 26 Jan 2009 14:08:42 -0000 1.2 +++ misc/timezone.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: timezone.js,v 1.2 2009/01/26 14:08:42 dries Exp $ +(function($) { /** * Set the client's system time zone as default values of form fields. @@ -57,8 +58,10 @@ if (data) { $(element).val(data); } - }, + } }); }); } }; + +})(jQuery); Index: misc/textarea.js =================================================================== RCS file: /cvs/drupal/drupal/misc/textarea.js,v retrieving revision 1.25 diff -u -r1.25 textarea.js --- misc/textarea.js 20 Dec 2008 18:24:34 -0000 1.25 +++ misc/textarea.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: textarea.js,v 1.25 2008/12/20 18:24:34 dries Exp $ +(function($) { Drupal.behaviors.textarea = { attach: function(context) { @@ -36,3 +37,5 @@ }); } }; + +})(jQuery); Index: modules/openid/openid.js =================================================================== RCS file: /cvs/drupal/drupal/modules/openid/openid.js,v retrieving revision 1.7 diff -u -r1.7 openid.js --- modules/openid/openid.js 29 Oct 2008 10:01:27 -0000 1.7 +++ modules/openid/openid.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: openid.js,v 1.7 2008/10/29 10:01:27 dries Exp $ +(function($) { Drupal.behaviors.openid = { attach: function(context) { @@ -38,3 +39,5 @@ }); } }; + +})(jQuery); Index: modules/book/book.module =================================================================== RCS file: /cvs/drupal/drupal/modules/book/book.module,v retrieving revision 1.485 diff -u -r1.485 book.module --- modules/book/book.module 26 Jan 2009 14:08:42 -0000 1.485 +++ modules/book/book.module 16 Feb 2009 01:37:13 -0000 @@ -415,7 +415,7 @@ function _book_add_form_elements(&$form, $node) { // Need this for AJAX. $form['#cache'] = TRUE; - drupal_add_js("if (Drupal.jsEnabled) { $(document).ready(function() { $('#edit-book-pick-book').css('display', 'none'); }); }", 'inline'); + drupal_add_js("if (Drupal.jsEnabled) { jQuery(function() { jQuery('#edit-book-pick-book').css('display', 'none'); }); }", 'inline'); $form['book'] = array( '#type' => 'fieldset', Index: includes/common.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/common.inc,v retrieving revision 1.867 diff -u -r1.867 common.inc --- includes/common.inc 13 Feb 2009 04:43:00 -0000 1.867 +++ includes/common.inc 16 Feb 2009 01:37:12 -0000 @@ -2334,6 +2334,8 @@ * directly in the page. This can, for example, be useful to tell the user that * a new message arrived, by opening a pop up, alert box etc. This should only * be used for JavaScript which cannot be placed and executed from a file. + * When adding inline code, make sure that you are not relying on $ being jQuery. + * Wrap your code in (function($) { ... })(jQuery); or use jQuery instead of $. * * - Add settings ('setting'): * Adds a setting to Drupal's global storage of JavaScript settings. Per-page @@ -2344,8 +2346,8 @@ * @code * drupal_add_js('misc/collapse.js'); * drupal_add_js('misc/collapse.js', 'file'); - * drupal_add_js('$(document).ready(function(){alert("Hello!");});', 'inline'); - * drupal_add_js('$(document).ready(function(){alert("Hello!");});', + * drupal_add_js('jQuery(document).ready(function(){alert("Hello!");});', 'inline'); + * drupal_add_js('jQuery(document).ready(function(){alert("Hello!");});', * array('type' => 'inline', 'scope' => 'footer', 'weight' => 5) * ); * @endcode Index: modules/comment/comment.js =================================================================== RCS file: /cvs/drupal/drupal/modules/comment/comment.js,v retrieving revision 1.7 diff -u -r1.7 comment.js --- modules/comment/comment.js 29 Oct 2008 10:01:27 -0000 1.7 +++ modules/comment/comment.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: comment.js,v 1.7 2008/10/29 10:01:27 dries Exp $ +(function($) { Drupal.behaviors.comment = { attach: function(context) { @@ -35,3 +36,5 @@ return returnValue; }; + +})(jQuery); Index: misc/farbtastic/farbtastic.js =================================================================== RCS file: /cvs/drupal/drupal/misc/farbtastic/farbtastic.js,v retrieving revision 1.6 diff -u -r1.6 farbtastic.js --- misc/farbtastic/farbtastic.js 22 Oct 2008 18:27:51 -0000 1.6 +++ misc/farbtastic/farbtastic.js 16 Feb 2009 01:37:13 -0000 @@ -1,17 +1,18 @@ // $Id: farbtastic.js,v 1.6 2008/10/22 18:27:51 dries Exp $ // Farbtastic 1.2 +(function($) { -jQuery.fn.farbtastic = function (callback) { +$.farbtastic = function (callback) { $.farbtastic(this, callback); return this; }; -jQuery.farbtastic = function (container, callback) { +$.farbtastic = function (container, callback) { var container = $(container).get(0); - return container.farbtastic || (container.farbtastic = new jQuery._farbtastic(container, callback)); + return container.farbtastic || (container.farbtastic = new $._farbtastic(container, callback)); }; -jQuery._farbtastic = function (container, callback) { +$._farbtastic = function (container, callback) { // Store farbtastic object var fb = this; @@ -266,4 +267,6 @@ if (callback) { fb.linkTo(callback); } -}; \ No newline at end of file +}; + +})(jQuery); Index: install.php =================================================================== RCS file: /cvs/drupal/drupal/install.php,v retrieving revision 1.154 diff -u -r1.154 install.php --- install.php 10 Feb 2009 05:43:06 -0000 1.154 +++ install.php 16 Feb 2009 01:37:10 -0000 @@ -731,7 +731,7 @@ drupal_add_js(' // Global Killswitch if (Drupal.jsEnabled) { - $(document).ready(function() { + jQuery(document).ready(function() { Drupal.cleanURLsInstallCheck(); }); }', 'inline'); Index: modules/simpletest/simpletest.js =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/simpletest.js,v retrieving revision 1.7 diff -u -r1.7 simpletest.js --- modules/simpletest/simpletest.js 19 Jan 2009 10:15:54 -0000 1.7 +++ modules/simpletest/simpletest.js 16 Feb 2009 01:37:13 -0000 @@ -1,4 +1,5 @@ // $Id: simpletest.js,v 1.7 2009/01/19 10:15:54 dries Exp $ +(function($) { /** * Add the cool table collapsing on the testing overview page. @@ -76,7 +77,7 @@ }); } $(groupCheckbox).attr('checked', (checkedTests == testCheckboxes.length)); - } + }; // Have the single-test checkboxes follow the group checkbox. groupCheckbox.change(function() { @@ -99,3 +100,5 @@ }); } }; + +})(jQuery); Index: modules/system/system.js =================================================================== RCS file: /cvs/drupal/drupal/modules/system/system.js,v retrieving revision 1.18 diff -u -r1.18 system.js --- modules/system/system.js 22 Nov 2008 11:54:40 -0000 1.18 +++ modules/system/system.js 16 Feb 2009 01:37:14 -0000 @@ -1,4 +1,5 @@ // $Id: system.js,v 1.18 2008/11/22 11:54:40 dries Exp $ +(function($) { /** * Internal function to check using Ajax if clean URLs can be enabled on the @@ -80,7 +81,7 @@ for (var sourceId in Drupal.settings.copyFieldValue) { // Get the list of target fields. targetIds = Drupal.settings.copyFieldValue[sourceId]; - if (!$('#'+ sourceId + '.copy-field-values-processed').size(), context) { + if (!$('#'+ sourceId + '.copy-field-values-processed', context).size()) { // Add the behavior to update target fields on blur of the primary field. sourceField = $('#' + sourceId); sourceField.bind('blur', function() { @@ -131,4 +132,6 @@ $('img.powered-by-preview').attr('src', path); }); } -}; \ No newline at end of file +}; + +})(jQuery); \ No newline at end of file Index: modules/simpletest/tests/common.test =================================================================== RCS file: /cvs/drupal/drupal/modules/simpletest/tests/common.test,v retrieving revision 1.28 diff -u -r1.28 common.test --- modules/simpletest/tests/common.test 13 Feb 2009 04:43:00 -0000 1.28 +++ modules/simpletest/tests/common.test 16 Feb 2009 01:37:14 -0000 @@ -445,7 +445,7 @@ * Test adding inline scripts. */ function testAddInline() { - $inline = '$(document).ready(function(){});'; + $inline = 'jQuery(function(){});'; $javascript = drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer')); $this->assertTrue(array_key_exists('misc/jquery.js', $javascript), t('jQuery is added when inline scripts are added.')); $data = end($javascript); @@ -456,7 +456,7 @@ * Test drupal_get_js() with a footer scope. */ function testFooterHTML() { - $inline = '$(document).ready(function(){});'; + $inline = 'jQuery(function(){});'; drupal_add_js($inline, array('type' => 'inline', 'scope' => 'footer')); $javascript = drupal_get_js('footer'); $this->assertTrue(strpos($javascript, $inline) > 0, t('Rendered JavaScript footer returns the inline code.')); Index: modules/user/user.js =================================================================== RCS file: /cvs/drupal/drupal/modules/user/user.js,v retrieving revision 1.9 diff -u -r1.9 user.js --- modules/user/user.js 20 Nov 2008 06:56:17 -0000 1.9 +++ modules/user/user.js 16 Feb 2009 01:37:14 -0000 @@ -1,4 +1,5 @@ // $Id: user.js,v 1.9 2008/11/20 06:56:17 webchick Exp $ +(function($) { /** * Attach handlers to evaluate the strength of any password fields and to check @@ -76,7 +77,7 @@ else { confirmResult.css({ visibility: "hidden" }); } - } + }; // Monitor keyup and blur events. // Blur must be used because a mouse paste does not trigger keyup. @@ -171,3 +172,5 @@ }); } }; + +})(jQuery); Index: modules/taxonomy/taxonomy.js =================================================================== RCS file: /cvs/drupal/drupal/modules/taxonomy/taxonomy.js,v retrieving revision 1.3 diff -u -r1.3 taxonomy.js --- modules/taxonomy/taxonomy.js 29 Oct 2008 10:01:27 -0000 1.3 +++ modules/taxonomy/taxonomy.js 16 Feb 2009 01:37:14 -0000 @@ -1,4 +1,5 @@ // $Id: taxonomy.js,v 1.3 2008/10/29 10:01:27 dries Exp $ +(function($) { /** * Move a block in the blocks table from one region to another via select list. @@ -36,3 +37,5 @@ }; } }; + +})(jQuery); Index: modules/node/content_types.js =================================================================== RCS file: /cvs/drupal/drupal/modules/node/content_types.js,v retrieving revision 1.1 diff -u -r1.1 content_types.js --- modules/node/content_types.js 16 Nov 2008 19:51:15 -0000 1.1 +++ modules/node/content_types.js 16 Feb 2009 01:37:13 -0000 @@ -1,3 +1,6 @@ +// $Id$ +(function($) { + Drupal.behaviors.contentTypes = { attach: function() { if ($('#edit-type').val() == $('#edit-name').val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_') || $('#edit-type').val() == '') { @@ -22,3 +25,5 @@ } } }; + +})(jQuery);