Commit 430d8395 authored by webchick's avatar webchick
Browse files

#231475 by birdmanx35 and redndahead: Coding style for comments in *.js.

parent 9dc60ce0
// $Id$
/**
* Attaches the autocomplete behavior to all required fields
* Attaches the autocomplete behavior to all required fields.
*/
Drupal.behaviors.autocomplete = function (context) {
var acdb = [];
......@@ -29,7 +29,7 @@ Drupal.autocompleteSubmit = function () {
};
/**
* An AutoComplete object
* An AutoComplete object.
*/
Drupal.jsAC = function (input, db) {
var ac = this;
......@@ -44,53 +44,53 @@ Drupal.jsAC = function (input, db) {
};
/**
* Handler for the "keydown" event
* Handler for the "keydown" event.
*/
Drupal.jsAC.prototype.onkeydown = function (input, e) {
if (!e) {
e = window.event;
}
switch (e.keyCode) {
case 40: // down arrow
case 40: // down arrow.
this.selectDown();
return false;
case 38: // up arrow
case 38: // up arrow.
this.selectUp();
return false;
default: // all other keys
default: // All other keys.
return true;
}
};
/**
* Handler for the "keyup" event
* Handler for the "keyup" event.
*/
Drupal.jsAC.prototype.onkeyup = function (input, e) {
if (!e) {
e = window.event;
}
switch (e.keyCode) {
case 16: // shift
case 17: // ctrl
case 18: // alt
case 20: // caps lock
case 33: // page up
case 34: // page down
case 35: // end
case 36: // home
case 37: // left arrow
case 38: // up arrow
case 39: // right arrow
case 40: // down arrow
case 16: // shift.
case 17: // ctrl.
case 18: // alt.
case 20: // caps lock.
case 33: // page up.
case 34: // page down.
case 35: // end.
case 36: // home.
case 37: // left arrow.
case 38: // up arrow.
case 39: // right arrow.
case 40: // down arrow.
return true;
case 9: // tab
case 13: // enter
case 27: // esc
case 9: // tab.
case 13: // enter.
case 27: // esc.
this.hidePopup(e.keyCode);
return true;
default: // all other keys
default: // All other keys.
if (input.value.length > 0)
this.populatePopup();
else
......@@ -100,14 +100,14 @@ Drupal.jsAC.prototype.onkeyup = function (input, e) {
};
/**
* Puts the currently highlighted suggestion into the autocomplete field
* Puts the currently highlighted suggestion into the autocomplete field.
*/
Drupal.jsAC.prototype.select = function (node) {
this.input.value = node.autocompleteValue;
};
/**
* Highlights the next suggestion
* Highlights the next suggestion.
*/
Drupal.jsAC.prototype.selectDown = function () {
if (this.selected && this.selected.nextSibling) {
......@@ -122,7 +122,7 @@ Drupal.jsAC.prototype.selectDown = function () {
};
/**
* Highlights the previous suggestion
* Highlights the previous suggestion.
*/
Drupal.jsAC.prototype.selectUp = function () {
if (this.selected && this.selected.previousSibling) {
......@@ -131,7 +131,7 @@ Drupal.jsAC.prototype.selectUp = function () {
};
/**
* Highlights a suggestion
* Highlights a suggestion.
*/
Drupal.jsAC.prototype.highlight = function (node) {
if (this.selected) {
......@@ -142,7 +142,7 @@ Drupal.jsAC.prototype.highlight = function (node) {
};
/**
* Unhighlights a suggestion
* Unhighlights a suggestion.
*/
Drupal.jsAC.prototype.unhighlight = function (node) {
$(node).removeClass('selected');
......@@ -150,14 +150,14 @@ Drupal.jsAC.prototype.unhighlight = function (node) {
};
/**
* Hides the autocomplete suggestions
* Hides the autocomplete suggestions.
*/
Drupal.jsAC.prototype.hidePopup = function (keycode) {
// Select item if the right key or mousebutton was pressed
// 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;
}
// Hide popup
// Hide popup.
var popup = this.popup;
if (popup) {
this.popup = null;
......@@ -167,10 +167,10 @@ Drupal.jsAC.prototype.hidePopup = function (keycode) {
};
/**
* Positions the suggestions popup and starts a search
* Positions the suggestions popup and starts a search.
*/
Drupal.jsAC.prototype.populatePopup = function () {
// Show popup
// Show popup.
if (this.popup) {
$(this.popup).remove();
}
......@@ -185,13 +185,13 @@ Drupal.jsAC.prototype.populatePopup = function () {
});
$(this.input).before(this.popup);
// Do search
// Do search.
this.db.owner = this;
this.db.search(this.input.value);
};
/**
* Fills the suggestion popup with any matches received
* Fills the suggestion popup with any matches received.
*/
Drupal.jsAC.prototype.found = function (matches) {
// If no value in the textfield, do not show the popup.
......@@ -199,7 +199,7 @@ Drupal.jsAC.prototype.found = function (matches) {
return false;
}
// Prepare matches
// Prepare matches.
var ul = document.createElement('ul');
var ac = this;
for (key in matches) {
......@@ -213,7 +213,7 @@ Drupal.jsAC.prototype.found = function (matches) {
$(ul).append(li);
}
// Show popup with matches, if any
// Show popup with matches, if any.
if (this.popup) {
if (ul.childNodes.length > 0) {
$(this.popup).empty().append(ul).show();
......@@ -239,7 +239,7 @@ Drupal.jsAC.prototype.setStatus = function (status) {
};
/**
* An AutoComplete DataBase object
* An AutoComplete DataBase object.
*/
Drupal.ACDB = function (uri) {
this.uri = uri;
......@@ -248,25 +248,25 @@ Drupal.ACDB = function (uri) {
};
/**
* Performs a cached and delayed search
* Performs a cached and delayed search.
*/
Drupal.ACDB.prototype.search = function (searchString) {
var db = this;
this.searchString = searchString;
// See if this key has been searched for before
// See if this key has been searched for before.
if (this.cache[searchString]) {
return this.owner.found(this.cache[searchString]);
}
// Initiate delayed search
// Initiate delayed search.
if (this.timer) {
clearTimeout(this.timer);
}
this.timer = setTimeout(function() {
db.owner.setStatus('begin');
// Ajax GET request for autocompletion
// Ajax GET request for autocompletion.
$.ajax({
type: "GET",
url: db.uri +'/'+ Drupal.encodeURIComponent(searchString),
......@@ -274,7 +274,7 @@ Drupal.ACDB.prototype.search = function (searchString) {
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
// Verify if these are still the matches the user wants to see.
if (db.searchString == searchString) {
db.owner.found(matches);
}
......@@ -289,7 +289,7 @@ Drupal.ACDB.prototype.search = function (searchString) {
};
/**
* Cancels the current autocomplete request
* Cancels the current autocomplete request.
*/
Drupal.ACDB.prototype.cancel = function() {
if (this.owner) this.owner.setStatus('cancel');
......
......@@ -3,7 +3,7 @@
var Drupal = Drupal || { 'settings': {}, 'behaviors': {}, 'themes': {}, 'locale': {} };
/**
* Set the variable that indicates if JavaScript behaviors should be applied
* Set the variable that indicates if JavaScript behaviors should be applied.
*/
Drupal.jsEnabled = document.getElementsByTagName && document.createElement && document.createTextNode && document.documentElement && document.getElementById;
......@@ -80,17 +80,17 @@ Drupal.t = function(str, args) {
}
if (args) {
// Transform arguments before inserting them
// Transform arguments before inserting them.
for (var key in args) {
switch (key.charAt(0)) {
// Escaped only
// Escaped only.
case '@':
args[key] = Drupal.checkPlain(args[key]);
break;
// Pass-through
// Pass-through.
case '!':
break;
// Escaped and placeholder
// Escaped and placeholder.
case '%':
default:
args[key] = Drupal.theme('placeholder', args[key]);
......@@ -209,7 +209,7 @@ Drupal.freezeHeight = function () {
};
/**
* Unfreeze the body height
* Unfreeze the body height.
*/
Drupal.unfreezeHeight = function () {
$('#freeze-height').remove();
......@@ -230,7 +230,7 @@ Drupal.encodeURIComponent = function (item, uri) {
*/
Drupal.getSelection = function (element) {
if (typeof(element.selectionStart) != 'number' && document.selection) {
// The current selection
// The current selection.
var range1 = document.selection.createRange();
var range2 = range1.duplicate();
// Select all text.
......@@ -263,11 +263,11 @@ Drupal.ahahError = function(xmlhttp, uri) {
return message;
}
// Global Killswitch on the <html> element
// Global Killswitch on the <html> element.
if (Drupal.jsEnabled) {
// Global Killswitch on the <html> element
// Global Killswitch on the <html> element.
$(document.documentElement).addClass('js');
// 'js enabled' cookie
// 'js enabled' cookie.
document.cookie = 'has_js=1; path=/';
// Attach all behaviors.
$(document).ready(function() {
......
......@@ -53,7 +53,7 @@ Drupal.progressBar.prototype.startMonitoring = function (uri, delay) {
*/
Drupal.progressBar.prototype.stopMonitoring = function () {
clearTimeout(this.timer);
// This allows monitoring to be stopped from within the callback
// This allows monitoring to be stopped from within the callback.
this.uri = null;
};
......@@ -74,14 +74,14 @@ Drupal.progressBar.prototype.sendPing = function () {
data: '',
dataType: 'json',
success: function (progress) {
// Display errors
// Display errors.
if (progress.status == 0) {
pb.displayError(progress.data);
return;
}
// Update display
// Update display.
pb.setProgress(progress.percentage, progress.message);
// Schedule next timer
// Schedule next timer.
pb.timer = setTimeout(function() { pb.sendPing(); }, pb.delay);
},
error: function (xmlhttp) {
......
......@@ -275,7 +275,7 @@ Drupal.tableDrag.prototype.makeDraggable = function(item) {
keyChange = true;
if ($(item).is('.tabledrag-root')) {
// Swap with the previous top-level row..
// Swap with the previous top-level row.
var groupHeight = 0;
while (previousRow && $('.indentation', previousRow).size()) {
previousRow = $(previousRow).prev('tr').get(0);
......
......@@ -105,7 +105,7 @@ Drupal.behaviors.tableHeader = function (context) {
this.viewHeight = 0;
tracker(this);
});
// Reset timer
// Reset timer.
time = null;
}, 250);
};
......
......@@ -56,10 +56,10 @@ Drupal.behaviors.teaser = function(context) {
// Note: using val() fails sometimes. jQuery bug?
teaser[0].value = trim(text.slice(0, split));
body[0].value = trim(text.slice(split));
// Reveal and enable teaser
// Reveal and enable teaser.
$(teaser).attr('disabled', '');
$(teaser).parent().slideDown('fast');
// Change label
// Change label.
$(this).val(Drupal.t('Join summary'));
// Show separate teaser checkbox, restore checked value.
$(checkbox).show().children('input').attr('checked', checked);
......@@ -87,7 +87,7 @@ Drupal.behaviors.teaser = function(context) {
if (Drupal.behaviors.textarea && teaser.is(('.form-textarea:not(.textarea-processed)'))) {
Drupal.behaviors.textarea(teaser.parentNode);
}
// Set initial visibility
// Set initial visibility.
if ($(teaser).is('[@disabled]')) {
$(teaser).parent().hide();
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment