rabin 7 лет назад
Родитель
Сommit
16195eb913
1 измененных файлов с 25 добавлено и 1 удалено
  1. 25 1
      assets/lib/manage/main.js

+ 25 - 1
assets/lib/manage/main.js

@@ -788,13 +788,37 @@ function autocomplete()
             $(this).attr('autocomplete', 'new-password');
         });
     }
+
+    $.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' style='font-weight: bold;padding: .2em .4em;margin: .8em 0 .2em;line-height: 1.5;'>" + item.category + "</li>" );
+            currentCategory = item.category;
+          }
+          li = that._renderItemData( ul, item );
+          if ( item.category ) {
+            li.attr( "aria-label", item.category + " : " + item.label );
+          }
+        });
+      }
+    });
+
 	if($("input[complete]").length)
 	{
 		$("input[complete]").each(function()
 		{
 			var cache = {};
 			var self = $(this);
-			self.autocomplete(
+			//autocomplete
+			self.catcomplete(
 			{
 				minLength: 2,
 				source: function( request, response )