Commit fc728323 authored by webchick's avatar webchick

#444402 follow-up by kkaefer: Fix autocomplete, enforce code style for anonymous JS functions.

parent 031ba7d6
......@@ -2362,7 +2362,7 @@ function drupal_clear_css_cache() {
* 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 $.
* Wrap your code in (function ($) { ... })(jQuery); or use jQuery instead of $.
*
* - Add external JavaScript ('external'):
* Allows the inclusion of external JavaScript files that are not hosted on the
......@@ -2378,8 +2378,8 @@ function drupal_clear_css_cache() {
* @code
* drupal_add_js('misc/collapse.js');
* drupal_add_js('misc/collapse.js', 'file');
* drupal_add_js('jQuery(document).ready(function(){alert("Hello!");});', 'inline');
* drupal_add_js('jQuery(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)
* );
* drupal_add_js('http://example.com/example.js', 'external');
......
......@@ -2391,7 +2391,7 @@ function _locale_rebuild_js($langcode = NULL) {
$data = "Drupal.locale = { ";
if (!empty($language->formula)) {
$data .= "'pluralFormula': function(\$n) { return Number({$language->formula}); }, ";
$data .= "'pluralFormula': function (\$n) { return Number({$language->formula}); }, ";
}
$data .= "'strings': " . drupal_to_js($translations) . " };";
......
......@@ -728,7 +728,7 @@ function install_tasks($profile, $task) {
// We add these strings as settings because JavaScript translation does not
// work on install time.
drupal_add_js(array('copyFieldValue' => array('edit-site-mail' => array('edit-account-mail'))), 'setting');
drupal_add_js('jQuery(function() { Drupal.cleanURLsInstallCheck(); });', 'inline');
drupal_add_js('jQuery(function () { Drupal.cleanURLsInstallCheck(); });', 'inline');
// Build menu to allow clean URL check.
menu_rebuild();
......
// $Id$
(function($) {
(function ($) {
/**
* Provides AJAX-like page updating via AHAH (Asynchronous HTML and HTTP).
......@@ -17,12 +17,12 @@
* Attaches the ahah behavior to each ahah form element.
*/
Drupal.behaviors.ahah = {
attach: function(context, settings) {
attach: function (context, settings) {
for (var base in settings.ahah) {
if (!$('#' + base + '.ahah-processed').size()) {
var element_settings = settings.ahah[base];
$(element_settings.selector).each(function() {
$(element_settings.selector).each(function () {
element_settings.element = this;
var ahah = new Drupal.ahah(base, element_settings);
});
......@@ -36,7 +36,7 @@ Drupal.behaviors.ahah = {
/**
* AHAH object.
*/
Drupal.ahah = function(base, element_settings) {
Drupal.ahah = function (base, element_settings) {
// Set the properties for this object.
this.element = element_settings.element;
this.selector = element_settings.selector;
......@@ -77,10 +77,10 @@ Drupal.ahah = function(base, element_settings) {
var options = {
url: ahah.url,
data: ahah.button,
beforeSubmit: function(form_values, element_settings, options) {
beforeSubmit: function (form_values, element_settings, options) {
return ahah.beforeSubmit(form_values, element_settings, options);
},
success: function(response, status) {
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') {
......@@ -88,7 +88,7 @@ Drupal.ahah = function(base, element_settings) {
}
return ahah.success(response, status);
},
complete: function(response, status) {
complete: function (response, status) {
if (status == 'error' || status == 'parsererror') {
return ahah.error(response, ahah.url);
}
......@@ -98,7 +98,7 @@ Drupal.ahah = function(base, element_settings) {
};
// Bind the ajaxSubmit function to the element event.
$(element_settings.element).bind(element_settings.event, function() {
$(element_settings.element).bind(element_settings.event, function () {
$(element_settings.element).parents('form').ajaxSubmit(options);
return false;
});
......@@ -106,7 +106,7 @@ Drupal.ahah = function(base, element_settings) {
// can be triggered through keyboard input as well as e.g. a mousedown
// action.
if (element_settings.keypress) {
$(element_settings.element).keypress(function(event) {
$(element_settings.element).keypress(function (event) {
// Detect enter key.
if (event.keyCode == 13) {
$(element_settings.element).trigger(element_settings.event);
......@@ -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
......@@ -206,7 +206,7 @@ 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 });
......
// $Id$
(function($) {
(function ($) {
/**
* Attaches the autocomplete behavior to all required fields.
*/
Drupal.behaviors.autocomplete = {
attach: function(context, settings) {
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) {
this.input.value = node.autocompleteValue;
Drupal.jsAC.prototype.select = function (node) {
this.input.value = $(node).data('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,16 +155,16 @@ 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;
this.input.value = $(this.selected).data('autocompleteValue');
}
// Hide popup.
var popup = this.popup;
if (popup) {
this.popup = null;
$(popup).fadeOut('fast', function() { $(popup).remove(); });
$(popup).fadeOut('fast', function () { $(popup).remove(); });
}
this.selected = false;
};
......@@ -172,7 +172,7 @@ 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();
......@@ -195,7 +195,7 @@ 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;
......@@ -207,10 +207,10 @@ Drupal.jsAC.prototype.found = function(matches) {
for (key in matches) {
$('<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)
.mousedown(function () { ac.select(this); })
.mouseover(function () { ac.highlight(this); })
.mouseout(function () { ac.unhighlight(this); })
.data('autocompleteValue', key)
.appendTo(ul);
}
......@@ -226,7 +226,7 @@ Drupal.jsAC.prototype.found = function(matches) {
}
};
Drupal.jsAC.prototype.setStatus = function(status) {
Drupal.jsAC.prototype.setStatus = function (status) {
switch (status) {
case 'begin':
$(this.input).addClass('throbbing');
......@@ -242,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 = {};
......@@ -251,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;
......@@ -264,7 +264,7 @@ Drupal.ACDB.prototype.search = function(searchString) {
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(function() {
this.timer = setTimeout(function () {
db.owner.setStatus('begin');
// Ajax GET request for autocompletion.
......@@ -272,7 +272,7 @@ Drupal.ACDB.prototype.search = function(searchString) {
type: 'GET',
url: db.uri + '/' + Drupal.encodeURIComponent(searchString),
dataType: 'json',
success: function(matches) {
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.
......@@ -282,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));
}
});
......@@ -292,7 +292,7 @@ Drupal.ACDB.prototype.search = function(searchString) {
/**
* Cancels the current autocomplete request.
*/
Drupal.ACDB.prototype.cancel = function() {
Drupal.ACDB.prototype.cancel = function () {
if (this.owner) this.owner.setStatus('cancel');
if (this.timer) clearTimeout(this.timer);
this.searchString = '';
......
// $Id$
(function($) {
(function ($) {
/**
* Attaches the batch behavior to progress bars.
*/
Drupal.behaviors.batch = {
attach: function(context, settings) {
attach: function (context, settings) {
// This behavior attaches by ID, so is only valid once on a page.
if ($('#progress.batch-processed').size()) {
return;
}
$('#progress', context).addClass('batch-processed').each(function() {
$('#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 = settings.batch.uri + '&op=finished';
}
};
var errorCallback = function(pb) {
var errorCallback = function (pb) {
holder.prepend($('<p class="error"></p>').html(settings.batch.errorMessage));
$('#wait').hide();
};
......
// $Id$
(function($) {
(function ($) {
/**
* Toggle the visibility of a fieldset using smooth animations
*/
Drupal.toggleFieldset = function(fieldset) {
Drupal.toggleFieldset = function (fieldset) {
if ($(fieldset).is('.collapsed')) {
// Action div containers are processed separately because of a IE bug
// that alters the default submit button behavior.
......@@ -14,12 +14,12 @@ Drupal.toggleFieldset = function(fieldset) {
content.slideDown({
duration: 'fast',
easing: 'linear',
complete: function() {
complete: function () {
Drupal.collapseScrollIntoView(this.parentNode);
this.parentNode.animating = false;
$('div.action', fieldset).show();
},
step: function() {
step: function () {
// Scroll the fieldset into view
Drupal.collapseScrollIntoView(this.parentNode);
}
......@@ -27,7 +27,7 @@ Drupal.toggleFieldset = function(fieldset) {
}
else {
$('div.action', fieldset).hide();
var content = $('> div:not(.action)', fieldset).slideUp('fast', function() {
var content = $('> div:not(.action)', fieldset).slideUp('fast', function () {
$(this.parentNode).addClass('collapsed');
this.parentNode.animating = false;
});
......@@ -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;
......@@ -52,8 +52,8 @@ Drupal.collapseScrollIntoView = function(node) {
};
Drupal.behaviors.collapse = {
attach: function(context, settings) {
$('fieldset.collapsible > legend:not(.collapse-processed)', context).each(function() {
attach: function (context, settings) {
$('fieldset.collapsible > legend:not(.collapse-processed)', context).each(function () {
var fieldset = $(this.parentNode);
// Expand if there are errors inside
if ($('input.error, textarea.error, select.error', fieldset).size() > 0) {
......@@ -62,7 +62,7 @@ Drupal.behaviors.collapse = {
var summary = $('<span class="summary"></span>');
fieldset.
bind('summaryUpdated', function() {
bind('summaryUpdated', function () {
var text = $.trim(fieldset.getSummary());
summary.html(text ? ' (' + text + ')' : '');
})
......@@ -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) {
......
......@@ -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 = { '&': '&amp;', '"': '&quot;', '<': '&lt;', '>': '&gt;' };
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>';
}
};
......
// $Id$
(function($) {
(function ($) {
/**
* Retrieves the summary for the first element.
*/
$.fn.getSummary = function() {
$.fn.getSummary = function () {
var callback = this.data('summaryCallback');
return (this[0] && callback) ? $.trim(callback(this[0])) : '';
};
......@@ -16,14 +16,14 @@ $.fn.getSummary = function() {
* Either a function that will be called each time the summary is
* retrieved or a string (which is returned each time).
*/
$.fn.setSummary = function(callback) {
$.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.
if (typeof callback != 'function') {
var val = callback;
callback = function() { return val; };
callback = function () { return val; };
}
return this
......@@ -31,7 +31,7 @@ $.fn.setSummary = function(callback) {
// To prevent duplicate events, the handlers are first removed and then
// (re-)added.
.unbind('formUpdated.summary')
.bind('formUpdated.summary', function() {
.bind('formUpdated.summary', function () {
that.trigger('summaryUpdated');
})
// The actual summaryUpdated handler doesn't fire when the callback is
......@@ -43,7 +43,7 @@ $.fn.setSummary = function(callback) {
* Sends a 'formUpdated' event each time a form element is modified.
*/
Drupal.behaviors.formUpdated = {
attach: function(context) {
attach: function (context) {
// These events are namespaced so that we can remove them later.
var events = 'change.formUpdated click.formUpdated blur.formUpdated keyup.formUpdated';
$(context)
......@@ -52,17 +52,17 @@ Drupal.behaviors.formUpdated = {
.find(':input').andSelf().filter(':input')
// To prevent duplicate events, the handlers are first removed and then
// (re-)added.
.unbind(events).bind(events, function() {
.unbind(events).bind(events, function () {
$(this).trigger('formUpdated');
});
}
};
Drupal.behaviors.multiselectSelector = {
attach: function(context, settings) {
attach: function (context, settings) {
// Automatically selects the right radio button in a multiselect control.
$('.multiselect select:not(.multiselectSelector-processed)', context)
.addClass('multiselectSelector-processed').change(function() {
.addClass('multiselectSelector-processed').change(function () {
$('.multiselect input:radio[value="' + this.id.substr(5) + '"]')
.attr('checked', true);
});
......@@ -74,12 +74,12 @@ Drupal.behaviors.multiselectSelector = {
* Automatically display the guidelines of the selected text format.
*/
Drupal.behaviors.filterGuidelines = {
attach: function(context) {
attach: function (context) {
$('.filter-guidelines:not(.filter-guidelines-processed)', context)
.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();
......
<
// $Id$
(function($) {
(function ($) {
/**
* A progressbar object. Initialized with the given id. Must be inserted into
......@@ -11,7 +11,7 @@
* 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;