From 228f6dc3d28ead4222e38e0d1188f80d3aabcf6f Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Tue, 8 Oct 2013 15:04:04 +0200 Subject: [PATCH] Autocompleter fixes and application keybindings --- public_html/static/js/jquery-autocomplete.js | 4 ++-- public_html/static/js/jsde.js | 5 +++++ public_html/static/js/openng.js | 23 +++++++++++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) diff --git a/public_html/static/js/jquery-autocomplete.js b/public_html/static/js/jquery-autocomplete.js index 1a25bfd..ae004f4 100644 --- a/public_html/static/js/jquery-autocomplete.js +++ b/public_html/static/js/jquery-autocomplete.js @@ -61,7 +61,7 @@ AutoCompleterInstance.prototype._handleKeyUp = function(event) { { case 9: // Tab case 13: // Enter/Return - if(this.visible == true) + if(this.visible == true && this.total_items > 0) { this._selectCurrent(); event.stopPropagation(); @@ -77,7 +77,7 @@ AutoCompleterInstance.prototype._handleKeyDown = function(event) { case 9: // Tab case 13: // Enter/Return /* We don't want this to do anything. */ - if(this.visible == true) + if(this.visible == true && this.total_items > 0) { event.stopPropagation(); event.preventDefault(); diff --git a/public_html/static/js/jsde.js b/public_html/static/js/jsde.js index 8146009..e8f0df0 100755 --- a/public_html/static/js/jsde.js +++ b/public_html/static/js/jsde.js @@ -67,6 +67,7 @@ function JsdeWindow(options) } this.loading = true; + this.loaded_callback = options.callback; var container = this; @@ -76,6 +77,10 @@ function JsdeWindow(options) success: function(response){ container.SetContents(response.contents); container.loading = false; + if(typeof container.loaded_callback !== "undefined") + { + container.loaded_callback(); + } }, data: options.source_data, dataType: "json" diff --git a/public_html/static/js/openng.js b/public_html/static/js/openng.js index 43f3b16..d549990 100644 --- a/public_html/static/js/openng.js +++ b/public_html/static/js/openng.js @@ -216,7 +216,7 @@ $(function(){ hookSubmitEvent($("#form_search")); $("#button_toolbar_addnode").click(function(){ - new JsdeWindow({ + var win = new JsdeWindow({ width: 320, height: 400, x: 40, @@ -224,6 +224,7 @@ $(function(){ title: "Create new node", contents: "Loading...", source_url: "/nodes/create", + callback: function(){ $(win._inner).find("input[name=name]").focus(); }, noscroll: true }); }); @@ -258,4 +259,24 @@ $(function(){ openWindowNodeDetails(data.value); this.target.val(""); }); + + $("body").keydown(function(event){ + switch(event.which) + { + case 70: // F + if(event.ctrlKey) + { + $("#input_search_query").focus(); + event.preventDefault(); + } + break; + case 77: // M + if(event.ctrlKey) + { + $("#button_toolbar_addnode").click(); + event.preventDefault(); + } + break; + } + }); });