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';
145 Behaviour definitions
148 'input': function(e) {
149 if(e.onfocus==undefined) {
150 e.onfocus = function() {
152 if (this.className == 'combo')
156 if (e.className == 'combo' || e.className == 'combo2') {
160 'input.combo2,input[aspect="fallback"]':
162 // this hides search button for js enabled browsers
163 e.style.display = 'none';
167 // this shows divs for js enabled browsers only
168 e.style.display = 'block';
170 'input.ajaxsubmit,input.editbutton,input.navibutton':
172 e.onclick = function() {
173 if (this.getAttribute('aspect') == 'process')
175 JsHttpRequest.request(this);
179 '.amount': function(e) {
180 if(e.onblur==undefined) {
181 e.onblur = function() {
182 var dec = this.getAttribute("dec");
183 price_format(this.name, get_amount(this.name), dec);
187 '.searchbox': // emulated onchange event handling for text inputs
189 e.setAttribute('_last_val', e.value);
190 e.setAttribute('autocomplete', 'off'); //must be off when calling onblur
191 e.onblur = function() {
192 var val = this.getAttribute('_last_val');
193 if (val != this.value) {
194 this.setAttribute('_last_val', this.value);
195 JsHttpRequest.request('_'+this.name+'_changed', this.form);
198 /* e.onkeydown = function(ev) {
199 ev = ev||window.event;
200 key = ev.keyCode||ev.which;
201 if (key == 13 && (this.value != this.getAttribute('_last_val'))) {
207 'select': function(e) {
208 if(e.onfocus==undefined) {
209 e.onfocus = function() {
213 if (c == 'combo' || c == 'combo2')
214 _set_combo_select(e);
217 'textarea,a': function(e) {
218 if(e.onfocus==undefined) {
219 e.onfocus = function() {
224 'ul.ajaxtabs': function(ul) {
225 var ulist=ul.getElementsByTagName("li");
226 for (var x=0; x<ulist.length; x++){ //loop through each LI e
227 var ulistlink=ulist[x].getElementsByTagName("input")[0];
228 if(ulistlink.onclick==undefined) {
229 // ? var modifiedurl=ulistlink.getAttribute("href").replace(/^http:\/\/[^\/]+\//i, "http://"+window.location.hostname+"/")
230 var url = ulistlink.form.action
231 ulistlink.onclick=function(){
238 '#msgbox': function(e) {
239 // this is to avoid changing div height after ajax update in IE7
240 e.style.display = e.innerHTML.length ? 'block' : 'none';
243 'a.date_picker': function(e) {
244 // this un-hides data picker for js enabled browsers
245 e.href = date_picker(this.getAttribute('rel'));
246 e.style.display = '';
247 e.tabindex = -1; // skip in tabbing order
252 Behaviour.register(inserts);
254 Behaviour.addLoadEvent(setFocus);