Wrong include file path in /includes/ui/items_cart.inc changed /inventory/includes...
[fa-stable.git] / js / inserts.js
index 3b4e09788f6ce1c5ab46c17d62dbf73f9583695c..9d00636dff27cba9b04be6c8d5f6f92763a7ce97 100644 (file)
@@ -15,20 +15,36 @@ var inserts = {
                        element.onfocus = function() {
                                document.getElementsByName('_focus')[0].value = element.name;
                        };
+                       element.onkeydown = function(event) { 
+                         if (event.keyCode==32) {
+                          if(this.init_size==undefined)
+                               this.init_size = this.size;
+                         if(this.init_size<=1) {
+                          if(this.size>1) {
+                               this.size = 1;
+                          } else{
+                               var sel = this.selectedIndex;
+                               this.size = this.options.length;
+                               if(this.size>10) this.size = 10;
+                               this.selectedIndex = sel;
+                          }
+                         }
+                        }
+                       }
+                       element.onblur = function(event) { 
+                           if(this.init_size<=1)
+                               this.size = 1;
+                       }
                }
        },
-       'input': function(element) {
-               if(element.onfocus==undefined) {
+       'input': function(element) { // we do not want to change focus on submit
+               if(element.type!='submit' && element.onfocus==undefined) {
                        element.onfocus = function() {
                                document.getElementsByName('_focus')[0].value = element.name;
                        };
                }
-       
-       },
-       'input.submit': function(element) {
-               element.onfocus = function() {} // we do not want to change focus on submit
        },
-       // combo: text input and related selector in next <TD> cell
+       // combo: text input and related selector
        'input.combo': function(element) {
          if(element.onkeydown==undefined) {
                  element.onkeydown=function(event) { 
@@ -43,45 +59,50 @@ var inserts = {
                        for (i = 0; i < len; i++) {
 //                       txt = select.options[i].text;
                          txt = select.options[i].value;
-                         if (txt.indexOf(ac) == 0) {
+                         if (txt.indexOf(ac) >= 0) {
                                select.options[i].selected = true;
                                break;
                          }
                        }
                  };
-                 if(element.onblur==undefined) {  // onblur can be set to submit(); here
-                       element.onblur = function() {
+                 element.onblur = function() {
+                         var button = document.getElementsByName(this.name+'_button')[0];
                          var select = document.getElementsByName(this.getAttribute('rel'))[0];
+//                       var val = select.options[select.selectedIndex].text;
+                         var val = select.options[select.selectedIndex].value; TODO
                          if (this.value != "")
-                               this.value = select.options[select.selectedIndex].value;
-//                                     myForm.$next_name.focus();
+                                 this.value = val;
                          return true;
-                       };
-                 }
+                 };
                }
        },
        'select.combo': function(element) {
-               if(element.onchange==undefined) { 
-                         element.onchange = function() {
-                         var input = document.getElementsByName(this.getAttribute('rel'))[0];
-                               input.value = this.options[this.selectedIndex].value;
-//                             myForm.$next_name.focus();
+                         element.onblur = function() {
+                               var box = document.getElementsByName(this.getAttribute('rel'))[0];
+                               val = this.options[this.selectedIndex].value;
+                               box.value = val; 
+                               this.size = 1;
                                return true;
-                         };
-               }
+                        }
+       },
+       'input.combo_submit': function(element) {
+           // this hides search button for js enabled browsers
+           element.style.display = 'none';
        }
-
 };
 
 Behaviour.register(inserts);
 
 function setFocus(name, byId) {
   if(byId)
-       input = document.getElementById(name).focus();
+       input = document.getElementById(name);
   else
-       input = document.getElementsByName(name)[0].focus();
+       input = document.getElementsByName(name)[0];
+  if(input.focus)
+       input.focus();
 }
 
+
 Behaviour.addLoadEvent(function() {
     var inp = document.getElementsByName('_focus')[0];
 if(inp!=null) {