mirror of
https://github.com/seigler/dash-docs
synced 2025-07-27 01:36:13 +00:00
Beautify javascript (fixes #980)
This commit is contained in:
parent
75a3c45628
commit
d814977536
5 changed files with 654 additions and 647 deletions
|
@ -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 %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue