TagSpaces is an offline, open source, document manager with tagging support
Added autocomplete functionality to the add tag dialog.
uggrockfc0f1d270e25
diff --git a/data/js/basicviews.ui.js b/data/js/basicviews.ui.jsindex eba066707..abb013f66 100644--- a/data/js/basicviews.ui.js+++ b/data/js/basicviews.ui.js@@ -334,6 +334,12 @@ BasicViewsUI.initContextMenus = function() {select: function( event, ui ) {var commandName = ui.item.attr( "action" );switch (commandName) {+ case "addTag":+ $( this ).hide();+ console.debug("Adding tag...");+ $("#tags").val("");+ $( "#dialogAddTags" ).dialog( "open" );+ break;case "openFile":$( this ).hide();console.debug("Opening file...");@@ -566,7 +572,48 @@ BasicViewsUI.initDialogs = function() {Cancel: function() {$( this ).dialog( "close" );}- }+ },+ open: function() {++ function split( val ) {+ return val.split( /,\s*/ );+ }+ function extractLast( term ) {+ return split( term ).pop();+ }++ $( "#tags" )+ // don't navigate away from the field on tab when selecting an item+ .bind( "keydown", function( event ) {+ if ( event.keyCode === $.ui.keyCode.TAB &&+ $( this ).data( "autocomplete" ).menu.active ) {+ event.preventDefault();+ }+ })+ .autocomplete({+ minLength: 0,+ source: function( request, response ) {+ // delegate back to autocomplete, but extract the last term+ response( $.ui.autocomplete.filter(+ TSSETTINGS.getAllTags(), extractLast( request.term ) ) );+ },+ focus: function() {+ // prevent value inserted on focus+ return false;+ },+ select: function( event, ui ) {+ var terms = split( this.value );+ // remove the current input+ terms.pop();+ // add the selected item+ terms.push( ui.item.value );+ // add placeholder to get the comma-and-space at the end+ terms.push( "" );+ this.value = terms.join( ", " );+ return false;+ }+ });+ }});$( "#tagTypeRadio" ).buttonset();diff --git a/data/loader.js b/data/loader.jsindex 79e3fec4c..ef67b0305 100644--- a/data/loader.js+++ b/data/loader.js@@ -58,7 +58,8 @@ require.config({'jqueryuimenu','jqueryuibutton','jqueryuidialog',- 'jqueryuiselectable',+ 'jqueryuiselectable',+ 'jqueryuiautocomplete',]},'dynatree': {