-
+ Copy Table Name
-
+
@@ -248,9 +250,6 @@
-
- Export SQL dump diff --git a/static/js/app.js b/static/js/app.js index 10002b0..33f1fe3 100644 --- a/static/js/app.js +++ b/static/js/app.js @@ -850,20 +850,11 @@ function bindContextMenus() { } }); }); +} - $(".tables-list .title").contextmenu({ - target: "#databases_context_menu", - onItem: function(context, e) { - var name = $(e.target).text(); - apiCall("post", "/switchdb", { db: name }, function(resp) { - if (resp.error) { - alert(resp.error); - return; - } - window.location.reload(); - }); - } - }); +function toggleDatabaseSearch() { + $("#current_database").toggle(); + $("#database_search").toggle(); } $(document).ready(function() { @@ -1059,13 +1050,36 @@ $(document).ready(function() { $("#current_database").on("click", function(e) { apiCall("get", "/databases", {}, function(resp) { - $("#databases_context_menu > ul > li").remove(); - resp.forEach(function(name) { - $("
- " + name + " ").appendTo("#databases_context_menu > ul"); + toggleDatabaseSearch(); + var input = $("#database_search"); + input.typeahead("destroy"); + input.typeahead({ + source: resp, + minLength: 0, + items: "all", + autoSelect: false, + fitToElement: true + }); + input.typeahead("lookup").focus(); + input.on("focusout", function(e){ + toggleDatabaseSearch(); + input.off("focusout"); }); - $(".tables-list .title").triggerHandler("contextmenu"); }); }); + + $("#database_search").change(function(e) { + var current = $("#database_search").typeahead("getActive"); + if (current && current == $("#database_search").val()) { + apiCall("post", "/switchdb", { db: current }, function(resp) { + if (resp.error) { + alert(resp.error); + return; + }; + window.location.reload(); + }); + }; + }); $("#edit_connection").on("click", function() { if (connected) { diff --git a/static/js/bootstrap3-typeahead.min.js b/static/js/bootstrap3-typeahead.min.js new file mode 100644 index 0000000..8e5f560 --- /dev/null +++ b/static/js/bootstrap3-typeahead.min.js @@ -0,0 +1 @@ +!function(a,b){"use strict";"undefined"!=typeof module&&module.exports?module.exports=b(require("jquery")):"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):b(a.jQuery)}(this,function(a){"use strict";var b=function(c,d){this.$element=a(c),this.options=a.extend({},b.defaults,d),this.matcher=this.options.matcher||this.matcher,this.sorter=this.options.sorter||this.sorter,this.select=this.options.select||this.select,this.autoSelect="boolean"!=typeof this.options.autoSelect||this.options.autoSelect,this.highlighter=this.options.highlighter||this.highlighter,this.render=this.options.render||this.render,this.updater=this.options.updater||this.updater,this.displayText=this.options.displayText||this.displayText,this.source=this.options.source,this.delay=this.options.delay,this.$menu=a(this.options.menu),this.$appendTo=this.options.appendTo?a(this.options.appendTo):null,this.fitToElement="boolean"==typeof this.options.fitToElement&&this.options.fitToElement,this.shown=!1,this.listen(),this.showHintOnFocus=("boolean"==typeof this.options.showHintOnFocus||"all"===this.options.showHintOnFocus)&&this.options.showHintOnFocus,this.afterSelect=this.options.afterSelect,this.addItem=!1,this.value=this.$element.val()||this.$element.text(),this.keyPressed=!1};b.prototype={constructor:b,select:function(){var a=this.$menu.find(".active").data("value");if(this.$element.data("active",a),this.autoSelect||a){var b=this.updater(a);b||(b=""),this.$element.val(this.displayText(b)||b).text(this.displayText(b)||b).change(),this.afterSelect(b)}return this.hide()},updater:function(a){return a},setSource:function(a){this.source=a},show:function(){var b,c=a.extend({},this.$element.position(),{height:this.$element[0].offsetHeight}),d="function"==typeof this.options.scrollHeight?this.options.scrollHeight.call():this.options.scrollHeight;if(this.shown?b=this.$menu:this.$appendTo?(b=this.$menu.appendTo(this.$appendTo),this.hasSameParent=this.$appendTo.is(this.$element.parent())):(b=this.$menu.insertAfter(this.$element),this.hasSameParent=!0),!this.hasSameParent){b.css("position","fixed");var e=this.$element.offset();c.top=e.top,c.left=e.left}var f=a(b).parent().hasClass("dropup"),g=f?"auto":c.top+c.height+d,h=a(b).hasClass("dropdown-menu-right"),i=h?"auto":c.left;return b.css({top:g,left:i}).show(),!0===this.options.fitToElement&&b.css("width",this.$element.outerWidth()+"px"),this.shown=!0,this},hide:function(){return this.$menu.hide(),this.shown=!1,this},lookup:function(b){if(this.query=void 0!==b&&null!==b?b:this.$element.val()||this.$element.text()||"",this.query.length
- ',minLength:1,scrollHeight:0,autoSelect:!0,afterSelect:a.noop,addItem:!1,delay:0,separator:"category",headerHtml:'',headerDivider:''},a.fn.typeahead.Constructor=b,a.fn.typeahead.noConflict=function(){return a.fn.typeahead=c,this},a(document).on("focus.typeahead.data-api",'[data-provide="typeahead"]',function(b){var c=a(this);c.data("typeahead")||c.typeahead(c.data())})}); \ No newline at end of file