diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-27 20:19:38 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-27 20:19:38 +0000 |
commit | fc7283235bb9e5ae4300714d03c0bf3723f4792b (patch) | |
tree | 0dc443ba5dc1f74fbfc5ad5762c7c7a556232b73 /misc/drupal.js | |
parent | 031ba7d66533b3bb6e1ceb1cc834e9af9b1a3c71 (diff) | |
download | brdo-fc7283235bb9e5ae4300714d03c0bf3723f4792b.tar.gz brdo-fc7283235bb9e5ae4300714d03c0bf3723f4792b.tar.bz2 |
#444402 follow-up by kkaefer: Fix autocomplete, enforce code style for anonymous JS functions.
Diffstat (limited to 'misc/drupal.js')
-rw-r--r-- | misc/drupal.js | 42 |
1 files changed, 21 insertions, 21 deletions
diff --git a/misc/drupal.js b/misc/drupal.js index d83bb8a30..cb650ac65 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -7,13 +7,13 @@ 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 () { + alert('Please wrap your JavaScript code in (function ($) { ... })(jQuery); to be compatible. See http://docs.jquery.com/Using_jQuery_with_Other_Libraries.'); }; } -(function($) { +(function ($) { /** * Attach all registered behaviors to a page element. @@ -23,10 +23,10 @@ if ($ === undefined) { * object using the method 'attach' and optionally also 'detach' as follows: * @code * Drupal.behaviors.behaviorName = { - * attach: function(context) { + * attach: function (context) { * ... * }, - * detach: function(context) { + * detach: function (context) { * ... * } * }; @@ -50,11 +50,11 @@ if ($ === undefined) { * An object containing settings for the current context. If none given, the * global Drupal.settings object is used. */ -Drupal.attachBehaviors = function(context, settings) { +Drupal.attachBehaviors = function (context, settings) { context = context || document; settings = settings || Drupal.settings; // Execute all of them. - $.each(Drupal.behaviors, function() { + $.each(Drupal.behaviors, function () { if ($.isFunction(this.attach)) { this.attach(context, settings); } @@ -80,11 +80,11 @@ Drupal.attachBehaviors = function(context, settings) { * * @see Drupal.attachBehaviors */ -Drupal.detachBehaviors = function(context, settings) { +Drupal.detachBehaviors = function (context, settings) { context = context || document; settings = settings || Drupal.settings; // Execute all of them. - $.each(Drupal.behaviors, function() { + $.each(Drupal.behaviors, function () { if ($.isFunction(this.detach)) { this.detach(context, settings); } @@ -94,7 +94,7 @@ Drupal.detachBehaviors = function(context, settings) { /** * Encode special characters in a plain-text string for display as HTML. */ -Drupal.checkPlain = function(str) { +Drupal.checkPlain = function (str) { str = String(str); var replace = { '&': '&', '"': '"', '<': '<', '>': '>' }; for (var character in replace) { @@ -122,7 +122,7 @@ Drupal.checkPlain = function(str) { * @return * The translated string. */ -Drupal.t = function(str, args) { +Drupal.t = function (str, args) { // Fetch the localized version of the string. if (Drupal.locale.strings && Drupal.locale.strings[str]) { str = Drupal.locale.strings[str]; @@ -182,7 +182,7 @@ Drupal.t = function(str, args) { * @return * A translated string. */ -Drupal.formatPlural = function(count, singular, plural, args) { +Drupal.formatPlural = function (count, singular, plural, args) { var args = args || {}; args['@count'] = count; // Determine the index of the plural form. @@ -220,7 +220,7 @@ Drupal.formatPlural = function(count, singular, plural, args) { * Any data the theme function returns. This could be a plain HTML string, * but also a complex object. */ -Drupal.theme = function(func) { +Drupal.theme = function (func) { for (var i = 1, args = []; i < arguments.length; i++) { args.push(arguments[i]); } @@ -233,7 +233,7 @@ Drupal.theme = function(func) { * * The result is either the JSON object, or an object with 'status' 0 and 'data' an error message. */ -Drupal.parseJson = function(data) { +Drupal.parseJson = function (data) { if ((data.substring(0, 1) != '{') && (data.substring(0, 1) != '[')) { return { status: 0, data: data.length ? data : Drupal.t('Unspecified error') }; } @@ -244,7 +244,7 @@ Drupal.parseJson = function(data) { * Freeze the current body height (as minimum height). Used to prevent * unnecessary upwards scrolling when doing DOM manipulations. */ -Drupal.freezeHeight = function() { +Drupal.freezeHeight = function () { Drupal.unfreezeHeight(); $('<div id="freeze-height"></div>').css({ position: 'absolute', @@ -258,7 +258,7 @@ Drupal.freezeHeight = function() { /** * Unfreeze the body height. */ -Drupal.unfreezeHeight = function() { +Drupal.unfreezeHeight = function () { $('#freeze-height').remove(); }; @@ -266,7 +266,7 @@ Drupal.unfreezeHeight = function() { * Wrapper to address the mod_rewrite url encoding bug * (equivalent of drupal_urlencode() in PHP). */ -Drupal.encodeURIComponent = function(item, uri) { +Drupal.encodeURIComponent = function (item, uri) { uri = uri || location.href; item = encodeURIComponent(item).replace(/%2F/g, '/'); return (uri.indexOf('?q=') != -1) ? item : item.replace(/%26/g, '%2526').replace(/%23/g, '%2523').replace(/\/\//g, '/%252F'); @@ -275,7 +275,7 @@ Drupal.encodeURIComponent = function(item, uri) { /** * Get the text selection in a textarea. */ -Drupal.getSelection = function(element) { +Drupal.getSelection = function (element) { if (typeof element.selectionStart != 'number' && document.selection) { // The current selection. var range1 = document.selection.createRange(); @@ -295,7 +295,7 @@ Drupal.getSelection = function(element) { /** * Build an error message from ahah response. */ -Drupal.ahahError = function(xmlhttp, uri) { +Drupal.ahahError = function (xmlhttp, uri) { if (xmlhttp.status == 200) { if ($.trim(xmlhttp.responseText)) { var message = Drupal.t('An error occurred. \n@uri\n@text', { '@uri': uri, '@text': xmlhttp.responseText }); @@ -317,7 +317,7 @@ $('html').addClass('js'); document.cookie = 'has_js=1; path=/'; // Attach all behaviors. -$(function() { +$(function () { Drupal.attachBehaviors(document, Drupal.settings); }); @@ -334,7 +334,7 @@ Drupal.theme.prototype = { * @return * The formatted text (html). */ - placeholder: function(str) { + placeholder: function (str) { return '<em>' + Drupal.checkPlain(str) + '</em>'; } }; |