Skip to content

Commit

Permalink
Updated css classes
Browse files Browse the repository at this point in the history
  • Loading branch information
hernantz committed Feb 18, 2012
1 parent b1a986e commit 02e3d6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 26 deletions.
20 changes: 10 additions & 10 deletions doubleSugest.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* doubleSuggest CSS - Version 0.1 */
/* doubleSuggest CSS */

div.ds-container input.ds-input {
border: 1px solid #CCCCCC;
Expand All @@ -17,7 +17,7 @@ div.ds-container input.ds-input.loading {
background-color: #eee;
}

ul.as-list {
ul.ds-list {
position: absolute;
list-style-type: none;
margin: 2px 0 0 0;
Expand All @@ -36,7 +36,7 @@ ul.as-list {
-moz-border-radius: 5px;
}

li.as-result-item, li.as-message {
li.ds-result-item, li.ds-message {
margin: 0 0 0 0;
padding: 5px 12px;
background-color: transparent;
Expand All @@ -48,30 +48,30 @@ li.as-result-item, li.as-message {
-moz-border-radius: 5px;
}

li:first-child.as-result-item {
li:first-child.ds-result-item {
margin: 0;
}

li.as-message {
li.ds-message {
margin: 0;
cursor: default;
}

li.as-result-item.active {
li.ds-result-item.active {
background-color: #3668d9;
border-color: #3342e8;
color: #fff;
text-shadow: 0 1px 2px #122042;
}

li.as-result-item em {
li.ds-result-item em {
font-style: normal;
background: #444;
padding: 0 2px;
color: #fff;
}

li.as-result-item.active em {
li.ds-result-item.active em {
background: #253f7a;
color: #fff;
}
Expand All @@ -85,12 +85,12 @@ li.as-result-item.active em {

/* Opera Hacks */
@media all and (-webkit-min-device-pixel-ratio:10000), not all and (-webkit-min-device-pixel-ratio:0) {
ul.as-list {
ul.ds-list {
border: 1px solid #888;
}
}

/* IE Hacks */
ul.as-list {
ul.ds-list {
border: 1px solid #888\9;
}
34 changes: 18 additions & 16 deletions jquery.doubleSuggest.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$input.after($resultsHolder);

// UL where all search results and messages are placed.
var $resultsUL = $('<ul class="as-list"></ul>').css('width', $input.outerWidth()).appendTo($resultsHolder);
var $resultsUL = $('<ul class="ds-list"></ul>').css('width', $input.outerWidth()).appendTo($resultsHolder);

// Used internally to know what text was typed by the user
var typedText = '';
Expand Down Expand Up @@ -92,7 +92,7 @@

// If the tab or return keys are pressed when an result item is active, add it.
// Prevent default behaviour if the comma or return keys are pressed to avoid submiting the form which doubleSuggest is part of.
if ((lastKey === 9 || lastKey === 13) && $('li.as-result-item:visible', $resultsHolder).length > 0 && $('li.active:first', $resultsUL).length > 0) {
if ((lastKey === 9 || lastKey === 13) && $('li.ds-result-item:visible', $resultsHolder).length > 0 && $('li.active:first', $resultsUL).length > 0) {
$('li.active:first', $resultsUL).trigger('select');
e.preventDefault();
}
Expand All @@ -115,9 +115,14 @@
break;

default:

// Other key was pressed, call the keyChange event after the timeout delay.
refreshSearch(lastKey, timeout)

// Ignore if the following keys are pressed: [del] [shift] [capslock] [esc]
if ( lastKey == 46 || (lastKey > 9 && lastKey < 32) ) {
$resultsHolder.hide();
} else {
// Other key was pressed, call the keyChange event after the timeout delay.
refreshSearch(timeout)
}
break;
}
},
Expand All @@ -144,16 +149,13 @@
});

// Performs a new search by calling the keyChange function after the delay set.
function refreshSearch (timeout, lastKey) {
function refreshSearch (timeout) {
if (timeout) { clearTimeout(timeout); }
timeout = setTimeout(function(){ keyChange(lastKey); }, opts.keyDelay);
timeout = setTimeout(function(){ keyChange(); }, opts.keyDelay);
}

// Function that is executed when typing and after the key delay timeout.
function keyChange(lastKey) {

// ignore if the following keys are pressed: [del] [shift] [capslock]
if ( lastKey == 46 || (lastKey > 9 && lastKey < 32) ) { return $resultsHolder.hide(); }
function keyChange() {

// Get the text from the input.
// Remove the slashes "\" & "/" and then the extra whitespaces.
Expand All @@ -170,7 +172,7 @@

// Show the loading text, and start the loading state.
$input.addClass('loading');
if(opts.loadingText) { $resultsUL.html('<li class="as-message">'+opts.loadingText+'</li>').show(); } // FIXME - remove show()?
if(opts.loadingText) { $resultsUL.html('<li class="ds-message">'+opts.loadingText+'</li>').show(); } // FIXME - remove show()?
$resultsHolder.show();

// If the data is a URL, build the query and retrieve the response in JSON format.
Expand All @@ -196,7 +198,7 @@
function spotResult(dir) {

// If there is at least one visible item in the results list.
if ($('li.as-result-item:visible', $resultsHolder).length > 0) {
if ($('li.ds-result-item:visible', $resultsHolder).length > 0) {

// Get all the LI elements from the results list.
var lis = $('li', $resultsHolder);
Expand Down Expand Up @@ -242,7 +244,7 @@
// $input.val('').focus();
$resultsHolder.hide();
}
}, ".as-result-item");
}, ".ds-result-item");

// Function that gets the matched results and displays them.
function processData (data, queryString, local) {
Expand Down Expand Up @@ -280,7 +282,7 @@
data[i]['_position'] = matchCount;

// Build each result li element to show on the results list.
var resultLI = $('<li class="as-result-item" id="as-result-item-'+i+'"></li>').data(data[i]);
var resultLI = $('<li class="ds-result-item" id="ds-result-item-'+i+'"></li>').data(data[i]);
var resultData = $.extend({}, data[i]);

// Make the suggestions case sensitive or not.
Expand Down Expand Up @@ -311,7 +313,7 @@

// If no results were found, show the empty text message.
if (matchCount <= 0 && opts.emptyText){
$resultsUL.html('<li class="as-message">'+opts.emptyText+'</li>');
$resultsUL.html('<li class="ds-message">'+opts.emptyText+'</li>');
}

// Show the results list.
Expand Down

0 comments on commit 02e3d6e

Please sign in to comment.