From: Joe Hunt Date: Fri, 6 Jan 2012 11:55:57 +0000 (+0100) Subject: Optimized editkey graphics by using JS callEditor instead. X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;h=c98f7f9f9b2f825ab73c410be105ae418db9657d;p=textcart.git Optimized editkey graphics by using JS callEditor instead. --- diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index 1a1e658..d83a470 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -417,33 +417,17 @@ function _format_add_curr($row) '' : (" - " . $row[2])); } -function add_edit_combo($combo_name,$url,$key_param='',$restrict_pages='') +function add_edit_combo($type) { - global $path_to_root, $page_security; + global $path_to_root, $popup_editors; // Derive theme path $theme_path = $path_to_root . '/themes/' . user_theme(); - // Check if $url already has other parameters - if ($key_param) { - $key_param = ((strpos($url,'?')) ? '&' : '?') . $key_param; - } - - $href1 = "href='$url${key_param}='"; - $href2 = "href='$url${key_param}'"; - $onclick1 = "onclick=\"javascript:var sel=(document.forms[0].$combo_name.selectedIndex == -1 ? '' : document.forms[0].$combo_name.options[document.forms[0].$combo_name.selectedIndex].value);openWindow(this.href+sel,this.target); return false;\""; - $onclick2 = "onclick=\"javascript:openWindow(this.href,this.target); return false;\""; + $key = $popup_editors[$type][1]; + $onclick = "onclick=\"javascript:callEditor($key); return false;\""; $img = "Add/Edit"; - $return_url = ($key_param) ? - "$img" : - "$img"; - - // Don't pass edit button code If restrict_pages contains instructions but fails security check - if ($restrict_pages && strpos($restrict_pages, $page_security) === false) { - return ''; - } - - return $return_url; + return "$img"; } function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_change=false, @@ -473,10 +457,7 @@ function supplier_list($name, $selected_id=null, $spec_option=false, $submit_on_ 'show_inactive'=>$all )); if ($editkey) - { - global $path_to_root; - $ret .= add_edit_combo('supplier_id',"$path_to_root/purchasing/manage/suppliers.php?popup=1",'supplier_id'); - } + $ret .= add_edit_combo('supplier'); return $ret; } @@ -528,10 +509,7 @@ function customer_list($name, $selected_id=null, $spec_option=false, $submit_on_ 'show_inactive' => $show_inactive ) ); if ($editkey) - { - global $path_to_root; - $ret .= add_edit_combo('customer_id',"$path_to_root/sales/manage/customers.php?popup=1", "debtor_no"); - } + $ret .= add_edit_combo('customer'); return $ret; } @@ -582,8 +560,7 @@ function customer_branches_list($customer_id, $name, $selected_id=null, ) ); if ($editkey) { - global $path_to_root; - $ret .= add_edit_combo('branch_id',"$path_to_root/sales/manage/customer_branches.php?popup=1",'SelectedBranch'); + $ret .= add_edit_combo('branch'); } return $ret; } @@ -782,10 +759,7 @@ function stock_items_list($name, $selected_id=null, $all_option=false, 'order' => array('c.description','stock_id') ), $opts) ); if ($editkey) - { - global $path_to_root; - $ret .= add_edit_combo('stock_id',"$path_to_root/inventory/manage/items.php?popup=1",'stock_id'); - } + $ret .= add_edit_combo('item'); return $ret; } diff --git a/js/inserts.js b/js/inserts.js index a4207de..d8f033e 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -168,8 +168,10 @@ var _w; function callEditor(key) { var el = document.getElementsByName(editors[key][1])[0]; if(_w) _w.close(); // this is really necessary to have window on top in FF2 :/ + var left = (screen.width - editors[key][2]) / 2; + var top = (screen.height - editors[key][3]) / 2; _w = open(editors[key][0]+el.value+'&popup=1', - "edit","scrollbars=yes,resizable=0,width="+editors[key][2]+",height="+editors[key][3]); + "edit","scrollbars=yes,resizable=0,width="+editors[key][2]+",height="+editors[key][3]+",left="+left+",top="+top+",screenX="+left+",screenY="+top); if (_w.opener == null) _w.opener = self; editors._call = key; // store call point for passBack @@ -279,8 +281,10 @@ var inserts = { 'button[aspect=popup]': function(e) { e.onclick = function() { if(_w) _w.close(); // this is really necessary to have window on top in FF2 :/ + var left = (screen.width - 800)/2; + var top = (screen.height - 600)/2; _w = open(document.location+'popup=1', - "edit","Scrollbars=0,resizable=0,width=800,height=600, top=50,left=50"); + "edit","Scrollbars=0,resizable=0,width=800,height=600, top="+top+",left="+left+",screenX="+left+",screenY="+top); if (_w.opener == null) _w.opener = self; // editors._call = key; // store call point for passBack