Beautify javascript (fixes #980)

This commit is contained in:
Saivann 2015-07-29 16:55:50 -04:00
parent 75a3c45628
commit d814977536
5 changed files with 654 additions and 647 deletions

View file

@ -38,36 +38,36 @@ category: "{{category_name}}"
// code adapted from http://jqueryui.com/autocomplete/#categories
// MIT license: https://jquery.org/license/
$.widget( "custom.catcomplete", $.ui.autocomplete, {
_create: function() {
this._super();
this.widget().menu( "option", "items", "> :not(.ui-autocomplete-category)" );
},
_renderMenu: function( ul, items ) {
var that = this,
currentCategory = "";
$.each( items, function( index, item ) {
var li;
if ( item.category != currentCategory ) {
ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
currentCategory = item.category;
}
li = that._renderItemData( ul, item );
if ( item.category ) {
li.attr( "aria-label", item.category + " : " + item.label );
}
});
}
$.widget("custom.catcomplete", $.ui.autocomplete, {
_create: function() {
this._super();
this.widget().menu("option", "items", "> :not(.ui-autocomplete-category)");
},
_renderMenu: function(ul, items) {
var that = this,
currentCategory = "";
$.each(items, function(index, item) {
var li;
if (item.category != currentCategory) {
ul.append("<li class='ui-autocomplete-category'>" + item.category + "</li>");
currentCategory = item.category;
}
li = that._renderItemData(ul, item);
if (item.category) {
li.attr("aria-label", item.category + " : " + item.label);
}
});
}
});
$(function() {
$( "#glossary_term" ).catcomplete({
source: search_data,
delay: 0,
minLength: 2,
autoFocus: true,
select: function( event, ui ) {
location.href = ui.item.uri;
}
});
$("#glossary_term").catcomplete({
source: search_data,
delay: 0,
minLength: 2,
autoFocus: true,
select: function(event, ui) {
location.href = ui.item.uri;
}
});
});
{% endraw %}