diff options
Diffstat (limited to 'misc')
-rw-r--r-- | misc/ahah.js | 5 | ||||
-rw-r--r-- | misc/autocomplete.js | 3 | ||||
-rw-r--r-- | misc/batch.js | 3 | ||||
-rw-r--r-- | misc/collapse.js | 3 | ||||
-rw-r--r-- | misc/drupal.js | 29 | ||||
-rw-r--r-- | misc/farbtastic/farbtastic.js | 13 | ||||
-rw-r--r-- | misc/form.js | 3 | ||||
-rw-r--r-- | misc/progress.js | 3 | ||||
-rw-r--r-- | misc/tabledrag.js | 11 | ||||
-rw-r--r-- | misc/tableheader.js | 5 | ||||
-rw-r--r-- | misc/tableselect.js | 5 | ||||
-rw-r--r-- | misc/teaser.js | 3 | ||||
-rw-r--r-- | misc/textarea.js | 3 | ||||
-rw-r--r-- | misc/timezone.js | 5 |
14 files changed, 75 insertions, 19 deletions
diff --git a/misc/ahah.js b/misc/ahah.js index ca5580a46..e2469fe37 100644 --- a/misc/ahah.js +++ b/misc/ahah.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * Provides AJAX-like page updating via AHAH (Asynchronous HTML and HTTP). @@ -138,7 +139,7 @@ Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) { else if (this.progress.type == 'throbber') { this.progress.element = $('<div class="ahah-progress ahah-progress-throbber"><div class="throbber"> </div></div>'); if (this.progress.message) { - $('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>') + $('.throbber', this.progress.element).after('<div class="message">' + this.progress.message + '</div>'); } $(this.element).after(this.progress.element); } @@ -225,3 +226,5 @@ Drupal.ahah.prototype.error = function (response, uri) { // Re-enable the element. $(this.element).removeClass('progess-disabled').attr('disabled', false); }; + +})(jQuery); diff --git a/misc/autocomplete.js b/misc/autocomplete.js index da76380c4..48253c70f 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * Attaches the autocomplete behavior to all required fields. @@ -298,3 +299,5 @@ Drupal.ACDB.prototype.cancel = function() { if (this.timer) clearTimeout(this.timer); this.searchString = ''; }; + +})(jQuery); diff --git a/misc/batch.js b/misc/batch.js index 4d1a4d551..17c4caae9 100644 --- a/misc/batch.js +++ b/misc/batch.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * Attaches the batch behavior to progress bars. @@ -38,3 +39,5 @@ Drupal.behaviors.batch = { }); } }; + +})(jQuery); diff --git a/misc/collapse.js b/misc/collapse.js index 4626b4519..7da7e16b1 100644 --- a/misc/collapse.js +++ b/misc/collapse.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * Toggle the visibility of a fieldset using smooth animations @@ -77,3 +78,5 @@ Drupal.behaviors.collapse = { }); } }; + +})(jQuery); diff --git a/misc/drupal.js b/misc/drupal.js index 9d5941f36..9b99a1d2e 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -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.jsEnabled = document.getElementsByTagName && document.createElement && do 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.attachBehaviors = function(context) { 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.getSelection = function (element) { */ 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 @@ Drupal.ahahError = function(xmlhttp, uri) { else { var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status }); } - return message.replace(/\n/g, '<br />');; -} + return message.replace(/\n/g, '<br />'); +}; // Global Killswitch on the <html> element. if (Drupal.jsEnabled) { @@ -328,3 +341,5 @@ Drupal.theme.prototype = { return '<em>' + Drupal.checkPlain(str) + '</em>'; } }; + +})(jQuery); diff --git a/misc/farbtastic/farbtastic.js b/misc/farbtastic/farbtastic.js index 028b00b36..18b083eab 100644 --- a/misc/farbtastic/farbtastic.js +++ b/misc/farbtastic/farbtastic.js @@ -1,17 +1,18 @@ // $Id$ // 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 @@ jQuery._farbtastic = function (container, callback) { if (callback) { fb.linkTo(callback); } -};
\ No newline at end of file +}; + +})(jQuery); diff --git a/misc/form.js b/misc/form.js index d3a9f692f..8631ed68c 100644 --- a/misc/form.js +++ b/misc/form.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { Drupal.behaviors.multiselectSelector = { attach: function(context) { @@ -10,3 +11,5 @@ Drupal.behaviors.multiselectSelector = { }); } }; + +})(jQuery); diff --git a/misc/progress.js b/misc/progress.js index 631a5f4f8..b0fad1573 100644 --- a/misc/progress.js +++ b/misc/progress.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * A progressbar object. Initialized with the given id. Must be inserted into @@ -105,3 +106,5 @@ Drupal.progressBar.prototype.displayError = function (string) { this.errorCallback(this); } }; + +})(jQuery); diff --git a/misc/tabledrag.js b/misc/tabledrag.js index 3fce73041..aea64d617 100644 --- a/misc/tabledrag.js +++ b/misc/tabledrag.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * Drag and drop table rows with field manipulation. @@ -321,7 +322,9 @@ Drupal.tableDrag.prototype.makeDraggable = function(item) { 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 @@ Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow } return {'min':minIndent, 'max':maxIndent}; -} +}; /** * Indent a row within the legal bounds of the table. @@ -1021,7 +1024,7 @@ Drupal.tableDrag.prototype.row.prototype.findSiblings = function(rowSettings) { // 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.tableDragIndentation = function () { Drupal.theme.prototype.tableDragChangedWarning = function () { return '<div class="warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t("Changes made in this table will not be saved until the form is submitted.") + '</div>'; }; + +})(jQuery);
\ No newline at end of file diff --git a/misc/tableheader.js b/misc/tableheader.js index dbb8873ea..1c8c9bf1c 100644 --- a/misc/tableheader.js +++ b/misc/tableheader.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { Drupal.tableHeaderDoScroll = function() { if (typeof(Drupal.tableHeaderOnScroll)=='function') { @@ -9,7 +10,7 @@ Drupal.tableHeaderDoScroll = function() { 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 @@ Drupal.behaviors.tableHeader = { $(window).resize(resize); } }; + +})(jQuery); diff --git a/misc/tableselect.js b/misc/tableselect.js index 36a209f3c..152e93fb4 100644 --- a/misc/tableselect.js +++ b/misc/tableselect.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { Drupal.behaviors.tableSelect = { attach: function(context) { @@ -82,8 +83,10 @@ Drupal.tableSelectRange = function(from, to, state) { } } // 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); diff --git a/misc/teaser.js b/misc/teaser.js index e303aa963..af50803d4 100644 --- a/misc/teaser.js +++ b/misc/teaser.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * Auto-attach for teaser behavior. @@ -96,3 +97,5 @@ Drupal.behaviors.teaser = { }); } }; + +})(jQuery); diff --git a/misc/textarea.js b/misc/textarea.js index 246ca1571..68e696b2d 100644 --- a/misc/textarea.js +++ b/misc/textarea.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { Drupal.behaviors.textarea = { attach: function(context) { @@ -36,3 +37,5 @@ Drupal.behaviors.textarea = { }); } }; + +})(jQuery); diff --git a/misc/timezone.js b/misc/timezone.js index 7cd4cdde9..db7c4560a 100644 --- a/misc/timezone.js +++ b/misc/timezone.js @@ -1,4 +1,5 @@ // $Id$ +(function($) { /** * Set the client's system time zone as default values of form fields. @@ -57,8 +58,10 @@ Drupal.behaviors.setTimezone = { if (data) { $(element).val(data); } - }, + } }); }); } }; + +})(jQuery); |