From bdbbf0bd987bd4ef586ded4e94efdc6350f06be9 Mon Sep 17 00:00:00 2001 From: Rick Falkvinge Date: Sat, 15 Nov 2014 19:35:16 +0100 Subject: [PATCH] Massive improvements to keyboard nav --- Site5/Controls/v5/Base/DropDown.ascx | 43 ++++++------ Site5/Controls/v5/Base/DropDown.ascx.cs | 2 +- Site5/Controls/v5/Financial/ComboBudgets.ascx | 67 ++++++++++++++++++- Site5/Pages/v5/Admin/CreateOrganization.aspx | 34 ++-------- Site5/Pages/v5/Admin/EditOrganization.aspx | 14 +++- Site5/Pages/v5/Admin/EditOrganization.aspx.cs | 7 ++ Site5/Style/v5-easyui-elements.css | 28 +++++++- 7 files changed, 141 insertions(+), 54 deletions(-) diff --git a/Site5/Controls/v5/Base/DropDown.ascx b/Site5/Controls/v5/Base/DropDown.ascx index 31ef3a01..9315ae6d 100644 --- a/Site5/Controls/v5/Base/DropDown.ascx +++ b/Site5/Controls/v5/Base/DropDown.ascx @@ -1,29 +1,34 @@ <%@ Control Language="C#" AutoEventWireup="true" CodeFile="DropDown.ascx.cs" Inherits="Swarmops.Frontend.Controls.v5.Base.DropDown" %> + diff --git a/Site5/Controls/v5/Base/DropDown.ascx.cs b/Site5/Controls/v5/Base/DropDown.ascx.cs index c0ef1c7d..a884f329 100644 --- a/Site5/Controls/v5/Base/DropDown.ascx.cs +++ b/Site5/Controls/v5/Base/DropDown.ascx.cs @@ -21,7 +21,7 @@ namespace Swarmops.Frontend.Controls.v5.Base public string SelectedValue { - get { return this.SelectedValue; } + get { return this.DropControl.SelectedValue; } } } } \ No newline at end of file diff --git a/Site5/Controls/v5/Financial/ComboBudgets.ascx b/Site5/Controls/v5/Financial/ComboBudgets.ascx index 0d1f3aae..8ebe00ec 100644 --- a/Site5/Controls/v5/Financial/ComboBudgets.ascx +++ b/Site5/Controls/v5/Financial/ComboBudgets.ascx @@ -24,7 +24,11 @@ $('#<%=this.ClientID %>_SpanBudgets span.combo input.combo-text').keydown(function (e) { switch (e.which) { case 40: // down - $('#<%=this.ClientID %>_SpanBudgets span.combo span span.combo-arrow').click(); + var panel = $('#<%=this.ClientID %>_DropBudgets').combotree('panel'); + if (!panel.is(':visible')) { + $('#<%=this.ClientID %>_SpanBudgets span.combo span span.combo-arrow').click(); + panel.focus(); + } break; default: return; // exit this handler for other keys @@ -32,6 +36,67 @@ e.preventDefault(); // prevent the default action (scroll / move caret) }); }); + + // below code from http://doc.javake.cn/jeasyui/www.jeasyui.com/forum/index.php-topic=1972.0.htm, understood to be in public domain + + (function () { + $.extend($.fn.combotree.methods, { + nav: function (jq, dir) { + return jq.each(function () { + var opts = $(this).combotree('options'); + var t = $(this).combotree('tree'); + var nodes = t.tree('getChildren'); + if (!nodes.length) { return } + var node = t.tree('getSelected'); + if (!node) { + t.tree('select', dir > 0 ? nodes[0].target : nodes[nodes.length - 1].target); + } else { + var index = 0; + for (var i = 0; i < nodes.length; i++) { + if (nodes[i].target == node.target) { + index = i; + break; + } + } + if (dir > 0) { + while (index < nodes.length - 1) { + index++; + if ($(nodes[index].target).is(':visible')) { break } + } + } else { + while (index > 0) { + index--; + if ($(nodes[index].target).is(':visible')) { break } + } + } + t.tree('select', nodes[index].target); + } + if (opts.selectOnNavigation) { + var node = t.tree('getSelected'); + $(node.target).trigger('click'); + $(this).combotree('showPanel'); + } + }); + } + }); + $.extend($.fn.combotree.defaults.keyHandler, { + up: function () { + $(this).combotree('nav', -1); + }, + down: function () { + $(this).combotree('nav', 1); + }, + enter: function () { + var t = $(this).combotree('tree'); + var node = t.tree('getSelected'); + if (node) { + $(node.target).trigger('click'); + } + $(this).combotree('hidePanel'); + } + }); + })(jQuery); + \ No newline at end of file diff --git a/Site5/Pages/v5/Admin/CreateOrganization.aspx b/Site5/Pages/v5/Admin/CreateOrganization.aspx index 8441df21..644fdd99 100644 --- a/Site5/Pages/v5/Admin/CreateOrganization.aspx +++ b/Site5/Pages/v5/Admin/CreateOrganization.aspx @@ -1,35 +1,11 @@ <%@ Page Title="" Language="C#" MasterPageFile="~/Master-v5.master" AutoEventWireup="true" CodeFile="CreateOrganization.aspx.cs" Inherits="Swarmops.Frontend.Pages.v5.Admin.CreateOrganization" %> -<%@ Register TagPrefix="Swarmops5" TagName="ExternalScripts" Src="~/Controls/v5/UI/ExternalScripts.ascx" %> +<%@ Register TagPrefix="Swarmops5" TagName="DropDown" Src="~/Controls/v5/Base/DropDown.ascx" %>