diff options
author | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-26 19:18:46 +0000 |
---|---|---|
committer | Angie Byron <webchick@24967.no-reply.drupal.org> | 2009-04-26 19:18:46 +0000 |
commit | bda52632a5aa033d44151c224a39236b223c6b0e (patch) | |
tree | da56b8095f58963707655312071d41de95adca84 | |
parent | a4dc8467bbe69ba984be31309f536af74dc64e73 (diff) | |
download | brdo-bda52632a5aa033d44151c224a39236b223c6b0e.tar.gz brdo-bda52632a5aa033d44151c224a39236b223c6b0e.tar.bz2 |
#444402 by kkaefer and RobLoach: Enforce coding standards on all core JavaScript.
-rw-r--r-- | misc/ahah.js | 18 | ||||
-rw-r--r-- | misc/autocomplete.js | 78 | ||||
-rw-r--r-- | misc/batch.js | 26 | ||||
-rw-r--r-- | misc/collapse.js | 10 | ||||
-rw-r--r-- | misc/drupal.js | 30 | ||||
-rw-r--r-- | misc/form.js | 6 | ||||
-rw-r--r-- | misc/progress.js | 37 | ||||
-rw-r--r-- | misc/tabledrag.js | 56 | ||||
-rw-r--r-- | misc/tableheader.js | 18 | ||||
-rw-r--r-- | misc/teaser.js | 8 | ||||
-rw-r--r-- | misc/textarea.js | 4 | ||||
-rw-r--r-- | misc/timezone.js | 2 | ||||
-rw-r--r-- | misc/vertical-tabs.js | 2 | ||||
-rw-r--r-- | modules/block/block.js | 6 | ||||
-rw-r--r-- | modules/color/color.js | 16 | ||||
-rw-r--r-- | modules/comment/comment.js | 12 | ||||
-rw-r--r-- | modules/node/content_types.js | 2 | ||||
-rw-r--r-- | modules/openid/openid.js | 40 | ||||
-rw-r--r-- | modules/profile/profile.js | 2 | ||||
-rw-r--r-- | modules/simpletest/simpletest.js | 2 | ||||
-rw-r--r-- | modules/system/system.js | 40 | ||||
-rw-r--r-- | modules/user/user.js | 44 |
22 files changed, 221 insertions, 238 deletions
diff --git a/misc/ahah.js b/misc/ahah.js index ebfdffb75..019680f42 100644 --- a/misc/ahah.js +++ b/misc/ahah.js @@ -19,7 +19,7 @@ Drupal.behaviors.ahah = { attach: function(context, settings) { for (var base in settings.ahah) { - if (!$('#'+ base + '.ahah-processed').size()) { + if (!$('#' + base + '.ahah-processed').size()) { var element_settings = settings.ahah[base]; $(element_settings.selector).each(function() { @@ -27,7 +27,7 @@ Drupal.behaviors.ahah = { var ahah = new Drupal.ahah(base, element_settings); }); - $('#'+ base).addClass('ahah-processed'); + $('#' + base).addClass('ahah-processed'); } } } @@ -43,7 +43,7 @@ Drupal.ahah = function(base, element_settings) { this.event = element_settings.event; this.keypress = element_settings.keypress; this.url = element_settings.url; - this.wrapper = '#'+ element_settings.wrapper; + this.wrapper = '#' + element_settings.wrapper; this.effect = element_settings.effect; this.method = element_settings.method; this.progress = element_settings.progress; @@ -83,7 +83,7 @@ Drupal.ahah = function(base, element_settings) { success: function(response, status) { // Sanity check for browser support (object expected). // When using iFrame uploads, responses must be returned as a string. - if (typeof(response) == 'string') { + if (typeof response == 'string') { response = Drupal.parseJson(response); } return ahah.success(response, status); @@ -119,7 +119,7 @@ Drupal.ahah = function(base, element_settings) { /** * Handler for the form redirection submission. */ -Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) { +Drupal.ahah.prototype.beforeSubmit = function(form_values, element, options) { // Disable the element that received the change. $(this.element).addClass('progress-disabled').attr('disabled', true); @@ -148,7 +148,7 @@ Drupal.ahah.prototype.beforeSubmit = function (form_values, element, options) { /** * Handler for the form redirection completion. */ -Drupal.ahah.prototype.success = function (response, status) { +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 @@ -188,7 +188,7 @@ Drupal.ahah.prototype.success = function (response, status) { if ($('.ahah-new-content', new_content).size() > 0) { $('.ahah-new-content', new_content).hide(); new_content.show(); - $(".ahah-new-content", new_content)[this.showEffect](this.showSpeed); + $('.ahah-new-content', new_content)[this.showEffect](this.showSpeed); } else if (this.showEffect != 'show') { new_content[this.showEffect](this.showSpeed); @@ -206,10 +206,10 @@ Drupal.ahah.prototype.success = function (response, status) { /** * Handler for the form redirection error. */ -Drupal.ahah.prototype.error = function (response, uri) { +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} ); + $(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(); diff --git a/misc/autocomplete.js b/misc/autocomplete.js index 920865b4b..85469cc95 100644 --- a/misc/autocomplete.js +++ b/misc/autocomplete.js @@ -7,7 +7,7 @@ Drupal.behaviors.autocomplete = { attach: function(context, settings) { var acdb = []; - $('input.autocomplete:not(.autocomplete-processed)', context).each(function () { + $('input.autocomplete:not(.autocomplete-processed)', context).each(function() { var uri = this.value; if (!acdb[uri]) { acdb[uri] = new Drupal.ACDB(uri); @@ -25,8 +25,8 @@ Drupal.behaviors.autocomplete = { * Prevents the form from submitting if the suggestions popup is open * and closes the suggestions popup when doing so. */ -Drupal.autocompleteSubmit = function () { - return $('#autocomplete').each(function () { +Drupal.autocompleteSubmit = function() { + return $('#autocomplete').each(function() { this.owner.hidePopup(); }).size() == 0; }; @@ -34,22 +34,22 @@ Drupal.autocompleteSubmit = function () { /** * An AutoComplete object. */ -Drupal.jsAC = function (input, db) { +Drupal.jsAC = function(input, db) { var ac = this; this.input = input; this.db = db; $(this.input) - .keydown(function (event) { return ac.onkeydown(this, event); }) - .keyup(function (event) { ac.onkeyup(this, event); }) - .blur(function () { ac.hidePopup(); ac.db.cancel(); }); + .keydown(function(event) { return ac.onkeydown(this, event); }) + .keyup(function(event) { ac.onkeyup(this, event); }) + .blur(function() { ac.hidePopup(); ac.db.cancel(); }); }; /** * Handler for the "keydown" event. */ -Drupal.jsAC.prototype.onkeydown = function (input, e) { +Drupal.jsAC.prototype.onkeydown = function(input, e) { if (!e) { e = window.event; } @@ -68,7 +68,7 @@ Drupal.jsAC.prototype.onkeydown = function (input, e) { /** * Handler for the "keyup" event. */ -Drupal.jsAC.prototype.onkeyup = function (input, e) { +Drupal.jsAC.prototype.onkeyup = function(input, e) { if (!e) { e = window.event; } @@ -105,14 +105,14 @@ Drupal.jsAC.prototype.onkeyup = function (input, e) { /** * Puts the currently highlighted suggestion into the autocomplete field. */ -Drupal.jsAC.prototype.select = function (node) { +Drupal.jsAC.prototype.select = function(node) { this.input.value = node.autocompleteValue; }; /** * Highlights the next suggestion. */ -Drupal.jsAC.prototype.selectDown = function () { +Drupal.jsAC.prototype.selectDown = function() { if (this.selected && this.selected.nextSibling) { this.highlight(this.selected.nextSibling); } @@ -127,7 +127,7 @@ Drupal.jsAC.prototype.selectDown = function () { /** * Highlights the previous suggestion. */ -Drupal.jsAC.prototype.selectUp = function () { +Drupal.jsAC.prototype.selectUp = function() { if (this.selected && this.selected.previousSibling) { this.highlight(this.selected.previousSibling); } @@ -136,7 +136,7 @@ Drupal.jsAC.prototype.selectUp = function () { /** * Highlights a suggestion. */ -Drupal.jsAC.prototype.highlight = function (node) { +Drupal.jsAC.prototype.highlight = function(node) { if (this.selected) { $(this.selected).removeClass('selected'); } @@ -147,7 +147,7 @@ Drupal.jsAC.prototype.highlight = function (node) { /** * Unhighlights a suggestion. */ -Drupal.jsAC.prototype.unhighlight = function (node) { +Drupal.jsAC.prototype.unhighlight = function(node) { $(node).removeClass('selected'); this.selected = false; }; @@ -155,7 +155,7 @@ Drupal.jsAC.prototype.unhighlight = function (node) { /** * Hides the autocomplete suggestions. */ -Drupal.jsAC.prototype.hidePopup = function (keycode) { +Drupal.jsAC.prototype.hidePopup = function(keycode) { // Select item if the right key or mousebutton was pressed. if (this.selected && ((keycode && keycode != 46 && keycode != 8 && keycode != 27) || !keycode)) { this.input.value = this.selected.autocompleteValue; @@ -172,18 +172,17 @@ Drupal.jsAC.prototype.hidePopup = function (keycode) { /** * Positions the suggestions popup and starts a search. */ -Drupal.jsAC.prototype.populatePopup = function () { +Drupal.jsAC.prototype.populatePopup = function() { // Show popup. if (this.popup) { $(this.popup).remove(); } this.selected = false; - this.popup = document.createElement('div'); - this.popup.id = 'autocomplete'; + this.popup = $('<div id="autocomplete"></div>')[0]; this.popup.owner = this; $(this.popup).css({ - marginTop: this.input.offsetHeight +'px', - width: (this.input.offsetWidth - 4) +'px', + marginTop: this.input.offsetHeight + 'px', + width: (this.input.offsetWidth - 4) + 'px', display: 'none' }); $(this.input).before(this.popup); @@ -196,39 +195,38 @@ Drupal.jsAC.prototype.populatePopup = function () { /** * Fills the suggestion popup with any matches received. */ -Drupal.jsAC.prototype.found = function (matches) { +Drupal.jsAC.prototype.found = function(matches) { // If no value in the textfield, do not show the popup. if (!this.input.value.length) { return false; } // Prepare matches. - var ul = document.createElement('ul'); + var ul = $('<ul></ul>'); var ac = this; for (key in matches) { - var li = document.createElement('li'); - $(li) - .html('<div>'+ matches[key] +'</div>') - .mousedown(function () { ac.select(this); }) - .mouseover(function () { ac.highlight(this); }) - .mouseout(function () { ac.unhighlight(this); }); - li.autocompleteValue = key; - $(ul).append(li); + $('<li></li>') + .html($('<div></div>').html(matches[key])) + .mousedown(function() { ac.select(this); }) + .mouseover(function() { ac.highlight(this); }) + .mouseout(function() { ac.unhighlight(this); }) + .attr('autocompleteValue', key) + .appendTo(ul); } // Show popup with matches, if any. if (this.popup) { - if (ul.childNodes.length > 0) { + if (ul.children().size()) { $(this.popup).empty().append(ul).show(); } else { - $(this.popup).css({visibility: 'hidden'}); + $(this.popup).css({ visibility: 'hidden' }); this.hidePopup(); } } }; -Drupal.jsAC.prototype.setStatus = function (status) { +Drupal.jsAC.prototype.setStatus = function(status) { switch (status) { case 'begin': $(this.input).addClass('throbbing'); @@ -244,7 +242,7 @@ Drupal.jsAC.prototype.setStatus = function (status) { /** * An AutoComplete DataBase object. */ -Drupal.ACDB = function (uri) { +Drupal.ACDB = function(uri) { this.uri = uri; this.delay = 300; this.cache = {}; @@ -253,7 +251,7 @@ Drupal.ACDB = function (uri) { /** * Performs a cached and delayed search. */ -Drupal.ACDB.prototype.search = function (searchString) { +Drupal.ACDB.prototype.search = function(searchString) { var db = this; this.searchString = searchString; @@ -271,11 +269,11 @@ Drupal.ACDB.prototype.search = function (searchString) { // Ajax GET request for autocompletion. $.ajax({ - type: "GET", - url: db.uri +'/'+ Drupal.encodeURIComponent(searchString), + type: 'GET', + url: db.uri + '/' + Drupal.encodeURIComponent(searchString), dataType: 'json', - success: function (matches) { - if (typeof matches['status'] == 'undefined' || matches['status'] != 0) { + success: function(matches) { + if (typeof matches.status == 'undefined' || matches.status != 0) { db.cache[searchString] = matches; // Verify if these are still the matches the user wants to see. if (db.searchString == searchString) { @@ -284,7 +282,7 @@ Drupal.ACDB.prototype.search = function (searchString) { db.owner.setStatus('found'); } }, - error: function (xmlhttp) { + error: function(xmlhttp) { alert(Drupal.ahahError(xmlhttp, db.uri)); } }); diff --git a/misc/batch.js b/misc/batch.js index b603a2ffc..fc334617d 100644 --- a/misc/batch.js +++ b/misc/batch.js @@ -10,32 +10,26 @@ Drupal.behaviors.batch = { if ($('#progress.batch-processed').size()) { return; } - $('#progress', context).addClass('batch-processed').each(function () { - var holder = this; - var uri = settings.batch.uri; - var initMessage = settings.batch.initMessage; - var errorMessage = settings.batch.errorMessage; + $('#progress', context).addClass('batch-processed').each(function() { + var holder = $(this); // Success: redirect to the summary. - var updateCallback = function (progress, status, pb) { + var updateCallback = function(progress, status, pb) { if (progress == 100) { pb.stopMonitoring(); - window.location = uri+'&op=finished'; + window.location = settings.batch.uri + '&op=finished'; } }; - var errorCallback = function (pb) { - var div = document.createElement('p'); - div.className = 'error'; - $(div).html(errorMessage); - $(holder).prepend(div); + var errorCallback = function(pb) { + holder.prepend($('<p class="error"></p>').html(settings.batch.errorMessage)); $('#wait').hide(); }; - var progress = new Drupal.progressBar('updateprogress', updateCallback, "POST", errorCallback); - progress.setProgress(-1, initMessage); - $(holder).append(progress.element); - progress.startMonitoring(uri+'&op=do', 10); + var progress = new Drupal.progressBar('updateprogress', updateCallback, 'POST', errorCallback); + progress.setProgress(-1, settings.batch.initMessage); + holder.append(progress.element); + progress.startMonitoring(settings.batch.uri + '&op=do', 10); }); } }; diff --git a/misc/collapse.js b/misc/collapse.js index 11426a1de..4c07506df 100644 --- a/misc/collapse.js +++ b/misc/collapse.js @@ -11,7 +11,7 @@ Drupal.toggleFieldset = function(fieldset) { var content = $('> div:not(.action)', fieldset); $(fieldset).removeClass('collapsed'); content.hide(); - content.slideDown( { + content.slideDown({ duration: 'fast', easing: 'linear', complete: function() { @@ -37,7 +37,7 @@ Drupal.toggleFieldset = function(fieldset) { /** * Scroll a given fieldset into view as much as possible. */ -Drupal.collapseScrollIntoView = function (node) { +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; @@ -71,7 +71,7 @@ Drupal.behaviors.collapse = { // 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($('<a href="#">'+ text +'</a>').click(function() { + $(this).empty().append($('<a href="#">' + text + '</a>').click(function() { var fieldset = $(this).parents('fieldset:first')[0]; // Don't animate multiple times if (!fieldset.animating) { @@ -82,8 +82,8 @@ Drupal.behaviors.collapse = { })) .append(summary) .after($('<div class="fieldset-wrapper"></div>') - .append(fieldset.children(':not(legend):not(.action)'))) - .addClass('collapse-processed'); + .append(fieldset.children(':not(legend):not(.action)')) + ).addClass('collapse-processed'); }); } }; diff --git a/misc/drupal.js b/misc/drupal.js index b0cf64ce1..d83bb8a30 100644 --- a/misc/drupal.js +++ b/misc/drupal.js @@ -8,7 +8,7 @@ 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."); + alert('Please wrap your JavaScript code in (function($) { ... })(jQuery); to be compatible. See http://docs.jquery.com/Using_jQuery_with_Other_Libraries.'); }; } @@ -195,9 +195,9 @@ Drupal.formatPlural = function(count, singular, plural, args) { return Drupal.t(plural, args); } else { - args['@count['+ index +']'] = args['@count']; + args['@count[' + index + ']'] = args['@count']; delete args['@count']; - return Drupal.t(plural.replace('@count', '@count['+ index +']')); + return Drupal.t(plural.replace('@count', '@count[' + index + ']')); } }; @@ -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,23 +244,21 @@ 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(); - var div = document.createElement('div'); - $(div).css({ + $('<div id="freeze-height"></div>').css({ position: 'absolute', top: '0px', left: '0px', width: '1px', height: $('body').css('height') - }).attr('id', 'freeze-height'); - $('body').append(div); + }).appendTo('body'); }; /** * Unfreeze the body height. */ -Drupal.unfreezeHeight = function () { +Drupal.unfreezeHeight = function() { $('#freeze-height').remove(); }; @@ -268,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'); @@ -277,8 +275,8 @@ Drupal.encodeURIComponent = function (item, uri) { /** * Get the text selection in a textarea. */ -Drupal.getSelection = function (element) { - if (typeof(element.selectionStart) != 'number' && document.selection) { +Drupal.getSelection = function(element) { + if (typeof element.selectionStart != 'number' && document.selection) { // The current selection. var range1 = document.selection.createRange(); var range2 = range1.duplicate(); @@ -300,14 +298,14 @@ Drupal.getSelection = function (element) { 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 }); + var message = Drupal.t('An error occurred. \n@uri\n@text', { '@uri': uri, '@text': xmlhttp.responseText }); } else { - var message = Drupal.t("An error occurred. \n@uri\n(no information available).", {'@uri': uri }); + var message = Drupal.t('An error occurred. \n@uri\n(no information available).', { '@uri': uri }); } } else { - var message = Drupal.t("An HTTP error @status occurred. \n@uri", {'@uri': uri, '@status': xmlhttp.status }); + var message = Drupal.t('An HTTP error @status occurred. \n@uri', { '@uri': uri, '@status': xmlhttp.status }); } return message.replace(/\n/g, '<br />'); }; diff --git a/misc/form.js b/misc/form.js index b54582391..39c605978 100644 --- a/misc/form.js +++ b/misc/form.js @@ -20,7 +20,7 @@ $.fn.setSummary = function(callback) { var that = this; // To facilitate things, the callback should always be a function. If it's - // not, we wrap it into an anonymous function which just returns the value. + // not, we wrap it into an anonymous function which just returns the value. if (typeof callback != 'function') { var val = callback; callback = function() { return val; }; @@ -63,7 +63,7 @@ Drupal.behaviors.multiselectSelector = { // Automatically selects the right radio button in a multiselect control. $('.multiselect select:not(.multiselectSelector-processed)', context) .addClass('multiselectSelector-processed').change(function() { - $('.multiselect input:radio[value="'+ this.id.substr(5) +'"]') + $('.multiselect input:radio[value="' + this.id.substr(5) + '"]') .attr('checked', true); }); } @@ -79,7 +79,7 @@ Drupal.behaviors.filterGuidelines = { .addClass('filter-guidelines-processed') .find('label').hide() .parents('.filter-wrapper').find('select.filter-list') - .bind('change', function () { + .bind('change', function() { $(this).parents('.filter-wrapper') .find('.filter-guidelines-item').hide() .siblings('#filter-guidelines-' + this.value).show(); diff --git a/misc/progress.js b/misc/progress.js index b0fad1573..265c538f7 100644 --- a/misc/progress.js +++ b/misc/progress.js @@ -11,28 +11,26 @@ * e.g. pb = new progressBar('myProgressBar'); * some_element.appendChild(pb.element); */ -Drupal.progressBar = function (id, updateCallback, method, errorCallback) { +Drupal.progressBar = function(id, updateCallback, method, errorCallback) { var pb = this; this.id = id; - this.method = method || "GET"; + this.method = method || 'GET'; this.updateCallback = updateCallback; this.errorCallback = errorCallback; - this.element = document.createElement('div'); - this.element.id = id; - this.element.className = 'progress'; - $(this.element).html('<div class="bar"><div class="filled"></div></div>'+ - '<div class="percentage"></div>'+ - '<div class="message"> </div>'); + this.element = $('<div class="progress"></div>').attr('id', id); + this.element.html('<div class="bar"><div class="filled"></div></div>' + + '<div class="percentage"></div>' + + '<div class="message"> </div>'); }; /** * Set the percentage and status message for the progressbar. */ -Drupal.progressBar.prototype.setProgress = function (percentage, message) { +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 +'%'); + $('div.filled', this.element).css('width', percentage + '%'); + $('div.percentage', this.element).html(percentage + '%'); } $('div.message', this.element).html(message); if (this.updateCallback) { @@ -43,7 +41,7 @@ Drupal.progressBar.prototype.setProgress = function (percentage, message) { /** * Start monitoring progress via Ajax. */ -Drupal.progressBar.prototype.startMonitoring = function (uri, delay) { +Drupal.progressBar.prototype.startMonitoring = function(uri, delay) { this.delay = delay; this.uri = uri; this.sendPing(); @@ -52,7 +50,7 @@ Drupal.progressBar.prototype.startMonitoring = function (uri, delay) { /** * Stop monitoring progress via Ajax. */ -Drupal.progressBar.prototype.stopMonitoring = function () { +Drupal.progressBar.prototype.stopMonitoring = function() { clearTimeout(this.timer); // This allows monitoring to be stopped from within the callback. this.uri = null; @@ -61,7 +59,7 @@ Drupal.progressBar.prototype.stopMonitoring = function () { /** * Request progress data from server. */ -Drupal.progressBar.prototype.sendPing = function () { +Drupal.progressBar.prototype.sendPing = function() { if (this.timer) { clearTimeout(this.timer); } @@ -74,7 +72,7 @@ Drupal.progressBar.prototype.sendPing = function () { url: this.uri, data: '', dataType: 'json', - success: function (progress) { + success: function(progress) { // Display errors. if (progress.status == 0) { pb.displayError(progress.data); @@ -85,7 +83,7 @@ Drupal.progressBar.prototype.sendPing = function () { // Schedule next timer. pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay); }, - error: function (xmlhttp) { + error: function(xmlhttp) { pb.displayError(Drupal.ahahError(xmlhttp, pb.uri)); } }); @@ -95,11 +93,8 @@ Drupal.progressBar.prototype.sendPing = function () { /** * Display errors on the page. */ -Drupal.progressBar.prototype.displayError = function (string) { - var error = document.createElement('div'); - error.className = 'error'; - error.innerHTML = string; - +Drupal.progressBar.prototype.displayError = function(string) { + var error = $('<div class="error"></div>').html(string); $(this.element).before(error).hide(); if (this.errorCallback) { diff --git a/misc/tabledrag.js b/misc/tabledrag.js index ace82cfc0..1901f84be 100644 --- a/misc/tabledrag.js +++ b/misc/tabledrag.js @@ -64,11 +64,11 @@ Drupal.tableDrag = function(table, tableSettings) { this.indentEnabled = false; for (group in tableSettings) { for (n in tableSettings[group]) { - if (tableSettings[group][n]['relationship'] == 'parent') { + if (tableSettings[group][n].relationship == 'parent') { this.indentEnabled = true; } - if (tableSettings[group][n]['limit'] > 0) { - this.maxDepth = tableSettings[group][n]['limit']; + if (tableSettings[group][n].limit > 0) { + this.maxDepth = tableSettings[group][n].limit; } } } @@ -100,13 +100,13 @@ Drupal.tableDrag = function(table, tableSettings) { * Hide the columns containing form elements according to the settings for * this tableDrag instance. */ -Drupal.tableDrag.prototype.hideColumns = function(){ +Drupal.tableDrag.prototype.hideColumns = function() { 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); - if (field.size() && this.tableSettings[group][d]['hidden']) { - var hidden = this.tableSettings[group][d]['hidden']; + var field = $('.' + 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'); break; } @@ -117,7 +117,7 @@ Drupal.tableDrag.prototype.hideColumns = function(){ // 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(){ + $('tr', this.table).each(function() { var row = $(this); var parentTag = row.parent().get(0).tagName.toLowerCase(); var index = (parentTag == 'thead') ? headerIndex : columnIndex; @@ -151,10 +151,10 @@ Drupal.tableDrag.prototype.hideColumns = function(){ Drupal.tableDrag.prototype.rowSettings = function(group, row) { var field = $('.' + group, row); for (delta in this.tableSettings[group]) { - var targetClass = this.tableSettings[group][delta]['target']; + var targetClass = this.tableSettings[group][delta].target; if (field.is('.' + targetClass)) { // Return a copy of the row settings. - var rowSettings = new Object(); + var rowSettings = {}; for (var n in this.tableSettings[group][delta]) { rowSettings[n] = this.tableSettings[group][delta][n]; } @@ -190,7 +190,7 @@ Drupal.tableDrag.prototype.makeDraggable = function(item) { // Add the mousedown action for the handle. handle.mousedown(function(event) { // Create a new dragObject recording the event information. - self.dragObject = new Object(); + self.dragObject = {}; self.dragObject.initMouseOffset = self.getMouseOffset(item, event); self.dragObject.initMouseCoords = self.mouseCoords(event); if (self.indentEnabled) { @@ -322,7 +322,7 @@ 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 () { + $(nextGroup.group).each(function() { groupHeight += $(this).is(':hidden') ? 0 : this.offsetHeight; }); nextGroupRow = $(nextGroup.group).filter(':last').get(0); @@ -488,13 +488,13 @@ Drupal.tableDrag.prototype.dropRow = function(event, self) { /** * Get the mouse coordinates from the event (allowing for browser differences). */ -Drupal.tableDrag.prototype.mouseCoords = function(event){ +Drupal.tableDrag.prototype.mouseCoords = function(event) { if (event.pageX || event.pageY) { - return {x:event.pageX, y:event.pageY}; + return { x: event.pageX, y: event.pageY }; } return { - x:event.clientX + document.body.scrollLeft - document.body.clientLeft, - y:event.clientY + document.body.scrollTop - document.body.clientTop + x: event.clientX + document.body.scrollLeft - document.body.clientLeft, + y: event.clientY + document.body.scrollTop - document.body.clientTop }; }; @@ -519,7 +519,7 @@ Drupal.tableDrag.prototype.getMouseOffset = function(target, event) { */ Drupal.tableDrag.prototype.findDropTargetRow = function(x, y) { var rows = this.table.tBodies[0].rows; - for (var n=0; n<rows.length; n++) { + for (var n = 0; n < rows.length; n++) { var row = rows[n]; var indentDiff = 0; var rowY = $(row).offset().top; @@ -682,7 +682,7 @@ Drupal.tableDrag.prototype.updateField = function(changedRow, group) { var siblings = this.rowObject.findSiblings(rowSettings); if ($(targetElement).is('select')) { // Get a list of acceptable values. - var values = new Array(); + var values = []; $('option', targetElement).each(function() { values.push(this.value); }); @@ -802,7 +802,7 @@ Drupal.tableDrag.prototype.onDrop = function() { Drupal.tableDrag.prototype.row = function(tableRow, method, indentEnabled, maxDepth, addClasses) { this.element = tableRow; this.method = method; - this.group = new Array(tableRow); + this.group = [tableRow]; this.groupDepth = $('.indentation', tableRow).size(); this.changed = false; this.table = $(tableRow).parents('table:first').get(0); @@ -830,7 +830,7 @@ Drupal.tableDrag.prototype.row = function(tableRow, method, indentEnabled, maxDe Drupal.tableDrag.prototype.row.prototype.findChildren = function(addClasses) { var parentIndentation = this.indents; var currentRow = $(this.element, this.table).next('tr.draggable'); - var rows = new Array(); + var rows = []; var child = 0; while (currentRow.length) { var rowIndentation = $('.indentation', currentRow).length; @@ -921,7 +921,7 @@ Drupal.tableDrag.prototype.row.prototype.swap = function(position, row) { * DOM object for the row after the tested position * (or null for last position in the table). */ -Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow, nextRow) { +Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function(prevRow, nextRow) { var minIndent, maxIndent; // Minimum indentation: @@ -942,7 +942,7 @@ Drupal.tableDrag.prototype.row.prototype.validIndentInterval = function (prevRow } } - return {'min':minIndent, 'max':maxIndent}; + return { 'min': minIndent, 'max': maxIndent }; }; /** @@ -996,8 +996,8 @@ Drupal.tableDrag.prototype.row.prototype.indent = function(indentDiff) { * The field settings we're using to identify what constitutes a sibling. */ Drupal.tableDrag.prototype.row.prototype.findSiblings = function(rowSettings) { - var siblings = new Array(); - var directions = new Array('prev', 'next'); + var siblings = []; + var directions = ['prev', 'next']; var rowIndentation = this.indents; for (var d in directions) { var checkRow = $(this.element)[directions[d]](); @@ -1071,16 +1071,16 @@ Drupal.tableDrag.prototype.row.prototype.onSwap = function(swappedRow) { return null; }; -Drupal.theme.prototype.tableDragChangedMarker = function () { +Drupal.theme.prototype.tableDragChangedMarker = function() { return '<span class="warning tabledrag-changed">*</span>'; }; -Drupal.theme.prototype.tableDragIndentation = function () { +Drupal.theme.prototype.tableDragIndentation = function() { return '<div class="indentation"> </div>'; }; -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>'; +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); diff --git a/misc/tableheader.js b/misc/tableheader.js index fbc317583..92fc28281 100644 --- a/misc/tableheader.js +++ b/misc/tableheader.js @@ -2,7 +2,7 @@ (function($) { Drupal.tableHeaderDoScroll = function() { - if (typeof(Drupal.tableHeaderOnScroll)=='function') { + if ($.isFunction(Drupal.tableHeaderOnScroll)) { Drupal.tableHeaderOnScroll(); } }; @@ -10,14 +10,14 @@ Drupal.tableHeaderDoScroll = function() { Drupal.behaviors.tableHeader = { attach: function(context, settings) { // This breaks in anything less than IE 7. Prevent it from running. - if ($.browser.msie && parseInt($.browser.version, 10) < 7) { + if ($.browser.msie && parseInt($.browser.version) < 7) { return; } // Keep track of all cloned table headers. var headers = []; - $('table.sticky-enabled thead:not(.tableHeader-processed)', context).each(function () { + $('table.sticky-enabled thead:not(.tableHeader-processed)', context).each(function() { // Clone thead so it inherits original jQuery properties. var headerClone = $(this).clone(true).insertBefore(this.parentNode).wrap('<table class="sticky-header"></table>').parent().css({ position: 'fixed', @@ -55,7 +55,7 @@ Drupal.behaviors.tableHeader = { var cellWidth = parentCell.eq(index).css('width'); // Exception for IE7. if (cellWidth == 'auto') { - cellWidth = parentCell.get(index).clientWidth +'px'; + cellWidth = parentCell.get(index).clientWidth + 'px'; } $(this).css('width', cellWidth); }); @@ -66,7 +66,7 @@ Drupal.behaviors.tableHeader = { var hScroll = document.documentElement.scrollLeft || document.body.scrollLeft; var vOffset = (document.documentElement.scrollTop || document.body.scrollTop) - e.vPosition; var visState = (vOffset > 0 && vOffset < e.vLength) ? 'visible' : 'hidden'; - $(e).css({left: -hScroll + e.hPosition +'px', visibility: visState}); + $(e).css({ left: -hScroll + e.hPosition + 'px', visibility: visState }); // Check the previous anchor to see if we need to scroll to make room for the header. // Get the height of the header table and scroll up that amount. @@ -89,20 +89,20 @@ Drupal.behaviors.tableHeader = { // Track scrolling. Drupal.tableHeaderOnScroll = function() { - $(headers).each(function () { + $(headers).each(function() { tracker(this); }); }; // Track resizing. var time = null; - var resize = function () { + var resize = function() { // Ensure minimum time between adjustments. if (time) { return; } - time = setTimeout(function () { - $('table.sticky-header').each(function () { + time = setTimeout(function() { + $('table.sticky-header').each(function() { // Force cell width calculation. this.viewHeight = 0; tracker(this); diff --git a/misc/teaser.js b/misc/teaser.js index abb008bc7..d54605018 100644 --- a/misc/teaser.js +++ b/misc/teaser.js @@ -12,8 +12,8 @@ Drupal.behaviors.teaser = { var teaser = $(this).addClass('teaser-processed'); // Move teaser textarea before body, and remove its form-item wrapper. - var body = $('#'+ settings.teaser[this.id]); - var checkbox = $('#'+ settings.teaserCheckbox[this.id]).parent(); + var body = $('#' + settings.teaser[this.id]); + var checkbox = $('#' + settings.teaserCheckbox[this.id]).parent(); var checked = $(checkbox).children('input').attr('checked') ? true : false; var parent = teaser[0].parentNode; $(body).before(teaser); @@ -26,7 +26,7 @@ Drupal.behaviors.teaser = { // Join the teaser back to the body. function join_teaser() { if (teaser.val()) { - body.val(trim(teaser.val()) +'\r\n\r\n'+ trim(body.val())); + body.val(trim(teaser.val()) + '\r\n\r\n' + trim(body.val())); } // Empty, hide and disable teaser. teaser[0].value = ''; @@ -64,7 +64,7 @@ Drupal.behaviors.teaser = { // Add split/join button. var button = $('<div class="teaser-button-wrapper"><input type="button" class="teaser-button" /></div>'); - var include = $('#'+ this.id.substring(0, this.id.length - 2) +'include'); + var include = $('#' + this.id.substring(0, this.id.length - 2) + 'include'); $(include).parent().parent().before(button); // Extract the teaser from the body, if set. Otherwise, stay in joined mode. diff --git a/misc/textarea.js b/misc/textarea.js index 2f7ee8d3c..88f5b0970 100644 --- a/misc/textarea.js +++ b/misc/textarea.js @@ -16,7 +16,7 @@ Drupal.behaviors.textarea = { .parent().append($('<div class="grippie"></div>').mousedown(startDrag)); var grippie = $('div.grippie', $(this).parent())[0]; - grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) +'px'; + grippie.style.marginRight = (grippie.offsetWidth - $(this)[0].offsetWidth) + 'px'; function startDrag(e) { staticOffset = textarea.height() - e.pageY; @@ -31,7 +31,7 @@ Drupal.behaviors.textarea = { } function endDrag(e) { - $(document).unbind("mousemove", performDrag).unbind("mouseup", endDrag); + $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag); textarea.css('opacity', 1); } }); diff --git a/misc/timezone.js b/misc/timezone.js index c877353af..c4ababfad 100644 --- a/misc/timezone.js +++ b/misc/timezone.js @@ -54,7 +54,7 @@ Drupal.behaviors.setTimezone = { url: settings.basePath, data: { q: path, date: dateString }, dataType: 'json', - success: function (data) { + success: function(data) { if (data) { $(element).val(data); } diff --git a/misc/vertical-tabs.js b/misc/vertical-tabs.js index 045a5b7a3..f0819475e 100644 --- a/misc/vertical-tabs.js +++ b/misc/vertical-tabs.js @@ -8,7 +8,7 @@ * tab. * * Each tab may have a summary which can be updated by another - * script. For that to work, each fieldset has an associated + * script. For that to work, each fieldset has an associated * 'verticalTabCallback' (with jQuery.data() attached to the fieldset), * which is called every time the user performs an update to a form * element inside the tab pane. diff --git a/modules/block/block.js b/modules/block/block.js index f095c3dbc..f8f96111c 100644 --- a/modules/block/block.js +++ b/modules/block/block.js @@ -18,8 +18,8 @@ Drupal.behaviors.blockDrag = { }; // A custom message for the blocks page specifically. - Drupal.theme.tableDragChangedWarning = function () { - return '<div class="warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t("The changes to these blocks will not be saved until the <em>Save blocks</em> button is clicked.") + '</div>'; + Drupal.theme.tableDragChangedWarning = function() { + return '<div class="warning">' + Drupal.theme('tableDragChangedMarker') + ' ' + Drupal.t('The changes to these blocks will not be saved until the <em>Save blocks</em> button is clicked.') + '</div>'; }; // Add a handler so when a row is dropped, update fields dropped into new regions. @@ -32,7 +32,7 @@ Drupal.behaviors.blockDrag = { var weightField = $('select.block-weight', dragObject.rowObject.element); var oldRegionName = weightField[0].className.replace(/([^ ]+[ ]+)*block-weight-([^ ]+)([ ]+[^ ]+)*/, '$2'); - if (!regionField.is('.block-region-'+ regionName)) { + if (!regionField.is('.block-region-' + regionName)) { regionField.removeClass('block-region-' + oldRegionName).addClass('block-region-' + regionName); weightField.removeClass('block-weight-' + oldRegionName).addClass('block-weight-' + regionName); regionField.val(regionName); diff --git a/modules/color/color.js b/modules/color/color.js index 8ab30fa90..1b1199899 100644 --- a/modules/color/color.js +++ b/modules/color/color.js @@ -42,7 +42,7 @@ Drupal.behaviors.color = { } // Set up colorscheme selector. - $('#edit-scheme', form).change(function () { + $('#edit-scheme', form).change(function() { var colors = this.options[this.selectedIndex].value; if (colors != '') { colors = colors.split(','); @@ -75,7 +75,7 @@ Drupal.behaviors.color = { var accum = top; // Render gradient lines. - $('#gradient > div', form).each(function () { + $('#gradient > div', form).each(function() { for (i in accum) { accum[i] += delta[i]; } @@ -175,7 +175,7 @@ Drupal.behaviors.color = { * Reset the color scheme selector. */ function resetScheme() { - $('#edit-scheme', form).each(function () { + $('#edit-scheme', form).each(function() { this.selectedIndex = this.options.length - 1; }); } @@ -190,7 +190,7 @@ Drupal.behaviors.color = { // Add new bindings. focused = this; - farb.linkTo(function (color) { callback(input, color, true, false); }); + farb.linkTo(function(color) { callback(input, color, true, false); }); farb.setColor(this.value); $(focused).keyup(farb.updateValue).keyup(preview).keyup(resetScheme) .parent().addClass('item-selected'); @@ -198,18 +198,18 @@ Drupal.behaviors.color = { // Initialize color fields. $('#palette input.form-text', form) - .each(function () { + .each(function() { // Extract palette field name this.key = this.id.substring(13); // Link to color picker temporarily to initialize. - farb.linkTo(function () {}).setColor('#000').linkTo(this); + farb.linkTo(function() {}).setColor('#000').linkTo(this); // Add lock. var i = inputs.length; if (inputs.length) { var lock = $('<div class="lock"></div>').toggle( - function () { + function() { $(this).addClass('unlocked'); $(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.unlocked)') ? 'hook up' : 'hook' @@ -218,7 +218,7 @@ Drupal.behaviors.color = { locks[i] && $(locks[i]).is(':not(.unlocked)') ? 'hook down' : 'hook' ); }, - function () { + function() { $(this).removeClass('unlocked'); $(hooks[i - 1]).attr('class', locks[i - 2] && $(locks[i - 2]).is(':not(.unlocked)') ? 'hook both' : 'hook down' diff --git a/modules/comment/comment.js b/modules/comment/comment.js index 38a026b72..3d2b92edd 100644 --- a/modules/comment/comment.js +++ b/modules/comment/comment.js @@ -3,16 +3,14 @@ Drupal.behaviors.comment = { attach: function(context, settings) { - var parts = new Array("name", "homepage", "mail"); - var cookie = ''; - for (i=0;i<3;i++) { - cookie = Drupal.comment.getCookie('comment_info_' + parts[i]); - if (cookie != '') { - $("#comment-form input[name=" + parts[i] + "]:not(.comment-processed)", context) + $.each(['name', 'homepage', 'mail'], function() { + var cookie = Drupal.comment.getCookie('comment_info_' + this); + if (cookie) { + $('#comment-form input[name=' + this + ']:not(.comment-processed)', context) .val(cookie) .addClass('comment-processed'); } - } + }); } }; diff --git a/modules/node/content_types.js b/modules/node/content_types.js index 7f6ff3a2d..8b32ae8ea 100644 --- a/modules/node/content_types.js +++ b/modules/node/content_types.js @@ -9,7 +9,7 @@ Drupal.behaviors.contentTypes = { var machine = $(this).val().toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/_+/g, '_'); if (machine != '_' && machine != '') { $('#edit-type').val(machine); - $('#node-type-name-suffix').empty().append(' Machine name: ' + machine + ' [').append($('<a href="#">'+ Drupal.t('Edit') +'</a>').click(function() { + $('#node-type-name-suffix').empty().append(' Machine name: ' + machine + ' [').append($('<a href="#">' + Drupal.t('Edit') + '</a>').click(function() { $('#edit-type-wrapper').show(); $('#node-type-name-suffix').hide(); $('#edit-name').unbind('keyup'); diff --git a/modules/openid/openid.js b/modules/openid/openid.js index 1511348c8..14d70d3a1 100644 --- a/modules/openid/openid.js +++ b/modules/openid/openid.js @@ -3,38 +3,38 @@ Drupal.behaviors.openid = { attach: function(context) { - var $loginElements = $("#edit-name-wrapper, #edit-pass-wrapper, li.openid-link"); - var $openidElements = $("#edit-openid-identifier-wrapper, li.user-link"); + var loginElements = $('#edit-name-wrapper, #edit-pass-wrapper, li.openid-link'); + var openidElements = $('#edit-openid-identifier-wrapper, li.user-link'); // This behavior attaches by ID, so is only valid once on a page. - if (!$("#edit-openid-identifier.openid-processed").size() && $("#edit-openid-identifier").val()) { - $("#edit-openid-identifier").addClass('openid-processed'); - $loginElements.hide(); - // Use .css("display", "block") instead of .show() to be Konqueror friendly. - $openidElements.css("display", "block"); + if (!$('#edit-openid-identifier.openid-processed').size() && $('#edit-openid-identifier').val()) { + $('#edit-openid-identifier').addClass('openid-processed'); + loginElements.hide(); + // Use .css('display', 'block') instead of .show() to be Konqueror friendly. + openidElements.css('display', 'block'); } - $("li.openid-link:not(.openid-processed)", context) + $('li.openid-link:not(.openid-processed)', context) .addClass('openid-processed') - .click( function() { - $loginElements.hide(); - $openidElements.css("display", "block"); + .click(function() { + loginElements.hide(); + openidElements.css('display', 'block'); // Remove possible error message. - $("#edit-name, #edit-pass").removeClass("error"); - $("div.messages.error").hide(); + $('#edit-name, #edit-pass').removeClass('error'); + $('div.messages.error').hide(); // Set focus on OpenID Identifier field. - $("#edit-openid-identifier")[0].focus(); + $('#edit-openid-identifier')[0].focus(); return false; }); - $("li.user-link:not(.openid-processed)", context) + $('li.user-link:not(.openid-processed)', context) .addClass('openid-processed') .click(function() { - $openidElements.hide(); - $loginElements.css("display", "block"); + openidElements.hide(); + loginElements.css('display', 'block'); // Clear OpenID Identifier field and remove possible error message. - $("#edit-openid-identifier").val('').removeClass("error"); - $("div.messages.error").css("display", "block"); + $('#edit-openid-identifier').val('').removeClass('error'); + $('div.messages.error').css('display', 'block'); // Set focus on username field. - $("#edit-name")[0].focus(); + $('#edit-name')[0].focus(); return false; }); } diff --git a/modules/profile/profile.js b/modules/profile/profile.js index f1d53378b..334d71df6 100644 --- a/modules/profile/profile.js +++ b/modules/profile/profile.js @@ -45,7 +45,7 @@ Drupal.behaviors.profileDrag = { var weightField = $('select.profile-weight', dragObject.rowObject.element); var oldcategoryNum = weightField[0].className.replace(/([^ ]+[ ]+)*profile-weight-([^ ]+)([ ]+[^ ]+)*/, '$2'); - if (!categoryField.is('.profile-category-'+ categoryNum)) { + if (!categoryField.is('.profile-category-' + categoryNum)) { categoryField.removeClass('profile-category-' + oldcategoryNum).addClass('profile-category-' + categoryNum); weightField.removeClass('profile-weight-' + oldcategoryNum).addClass('profile-weight-' + categoryNum); diff --git a/modules/simpletest/simpletest.js b/modules/simpletest/simpletest.js index 06fb70f30..91912599f 100644 --- a/modules/simpletest/simpletest.js +++ b/modules/simpletest/simpletest.js @@ -83,7 +83,7 @@ Drupal.behaviors.simpleTestSelectAll = { groupCheckbox.change(function() { var checked = !!($(this).attr('checked')); for (var i = 0; i < testCheckboxes.length; i++) { - $('#'+ testCheckboxes[i]).attr('checked', checked); + $('#' + testCheckboxes[i]).attr('checked', checked); } }); diff --git a/modules/system/system.js b/modules/system/system.js index 3015a2a8a..0b424812a 100644 --- a/modules/system/system.js +++ b/modules/system/system.js @@ -13,28 +13,28 @@ Drupal.behaviors.cleanURLsSettingsCheck = { // This behavior attaches by ID, so is only valid once on a page. // Also skip if we are on an install page, as Drupal.cleanURLsInstallCheck will handle // the processing. - if ($(".clean-url-processed, #edit-clean-url.install").size()) { + if ($('.clean-url-processed, #edit-clean-url.install').size()) { return; } - var url = settings.basePath +"admin/settings/clean-urls/check"; - $("#clean-url .description span").html('<div id="testing">'+ Drupal.t('Testing clean URLs...') +"</div>"); - $("#clean-url p").hide(); + var url = settings.basePath + 'admin/settings/clean-urls/check'; + $('#clean-url .description span').html('<div id="testing">' + Drupal.t('Testing clean URLs...') + '</div>'); + $('#clean-url p').hide(); $.ajax({ - url: location.protocol +"//"+ location.host + url, + url: location.protocol + '//' + location.host + url, dataType: 'json', - success: function () { + success: function() { // Check was successful. - $("#clean-url input.form-radio").attr("disabled", false); - $("#clean-url .description span").append('<div class="ok">'+ Drupal.t('Your server has been successfully tested to support this feature.') +"</div>"); - $("#testing").hide(); + $('#clean-url input.form-radio').attr('disabled', false); + $('#clean-url .description span').append('<div class="ok">' + Drupal.t('Your server has been successfully tested to support this feature.') + '</div>'); + $('#testing').hide(); }, error: function() { // Check failed. - $("#clean-url .description span").append('<div class="warning">'+ Drupal.t('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.') +"</div>"); - $("#testing").hide(); + $('#clean-url .description span').append('<div class="warning">' + Drupal.t('Your system configuration does not currently support this feature. The <a href="http://drupal.org/node/15365">handbook page on Clean URLs</a> has additional troubleshooting information.') + '</div>'); + $('#testing').hide(); } }); - $("#clean-url").addClass('clean-url-processed'); + $('#clean-url').addClass('clean-url-processed'); } }; @@ -46,19 +46,19 @@ Drupal.behaviors.cleanURLsSettingsCheck = { * are currently enabled. */ Drupal.cleanURLsInstallCheck = function() { - var url = location.protocol +"//"+ location.host + Drupal.settings.basePath +"admin/settings/clean-urls/check"; + var url = location.protocol + '//' + location.host + Drupal.settings.basePath + 'admin/settings/clean-urls/check'; // Submit a synchronous request to avoid database errors associated with // concurrent requests during install. $.ajax({ async: false, url: url, dataType: 'json', - success: function () { + success: function() { // Check was successful. - $("#edit-clean-url").attr("value", 1); - }, + $('#edit-clean-url').attr('value', 1); + } }); - $("#edit-clean-url").addClass('clean-url-processed'); + $('#edit-clean-url').addClass('clean-url-processed'); }; /** @@ -95,15 +95,15 @@ Drupal.behaviors.dateTime = { attach: function(context, settings) { // Show/hide custom format depending on the select's value. $('select.date-format:not(.date-time-processed)', context).change(function() { - $(this).addClass('date-time-processed').parents("div.date-container").children("div.custom-container")[$(this).val() == "custom" ? "show" : "hide"](); + $(this).addClass('date-time-processed').parents('div.date-container').children('div.custom-container')[$(this).val() == 'custom' ? 'show' : 'hide'](); }); // Attach keyup handler to custom format inputs. $('input.custom-format:not(.date-time-processed)', context).addClass('date-time-processed').keyup(function() { var input = $(this); - var url = settings.dateTime.lookup +(settings.dateTime.lookup.match(/\?q=/) ? "&format=" : "?format=") + Drupal.encodeURIComponent(input.val()); + var url = settings.dateTime.lookup +(settings.dateTime.lookup.match(/\?q=/) ? '&format=' : '?format=') + Drupal.encodeURIComponent(input.val()); $.getJSON(url, function(data) { - $("div.description span", input.parent()).html(data); + $('div.description span', input.parent()).html(data); }); }); diff --git a/modules/user/user.js b/modules/user/user.js index 66e74e890..10077434c 100644 --- a/modules/user/user.js +++ b/modules/user/user.js @@ -8,30 +8,30 @@ Drupal.behaviors.password = { attach: function(context, settings) { var translate = settings.password; - $("input.password-field:not(.password-processed)", context).each(function() { + $('input.password-field:not(.password-processed)', context).each(function() { var passwordInput = $(this).addClass('password-processed'); var innerWrapper = $(this).parent(); var outerWrapper = $(this).parent().parent(); // Add the password strength layers. - var passwordStrength = $("span.password-strength", innerWrapper); - var passwordResult = $("span.password-result", passwordStrength); - innerWrapper.addClass("password-parent"); + var passwordStrength = $('span.password-strength', innerWrapper); + var passwordResult = $('span.password-result', passwordStrength); + innerWrapper.addClass('password-parent'); // Add the description box at the end. var passwordMeter = '<div id="password-strength"><div class="password-strength-title">' + translate.strengthTitle + '</div><div id="password-indicator"><div id="indicator"></div></div></div>'; - $("div.description", outerWrapper).prepend('<div class="password-suggestions"></div>'); + $('div.description', outerWrapper).prepend('<div class="password-suggestions"></div>'); $(innerWrapper).append(passwordMeter); - var passwordDescription = $("div.password-suggestions", outerWrapper).hide(); + var passwordDescription = $('div.password-suggestions', outerWrapper).hide(); // Add the password confirmation layer. - $("input.password-confirm", outerWrapper).after('<div class="password-confirm">' + translate["confirmTitle"] + ' <span></span></div>').parent().addClass("confirm-parent"); - var confirmInput = $("input.password-confirm", outerWrapper); - var confirmResult = $("div.password-confirm", outerWrapper); - var confirmChild = $("span", confirmResult); + $('input.password-confirm', outerWrapper).after('<div class="password-confirm">' + translate['confirmTitle'] + ' <span></span></div>').parent().addClass('confirm-parent'); + var confirmInput = $('input.password-confirm', outerWrapper); + var confirmResult = $('div.password-confirm', outerWrapper); + var confirmChild = $('span', confirmResult); // Check the password strength. - var passwordCheck = function () { + var passwordCheck = function() { // Evaluate the password strength. var result = Drupal.evaluatePasswordStrength(passwordInput.val(), settings.password); @@ -50,19 +50,19 @@ Drupal.behaviors.password = { } // Adjust the length of the strength indicator. - $("#indicator").css('width', result.strength + '%'); + $('#indicator').css('width', result.strength + '%'); passwordCheckMatch(); }; // Check that password and confirmation inputs match. - var passwordCheckMatch = function () { + var passwordCheckMatch = function() { if (confirmInput.val()) { var success = passwordInput.val() === confirmInput.val(); // Show the confirm result. - confirmResult.css({ visibility: "visible" }); + confirmResult.css({ visibility: 'visible' }); // Remove the previous styling if any exists. if (this.confirmClass) { @@ -70,12 +70,12 @@ Drupal.behaviors.password = { } // Fill in the success message and set the class accordingly. - var confirmClass = success ? "ok" : 'error'; - confirmChild.html(translate["confirm" + (success ? "Success" : "Failure")]).addClass(confirmClass); + var confirmClass = success ? 'ok' : 'error'; + confirmChild.html(translate['confirm' + (success ? 'Success' : 'Failure')]).addClass(confirmClass); this.confirmClass = confirmClass; } else { - confirmResult.css({ visibility: "hidden" }); + confirmResult.css({ visibility: 'hidden' }); } }; @@ -92,7 +92,7 @@ Drupal.behaviors.password = { * * Returns the estimated strength and the relevant output message. */ -Drupal.evaluatePasswordStrength = function (password, translate) { +Drupal.evaluatePasswordStrength = function(password, translate) { var weaknesses = 0, strength = 100, msg = []; var hasLowercase = password.match(/[a-z]+/); @@ -102,7 +102,7 @@ Drupal.evaluatePasswordStrength = function (password, translate) { // If there is a username edit box on the page, compare password to that, otherwise // use value from the database. - var usernameBox = $("input.username"); + var usernameBox = $('input.username'); var username = (usernameBox.length > 0) ? usernameBox.val() : translate.username; // Lose 10 points for every character less than 6. @@ -149,14 +149,14 @@ Drupal.evaluatePasswordStrength = function (password, translate) { } // Check if password is the same as the username. - if ((password !== '') && (password.toLowerCase() === username.toLowerCase())){ + if (password !== '' && password.toLowerCase() === username.toLowerCase()) { msg.push(translate.sameAsUsername); // Passwords the same as username are always very weak. strength = 5; } // Assemble the final message. - msg = translate.hasWeaknesses + "<ul><li>" + msg.join("</li><li>") + "</li></ul>"; + msg = translate.hasWeaknesses + '<ul><li>' + msg.join('</li><li>') + '</li></ul>'; return { strength: strength, message: msg }; }; @@ -167,7 +167,7 @@ Drupal.evaluatePasswordStrength = function (password, translate) { */ Drupal.behaviors.userSettings = { attach: function(context, settings) { - $('div.user-admin-picture-radios input[type=radio]:not(.userSettings-processed)', context).addClass('userSettings-processed').click(function () { + $('div.user-admin-picture-radios input[type=radio]:not(.userSettings-processed)', context).addClass('userSettings-processed').click(function() { $('div.user-admin-picture-settings', context)[['hide', 'show'][this.value]](); }); } |