Last active
August 29, 2015 14:04
-
-
Save petdance/8f461a266043d8f81db9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require(['jquery-ui-1.8.21.custom/js/jquery-ui-1.8.21.custom.min-65153'], function () { | |
"use strict"; | |
var availableTags = [ | |
"1 to 3 Words per Page", | |
"Action & Adventure", | |
// .... | |
"Writing Process", | |
"Writing Traits" ]; | |
var rlistid_lookup = { | |
"1 to 3 Words per Page": 160227, | |
"Action & Adventure": 156272, | |
// ... | |
"Writing Process": 160253, | |
"Writing Traits": 156362 }; | |
var droppy = $( 'input#ccsstag_search' ).autocomplete({ | |
appendTo: 'div#ccsstag_search_content', | |
source: availableTags, | |
delay: 0, | |
close: function() { | |
$('div#ccsstag_search_div').removeClass('active'); | |
var strval = $('input#ccsstag_search').val(); | |
var rlistid = rlistid_lookup[strval]; | |
if ( rlistid ) { | |
document.location = '/search?ccsstag_search=' + rlistid + '&SID=[% SID %]'; | |
} | |
return false; | |
} | |
}); | |
droppy.data('autocomplete')._renderItem = function( ul, item ) { | |
item.label = item.label.replace( | |
new RegExp( '(?![^&;]+;)(?!<[^<>]*)(' + $.ui.autocomplete.escapeRegex(this.term) + ')(?![^<>]*>)(?![^&;]+;)', 'gi'), | |
'<strong>$1</strong>' | |
); | |
return $( '<li>' ) | |
.append( '<a>' + item.label + '</a>' ) | |
.appendTo( ul ); | |
}; | |
droppy.data('autocomplete')._renderMenu = function( ul, items ) { | |
$('div#ccsstag_search_div').addClass('active'); // Not sure this is the right place for this | |
var that = this; | |
$( ul ).addClass( 'nav-select' ); | |
$.each( items, function( index, item ) { | |
that._renderItem( ul, item ); | |
}); | |
//$( ul ).find( "li:odd" ).addClass( "strong" ); | |
var div = $('div#ccsstag_search_content'); | |
console.log(div); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment