Support for default buttons with Ctrl-Enter/Escpae hotkeys, arrow navigation in menus.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 16 Mar 2009 19:19:13 +0000 (19:19 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Mon, 16 Mar 2009 19:19:13 +0000 (19:19 +0000)
14 files changed:
includes/page/footer.inc
includes/ui/ui_controls.inc
includes/ui/ui_input.inc
includes/ui/ui_view.inc
js/inserts.js
js/utils.js
reporting/includes/reporting.inc
themes/aqua/default.css
themes/aqua/renderer.php
themes/cool/default.css
themes/cool/renderer.php
themes/default/default.css
themes/default/images/escape.png
themes/default/renderer.php

index 2ce07a2947590d17668d0cffe02fa40e9141cabb..61c731186c39b3e407ec06a7ffbb106fcf7449b4 100644 (file)
@@ -21,6 +21,7 @@ function page_footer($no_menu=false, $is_index=false)
        include_once($path_to_root."/themes/".user_theme()."/renderer.php");
        $rend = new renderer();
        $rend->menu_footer($no_menu, $is_index);
+       echo "<script>_focus = '".get_post('_focus')."';</script>";
     echo "</body></html>\n";
 }
 
index 8546255bf6b4f192859a3dde428e6a0b6fd143ba..fe23de17defe268336d8a5495da20ad7da0cfd66 100644 (file)
@@ -9,21 +9,21 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
+function get_post($name, $dflt='')
+{
+       return ((!isset($_POST[$name]) || $_POST[$name] === '') ? $dflt : $_POST[$name]);
+}
 //---------------------------------------------------------------------------------
 
-function start_form($multi=false, $sid=false, $action="", $name="")
+function start_form($multi=false, $dummy=false, $action="", $name="")
 {
+       // $dummy - leaved for compatibility with 2.0 API
+
        if ($name != "")
                $name = "name='$name'";
        if ($action == "")
                $action = $_SERVER['PHP_SELF'];
-       if ($sid)
-       {
-               if (strpos($action, "?"))
-                       $action .= "&" . SID;
-               else
-                       $action .= "?" . SID;
-       }
+
        if ($multi)
                echo "<form enctype='multipart/form-data' method='post' action='$action' $name>\n";
        else
@@ -125,7 +125,6 @@ function hyperlink_back($center=true)
 {
        if ($center)
                echo "<center>";
-       //echo "<a href='javascript:goBack();'>"._("Back")."</a>\n";
        echo "<p><a href='javascript:goBack();'>"._("Back")."</a></p>\n";
        if ($center)
                echo "</center>";
@@ -134,10 +133,11 @@ function hyperlink_back($center=true)
 
 function hyperlink_no_params($target, $label, $center=true)
 {
+       $id = default_focus();
        $pars = access_string($label);
        if ($center)
                echo "<br><center>";
-       echo "<a href='$target?=" . SID . "'$pars[1]>$pars[0]</a>\n";
+       echo "<a href='$target' $id='$id' $pars[1]>$pars[0]</a>\n";
        if ($center)
                echo "</center>";
 }
@@ -149,14 +149,65 @@ function hyperlink_no_params_td($target, $label)
        echo "</td>\n";
 }
 
+function viewer_link($label, $url='', $class='', $id='',  $icon=null)
+{
+       global $path_to_root;
+       
+       if ($class != '')
+               $class = " class='$class'";
+
+       if ($id != '')
+               $class = " id='$id'";
+
+       if ($url != "")
+       {
+               $pars = access_string($label);
+               if (user_graphic_links() && $icon)
+                       $pars[0] = set_icon($icon, $pars[0]);
+               $preview_str = "<a target='_blank' $class $id href='$path_to_root/$url' onclick=\"javascript:openWindow(this.href,this.target); return false;\"$pars[1]>$pars[0]</a>";
+       }
+       else
+               $preview_str = $label;
+
+ return $preview_str;
+}
+
+function menu_link($url, $label, $id=null)
+{
+
+       $id = default_focus($id);
+       $pars = access_string($label);
+       return "<a href='$url' class='menu_option' id='$id' $pars[1]>$pars[0]</a>";
+}
+
+function submenu_option($title, $url, $id=null)
+{
+       global $path_to_root;
+       display_note(menu_link($path_to_root . $url, $title, $id));
+       echo '<br>';
+}
+
+function submenu_view($title, $type, $number, $id=null)
+{
+       display_note(get_trans_view_str($type, $number, $title, false, 'menu_option', $id));
+       echo '<br>';
+}
+
+function submenu_print($title, $type, $number, $id=null)
+{
+       display_note(print_document_link($number, $title, true, $type, false, 'menu_option', $id));
+       echo '<br>';
+}
 //-----------------------------------------------------------------------------------
 
 function hyperlink_params($target, $label, $params, $center=true)
 {
+       $id = default_focus();
+       
        $pars = access_string($label);
        if ($center)
                echo "<br><center>";
-       echo "<a href='$target?$params'$pars[1]>$pars[0]</a>\n";
+       echo "<a id='$id' href='$target?$params'$pars[1]>$pars[0]</a>\n";
        if ($center)
                echo "</center>";
 }
@@ -172,10 +223,12 @@ function hyperlink_params_td($target, $label, $params)
 
 function hyperlink_params_separate($target, $label, $params, $center=false)
 {
+       $id = default_focus();
+
        $pars = access_string($label);
        if ($center)
                echo "<br><center>";
-       echo "<a target='_blank' href='$target?$params" . SID . "'$pars[1]>$pars[0]</a>\n";
+       echo "<a target='_blank' $id='$id' href='$target?$params' $pars[1]>$pars[0]</a>\n";
        if ($center)
                echo "</center>";
 }
index 3da07206ac88c05321bf6260661bc22f5f0839c5..434117e652553e16ffeabdbc06b5cebe0af80837 100644 (file)
@@ -9,11 +9,6 @@
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
     See the License here <http://www.gnu.org/licenses/gpl-3.0.html>.
 ***********************************************************************/
-
-function get_post($name, $dflt='')
-{
-       return ((!isset($_POST[$name]) || $_POST[$name] === '') ? $dflt : $_POST[$name]);
-}
 //
 // Sets local POST value and adds Value to ajax posting if needed
 //
@@ -103,21 +98,48 @@ function hidden($name, $value=null, $echo=true)
        else
                return $ret;
 }
-
-function submit($name, $value, $echo=true, $title=false, $async=false, $icon=false)
+/*
+       Universal submit form button.
+       $atype - type of submit:
+        Normal submit:
+               false - normal button; optional icon
+               null  - button visible only in fallback mode; optional icon
+        Ajax submit:
+               true      - standard button; optional icon
+               'process' - displays progress bar during call; optional icon
+               'default' - default form submit on Ctrl-Enter press; dflt ICON_OK icon
+               'cancel'  - cancel form entry on Escape press; dflt ICON_CANCEL
+*/
+function submit($name, $value, $echo=true, $title=false, $atype=false, $icon=false)
 {
        global $path_to_root;
-       
+
+       $aspect='';
+       if (!is_bool($atype)) // necessary: switch uses '=='
+         switch($atype) {
+               case 'process':
+                       $aspect = " aspect='process'"; break;
+               case 'default':
+                       $aspect = " aspect='default'"; 
+                       if ($icon===false) $icon=ICON_SUBMIT; break;
+               case 'cancel':
+                       $aspect = " aspect='cancel'"; 
+                       if ($icon===false) $icon=ICON_ESCAPE; break;
+               case null: 
+                       $aspect = fallback_mode() ? 
+                               " aspect='fallback'" : " style='display:none;'"; break;
+        }
+
        default_focus($name);
        $submit_str = "<button class=\""
-           .($async ? 'ajaxsubmit' : 'inputsubmit')
+           .($atype ? 'ajaxsubmit' : 'inputsubmit')
                ."\" type=\"submit\""
-               .($async === null ? (fallback_mode() ? ' aspect="fallback"' : " style='display:none;'" ): 
-                       ($async === 'process' ? 'aspect="process"' : '') )
+               .$aspect
            ." name=\"$name\"  id=\"$name\" value=\"$value\""
            .($title ? " title='$title'" : '')
-           ."><span>$value</span>"
+           .">"
                .($icon ? "<img src='$path_to_root/themes/".user_theme()."/images/$icon'>" : '')
+               ."<span>$value</span>"
                ."</button>\n";
        if ($echo)
                echo $submit_str;
index 1d4f1fc1788ac6b6416e42b2ef72a2f40cb31b8c..d1262f1240a6122fe4dbb89f1fffec118f911f61 100644 (file)
@@ -14,46 +14,34 @@ include_once($path_to_root . "/includes/types.inc");
 
 //--------------------------------------------------------------------------------------
 
-function get_supplier_trans_view_str($type, $trans_no, $label="", $icon=false)
+function get_supplier_trans_view_str($type, $trans_no, $label="", $icon=false, 
+       $class='', $id='')
 {
-       global $path_to_root;
-
-       $viewer = "";
+       $viewer = "purchasing/view/";
        if ($type == systypes::po())
-               $viewer = "view_po.php";
+               $viewer .= "view_po.php";
        elseif ($type == 20)
-               $viewer = "view_supp_invoice.php";
+               $viewer .= "view_supp_invoice.php";
        elseif ($type == 21)
-               $viewer = "view_supp_credit.php";
+               $viewer .= "view_supp_credit.php";
        elseif ($type == 22)
                $viewer = "view_supp_payment.php";
        elseif ($type == 25)
-               $viewer = "view_grn.php";
+               $viewer .= "view_grn.php";
        else
                return null;
+       $viewer .= "?trans_no=$trans_no";
 
        if ($label == "")
                $label = $trans_no;
 
-       if ($viewer != "")
-       {
-               $pars = access_string($label);
-               if (user_graphic_links() && $icon)
-                       $pars[0] = set_icon($icon, $pars[0]);
-               $preview_str = "<a target='_blank' href='$path_to_root/purchasing/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\"$pars[1]>$pars[0]</a>";
-       }
-       else
-               $preview_str = $label;
-
-       return $preview_str;
+       return viewer_link($label, $viewer, $class, $id,  $icon);
 }
 
 //--------------------------------------------------------------------------------------
 
-function get_gl_view_str($type, $trans_no, $label="", $force=false)
+function get_gl_view_str($type, $trans_no, $label="", $force=false, $class='', $id='')
 {
-       global $path_to_root;
-
        if (!$force && !user_show_gl_info())
                return "";
 
@@ -63,12 +51,10 @@ function get_gl_view_str($type, $trans_no, $label="", $force=false)
                $label = _("GL");
                $icon = ICON_GL;
        }       
-       $pars = access_string($label);
-       if (user_graphic_links() && $icon)
-               $pars[0] = set_icon($icon, $pars[0]);
-       $gl_view = "<a target='_blank' href='$path_to_root/gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\"$pars[1]>$pars[0]</a>";
 
-       return $gl_view;
+       return viewer_link($label, 
+               "gl/view/gl_trans_view.php?type_id=$type&trans_no=$trans_no", 
+               $class, $id, $icon);
 }
 
 //--------------------------------------------------------------------------------------
@@ -82,21 +68,21 @@ function get_gl_view_str_cell($type, $trans_no, $label="")
 
 //--------------------------------------------------------------------------------------
 
-function get_customer_trans_view_str($type, $trans_no, $label="", $icon=false)
+function get_customer_trans_view_str($type, $trans_no, $label="", $icon=false, 
+       $class='', $id='')
 {
-       global $path_to_root;
+       $viewer = "sales/view/";
 
-       $viewer = "";
        if ($type == 10)
-               $viewer = "view_invoice.php";
+               $viewer .= "view_invoice.php";
        elseif ($type == 11)
-               $viewer = "view_credit.php";
+               $viewer .= "view_credit.php";
        elseif ($type == 12)
-               $viewer = "view_receipt.php";
+               $viewer .= "view_receipt.php";
        elseif ($type == 13)
-               $viewer = "view_dispatch.php";
+               $viewer .= "view_dispatch.php";
        elseif ($type == 30)
-               $viewer = "view_sales_order.php";
+               $viewer .= "view_sales_order.php";
        else
                return null;
 
@@ -110,27 +96,20 @@ function get_customer_trans_view_str($type, $trans_no, $label="", $icon=false)
                $lbl = $trans;
        if($preview_str!='') $preview_str .= ',';
 
-       if ($viewer != "")
-       {
-               $pars = access_string($lbl);
-               if (user_graphic_links() && $icon)
-                       $pars[0] = set_icon($icon, $pars[0]);
-               $preview_str .= "<a target='_blank' href='$path_to_root/sales/view/$viewer?trans_no=$trans' onclick=\"javascript:openWindow(this.href,this.target); return false;\" $pars[1]>$pars[0]</a>";
-       }
-       else
-               $preview_str .= $lbl;
-  }
+       $preview_str .= viewer_link($lbl, $viewer."?trans_no=$trans", 
+               $class, $id, $icon);
 
-       return $preview_str;
+  }
+  return $preview_str;
 }
 
 //--------------------------------------------------------------------------------------
 
-function get_banking_trans_view_str($type, $trans_no, $label="", $icon=false)
+function get_banking_trans_view_str($type, $trans_no, $label="", 
+       $icon=false, $class='', $id='')
 {
-       global $path_to_root;
-
-       $viewer = "";
+       if ($label == "")
+               $label = $trans_no;
 
        if ($type == 4)
                $viewer = "bank_transfer_view.php";
@@ -139,144 +118,101 @@ function get_banking_trans_view_str($type, $trans_no, $label="", $icon=false)
        elseif ($type == 2)
                $viewer = "gl_deposit_view.php";
        elseif ($type == 0)
-               $viewer = "";
+               return $label;
        else
                return null;
 
-       if ($label == "")
-               $label = $trans_no;
-
-       if ($viewer != "")
-       {
-               $pars = access_string($label);
-               if (user_graphic_links() && $icon)
-                       $pars[0] = set_icon($icon, $pars[0]);
-               $preview_str = "<a target='_blank' href='$path_to_root/gl/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\"$pars[1]>$pars[0]</a>";
-       }
-       else
-               $preview_str = $label;
-
-       return $preview_str;
+       return viewer_link($label, "gl/view/$viewer?trans_no=$trans_no", 
+               $class, $id,  $icon);
 }
 
 //--------------------------------------------------------------------------------------
 
-function get_inventory_trans_view_str($type, $trans_no, $label="", $icon=false)
+function get_inventory_trans_view_str($type, $trans_no, $label="", 
+       $icon=false, $class='', $id='')
 {
-       global $path_to_root;
-
-       $viewer = "";
+       $viewer = "inventory/view/";
 
        if ($type == systypes::inventory_adjustment())
-               $viewer = "view_adjustment.php";
+               $viewer .= "view_adjustment.php";
        elseif ($type == systypes::location_transfer())
-               $viewer = "view_transfer.php";
+               $viewer .= "view_transfer.php";
        else
                return null;
+       $viewer .= "?trans_no=$trans_no";
 
        if ($label == "")
                $label = $trans_no;
 
-       if ($viewer != "")
-       {
-               $pars = access_string($label);
-               if (user_graphic_links() && $icon)
-                       $pars[0] = set_icon($icon, $pars[0]);
-               $preview_str = "<a target='_blank' href='$path_to_root/inventory/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\"$pars[1]>$pars[0]</a>";
-       }
-       else
-               $preview_str = $label;
-
-       return $preview_str;
+       return viewer_link($label, $viewer, $class, $id,  $icon);
 }
 
 //--------------------------------------------------------------------------------------
 
-function get_manufacturing_trans_view_str($type, $trans_no, $label="", $icon=false)
+function get_manufacturing_trans_view_str($type, $trans_no, $label="", 
+       $icon=false, $class='', $id='')
 {
-       global $path_to_root;
-
-       $viewer = "";
+       $viewer = "manufacturing/view/";
 
        if ($type == 28)
-               $viewer = "wo_issue_view.php";
+               $viewer .= "wo_issue_view.php";
        elseif ($type == 29)
-               $viewer = "wo_production_view.php";
+               $viewer .= "wo_production_view.php";
        elseif ($type == systypes::work_order())
-               $viewer = "work_order_view.php";
+               $viewer .= "work_order_view.php";
        else
                return null;
 
+       $viewer .= "?trans_no=$trans_no";
+
        if ($label == "")
                $label = $trans_no;
 
-       if ($viewer != "")
-       {
-               $pars = access_string($label);
-               if (user_graphic_links() && $icon)
-                       $pars[0] = set_icon($icon, $pars[0]);
-               $preview_str = "<a target='_blank' href='$path_to_root/manufacturing/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\"$pars[1]>$pars[0]</a>";
-       }
-       else
-               $preview_str = $label;
-
-       return $preview_str;
+       return viewer_link($label, $viewer, $class, $id,  $icon);
 }
 
 //--------------------------------------------------------------------------------------
 
-function get_dimensions_trans_view_str($type, $trans_no, $label="", $icon=false)
+function get_dimensions_trans_view_str($type, $trans_no, $label="", $icon=false, 
+       $class='', $id='')
 {
-       global $path_to_root;
-
-       $viewer = "";
-
        if ($type == 40)
-               $viewer = "view_dimension.php";
+               $viewer = "dimensions/view_dimension.php?trans_no=$trans_no";
        else
                return null;
 
        if ($label == "")
                $label = $trans_no;
 
-       if ($viewer != "")
-       {
-               $pars = access_string($label);
-               if (user_graphic_links() && $icon)
-                       $pars[0] = set_icon($icon, $pars[0]);
-               $preview_str = "<a target='_blank' href='$path_to_root/dimensions/view/$viewer?trans_no=$trans_no' onclick=\"javascript:openWindow(this.href,this.target); return false;\"$pars[1]>$pars[0]</a>";
-       }
-       else
-               $preview_str = $label;
-
-       return $preview_str;
+       return viewer_link($label, $viewer, $class, $id,  $icon);
 }
 
 //--------------------------------------------------------------------------------------
 
-function get_trans_view_str($type, $trans_no, $label="", $icon=false)
+function get_trans_view_str($type, $trans_no, $label="", $icon=false, 
+       $class='', $id='')
 {
-       $view_str = get_customer_trans_view_str($type, $trans_no, $label, $icon);
+       $view_str = get_customer_trans_view_str($type, $trans_no, $label, $icon, $class, $id);
        if ($view_str != null)
                return $view_str;
 
-       $view_str = get_supplier_trans_view_str($type, $trans_no, $label, $icon);
+       $view_str = get_supplier_trans_view_str($type, $trans_no, $label, $icon, $class, $id);
        if ($view_str != null)
                return $view_str;
 
-       $view_str = get_banking_trans_view_str($type, $trans_no, $label, $icon);
+       $view_str = get_banking_trans_view_str($type, $trans_no, $label, $icon, $class, $id);
        if ($view_str != null)
                return $view_str;
 
-       $view_str = get_inventory_trans_view_str($type, $trans_no, $label, $icon);
+       $view_str = get_inventory_trans_view_str($type, $trans_no, $label, $icon, $class, $id);
        if ($view_str != null)
                return $view_str;
 
-       $view_str = get_manufacturing_trans_view_str($type, $trans_no, $label, $icon);
+       $view_str = get_manufacturing_trans_view_str($type, $trans_no, $label, $icon, $class, $id);
        if ($view_str != null)
                return $view_str;
 
-       $view_str = get_dimensions_trans_view_str($type, $trans_no, $label, $icon);
+       $view_str = get_dimensions_trans_view_str($type, $trans_no, $label, $icon, $class, $id);
        if ($view_str != null)
                return $view_str;
 
@@ -674,11 +610,15 @@ function set_focus($name, $form_no=0) {
 }
 //
 //     Set default focus on first field $name if not set yet
-//
-function default_focus($name, $form_no=0) {
+//     Returns unique name if $name=null
+//     
+function default_focus($name=null, $form_no=0) {
+       if ($name==null) 
+               $name = uniqid('_el');
     if (!isset($_POST['_focus'])) {
          set_focus($name);
     }
+       return $name;
 }
 
 function get_js_png_fix()
index 0c0067fdfcd2486315717f544c6fc09f500656e1..120c2ff24f03ae84007ff5f6e0e9cd659ff0116a 100644 (file)
@@ -11,7 +11,7 @@
 var _focus;
 var _hotkeys = {
        'alt': false,   // whether is the Alt key pressed
-       'focus': -1     // currently selected indeks of document.links
+       'focus': -1,    // currently selected indeks of document.links
 };
 
 function debug(msg) {
@@ -172,7 +172,13 @@ var inserts = {
                        if((ev.ctrlKey && key == 13) || key == 27) {
                                ev.cancelBubble = true;
                        if(ev.stopPropagation) ev.stopPropagation();
-// here ctrl-enter/escape support
+                               // activate submit/escape form
+                               for (var i=0; i<this.elements.length; i++){
+                                       var asp = this.elements[i].getAttribute('aspect');
+                                       if ((asp=='default' && key==13)||(asp=='cancel' && key==27))
+                                               JsHttpRequest.request(this.elements[i]);
+                               }
+                       
                                ev.returnValue = false;
                                return false;
                        } 
@@ -267,6 +273,10 @@ var inserts = {
                        e.onfocus = function() {
                            save_focus(this);
                        };
+                       e.onmouseover = function(e) {
+                       setFocus(this.id, 1);
+                               return false;
+                       }
                }
        },
        'a.printlink':  function(l) {
@@ -276,6 +286,16 @@ var inserts = {
                        return false;
                }
        },
+       'a': function(e) { // traverse menu
+               e.onkeydown = function(ev) { 
+                       ev = ev||window.event;
+                       key = ev.keyCode||ev.which;
+                       if(key==37 || key==38 || key==39 || key==40) {
+                                       move_focus(key, e, document.links);
+                                       return false;
+                       }
+               }
+       },
        'ul.ajaxtabs':  function(ul) {
            var ulist=ul.getElementsByTagName("li");
            for (var x=0; x<ulist.length; x++){ //loop through each LI e
@@ -290,7 +310,20 @@ var inserts = {
                }
            }
        },
-       '#msgbox': function(e) {
+/*     'tr.editrow': function(e) {
+                       e.onkeydown = function(ev) { 
+                       ev = ev||window.event;
+                       key = ev.keyCode||ev.which;
+                       if(key == 13) {
+                         // Find & click additem/update button
+                         
+                       } else  if(key == 27) {
+                         return false;
+                       }
+               }
+
+       },
+*/     '#msgbox': function(e) {
        // this is to avoid changing div height after ajax update in IE7
          e.style.display = e.innerHTML.length ? 'block' : 'none';
        }
@@ -368,7 +401,7 @@ function setHotKeys() {
                return true;
        }
 }
-
 Behaviour.register(inserts);
 
 Behaviour.addLoadEvent(setFocus);
index 98733d667d84f2542f72b59f3d5f1f1e4d99b23d..97200cfbf25bd77d156f71717de539b811897771 100644 (file)
@@ -213,12 +213,8 @@ function goBack() {
 }
 
 function setFocus(name, byId) {
-  if(document.location.pathname.indexOf('index.php') != -1) {
-       // this is application menu page - set focus on first link
-       // var el = document.getElementById('msgbox');
-       // TODO find first link after msgbox and set focus
-  }
-  if(!name) {
+
+  if(!name) { // page load/ajax update
        if (_focus)     
                name = _focus;  // last focus set in onfocus handlers
        else 
@@ -227,10 +223,8 @@ function setFocus(name, byId) {
          if(cur) name = cur.value;
        }
   }
-  if(byId)
+  if(byId || !(el = document.getElementsByName(name)[0]))
        el = document.getElementById(name);
-  else
-       el = document.getElementsByName(name)[0];
 
   if(el && el.focus) {
     // The timeout is needed to prevent unpredictable behaviour on IE & Gecko.
@@ -240,3 +234,64 @@ function setFocus(name, byId) {
        setTimeout(tmp, 0);
   }
 }
+/*
+       Find closest element in neighbourhood and set focus.
+       dir is direction as arrow code.
+*/
+function move_focus(dir, e, neighbours)
+{
+       var p0 = element_pos(e);
+       var t;
+       var l=0;
+       for(var i=0; i<neighbours.length; i++) {
+               var p = element_pos(neighbours[i]);
+               if (neighbours[i].className!='menu_option') continue;
+               if (((dir==40) && (p.y>p0.y)) || (dir==38 && (p.y<p0.y)) 
+                       || ((dir==37) && (p.x<p0.x)) || ((dir==39 && (p.x>p0.x)))) {
+                               var l1 = (p.y-p0.y)*(p.y-p0.y)+(p.x-p0.x)*(p.x-p0.x);
+                               if ((l1<l) || (l==0)) {
+                                       l = l1; t = neighbours[i];
+                               }
+               }
+       }
+       if (t) {
+       var tmp = function() {t.focus(); if (t.select) t.select();};
+               setTimeout(tmp, 0);
+       }
+       return t;
+}
+
+var __isFireFox = navigator.userAgent.match(/gecko/i);
+//returns the absolute position of some element within document
+function element_pos(e) {
+       var res = new Object();
+               res.x = 0; res.y = 0;
+       if (element !== null) {
+               res.x = e.offsetLeft;
+               res.y = e.offsetTop;
+               var offsetParent = e.offsetParent;
+               var parentNode = e.parentNode;
+
+               while (offsetParent !== null) {
+                       res.x += offsetParent.offsetLeft;
+                       res.y += offsetParent.offsetTop;
+
+                       if (offsetParent != document.body && offsetParent != document.documentElement) {
+                               res.x -= offsetParent.scrollLeft;
+                               res.y -= offsetParent.scrollTop;
+                       }
+                             //next lines are necessary to support FireFox problem with offsetParent
+                       if (__isFireFox) {
+                               while (offsetParent != parentNode && parentNode !== null) {
+                                       res.x -= parentNode.scrollLeft;
+                                       res.y -= parentNode.scrollTop;
+
+                                       parentNode = parentNode.parentNode;
+                               }
+                       }
+                       parentNode = offsetParent.parentNode;
+                       offsetParent = offsetParent.offsetParent;
+               }
+       }
+       return res;
+}
\ No newline at end of file
index 4f7f574a5c1f75862ed1b9cbc8f4b2d7798dd840..a5dd5f2e58f8271c2d7640fad96f204f05c3029d 100644 (file)
@@ -14,7 +14,8 @@
 // or display_note(print_document_link($order_no, _("Print this order")));
 // You only need full parameter list for invoices/credit notes
 
-function print_document_link($doc_no, $link_text, $link=true, $type_no, $icon=false)
+function print_document_link($doc_no, $link_text, $link=true, $type_no, 
+       $icon=false, $class='', $id='')
 {
        global $path_to_root;
        include_once($path_to_root . "/includes/types.inc");
@@ -72,27 +73,33 @@ function print_document_link($doc_no, $link_text, $link=true, $type_no, $icon=fa
 //             default: $ar = array();
        }
        
-       return print_link($link_text, $rep, $ar, "", $icon);
+       return print_link($link_text, $rep, $ar, "", $icon, $class, $id);
 }
 //
 //     Universal link to any kind of report.
 //
-function print_link($link_text, $rep, $pars = array(), $dir = '', $icon=false)
+function print_link($link_text, $rep, $pars = array(), $dir = '', 
+       $icon=false, $class='', $id='')
 {
        global $path_to_root, $pdf_debug;
 
        $url = $dir == '' ?  $path_to_root.'/reporting/prn_redirect.php?' : $dir;
 
+       $id = default_focus($id);
        foreach($pars as $par => $val) {
                $pars[$par] = "$par=".urlencode($val);
        }
        $pars[] = 'REP_ID='.urlencode($rep);
        $url .= implode ('&', $pars);
-       $class = $pdf_debug ? '' : "class='printlink'";
+
+       if ($class != '')
+               $class = $pdf_debug ? '' : " class='$class'";
+       if ($id != '')
+               $id = " id='$id'";
        $pars = access_string($link_text);
        if (user_graphic_links() && $icon)
                $pars[0] = set_icon($icon, $pars[0]);
-       return "<a $class target='_blank' href='$url'$pars[1]>$pars[0]</a>";
+       return "<a target='_blank' href='$url'$id$class $pars[1]>$pars[0]</a>";
 }
 
 function get_first_bank_account()
index 1377e2086f300dba30f91b0073ee478d003ff556..1c0f44c5226cc7c9c388238cf35b6e49565e2ad2 100644 (file)
@@ -70,7 +70,7 @@ a:active {
        text-decoration: none;
 }
 
-a:hover {
+a:hover, a:focus {
        color: #2d8628;
        text-decoration: underline;
 }
index c671e8e6ef93208161e3de1f072bf53aa60cdb14..87532dcb83b8907e0de19e3b8845b98a17f7a04c 100644 (file)
@@ -51,8 +51,8 @@
                                {
                                        $acc = access_string($app->name);
                                        echo "<a ".($sel_app == $app->id ? "class='selected' " : "").
-                                       "href='$local_path_to_root/index.php?application=".$app->id.
-                                               SID ."'$acc[1]>" .$acc[0] . "</a>";
+                                       "href='$local_path_to_root/index.php?application=".$app->id
+                                               ."'$acc[1]>" .$acc[0] . "</a>";
                                }
                                echo "</div>";
 
                                                if ($appfunction->label == "")
                                                        echo "&nbsp;<br>";
                                                else
-                                               {
-                                                       $lnk = access_string($appfunction->label);
-                                                       echo "$img<a href='$appfunction->link'$lnk[1]>$lnk[0]</a><br>";
-                                               }       
+                                                       echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                        }
                                }
                                echo "</td>";
                                                        if ($appfunction->label == "")
                                                                echo "&nbsp;<br>";
                                                        else
-                                                       {
-                                                               $lnk = access_string($appfunction->label);
-                                                               echo "$img<a href='$appfunction->link'$lnk[1]>$lnk[0]</a><br>";
-                                                       }
+                                                               echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                                }       
                                        }
                                        echo "</td>";
index a6439fa38865085af61c511101131829e3049407..768029ec7d7c8231946ceb036c910a49b0c95a60 100644 (file)
@@ -70,7 +70,7 @@ a:active {
        text-decoration: none;
 }
 
-a:hover {
+a:hover, a:focus {
        color: #2d8628;
        text-decoration: underline;
 }
index 34f1f3556c7585f54515001f31071e25f5d818ad..f98e6d16bfce0b3d54f8f949d9f2817059f5a01c 100644 (file)
@@ -51,8 +51,8 @@
                                {
                                        $acc = access_string($app->name);
                                        echo "<a ".($sel_app == $app->id ? "class='selected' " : "").
-                                       "href='$local_path_to_root/index.php?application=".$app->id.
-                                               SID ."'$acc[1]>" .$acc[0] . "</a>";
+                                       "href='$local_path_to_root/index.php?application=".$app->id
+                                               ."'$acc[1]>" .$acc[0] . "</a>";
                                }
                                echo "</div>";
 
                                                if ($appfunction->label == "")
                                                        echo "&nbsp;<br>";
                                                else
-                                               {
-                                                       $lnk = access_string($appfunction->label);
-                                                       echo "$img<a href='$appfunction->link'$lnk[1]>$lnk[0]</a><br>";
-                                               }       
+                                                       echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                        }
                                }
                                echo "</td>";
                                                        if ($appfunction->label == "")
                                                                echo "&nbsp;<br>";
                                                        else
-                                                       {
-                                                               $lnk = access_string($appfunction->label);
-                                                               echo "$img<a href='$appfunction->link'$lnk[1]>$lnk[0]</a><br>";
-                                                       }       
+                                                               echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                                }
                                        }
                                        echo "</td>";
index febd24271e640d8b37c32aa79e0a2e71d09dc8ed..70a132b1d69ed216da283b46958f872a5b7bfff0 100644 (file)
@@ -70,7 +70,7 @@ a:active {
        text-decoration: none;
 }
 
-a:hover {
+a:hover, a:focus {
        color: #2d8628;
        text-decoration: underline;
 }
index c14484dcd18905b4c9640720105de63201ab274e..4d84554de4912582652bd90f9433c662019c85a1 100644 (file)
Binary files a/themes/default/images/escape.png and b/themes/default/images/escape.png differ
index 473cf82f279063963f8a6cfb6991212e02c23ead..6c4db65cde8062540e34a318497e06275f4bb00e 100644 (file)
@@ -13,6 +13,7 @@
        {
                function wa_header()
                {
+//                     add_js_ufile("themes/default/renderer.js");
                        page(_("Main Menu"), false, true);
                }
 
@@ -24,7 +25,6 @@
                function menu_header($title, $no_menu, $is_index)
                {
                        global $path_to_root, $help_base_url, $db_connections;
-                       
                        // you can owerride the table styles from config.php here, if you want.
                        //global $table_style, $table_style2;
                        //$table_style  = "cellpadding=3 border=1 bordercolor='#8cacbb' style='border-collapse: collapse'";
                                foreach($applications as $app)
                                {
                                        $acc = access_string($app->name);
-                                       echo "<a ".($sel_app == $app->id ? "class='selected' " : "").
-                                       "href='$local_path_to_root/index.php?application=".$app->id.
-                                               SID ."'$acc[1]>" .$acc[0] . "</a>";
+                                       echo "<a ".($sel_app == $app->id ? 
+                                               ("class='selected'") : "")
+                                               ." href='$local_path_to_root/index.php?application=".$app->id
+                                               ."'$acc[1]>" .$acc[0] . "</a>";
                                }
                                echo "</div>";
                                echo "</td></tr></table>";
                                                if ($appfunction->label == "")
                                                        echo "&nbsp;<br>";
                                                else
-                                               {
-                                                       $lnk = access_string($appfunction->label);
-                                                       echo "$img<a href='$appfunction->link'$lnk[1]>$lnk[0]</a><br>";
-                                               }       
+                                                       echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                        }
                                }
                                echo "</td>";
                                                        if ($appfunction->label == "")
                                                                echo "&nbsp;<br>";
                                                        else
-                                                       {
-                                                               $lnk = access_string($appfunction->label);
-                                                               echo "$img<a href='$appfunction->link'$lnk[1]>$lnk[0]</a><br>";
-                                                       }       
+                                                               echo $img.menu_link($appfunction->link, $appfunction->label)."<br>\n";
                                                }
                                        }
                                        echo "</td>";