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 +"style='border-collapse: collapse' bordercolor='#007700'>"
12 +"<tr><td align='center' bgcolor='#ccffcc' >"
13 +"<img src='"+user.theme+"images/progressbar.gif' alt='"
14 +user.loadtxt+"' /></td></tr></table></center><br>";
17 function save_focus(e) {
18 _focus = e.name||e.id;
19 var h = document.getElementById('hints');
21 h.style.display = e.title && e.title.length ? 'inline' : 'none';
22 h.innerHTML = e.title ? e.title : '';
26 function _expand(tabobj) {
28 var ul = tabobj.parentNode.parentNode;
29 var alltabs=ul.getElementsByTagName("input");
30 var frm = tabobj.form;
32 if (ul.getAttribute("rel")){
33 for (var i=0; i<alltabs.length; i++){
34 alltabs[i].className = "ajaxbutton" //deselect all tabs
36 tabobj.className = "current";
37 JsHttpRequest.request(tabobj)
41 //interface for selecting a tab (plus expand corresponding content)
42 function expandtab(tabcontentid, tabnumber) {
43 var tabs = document.getElementById(tabcontentid);
44 _expand(tabs.getElementsByTagName("input")[tabnumber]);
47 function _set_combo_input(e) {
48 e.setAttribute('_last', e.value);
50 var but_name = this.name.substring(0, this.name.length-4)+'button';
51 var button = document.getElementsByName(but_name)[0];
52 var select = document.getElementsByName(this.getAttribute('rel'))[0];
54 // submit request if there is submit_on_change option set and
55 // search field has changed.
56 if (button && (this.value != this.getAttribute('_last'))) {
57 JsHttpRequest.request(button);
58 } else if(this.className=='combo2') {
59 this.style.display = 'none';
60 select.style.display = 'inline';
61 setFocus(select.name);
65 e.onkeyup = function(ev) {
66 var select = document.getElementsByName(this.getAttribute('rel'))[0];
67 if(select && select.selectedIndex>=0) {
68 var len = select.length;
69 var byid = this.className=='combo';
70 var ac = this.value.toUpperCase();
71 select.options[select.selectedIndex].selected = false;
72 for (i = 0; i < len; i++) {
73 var txt = byid ? select.options[i].value : select.options[i].text;
74 if (txt.toUpperCase().indexOf(ac) >= 0) {
75 select.options[i].selected = true;
81 e.onkeydown = function(ev) {
82 ev = ev||window.event;
83 key = ev.keyCode||ev.which;
91 function _update_box(s) {
92 var byid = s.className=='combo';
93 var rel = s.getAttribute('rel');
94 var box = document.getElementsByName(rel)[0];
95 if(box && s.selectedIndex>=0) {
96 var opt = s.options[s.selectedIndex];
98 box.value = byid ? opt.value : opt.text;
99 box.setAttribute('_last', box.value);
104 function _set_combo_select(e) {
105 // When combo position is changed via js (eg from searchbox)
106 // no onchange event is generated. To ensure proper change
107 // signaling we must track selectedIndex in onblur handler.
108 e.setAttribute('_last', e.selectedIndex);
109 e.onblur = function() {
110 if(this.className=='combo')
112 if (this.selectedIndex != this.getAttribute('_last'))
115 e.onchange = function() {
117 this.setAttribute('_last', this.selectedIndex);
118 if(s.className=='combo')
120 if(s.selectedIndex>=0) {
121 var sname = '_'+s.name+'_update';
122 var update = document.getElementsByName(sname)[0];
124 JsHttpRequest.request(update);
129 e.onkeydown = function(event) {
130 event = event||window.event;
131 key = event.keyCode||event.which;
132 var box = document.getElementsByName(this.getAttribute('rel'))[0];
133 if (box && key == 32 && this.className == 'combo2') {
134 this.style.display = 'none';
135 box.style.display = 'inline';
144 Behaviour definitions
147 'input': function(e) {
148 if(e.onfocus==undefined) {
149 e.onfocus = function() {
151 if (this.className == 'combo')
155 if (e.className == 'combo' || e.className == 'combo2') {
159 'input.combo2,input[aspect="fallback"]':
161 // this hides search button for js enabled browsers
162 e.style.display = 'none';
164 'input.ajaxsubmit,input.editbutton,input.navibutton':
166 e.onclick = function() {
167 if (this.getAttribute('aspect') == 'process')
169 JsHttpRequest.request(this);
173 '.amount': function(e) {
174 if(e.onblur==undefined) {
175 e.onblur = function() {
176 var dec = this.getAttribute("dec");
177 price_format(this.name, get_amount(this.name), dec);
181 '.searchbox': // emulated onchange event handling for text inputs
183 e.setAttribute('_last_val', e.value);
184 e.setAttribute('autocomplete', 'off'); //must be off when calling onblur
185 e.onblur = function() {
186 var val = this.getAttribute('_last_val');
187 if (val != this.value) {
188 this.setAttribute('_last_val', this.value);
189 JsHttpRequest.request('_'+this.name+'_changed', this.form);
192 /* e.onkeydown = function(ev) {
193 ev = ev||window.event;
194 key = ev.keyCode||ev.which;
195 if (key == 13 && (this.value != this.getAttribute('_last_val'))) {
201 'select': function(e) {
202 if(e.onfocus==undefined) {
203 e.onfocus = function() {
207 if (c == 'combo' || c == 'combo2')
208 _set_combo_select(e);
211 'textarea,a': function(e) {
212 if(e.onfocus==undefined) {
213 e.onfocus = function() {
218 'ul.ajaxtabs': function(ul) {
219 var ulist=ul.getElementsByTagName("li");
220 for (var x=0; x<ulist.length; x++){ //loop through each LI e
221 var ulistlink=ulist[x].getElementsByTagName("input")[0];
222 if(ulistlink.onclick==undefined) {
223 // ? var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
224 var url = ulistlink.form.action
225 ulistlink.onclick=function(){
232 '#msgbox': function(e) {
233 // this is to avoid changing div height after ajax update in IE7
234 e.style.display = e.innerHTML.length ? 'block' : 'none';
237 'a.date_picker': function(e) {
238 // this un-hides data picker for js enabled browsers
239 e.href = date_picker(this.getAttribute('rel'));
240 e.style.display = '';
241 e.tabindex = -1; // skip in tabbing order
246 Behaviour.register(inserts);
248 Behaviour.addLoadEvent(setFocus);