Commit c8373b18 authored by Dave Lane's avatar Dave Lane

possible fix for following links in dialogs via keyboard

parent 7f660cc1
......@@ -170,8 +170,8 @@ class OREMain extends OREBase {
$response = $this->logout();
$this->log('logout response: '.print_r($response, true));
break;
case 'password_reset':
//$this->log('password_reset');
case 'passwordreset':
//$this->log('passwordreset');
$response = $this->reset_password();
break;
case 'update_password':
......
......@@ -72,7 +72,7 @@ $dialog_definitions = array(
__('Make sure no one is watching as you type this.', 'oeru-register-enrol').
'<br/><br/>'.
__('Problems? You can do a ', 'oeru-register-enrol').
'<a id="ore-password-reset-auxillary-button" class="link ore-button" href="#password-reset">'.
'<a id="ore-passwordreset-auxillary-button" class="link ore-button" href="#passwordreset">'.
__('Password Reset', 'oeru-register-enrol').'</a>.<br/><br/><span class="ore-detail">'.
__('(The OERu encourages you to use "<a href="{{ore_data.password_manager}}">password manager</a>" software to store your passwords and help you create a strong and unique one for each website!)', 'oeru-register-enrol').
'</span>'.
......@@ -114,9 +114,9 @@ $dialog_definitions = array(
'destination' => 'login'
),
),
'password_reset' => array(
'passwordreset' => array(
'title' => __('Reset your password', 'oeru-register-enrol'),
'token' => 'password-reset',
'token' => 'passwordreset',
'auth' => 'both',
'markup' => '<p>'.__('If you have forgotten your password, you can request a reset. We need to know <em>one</em> of the following: (1) the email address you used to create your account, or (2) your username.', 'oeru-register-enrol').'</p>'.
'<div class="form-group">'.
......@@ -336,8 +336,8 @@ $dialog_definitions = array(
'<input type="password" class="form-control" id="current-password" name="current-password" aria-describedby="helpCurrentPassword">'.
'<span id="helpCurrentPassword" class="help-block">'.
__("Your current password, so that we can ensure you're you!<br/>If you can't remember your password, you can instead do a ").
'<span id="ore-password-reset-auxillary-button" class="link ore-button">'.
__('Password Reset', 'oeru-register-enrol').'</span><br/>'.__('(The OERu encourages you to use "password manager" software to store your passwords and help you create a strong and unique one for each website!)', 'oeru-register-enrol').'</span>'.
'<a id="ore-passwordreset-auxillary-button" class="link ore-button" href="#passwordreset">'.
__('Password Reset', 'oeru-register-enrol').'</a><br/>'.__('(The OERu encourages you to use "password manager" software to store your passwords and help you create a strong and unique one for each website!)', 'oeru-register-enrol').'</span>'.
'</div>'.
'<div class="form-group">'.
'<label for="new-password">'.__('New Password', 'oeru-register-enrol').'</label>'.
......
/* created by Dave Lane, dave@oerfoundation.org, https://oeru.org */
var ORE_DEBUG = true; // set to false to disable debugging
var ORE_DEBUG = false; // set to false to disable debugging
function LOG() { if (ORE_DEBUG) { console.log.apply(this, arguments); }}
LOG('ORE DEBUG =', ORE_DEBUG); // only prints if DEBUG = true
// jQuery selectors and related functions in that context
......@@ -62,7 +62,7 @@ jQuery(document).ready(function() {
}
}
},
'password_reset': {
'passwordreset': {
rules: {
'password': {
required: true
......@@ -491,7 +491,7 @@ jQuery(document).ready(function() {
}
});
// handle clicks within dialogs
$(document).on('click', 'button', function(e) {
$(document).on('click', 'button.ore-button', function(e) {
LOG('button click within dialog, event id ', e.currentTarget.id);
var action = action_from_id(e.currentTarget.id);
LOG('Action: ', action);
......@@ -503,6 +503,21 @@ jQuery(document).ready(function() {
handle_action(action);
}
});
// handle links
$(document).on('click', 'a', function(e) {
LOG('link click, event id ', e.currentTarget.id);
current_focus = $(':focus');
if (current_focus.hasClass('ore-button')) {
action = action_from_id(e.currentTarget.id);
LOG('executing action ', action);
handle_action(action);
} else {
LOG('just forwarding on the click...');
e.preventDefault();
window.open(current_focus.attr('href'));
}
});
// set this up to submit on 'enter',
// close dialogs on ESC,
......@@ -523,14 +538,14 @@ jQuery(document).ready(function() {
if (current_focus.hasClass('ore-trigger')) {
LOG('hitting space on trigger');
trigger.click();
} else if (current_focus.parent().hasClass('ore-trigger') || current_focus.hasClass('button')) {
} else if (current_focus.parent().hasClass('ore-trigger') || current_focus.hasClass('ore-button')) {
if (current_focus.parent().hasClass('ore-trigger')) {
LOG('our trigger is focused');
} else if (current_focus.hasClass('button')) {
} else if (current_focus.hasClass('ore-button')) {
LOG('a button is focused');
}
current_focus.click();
}
current_focus.click();
}
});
......@@ -540,16 +555,17 @@ jQuery(document).ready(function() {
var orig_action = action;
// check if there's a form that needs processing
if (action == 'log_out') {
busy();
LOG('logging user out');
log_out(action);
not_busy();
return;
}
if (process_form(action)) {
LOG('processed form for ', action);
return;
} else {
}
if (ore_data.dialogs.hasOwnProperty(action)) {
LOG('orig action '+orig_action+' and new action '+action);
if (create_dialog(action)) {
......@@ -649,10 +665,10 @@ jQuery(document).ready(function() {
LOG('purpose is not confirmation');
}
if (special_data = get_form_values(form)) {
if (action == 'password_reset' ||
if (action == 'passwordreset' ||
action == 'update_password' ||
action == 'edit_profile') {
LOG('setting special data for password_reset, or update_password, or edit_profile');
LOG('setting special data for passwordreset, or update_password, or edit_profile');
special_data['user_id'] = ore_data.user.user_id;
special_data['username'] = ore_data.user.username;
special_data['existing_email'] = ore_data.user.email;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment