Skip to content
Snippets Groups Projects
Commit 66afd056 authored by Demian Katz's avatar Demian Katz
Browse files

JS checkstyles.

parent 080fc6ee
No related merge requests found
/*global console*/
/** /**
* vufind.typeahead.js 0.8 * vufind.typeahead.js 0.8
* ~ @crhallberg * ~ @crhallberg
*/ */
(function ( $ ) { (function ( $ ) {
var xhr = false;
$.fn.autocomplete = function(settings) { $.fn.autocomplete = function(settings) {
var options = $.extend( {}, $.fn.autocomplete.options, settings ); var options = $.extend( {}, $.fn.autocomplete.options, settings );
function align(input, element) {
var offset = input[0].getBoundingClientRect();
element.css({
position: 'absolute',
top: offset.top + offset.height + document.body.scrollTop,
left: offset.left,
minWidth: offset.width,
maxWidth: input.closest('form').width(),
zIndex: 50
});
}
function show() { function show() {
$.fn.autocomplete.element.removeClass(options.hidingClass); $.fn.autocomplete.element.removeClass(options.hidingClass);
} }
...@@ -62,7 +76,7 @@ ...@@ -62,7 +76,7 @@
} }
function search(input, element) { function search(input, element) {
if (xhr) xhr.abort(); if (xhr) { xhr.abort(); }
if (input.val().length >= options.minLength) { if (input.val().length >= options.minLength) {
element.html('<i class="item loading">'+options.loadingString+'</i>'); element.html('<i class="item loading">'+options.loadingString+'</i>');
show(); show();
...@@ -93,18 +107,6 @@ ...@@ -93,18 +107,6 @@
} }
} }
function align(input, element) {
var offset = input[0].getBoundingClientRect();
element.css({
position: 'absolute',
top: offset.top + offset.height + document.body.scrollTop,
left: offset.left,
minWidth: offset.width,
maxWidth: input.closest('form').width(),
zIndex: 50
});
}
function setup(input, element) { function setup(input, element) {
if (typeof element === 'undefined') { if (typeof element === 'undefined') {
element = $('<div/>') element = $('<div/>')
...@@ -166,9 +168,8 @@ ...@@ -166,9 +168,8 @@
case 45: // insert case 45: // insert
case 144: // num lock case 144: // num lock
case 145: // scroll lock case 145: // scroll lock
case 19: { // pause/break case 19: // pause/break
return; return;
}
default: { default: {
search(input, element); search(input, element);
} }
...@@ -268,7 +269,6 @@ ...@@ -268,7 +269,6 @@
}); });
}; };
var xhr = false;
var timer = false; var timer = false;
if (typeof $.fn.autocomplete.cache === 'undefined') { if (typeof $.fn.autocomplete.cache === 'undefined') {
$.fn.autocomplete.cache = {}; $.fn.autocomplete.cache = {};
...@@ -284,7 +284,7 @@ ...@@ -284,7 +284,7 @@
}; };
$.fn.autocomplete.ajax = function(ops) { $.fn.autocomplete.ajax = function(ops) {
if (timer) clearTimeout(timer); if (timer) clearTimeout(timer);
if (xhr) xhr.abort(); if (xhr) { xhr.abort(); }
timer = setTimeout( timer = setTimeout(
function() { xhr = $.ajax(ops); }, function() { xhr = $.ajax(ops); },
$.fn.autocomplete.options.ajaxDelay $.fn.autocomplete.options.ajaxDelay
......
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