From: Janusz Dobrowolski Date: Sat, 6 Nov 2010 19:28:22 +0000 (+0000) Subject: Helpers for js confirmation dialog before data entry is abandoned. X-Git-Tag: v2.4.2~19^2~513 X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=6724489b9b146d2ebd8b89c1f0562954a14619f7;hp=960bbc5e344bce59854afae242a269dd6b54671b;p=fa-stable.git Helpers for js confirmation dialog before data entry is abandoned. --- diff --git a/includes/ui/ui_controls.inc b/includes/ui/ui_controls.inc index a6fd2ef6..f2e76d1b 100644 --- a/includes/ui/ui_controls.inc +++ b/includes/ui/ui_controls.inc @@ -56,6 +56,7 @@ function end_form($breaks=0) if ($breaks) br($breaks); echo "\n"; + echo "\n"; echo "\n"; } @@ -561,6 +562,35 @@ function confirm_dialog($submit, $msg) { return 0; } else return get_post('DialogConfirm', 0); -} +} + +/* + Block menu/shortcut links during transaction procesing. +*/ +function page_processing($msg = false) +{ + global $Ajax; + + if ($msg === true) + $msg = _('Entered data has not been saved yet.\nDo you want to abandon changes?'); + + $js = "_validate._processing=" . ( + $msg ? '\''.strtr($msg, array("\n"=>'\\n')) . '\';' : 'null;'); + if (in_ajax()) { + $Ajax->addScript(true, $js); + } else + add_js_source($js); +} + +function page_modified($status = true) +{ + global $Ajax; + + $js = "_validate._modified=" . ($status ? 1:0).';'; + if (in_ajax()) { + $Ajax->addScript(true, $js); + } else + add_js_source($js); +} ?> \ No newline at end of file diff --git a/js/inserts.js b/js/inserts.js index a1e1e5ea..45f45346 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -323,6 +323,19 @@ var inserts = { return false; } } + // prevent unneeded transaction entry abortion + if (e.className == 'shortcut' + || e.className == 'menu_option' + || e.className == 'menu_tab' + || e.className == 'selected') + e.onclick = function(ev) { + if (_validate._processing + && _validate._modified + && !confirm(_validate._processing)) { + ev.returnValue = false; + return false; + } + } }, 'ul.ajaxtabs': function(ul) { var ulist=ul.getElementsByTagName("li"); diff --git a/themes/aqua/renderer.php b/themes/aqua/renderer.php index 300f90f3..8ee81f2d 100644 --- a/themes/aqua/renderer.php +++ b/themes/aqua/renderer.php @@ -46,8 +46,8 @@ foreach($applications as $app) { $acc = access_string($app->name); - echo "id ? "class='selected' " : ""). - "href='$local_path_to_root/index.php?application=".$app->id + echo "" .$acc[0] . ""; } echo ""; @@ -58,14 +58,14 @@ echo "" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . " | " . $_SERVER['SERVER_NAME'] . " | " . $_SESSION["wa_current_user"]->name . ""; $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif"; echo ""; - echo " " . _("Preferences") . "   \n"; - echo " " . _("Change password") . "   \n"; + echo " " . _("Preferences") . "   \n"; + echo " " . _("Change password") . "   \n"; if ($help_base_url != null) { echo "$himg" . _("Help") . "   "; } - echo "$img" . _("Logout") . "   "; + echo "$img" . _("Logout") . "   "; echo ""; } echo ""; diff --git a/themes/cool/renderer.php b/themes/cool/renderer.php index e5ec015b..9bf46c95 100644 --- a/themes/cool/renderer.php +++ b/themes/cool/renderer.php @@ -46,8 +46,8 @@ foreach($applications as $app) { $acc = access_string($app->name); - echo "id ? "class='selected' " : ""). - "href='$local_path_to_root/index.php?application=".$app->id + echo "" .$acc[0] . ""; } echo ""; @@ -58,14 +58,14 @@ echo "" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . " | " . $_SERVER['SERVER_NAME'] . " | " . $_SESSION["wa_current_user"]->name . ""; $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif"; echo ""; - echo " " . _("Preferences") . "   \n"; - echo " " . _("Change password") . "   \n"; + echo " " . _("Preferences") . "   \n"; + echo " " . _("Change password") . "   \n"; if ($help_base_url != null) { echo "$himg" . _("Help") . "   "; } - echo "$img" . _("Logout") . "   "; + echo "$img" . _("Logout") . "   "; echo ""; } echo ""; diff --git a/themes/default/renderer.php b/themes/default/renderer.php index aaee7125..03a56f24 100644 --- a/themes/default/renderer.php +++ b/themes/default/renderer.php @@ -47,9 +47,8 @@ foreach($applications as $app) { $acc = access_string($app->name); - echo "id ? - ("class='selected'") : "") - ." href='$local_path_to_root/index.php?application=".$app->id + echo "" .$acc[0] . ""; } echo ""; @@ -59,14 +58,14 @@ echo "" . $db_connections[$_SESSION["wa_current_user"]->company]["name"] . " | " . $_SERVER['SERVER_NAME'] . " | " . $_SESSION["wa_current_user"]->name . ""; $indicator = "$path_to_root/themes/".user_theme(). "/images/ajax-loader.gif"; echo ""; - echo " " . _("Preferences") . "   \n"; - echo " " . _("Change password") . "   \n"; + echo " " . _("Preferences") . "   \n"; + echo " " . _("Change password") . "   \n"; if ($help_base_url != null) { echo "$himg" . _("Help") . "   "; } - echo "$img" . _("Logout") . "   "; + echo "$img" . _("Logout") . "   "; echo ""; echo ""; }