X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=js%2Finserts.js;h=17b71143b60187ac01455c2be1c0031b1f69d255;hb=865874e288d822a4a7ba07ec7a16813a37786dc7;hp=a639b2cc3ed623b6f968b856a4a97bc87a42b16d;hpb=73f7e2f83657966f999078917cf9404ec5d65fc3;p=fa-stable.git diff --git a/js/inserts.js b/js/inserts.js index a639b2cc..17b71143 100644 --- a/js/inserts.js +++ b/js/inserts.js @@ -1,348 +1,609 @@ -//ajax transfer progress indicator -var starttabs = new Array(); -var autoload = new Array(); -var onload_script = "" -var loadstatustext=" Requesting content..." -var loadedobjects="" - -function Querystring(qs) { // optionally pass a querystring to parse - this.params = new Object() - this.get=Querystring_get - this.set=Querystring_set - this.href=window.location.pathname - this.url=Querystring_url - - if (qs == null) - qs=location.search.substring(1,location.search.length) - - if (qs.length == 0) return - -// Turn back to -// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1 - qs = qs.replace(/\+/g, ' ') - var args = qs.split('&') // parse out name/value pairs separated via & - -// split out each name=value pair - for (var i=0;i. +***********************************************************************/ +var _focus; +var _hotkeys = { + 'alt': false, // whether is the Alt key pressed + 'list': false, // list of all elements with hotkey used recently + 'focus': -1 // currently selected list element +}; - if (pair.length == 2) - value = unescape(pair[1]) - else - value = name - - this.params[name] = value +function validate(e) { + if (e.name && (typeof _validate[e.name] == 'function')) + return _validate[e.name](e); + else { + var n = e.name.indexOf('['); + if(n!=-1) { + var key = e.name.substring(n+1, e.name.length-1); + if (key.length>1 && _validate[e.name.substring(0,n)]) + return _validate[e.name.substring(0,n)][key](e); + } } - - this.page = this.params.page - delete this.params.page + return true; } -function Querystring_get(key, default_) { - // This silly looking line changes UNDEFINED to NULL - if (default_ == null) default_ = null; - - var value=this.params[key] - if (value==null) value=default_; - - return value +function set_fullmode() { + document.getElementById('ui_mode').value = 1; + document.loginform.submit(); + return true; } -function Querystring_set(key, value) { - this.params[key] = value; +function save_focus(e) { + _focus = e.name||e.id; + var h = document.getElementById('hints'); + if (h) { + h.style.display = e.title && e.title.length ? 'inline' : 'none'; + h.innerHTML = e.title ? e.title : ''; + } } -function Querystring_url() { - var url = this.href + '?page='+ this.page - for( key in this.params) { - url += '&'+ key + '='+ this.params[key] - } - return url -} +function _expand(tabobj) { -function debug(msg) { -//alert(msg) -document.getElementById('debug').innerHTML=msg -} + var ul = tabobj.parentNode.parentNode; + var alltabs=ul.getElementsByTagName("button"); + var frm = tabobj.form; -function ajaxloader(url,vars,div) { - var container = document.getElementById(div) - var callback=function(response,headers,context) { - container.innerHTML=response; - Behaviour.apply(); - } - debug(url) - container.innerHTML=loadstatustext - ajaxCaller.postForPlainText(url,vars,callback) + if (ul.getAttribute("rel")){ + for (var i=0; i=0) { + var len = select.length; + var byid = string_contains(this.className, 'combo') || string_contains(this.className, 'combo3'); + var ac = this.value.toUpperCase(); + select.options[select.selectedIndex].selected = false; + for (i = 0; i < len; i++) { + var txt = byid ? select.options[i].value : select.options[i].text; + if (string_contains(this.className, 'combo3')) { + if(txt.toUpperCase().indexOf(ac) == 0) { + select.options[i].selected = true; + break; + } + } else { + if(txt.toUpperCase().indexOf(ac) >= 0) { + select.options[i].selected = true; + break; + } + } + } + } + }; + e.onkeydown = function(ev) { + ev = ev||window.event; + key = ev.keyCode||ev.which; + if(key == 13) { + this.blur(); + return false; + } + } } -function expandtab(tabcontentid, tabnumber){ //interface for selecting a tab (plus expand corresponding content) -var alltabs=document.getElementById(tabcontentid).getElementsByTagName("a") -var thetab=alltabs[tabnumber] -//debug(tabcontentid+' '+tabnumber) -if (thetab.getAttribute("rel")){ - for (var i=0; i=0) { + var opt = s.options[s.selectedIndex]; + if(box) { + var old = box.value; + box.value = byid ? opt.value : opt.text; + box.setAttribute('_last', box.value); + return old != box.value + } + } } -ajaxloader(thetab.getAttribute("href"), {}, thetab.getAttribute("rel")) -loadobjs(thetab.getAttribute("rev")) -} +function _set_combo_select(e) { + // When combo position is changed via js (eg from searchbox) + // no onchange event is generated. To ensure proper change + // signaling we must track selectedIndex in onblur handler. + e.setAttribute('_last', e.selectedIndex); + e.onblur = function() { + var box = document.getElementsByName(this.getAttribute('rel'))[0]; + if ((this.selectedIndex != this.getAttribute('_last')) + ||((string_contains(this.className, 'combo') || string_contains(this.className, 'combo3')) && _update_box(this)) + ) + this.onchange(); + } + e.onchange = function() { + var s = this; + this.setAttribute('_last', this.selectedIndex); + if(string_contains(s.className, 'combo') || string_contains(this.className, 'combo3')) + _update_box(s); + if(s.selectedIndex>=0) { + var sname = '_'+s.name+'_update'; + var update = document.getElementsByName(sname)[0]; + if(update) { + JsHttpRequest.request(update); + } + } + return true; + } + e.onkeydown = function(event) { + event = event||window.event; + key = event.keyCode||event.which; + var box = document.getElementsByName(this.getAttribute('rel'))[0]; + if(key == 8 || (key==37 && event.altKey)) { + event.returnValue = false; + return false; + } + if (box && (key == 32) && (string_contains(this.className, 'combo2'))) { + this.style.display = 'none'; + box.style.display = 'inline'; + box.value=''; + setFocus(box); + return false; + } else { + if (key == 13 && !e.length) // prevent chrome issue (blocked cursor after CR on empty selector) + return false; + } + } } -//--------------------- -function _setlink(element){ -if (element.getAttribute("rel")){ -var modifiedurl=element.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/") -modifiedurl +="&ajax="+element.getAttribute('id'); -//debug(modifiedurl) -element.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake -element.onclick=function(){ -ajaxloader(this.getAttribute("href"), {}, this.getAttribute("rel")) -loadobjs(this.getAttribute("rev")) -return false -} +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]+",left="+left+",top="+top+",screenX="+left+",screenY="+top); + if (_w.opener == null) + _w.opener = self; + editors._call = key; // store call point for passBack + _w.focus(); } + +function passBack(value) { + var o = opener; + if(value != false) { + var back = o.editors[o.editors._call]; // form input bindings + var to = o.document.getElementsByName(back[1])[0]; + if (to) { + if (to[0] != undefined) + to[0].value = value; // ugly hack to set selector to any value + to.value = value; + // update page after item selection + o.JsHttpRequest.request('_'+to.name+'_update', to.form); + o.setFocus(to.name); + } + } + close(); } -function _settabs(tab) { -var ulist=tab.getElementsByTagName("li") //array containing the LI elements within UL -for (var x=0; x47 && key<58) || (key>64 && key<91))) { + key = String.fromCharCode(key); + var n = _hotkeys.focus; + var l = document.getElementsBySelector('[accesskey='+key+']'); + var cnt = l.length; + _hotkeys.list = l; + for (var i=0; i= 0) { + var link = _hotkeys.list[_hotkeys.focus]; + if(link.onclick) + link.onclick(); + else + if (link.target=='_blank') { + window.open(link.href,'','toolbar=no,scrollbar=no,resizable=yes,menubar=no,width=900,height=500'); + openWindow(link.href,'_blank'); + } else + window.location = link.href; + } + return stopEv(ev); + } + } + return true; + } } -); + +Behaviour.register(inserts); + +Behaviour.addLoadEvent(setFocus); +Behaviour.addLoadEvent(setHotKeys);