4 box = document.getElementById('msgbox')
5 box.innerHTML= box.innerHTML+'<br>'+msg
9 box = document.getElementById('msgbox');
10 box.innerHTML= "<center><table width='98%' border='1' cellpadding=3 "
11 +"bordercolor='#007700' style='border-collapse: collapse'>"
12 +"<tr><td align='center' bgcolor='#ccffcc' >"
13 +"<img src='"+user.theme+"images/progressbar.gif' alt='"
14 +user.loadtxt+"' /></td></tr></table></center><br>";
15 box.style.display = 'block';
18 function save_focus(e) {
19 _focus = e.name||e.id;
20 var h = document.getElementById('hints');
22 h.style.display = e.title && e.title.length ? 'inline' : 'none';
23 h.innerHTML = e.title ? e.title : '';
27 function _expand(tabobj) {
29 var ul = tabobj.parentNode.parentNode;
30 var alltabs=ul.getElementsByTagName("input");
31 var frm = tabobj.form;
33 if (ul.getAttribute("rel")){
34 for (var i=0; i<alltabs.length; i++){
35 alltabs[i].className = "ajaxbutton" //deselect all tabs
37 tabobj.className = "current";
38 JsHttpRequest.request(tabobj)
42 //interface for selecting a tab (plus expand corresponding content)
43 function expandtab(tabcontentid, tabnumber) {
44 var tabs = document.getElementById(tabcontentid);
45 _expand(tabs.getElementsByTagName("input")[tabnumber]);
48 function _set_combo_input(e) {
49 e.setAttribute('_last', e.value);
51 var but_name = this.name.substring(0, this.name.length-4)+'button';
52 var button = document.getElementsByName(but_name)[0];
53 var select = document.getElementsByName(this.getAttribute('rel'))[0];
55 // submit request if there is submit_on_change option set and
56 // search field has changed.
57 if (button && (this.value != this.getAttribute('_last'))) {
58 JsHttpRequest.request(button);
59 } else if(this.className=='combo2') {
60 this.style.display = 'none';
61 select.style.display = 'inline';
62 setFocus(select.name);
66 e.onkeyup = function(ev) {
67 var select = document.getElementsByName(this.getAttribute('rel'))[0];
68 if(select && select.selectedIndex>=0) {
69 var len = select.length;
70 var byid = this.className=='combo';
71 var ac = this.value.toUpperCase();
72 select.options[select.selectedIndex].selected = false;
73 for (i = 0; i < len; i++) {
74 var txt = byid ? select.options[i].value : select.options[i].text;
75 if (txt.toUpperCase().indexOf(ac) >= 0) {
76 select.options[i].selected = true;
82 e.onkeydown = function(ev) {
83 ev = ev||window.event;
84 key = ev.keyCode||ev.which;
92 function _update_box(s) {
93 var byid = s.className=='combo';
94 var rel = s.getAttribute('rel');
95 var box = document.getElementsByName(rel)[0];
96 if(box && s.selectedIndex>=0) {
97 var opt = s.options[s.selectedIndex];
99 box.value = byid ? opt.value : opt.text;
100 box.setAttribute('_last', box.value);
105 function _set_combo_select(e) {
106 // When combo position is changed via js (eg from searchbox)
107 // no onchange event is generated. To ensure proper change
108 // signaling we must track selectedIndex in onblur handler.
109 e.setAttribute('_last', e.selectedIndex);
110 e.onblur = function() {
111 if(this.className=='combo')
113 if (this.selectedIndex != this.getAttribute('_last'))
116 e.onchange = function() {
118 this.setAttribute('_last', this.selectedIndex);
119 if(s.className=='combo')
121 if(s.selectedIndex>=0) {
122 var sname = '_'+s.name+'_update';
123 var update = document.getElementsByName(sname)[0];
125 JsHttpRequest.request(update);
130 e.onkeydown = function(event) {
131 event = event||window.event;
132 key = event.keyCode||event.which;
133 var box = document.getElementsByName(this.getAttribute('rel'))[0];
134 if (box && key == 32 && this.className == 'combo2') {
135 this.style.display = 'none';
136 box.style.display = 'inline';
141 if (this.getAttribute('aspect') == 'editable' && key==115) {
142 // F4: call related database editor - not available in non-js fallback mode
143 JsHttpRequest.request('_'+this.name+'_editor', this.form);
144 return false; // prevent default binding
145 // TODO: preventDefault, stopPropagation when needed
151 Behaviour definitions
154 'input': function(e) {
155 if(e.onfocus==undefined) {
156 e.onfocus = function() {
158 if (this.className == 'combo')
162 if (e.className == 'combo' || e.className == 'combo2') {
166 'input.combo2,input[aspect="fallback"]':
168 // this hides search button for js enabled browsers
169 e.style.display = 'none';
173 // this shows divs for js enabled browsers only
174 e.style.display = 'block';
176 'input.ajaxsubmit,input.editbutton,input.navibutton':
178 e.onclick = function() {
179 if (this.getAttribute('aspect') == 'process')
181 JsHttpRequest.request(this);
185 '.amount': function(e) {
186 if(e.onblur==undefined) {
187 e.onblur = function() {
188 var dec = this.getAttribute("dec");
189 price_format(this.name, get_amount(this.name), dec);
193 '.searchbox': // emulated onchange event handling for text inputs
195 e.setAttribute('_last_val', e.value);
196 e.setAttribute('autocomplete', 'off'); //must be off when calling onblur
197 e.onblur = function() {
198 var val = this.getAttribute('_last_val');
199 if (val != this.value) {
200 this.setAttribute('_last_val', this.value);
201 JsHttpRequest.request('_'+this.name+'_changed', this.form);
204 /* e.onkeydown = function(ev) {
205 ev = ev||window.event;
206 key = ev.keyCode||ev.which;
207 if (key == 13 && (this.value != this.getAttribute('_last_val'))) {
213 'select': function(e) {
214 if(e.onfocus==undefined) {
215 e.onfocus = function() {
219 if (c == 'combo' || c == 'combo2')
220 _set_combo_select(e);
223 'textarea,a': function(e) {
224 if(e.onfocus==undefined) {
225 e.onfocus = function() {
230 'ul.ajaxtabs': function(ul) {
231 var ulist=ul.getElementsByTagName("li");
232 for (var x=0; x<ulist.length; x++){ //loop through each LI e
233 var ulistlink=ulist[x].getElementsByTagName("input")[0];
234 if(ulistlink.onclick==undefined) {
235 // ? var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
236 var url = ulistlink.form.action
237 ulistlink.onclick=function(){
244 '#msgbox': function(e) {
245 // this is to avoid changing div height after ajax update in IE7
246 e.style.display = e.innerHTML.length ? 'block' : 'none';
249 'a.date_picker': function(e) {
250 // this un-hides data picker for js enabled browsers
251 e.href = date_picker(this.getAttribute('rel'));
252 e.style.display = '';
253 e.tabindex = -1; // skip in tabbing order
258 Behaviour.register(inserts);
260 Behaviour.addLoadEvent(setFocus);