X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=js%2Finserts.js;h=b16a11538f14c518292147060dc6d73f1498f206;hb=31629799f984d0237fe73f366d3d3d75448f1f34;hp=a639b2cc3ed623b6f968b856a4a97bc87a42b16d;hpb=73f7e2f83657966f999078917cf9404ec5d65fc3;p=fa-stable.git
diff --git a/js/inserts.js b/js/inserts.js
index a639b2cc..b16a1153 100644
--- a/js/inserts.js
+++ b/js/inserts.js
@@ -1,348 +1,365 @@
-//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'+msg
}
-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)
+function progbar() {
+ box = document.getElementById('msgbox');
+ box.innerHTML= ""
+ +""
+ +"!["
+ +user.loadtxt+"]("+user.theme+"images/progressbar.gif) |
";
+ box.style.display = 'block';
}
-function loadobjs(revattribute){
-if (revattribute!=null && revattribute!=""){ //if "rev" attribute is defined (load external .js or .css files)
-var objectlist=revattribute.split(/\s*,\s*/) //split the files and store as array
-for (var i=0; i=0) {
+ var len = select.length;
+ var byid = this.className=='combo';
+ 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 (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 _settabs(tab) {
-var ulist=tab.getElementsByTagName("li") //array containing the LI elements within UL
-for (var x=0; x=0) {
+ var opt = s.options[s.selectedIndex];
+ if(box) {
+ box.value = byid ? opt.value : opt.text;
+ box.setAttribute('_last', box.value);
+ }
+ }
}
-function _TableRowSelector(table,row) {
- var sels = table.getAttribute('selector').split(',') // tablica selektorów
- var cols = table.getElementsByTagName('th') //identyfikatory kolumn
- var colvals = row.getElementsByTagName("td")
- selector =''
- for(s=0; s=0) {
+ var sname = '_'+s.name+'_update';
+ var update = document.getElementsByName(sname)[0];
+ if(update) {
+ JsHttpRequest.request(update);
+ }
}
- }
- return selector;
-}
+ return true;
+ }
+ e.onkeydown = function(event) {
+ event = event||window.event;
+ 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='';
+ setFocus(box.name);
+ return false;
+ }
+ if (this.getAttribute('aspect') == 'editable' && key==115) {
+ // F4: call related database editor - not available in non-js fallback mode
+ JsHttpRequest.request('_'+this.name+'_editor', this.form);
+ return false; // prevent default binding
+ // TODO: stopPropagation when needed
+ }
+ }
+}
+
/*
- Ajax elements behaviour definitions
+ Behaviour definitions
*/
var inserts = {
- 'div.ajax-component': function(element) { // automatic ajax component init
- if(element.innerHTML=='') {
- autoload.push(element.id)
- }
+ 'form': function(e) {
+ e.onkeydown = function(ev) {
+ ev = ev||window.event;
+ key = ev.keyCode||ev.which;
+ if((ev.ctrlKey && key == 13) || key == 27) {
+ ev.cancelBubble = true;
+ if(ev.stopPropagation) ev.stopPropagation();
+// here ctrl-enter/escape support
+ ev.returnValue = false;
+ return false;
+ }
+ return true;
+ }
},
-
- 'form.ajaxform': function(element) {
- element.onsubmit=function(){
- var url=element.action;
- var div=element.getAttribute("rel")
- var submit
- var Query = new Querystring();
-
-// url.replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
-// url=window.location
- var vars = new Array();
- for(i=0; i-1) {
- ajaxloader(url,vars, table.getAttribute('rel'))
- } else { // this is external 'select' handler
- window.location = url;
- }
-
- }
- }
+ if (e.className == 'combo' || e.className == 'combo2') {
+ _set_combo_input(e);
+ }
+ else
+ if(e.type == 'text' ) {
+ e.onkeydown = function(ev) {
+ ev = ev||window.event;
+ key = ev.keyCode||ev.which;
+ if(key == 13) {
+ if(e.className == 'searchbox') e.onblur();
+ return false;
+ }
+ return true;
+ }
+ }
},
- 'table.ajaxgrid th': function(element) {
- element.onclick=function(){
- var table = this.parentNode.parentNode.parentNode
- var url = table.getAttribute('href')
- var vars = {}
- url+='&ajax='+table.id+'&action=sort&id='+ this.id
-// debug(url)
-
- ajaxloader(url, {}, table.getAttribute("rel"))
-// loadobjs(this.getAttribute("href"))
- return false
- }
+ 'input.combo2,input[aspect="fallback"]':
+ function(e) {
+ // this hides search button for js enabled browsers
+ e.style.display = 'none';
},
- 'a.ajaxgrid-navi': function(element) {
- if(element.onclick==undefined)
- if (element.getAttribute("rel")){
- var modifiedurl=element.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
- element.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake
- if( modifiedurl.indexOf('ajax=')>-1) {
- element.onclick=function(){ // set ajax handler
-// debug(this.getAttribute("href"))
- ajaxloader(this.getAttribute("href"), {}, this.getAttribute("rel"))
- loadobjs(this.getAttribute("href"))
- return false
- }
- }
- }
+ 'div.js_only':
+ function(e) {
+ // this shows divs for js enabled browsers only
+ e.style.display = 'block';
},
- 'a.ajaxgrid-select': function(element) {
- if(element.onclick==undefined) {
- var modifiedurl=element.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
- element.setAttribute("href", modifiedurl) //replace URL's root domain with dynamic root domain, for ajax security sake
- element.onclick=function(){
- var row = this.parentNode.parentNode
- var table = row.parentNode.parentNode
-
- var url = this.getAttribute('href')
- var vars = {}
-
- hideddrivetip()
-
-// url += '&ajax='+table.id
- url += _TableRowSelector(table,row)
-// alert( this.getAttribute('rel'))
- ajaxloader(url,vars, this.getAttribute('rel'))
- return false
+// '.ajaxsubmit,.editbutton,.navibutton': // much slower on IE7
+ 'button.ajaxsubmit,input.ajaxsubmit,input.editbutton,button.navibutton':
+ function(e) {
+ e.onclick = function() {
+ if (this.getAttribute('aspect') == 'process')
+ progbar();
+ save_focus(this);
+ JsHttpRequest.request(this);
+ return false;
+ }
+ },
+ '.amount': function(e) {
+ if(e.onblur==undefined) {
+ e.onblur = function() {
+ var dec = this.getAttribute("dec");
+ price_format(this.name, get_amount(this.name), dec);
+ };
+ }
+ },
+ '.searchbox': // emulated onchange event handling for text inputs
+ function(e) {
+ e.setAttribute('_last_val', e.value);
+ e.setAttribute('autocomplete', 'off'); //must be off when calling onblur
+ e.onblur = function() {
+ var val = this.getAttribute('_last_val');
+ if (val != this.value) {
+ this.setAttribute('_last_val', this.value);
+ JsHttpRequest.request('_'+this.name+'_changed', this.form);
+ }
+ }
+/* e.onkeydown = function(ev) {
+ ev = ev||window.event;
+ key = ev.keyCode||ev.which;
+ if (key == 13 && (this.value != this.getAttribute('_last_val'))) {
+ this.blur();
+ return false;
+ }
+ }
+*/ },
+ 'select': function(e) {
+ if(e.onfocus==undefined) {
+ e.onfocus = function() {
+ save_focus(this);
+ };
+ var c = e.className;
+ if (c == 'combo' || c == 'combo2')
+ _set_combo_select(e);
}
- element.tooltip = element.getAttribute('title') // save tooltip
- element.removeAttribute('title') // native tooltip off
- element.onmouseover=function() {
- ddrivetip(this.tooltip)
+ },
+ 'textarea,a': function(e) {
+ if(e.onfocus==undefined) {
+ e.onfocus = function() {
+ save_focus(this);
+ };
}
- element.onmouseout=function() {
- hideddrivetip()
+ },
+ 'a.printlink': function(l) {
+ l.onclick = function() {
+ save_focus(this);
+ JsHttpRequest.request(this);
+ return false;
}
- }
},
- '.amount': function(element) {
- if(element.onblur==undefined) {
- var dec = element.getAttribute("dec");
- element.onblur = function() {
- price_format(this.name, get_amount(this.name), dec);
- };
+ 'ul.ajaxtabs': function(ul) {
+ var ulist=ul.getElementsByTagName("li");
+ for (var x=0; x47 && key<58) || (key>64 && key<91))) {
+ var n = _hotkeys.focus;
+ var l = document.links;
+ var cnt = l.length;
+ key = String.fromCharCode(key);
+ for (var i=0; i=0) {
+ var link = document.links[_hotkeys.focus];
+ 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);