From 72e0fa41567973398fc2dce37c009c41a23d5113 Mon Sep 17 00:00:00 2001 From: Jennifer Taylor Date: Fri, 8 May 2020 20:07:55 +0000 Subject: [PATCH] Auto-focus on input elements when clicking Update button across various pages. --- .../static/controllers/account/account.react.js | 13 +++++++++++++ .../static/controllers/admin/api.react.js | 11 +++++++++++ .../static/controllers/admin/arcades.react.js | 9 +++++++++ .../static/controllers/admin/machines.react.js | 9 +++++++++ .../static/controllers/admin/news.react.js | 9 +++++++++ .../static/controllers/admin/user.react.js | 15 +++++++++++++++ .../static/controllers/arcade/arcade.react.js | 9 +++++++++ .../static/controllers/bishi/settings.react.js | 9 +++++++++ .../static/controllers/ddr/settings.react.js | 11 +++++++++++ .../static/controllers/iidx/settings.react.js | 9 +++++++++ .../static/controllers/jubeat/settings.react.js | 9 +++++++++ .../static/controllers/museca/settings.react.js | 9 +++++++++ .../static/controllers/popn/settings.react.js | 9 +++++++++ .../static/controllers/reflec/settings.react.js | 9 +++++++++ .../static/controllers/sdvx/settings.react.js | 9 +++++++++ 15 files changed, 149 insertions(+) diff --git a/bemani/frontend/static/controllers/account/account.react.js b/bemani/frontend/static/controllers/account/account.react.js index 67fc24a..7523e15 100644 --- a/bemani/frontend/static/controllers/account/account.react.js +++ b/bemani/frontend/static/controllers/account/account.react.js @@ -17,6 +17,13 @@ var account_management = React.createClass({ }; }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + saveEmail: function(event) { AJAX.post( Link.get('updateemail'), @@ -93,6 +100,8 @@ var account_management = React.createClass({ (this.focus_element = c)} value={this.state.old_password} onChange={function(event) { this.setState({old_password: event.target.value}); @@ -162,6 +171,8 @@ var account_management = React.createClass({ (this.focus_element = c)} value={this.state.email_password} onChange={function(event) { this.setState({email_password: event.target.value}); @@ -220,6 +231,8 @@ var account_management = React.createClass({ className="inline" maxlength="4" size="4" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_pin} onChange={function(event) { var intRegex = /^\d*$/; diff --git a/bemani/frontend/static/controllers/admin/api.react.js b/bemani/frontend/static/controllers/admin/api.react.js index 10686a3..3b97706 100644 --- a/bemani/frontend/static/controllers/admin/api.react.js +++ b/bemani/frontend/static/controllers/admin/api.react.js @@ -19,6 +19,13 @@ var api_management = React.createClass({ }; }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + scheduleServerInfo: function(servers) { var info = {}; @@ -230,6 +237,8 @@ var api_management = React.createClass({ return (this.focus_element = c)} value={ this.state.editing_client.name } onChange={function(event) { var client = this.state.editing_client; @@ -310,6 +319,8 @@ var api_management = React.createClass({ return (this.focus_element = c)} value={ this.state.editing_server.uri } onChange={function(event) { var server = this.state.editing_server; diff --git a/bemani/frontend/static/controllers/admin/arcades.react.js b/bemani/frontend/static/controllers/admin/arcades.react.js index 93af99f..bf10885 100644 --- a/bemani/frontend/static/controllers/admin/arcades.react.js +++ b/bemani/frontend/static/controllers/admin/arcades.react.js @@ -17,6 +17,13 @@ var card_management = React.createClass({ }; }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + addNewArcade: function(event) { AJAX.post( Link.get('addarcade'), @@ -136,6 +143,8 @@ var card_management = React.createClass({ return (this.focus_element = c)} value={ this.state.editing_arcade.name } onChange={function(event) { var arcade = this.state.editing_arcade; diff --git a/bemani/frontend/static/controllers/admin/machines.react.js b/bemani/frontend/static/controllers/admin/machines.react.js index 27aa5d1..31880f4 100644 --- a/bemani/frontend/static/controllers/admin/machines.react.js +++ b/bemani/frontend/static/controllers/admin/machines.react.js @@ -20,6 +20,13 @@ var machine_management = React.createClass({ }; }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + generateNewMachine: function(event) { AJAX.post( Link.get('generatepcbid'), @@ -125,6 +132,8 @@ var machine_management = React.createClass({ return (this.focus_element = c)} value={ this.state.editing_machine.description } onChange={function(event) { var machine = this.state.editing_machine; diff --git a/bemani/frontend/static/controllers/admin/news.react.js b/bemani/frontend/static/controllers/admin/news.react.js index 5e98f11..b43830c 100644 --- a/bemani/frontend/static/controllers/admin/news.react.js +++ b/bemani/frontend/static/controllers/admin/news.react.js @@ -12,6 +12,13 @@ var news_management = React.createClass({ }; }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + deleteExistingNews: function(event, newsid) { $.confirm({ escapeKey: 'Cancel', @@ -99,6 +106,8 @@ var news_management = React.createClass({ (this.focus_element = c)} value={ this.state.editing_news.title } onChange={function(event) { var entry = this.state.editing_news; diff --git a/bemani/frontend/static/controllers/admin/user.react.js b/bemani/frontend/static/controllers/admin/user.react.js index 64230e5..30213cc 100644 --- a/bemani/frontend/static/controllers/admin/user.react.js +++ b/bemani/frontend/static/controllers/admin/user.react.js @@ -33,6 +33,13 @@ var user_management = React.createClass({ this.refreshUser(); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + refreshUser: function() { AJAX.get( Link.get('refresh'), @@ -204,6 +211,8 @@ var user_management = React.createClass({ (this.focus_element = c)} value={this.state.new_username} onChange={function(event) { this.setState({new_username: event.target.value}); @@ -246,6 +255,8 @@ var user_management = React.createClass({ (this.focus_element = c)} value={this.state.new_password1} onChange={function(event) { this.setState({new_password1: event.target.value}); @@ -306,6 +317,8 @@ var user_management = React.createClass({ (this.focus_element = c)} value={this.state.new_email} onChange={function(event) { this.setState({new_email: event.target.value}); @@ -349,6 +362,8 @@ var user_management = React.createClass({ maxlength="4" size="4" className="inline" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_pin} onChange={function(event) { var intRegex = /^\d*$/; diff --git a/bemani/frontend/static/controllers/arcade/arcade.react.js b/bemani/frontend/static/controllers/arcade/arcade.react.js index ae52c5a..f744e5f 100644 --- a/bemani/frontend/static/controllers/arcade/arcade.react.js +++ b/bemani/frontend/static/controllers/arcade/arcade.react.js @@ -51,6 +51,13 @@ var arcade_management = React.createClass({ this.refreshArcade(); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + refreshArcade: function() { AJAX.get( Link.get('refresh'), @@ -245,6 +252,8 @@ var arcade_management = React.createClass({ className="inline" maxlength="8" size="8" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_pin} onChange={function(event) { var intRegex = /^\d*$/; diff --git a/bemani/frontend/static/controllers/bishi/settings.react.js b/bemani/frontend/static/controllers/bishi/settings.react.js index cc7b6a6..5158b33 100644 --- a/bemani/frontend/static/controllers/bishi/settings.react.js +++ b/bemani/frontend/static/controllers/bishi/settings.react.js @@ -30,6 +30,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + saveName: function(event) { AJAX.post( Link.get('updatename'), @@ -68,6 +75,8 @@ var settings_view = React.createClass({ className="inline" maxlength="6" size="6" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_name} onChange={function(event) { var rawvalue = event.target.value; diff --git a/bemani/frontend/static/controllers/ddr/settings.react.js b/bemani/frontend/static/controllers/ddr/settings.react.js index 720f9f2..05ce8bc 100644 --- a/bemani/frontend/static/controllers/ddr/settings.react.js +++ b/bemani/frontend/static/controllers/ddr/settings.react.js @@ -38,6 +38,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + setOptionsChanged: function(val) { this.state.options_changed[this.state.version] = val; return this.state.options_changed; @@ -176,6 +183,8 @@ var settings_view = React.createClass({ className="inline" maxlength="8" size="8" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_name} onChange={function(event) { var value = event.target.value.toUpperCase(); @@ -247,6 +256,8 @@ var settings_view = React.createClass({ className="inline" maxlength="5" size="5" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_weight} onChange={function(event) { var value = event.target.value.toUpperCase(); diff --git a/bemani/frontend/static/controllers/iidx/settings.react.js b/bemani/frontend/static/controllers/iidx/settings.react.js index 657213f..fd06ddc 100644 --- a/bemani/frontend/static/controllers/iidx/settings.react.js +++ b/bemani/frontend/static/controllers/iidx/settings.react.js @@ -70,6 +70,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + setMenuChanged: function(val) { this.state.menu_changed[this.state.version] = val; return this.state.menu_changed; @@ -219,6 +226,8 @@ var settings_view = React.createClass({ className="inline" maxlength="6" size="6" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_name} onChange={function(event) { var value = event.target.value.toUpperCase(); diff --git a/bemani/frontend/static/controllers/jubeat/settings.react.js b/bemani/frontend/static/controllers/jubeat/settings.react.js index af703dc..3fc49ca 100644 --- a/bemani/frontend/static/controllers/jubeat/settings.react.js +++ b/bemani/frontend/static/controllers/jubeat/settings.react.js @@ -23,6 +23,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + saveName: function(event) { AJAX.post( Link.get('updatename'), @@ -60,6 +67,8 @@ var settings_view = React.createClass({ type="text" className="inline" maxlength="8" + autofocus="true" + ref={c => (this.focus_element = c)} size="8" value={this.state.new_name} onChange={function(event) { diff --git a/bemani/frontend/static/controllers/museca/settings.react.js b/bemani/frontend/static/controllers/museca/settings.react.js index 9fadefc..97caca9 100644 --- a/bemani/frontend/static/controllers/museca/settings.react.js +++ b/bemani/frontend/static/controllers/museca/settings.react.js @@ -23,6 +23,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + saveName: function(event) { AJAX.post( Link.get('updatename'), @@ -60,6 +67,8 @@ var settings_view = React.createClass({ type="text" className="inline" maxlength="8" + autofocus="true" + ref={c => (this.focus_element = c)} size="16" value={this.state.new_name} onChange={function(event) { diff --git a/bemani/frontend/static/controllers/popn/settings.react.js b/bemani/frontend/static/controllers/popn/settings.react.js index 50e1537..35e426f 100644 --- a/bemani/frontend/static/controllers/popn/settings.react.js +++ b/bemani/frontend/static/controllers/popn/settings.react.js @@ -23,6 +23,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + saveName: function(event) { AJAX.post( Link.get('updatename'), @@ -61,6 +68,8 @@ var settings_view = React.createClass({ className="inline" maxlength="6" size="12" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_name} onChange={function(event) { var rawvalue = event.target.value; diff --git a/bemani/frontend/static/controllers/reflec/settings.react.js b/bemani/frontend/static/controllers/reflec/settings.react.js index 6862b8b..481d1ca 100644 --- a/bemani/frontend/static/controllers/reflec/settings.react.js +++ b/bemani/frontend/static/controllers/reflec/settings.react.js @@ -23,6 +23,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + saveName: function(event) { AJAX.post( Link.get('updatename'), @@ -61,6 +68,8 @@ var settings_view = React.createClass({ className="inline" maxlength="8" size="16" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_name} onChange={function(event) { var rawvalue = event.target.value; diff --git a/bemani/frontend/static/controllers/sdvx/settings.react.js b/bemani/frontend/static/controllers/sdvx/settings.react.js index 9fadefc..8df2d30 100644 --- a/bemani/frontend/static/controllers/sdvx/settings.react.js +++ b/bemani/frontend/static/controllers/sdvx/settings.react.js @@ -23,6 +23,13 @@ var settings_view = React.createClass({ }.bind(this)); }, + componentDidUpdate: function() { + if (this.focus_element && this.focus_element != this.already_focused) { + this.focus_element.focus(); + this.already_focused = this.focus_element; + } + }, + saveName: function(event) { AJAX.post( Link.get('updatename'), @@ -61,6 +68,8 @@ var settings_view = React.createClass({ className="inline" maxlength="8" size="16" + autofocus="true" + ref={c => (this.focus_element = c)} value={this.state.new_name} onChange={function(event) { var value = event.target.value.toUpperCase();