From c935a4090e3f152dd5549217d69b5b5036197024 Mon Sep 17 00:00:00 2001 From: Janusz Dobrowolski Date: Mon, 9 Jun 2008 07:39:51 +0000 Subject: [PATCH] Some additional fixes to last big committment --- CHANGELOG.txt | 11 +++++ gl/gl_journal.php | 2 +- includes/ajax.inc | 10 +++-- includes/ui/ui_lists.inc | 16 +++----- includes/ui/ui_view.inc | 2 + js/inserts.js | 61 ++++++++++++++-------------- js/utils.js | 14 +++---- sales/includes/ui/sales_order_ui.inc | 8 ++-- themes/default/default.css | 16 +------- 9 files changed, 67 insertions(+), 73 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 5b9821fc..b1d2c11e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -20,6 +20,17 @@ Legend: $ -> Affected files ---------------------------------------Release Candidate 1------------------------------- +09-Jun-2008 Janusz Dobrowolski +# Some additional fixes related to last big committment +$ /gl/gl_journal.php + /includes/ajax.inc + /includes/ui/ui_lists.inc + /includes/ui/ui_view.inc + /js/inserts.js + /js/utils.js + /sales/includes/ui/sales_order_ui.inc + /themes/default/default.css + 08-Jun-2008 Joe Hunt ! Preparing for release candidate 1 $ config.php diff --git a/gl/gl_journal.php b/gl/gl_journal.php index 5c974d29..c7ad55c0 100644 --- a/gl/gl_journal.php +++ b/gl/gl_journal.php @@ -19,7 +19,7 @@ if ($use_popup_windows) if ($use_date_picker) $js .= get_js_date_picker(); -set_focus('CodeID2'); +set_focus('_code_id_edit'); page(_("Journal Entry"), false, false,'', $js); diff --git a/includes/ajax.inc b/includes/ajax.inc index 5625fc90..3ad2966e 100644 --- a/includes/ajax.inc +++ b/includes/ajax.inc @@ -106,17 +106,19 @@ class Ajax extends JsHttpRequest { // remove not active commands foreach ($this->aCommands as $idx => $com) { - // display_error( $idx.':'.var_dump($com)); // If we should reload whole page content ignore all commands but the update. // This is page repost equivalent, although header and footer are not reloaded. + if ($com['why'] !== true && !isset($this->triggers[$com['why']])) { + unset($this->aCommands[$idx]); +// display_error('unset '.$com['t']); + } + else if($com['n'] == 'up' && $com['t'] == '_page_body') { $this->aCommands = array($com); break; } - else - if ($com['why'] !== true && !isset($this->triggers[$com['why']])) - unset($this->aCommands[$idx]); } +// display_error(htmlentities(print_r($this->aCommands, true))); $GLOBALS['_RESULT'] = $this->aCommands; // exit(); } diff --git a/includes/ui/ui_lists.inc b/includes/ui/ui_lists.inc index c2972932..785ab746 100644 --- a/includes/ui/ui_lists.inc +++ b/includes/ui/ui_lists.inc @@ -45,10 +45,6 @@ $opts = array( // default options 'max' => 50, 'cells' => false, // combo displayed as 2 cells 'search' => array(), // sql field names to search - // if _focus is not set on next field before combo_input call - // set this to false to avoid deadlock via onblur handler - 'next_focus' => (!isset($_POST['_focus']) || - (isset($_POST["_{$name}_button"]) && $_POST['_focus']==$name)) ? false : $_POST['_focus'], 'format' => null, // format functions for regular options 'disabled' => false, // FIX todo 'box_hint' => null // box/selectors hints; null = std see below @@ -89,17 +85,15 @@ $opts = array( // default options $Ajax->activate('_page_body'); else $Ajax->activate($name); - set_focus($opts['next_focus']); } - if ($search_box && $opts['search_submit']) { + if ($search_box) { // search related sql modifications $rel = "rel='$search_box'"; // set relation to list - + if ($opts['search_submit']) { // if selected from list - set focus on next field if (isset($_POST[$search_submit])) { $Ajax->activate($name); - set_focus($name); } if ($txt == '') { if ($spec_option === false) @@ -115,6 +109,7 @@ $opts = array( // default options $opts['where'][] = '('. implode($opts['search'], ' OR ') . ')'; } } + } // sql completion if (count($opts['where'])) { $sql .= strpos($sql, 'WHERE')==false ? ' WHERE ':' AND '; @@ -210,11 +205,10 @@ $edit_entry = ''; if ($search_box != false) { $edit_entry = "\n"; -// default_focus($search_box); if ($search_submit != false) { global $_search_button; $edit_entry .= sprintf($_search_button, user_theme(), @@ -1277,7 +1271,7 @@ function gl_all_accounts_list($name, $selected_id, $skip_bank_accounts=false, 'format' => '_format_account' . ($show_group ? '2' : ''), 'order' => 'account_code', 'search_box' => $cells, - 'search_submit' => true, + 'search_submit' => false, 'size' => 12, 'max' => 10, 'cells' => true diff --git a/includes/ui/ui_view.inc b/includes/ui/ui_view.inc index dce9fff4..65a9f393 100644 --- a/includes/ui/ui_view.inc +++ b/includes/ui/ui_view.inc @@ -548,6 +548,8 @@ function get_js_open_window($width, $height) If $form<0 $name is element id. */ function set_focus($name, $form_no=0) { + global $Ajax; + $Ajax->addFocus(true, $name); $_POST['_focus'] = $name; } // diff --git a/js/inserts.js b/js/inserts.js index c6c047f7..43b5f43b 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -1,9 +1,8 @@ - var _focus; function debug(msg) { - document.getElementById('msgbox').innerHTML= - document.getElementById('msgbox').innerHTML+'
'+msg + box = document.getElementById('msgbox') + box.innerHTML= box.innerHTML+'
'+msg } function progbar(container) { @@ -13,7 +12,6 @@ function progbar(container) { } function save_focus(e) { -// document.getElementsByName('_focus')[0].value = e.name; _focus = e.name||e.id; var h = document.getElementById('hints'); if (h) { @@ -44,18 +42,16 @@ function expandtab(tabcontentid, tabnumber) { } function _set_combo_input(e) { - e.onblur=function() { -// if(!this.back) { - var but_name = this.name.substring(0, this.name.length-4)+'button'; - var button = document.getElementsByName(but_name)[0]; - var select = document.getElementsByName(this.getAttribute('rel'))[0]; - save_focus(select); + e.onblur=function() { + var but_name = this.name.substring(0, this.name.length-4)+'button'; + var button = document.getElementsByName(but_name)[0]; + var select = document.getElementsByName(this.getAttribute('rel'))[0]; + save_focus(select); // this.style.display='none'; - if(button) { // if *_button set submit search request - JsHttpRequest.request(but_name); - } - return false; -// } + if(button) { // if *_button set submit search request + JsHttpRequest.request(but_name); + } + return false; }; e.onkeyup = function(ev) { var select = document.getElementsByName(this.getAttribute('rel'))[0]; @@ -73,14 +69,13 @@ function _set_combo_input(e) { } } }; - e.onkeydown = function(ev) { + e.onkeydown = function(ev) { ev = ev||window.event; key = ev.keyCode||ev.which; if(key == 13) { this.blur(); return false; } -// this.back = ev.shiftKey; // save shift state for onblur handler } } @@ -97,6 +92,10 @@ function _update_box(s) { } function _set_combo_select(e) { + e.onblur = function() { + if(this.className=='combo') + _update_box(this); + } e.onchange = function() { var s = this; @@ -111,22 +110,14 @@ function _set_combo_select(e) { } return true; } -// e.onblur = function() { -// if (this.className == 'combo') -// _update_box(this); -// }, e.onkeydown = function(event) { event = event||window.event; -// this.back = event.shiftKey; // save shift state for onblur handler key = event.keyCode||event.which; var box = document.getElementsByName(this.getAttribute('rel'))[0]; if (box && key == 32 && this.className == 'combo2') { this.style.display = 'none'; box.style.display = 'inline'; box.value=''; - // Konq does not like short syntax for nonstd attr -// this.setAttribute('back', 'true'); -// this.back=true; setFocus(box.name); return false; } @@ -152,7 +143,16 @@ var inserts = { // this hides search button for js enabled browsers e.style.display = 'none'; }, - 'input.ajaxsubmit,input.editbutton,input.navibutton': +/* 'select.combo,select.combo2': + function(e) { + var box = document.getElementsByName(e.getAttribute('rel'))[0]; + if(box) { + box.style.width = 200+'px'; + e.style.width = 200+'px'; + debug(e.name+':'+e.style.width) + } + }, +*/ 'input.ajaxsubmit,input.editbutton,input.navibutton': function(e) { e.onclick = function() { JsHttpRequest.request(this.name); @@ -172,11 +172,6 @@ var inserts = { e.onfocus = function() { save_focus(this); }; - e.onkeydown = function(event) { - event = event||window.event; - this.back = event.shiftKey; // save shift state for onblur handler - this.lastkey = event.keyCode; - }; var c = e.className; if (c == 'combo' || c == 'combo2') _set_combo_select(e); @@ -202,6 +197,10 @@ var inserts = { } } } + }, + '#msgbox': function(e) { + // this is to avoid changing div height after ajax update in IE7 + e.style.display = e.innerHTML.length ? 'block' : 'none'; } /* TODO 'a.date_picker': function(e) { diff --git a/js/utils.js b/js/utils.js index cb1c0db3..2bd2cfa5 100644 --- a/js/utils.js +++ b/js/utils.js @@ -11,14 +11,10 @@ // Function is called when an answer arrives. function(result, errors) { - // Write errors to the debug div. - document.getElementById('msgbox').innerHTML = errors; - // Write the answer. if (result) { for(var i in result ) { atom = result[i]; - cmd = atom['n']; property = atom['p']; type = atom['c']; @@ -47,13 +43,16 @@ } else { errors = errors+'
Unknown ajax function: '+cmd; } - } - Behaviour.apply(); + } + // Write errors to the debug div. + document.getElementById('msgbox').innerHTML = errors; + + Behaviour.apply(); if (errors.length>0) window.scrollTo(0,0); //document.getElementById('msgbox').scrollIntoView(true); // Restore focus if we've just lost focus because of DOM element refresh - setFocus(); + setFocus(); } }, false // do not disable caching @@ -168,6 +167,7 @@ function setFocus(name, byId) { 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. // Using tmp var prevents crash on IE5 diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index bf08381c..1df65425 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -159,8 +159,6 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group $customer_error = ""; $change_prices = 0; - $newcust = ($order->customer_id != get_post('customer_id', -1)); - $newbranch = ($order->Branch != get_post('branch_id', -1)) || $newcust; if (isset($order) && !$editable) { @@ -174,7 +172,7 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group { customer_list_row(_("Customer:"), 'customer_id', null, false, true); - if ($newcust) + if ($order->customer_id != get_post('customer_id', -1)) { // customer has changed // clear the branch selection @@ -195,7 +193,9 @@ function display_order_header(&$order, $editable, $date_text, $display_tax_group $order->Branch = 0; } else { - if($newcust || $newbranch) { + if( ($order->customer_id != get_post('customer_id', -1)) || + ($order->Branch != get_post('branch_id', -1))) { + $old_order = (PHP_VERSION<5) ? $order : clone( $order ); $customer_error = get_customer_details_to_order($order, $_POST['customer_id'], $_POST['branch_id']); diff --git a/themes/default/default.css b/themes/default/default.css index 635f419c..a32fa4e9 100644 --- a/themes/default/default.css +++ b/themes/default/default.css @@ -440,20 +440,6 @@ ul.ajaxtabs li input.current, ul.ajaxtabs li input.current:hover{ border-bottom: 1px solid #8cacbb; margin: -4px -2px -2px; border: 1px solid #8cacbb; -/* display: none;*/ background-color: #FFFFE0; white-space: nowrap; -/* - position: absolute; - left: 0; - left: -900px; - filter:alpha(opacity=0); - -moz-opacity:0; - border: 1px solid black; - height: 200px; - text-align: center; - width:200px; - z-index: 100; - padding: 5px; -*/ -} \ No newline at end of file +} -- 2.30.2