Commit 2b27a5c4 authored by Amit Asaravala's avatar Amit Asaravala
Browse files

by aasarava: added javascript block to prevent accidental double-click of...

by aasarava: added javascript block to prevent accidental double-click of confirmation button; fixed array error when no taxonomy terms are defined.
parent 10affe6b
...@@ -380,7 +380,7 @@ function scanner_form_submit($form_id, $form_values) { ...@@ -380,7 +380,7 @@ function scanner_form_submit($form_id, $form_values) {
$_SESSION['scanner_wholeword'] = $form_values['wholeword']; $_SESSION['scanner_wholeword'] = $form_values['wholeword'];
$_SESSION['scanner_published'] = $form_values['published']; $_SESSION['scanner_published'] = $form_values['published'];
$_SESSION['scanner_regex'] = $form_values['regex']; $_SESSION['scanner_regex'] = $form_values['regex'];
$_SESSION['scanner_terms'] = array_filter($form_values['terms']); $_SESSION['scanner_terms'] = $form_values['terms'];
$_SESSION['scanner_replace'] = $form_values['replace']; $_SESSION['scanner_replace'] = $form_values['replace'];
if ($form_values['op'] == 'Replace') { if ($form_values['op'] == 'Replace') {
...@@ -399,6 +399,39 @@ function scanner_form_submit($form_id, $form_values) { ...@@ -399,6 +399,39 @@ function scanner_form_submit($form_id, $form_values) {
* replacing things they don't intend to. * replacing things they don't intend to.
*/ */
function scanner_confirm_form() { function scanner_confirm_form() {
//using set_html_head because it seems unecessary to load a separate css
// file for just one declaration:
//you can override the styles by declaring with something "higher up"
// the chain, like: #wrapper #scanner-confirm-form .scanner-buttons .scanner-button-msg {...}
drupal_set_html_head('
<style type="text/css">
#scanner-confirm-form .scanner-buttons .scanner-button-msg {
position:absolute;
top:0; left:0; z-index:100;
width:100%; height:100%;
background-color:#000; opacity:0.75;
font-size:1.2em;
}
#scanner-confirm-form .scanner-buttons .scanner-button-msg p {
color:#fff;
}
</style>
');
//javascript to prevent further clicks on confirmation button after it's clicked once.
//unfortunately we can't just use css disable to disable the button because then
// the op values aren't sent to drupal correctly.
drupal_add_js("
$(document).ready(function() {
$('input[@type=submit][@value=Yes, Continue]').click(function() {
$('.scanner-buttons').css('position','relative')
.append('<div class=\"scanner-button-msg\"><p>Replacing items... please wait...</p></div>')
$('.scanner-button-msg').click(function() { return false; });
return true;
});
});
", 'inline');
$form = array(); $form = array();
$search = $_SESSION['scanner_search']; $search = $_SESSION['scanner_search'];
...@@ -467,10 +500,12 @@ function scanner_confirm_form() { ...@@ -467,10 +500,12 @@ function scanner_confirm_form() {
$form['confirm'] = array( $form['confirm'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('Yes, Continue'), '#value' => t('Yes, Continue'),
'#prefix' => '<div class="scanner-buttons">', //see suffix in cancel button element
); );
$form['cancel'] = array( $form['cancel'] = array(
'#type' => 'submit', '#type' => 'submit',
'#value' => t('No, Cancel'), '#value' => t('No, Cancel'),
'#suffix' => '</div>', //see prefix in confirm button element
); );
return $form; return $form;
......
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