Added KeyDown event to AjaxEditBox

This commit is contained in:
Falkvinge
2016-11-20 19:40:33 +01:00
parent 0fd8135342
commit 765cf16d2f
3 changed files with 27 additions and 8 deletions
+18 -7
View File
@@ -8,13 +8,24 @@
$(document).ready(function () {
$('#<%=this.TextInput.ClientID%>').keydown(function (e) {
// reset timer if set
if (<%=this.ClientID%>_onChangingTimer != null) {
clearTimeout(<%=this.ClientID%>_onChangingTimer);
<%=this.ClientID%>_onChangingTimer = setTimeout(function() { <%=this.ClientID%>_fireOnChanging(); }, 500);
} else {
// otherwise set new timer with a more generous timeout on keydown in general
<%=this.ClientID%>_onChangingTimer = setTimeout(function () { <%=this.ClientID%>_fireOnChanging(); }, 500);
if (e.keyCode != 9) { // tab key
// reset timer if set
if (<%=this.ClientID%>_onChangingTimer != null) {
clearTimeout(<%=this.ClientID%>_onChangingTimer);
<%=this.ClientID%>_onChangingTimer = setTimeout(function() { <%=this.ClientID%>_fireOnChanging(); }, 500);
} else {
// otherwise set new timer with a more generous timeout on keydown in general
<%=this.ClientID%>_onChangingTimer = setTimeout(function() { <%=this.ClientID%>_fireOnChanging(); }, 500);
}
<%
if (!string.IsNullOrEmpty(this.OnKeyDown))
{
Response.Write(this.OnKeyDown + "(e.keyCode);");
}
%>
}
});
@@ -30,6 +30,7 @@ namespace Swarmops.Frontend.Controls.Base
public string Cookie { set; get; }
public string OnChange { get; set; }
public string OnChanging { get; set; }
public string OnKeyDown { get; set; }
public string AjaxCallbackUrl { set; get; }
public TextBoxMode Mode { get; set; }
+8 -1
View File
@@ -248,7 +248,7 @@
<div title="<img src='/Images/Icons/iconshock-lock-256px.png' height='64' width='64' />">
<h2><span class="spanModalEditingPersonName">PERSONNAME</span>: <asp:Label runat="server" ID="MasterLabelEditPersonHeaderSecurity" Text="#Your Security#"/></h2>
<div class="entryFields">
<Swarmops5:AjaxTextBox ID="MasterEditPersonCurrentPassword" runat="server" Mode="Password" OnChanging="masterPersonEditorOnSecurityPasswordChanging" Cookie="CurrentPassword" AjaxCallbackUrl="" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonCurrentPassword" runat="server" Mode="Password" OnKeyDown="masterPersonEditorOnSecurityPasswordKeyDown" OnChanging="masterPersonEditorOnSecurityPasswordChanging" Cookie="CurrentPassword" AjaxCallbackUrl="" />&#8203;<br/>
<div class="divMasterPersonEditSecurityRolldown" style="display:none"><Swarmops5:AjaxToggleSlider ID="MasterEditPerson2FA" runat="server" OnChange="masterPersonEditorOnFieldChange" Cookie="2FA" AjaxCallbackUrl="" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonNewPassword1" runat="server" Mode="Password" OnChange="masterPersonEditorOnFieldChange" Cookie="Phone" AjaxCallbackUrl="" />&#8203;<br/>
<Swarmops5:AjaxTextBox ID="MasterEditPersonNewPassword2" runat="server" Mode="Password" OnChange="masterPersonEditorOnFieldChange" Cookie="TwitterId" AjaxCallbackUrl="" />
@@ -366,6 +366,13 @@
var _master_PersonEditor_SecurityShowing = false;
function masterPersonEditorOnSecurityPasswordKeyDown() {
if (_master_PersonEditor_SecurityShowing) {
$('div.divMasterPersonEditSecurityRolldown').slideUp();
_master_PersonEditor_SecurityShowing = false;
}
}
function masterPersonEditorOnSecurityPasswordChanging(newValue, cookie, controlName) {
if (_master_PersonEditor_SecurityShowing) {