Special XML conversion code for Firefox >= 20.0
[infodrom/rico3] / minsrc / ricoSimpleGrid.js
index e5462b8..6c8a6e6 100644 (file)
@@ -1,6 +1,6 @@
 /*
- *  (c) 2005-2009 Richard Cowin (http://openrico.org)
- *  (c) 2005-2009 Matt Brown (http://dowdybrown.com)
+ *  (c) 2005-2011 Richard Cowin (http://openrico.org)
+ *  (c) 2005-2011 Matt Brown (http://dowdybrown.com)
  *
  *  Licensed under the Apache License, Version 2.0 (the "License"); you may not use this
  *  file except in compliance with the License. You may obtain a copy of the License at
@@ -43,15 +43,10 @@ Rico.SimpleGrid.prototype = {
     var i;
     for (i=0; i<2; i++) {
       Rico.log("simpleGridInit "+i);\r
-      this.tabs[i]=document.getElementById(this.tableId+'_tab'+i);
+      this.tabs[i]=Rico.$(this.tableId+'_tab'+i);
       if (!this.tabs[i]) return;
-      this.hdrTabs[i]=document.getElementById(this.tableId+'_tab'+i+'h');
+      this.hdrTabs[i]=Rico.$(this.tableId+'_tab'+i+'h');
       if (!this.hdrTabs[i]) return;
-      //if (i==0) this.tabs[i].style.position='absolute';
-      //if (i==0) this.tabs[i].style.left='0px';
-      //this.hdrTabs[i].style.position='absolute';
-      //this.hdrTabs[i].style.top='0px';
-      //this.hdrTabs[i].style.zIndex=1;
       this.thead[i]=this.hdrTabs[i];
       this.tbody[i]=this.tabs[i];
       this.headerColCnt = this.getColumnInfo(this.hdrTabs[i].rows);
@@ -63,10 +58,6 @@ Rico.SimpleGrid.prototype = {
       alert('ERROR: no columns found in "'+this.tableId+'"');
       return;
     }
-    //this.hdrHt=Math.max(Rico.nan2zero(this.hdrTabs[0].offsetHeight),this.hdrTabs[1].offsetHeight);
-    //for (i=0; i<2; i++) {
-    //  if (i==0) this.tabs[i].style.top=this.hdrHt+'px';
-    //}
     this.createColumnArray('SimpleGridColumn');
     this.pageSize=this.columns[0].dataColDiv.childNodes.length;
     this.sizeDivs();
@@ -74,6 +65,8 @@ Rico.SimpleGrid.prototype = {
       this.createFilters(this.options.FilterLocation);
     this.attachMenuEvents();
     this.scrollEventFunc=Rico.eventHandle(this,'handleScroll');
+    this.scrollFrozenEventFunc=Rico.eventHandle(this,'handleScrollFrozen');
+    this.scrollHeadingEventFunc=Rico.eventHandle(this,'handleScrollHeading');
     this.pluginScroll();
     if (this.options.windowResize)
       Rico.eventBind(window,"resize", Rico.eventHandle(this,'sizeDivs'), false);
@@ -163,10 +156,38 @@ Rico.SimpleGrid.prototype = {
     this.sizeDivs();\r
   },
 
+  pluginScroll: function() {
+     if (this.scrollPluggedIn) return;
+     Rico.eventBind(this.scrollDiv,"scroll",this.scrollEventFunc, false);
+     Rico.eventBind(this.frozenTabs,"scroll",this.scrollFrozenEventFunc, false);
+     Rico.eventBind(this.innerDiv,"scroll",this.scrollHeadingEventFunc, false);
+     this.scrollPluggedIn=true;
+  },
+
+  unplugScroll: function() {
+     Rico.eventUnbind(this.scrollDiv,"scroll", this.scrollEventFunc , false);
+     Rico.eventUnbind(this.frozenTabs,"scroll", this.scrollFrozenEventFunc , false);
+     Rico.eventUnbind(this.innerDiv,"scroll", this.scrollHeadingEventFunc , false);
+     this.scrollPluggedIn=false;
+  },
+
   handleScroll: function(e) {
-    var newTop=(-this.scrollDiv.scrollTop)+'px';
-    this.tabs[0].style.marginTop=newTop;
-    this.setHorizontalScroll();
+    this.frozenTabs.scrollTop=this.scrollDiv.scrollTop;
+    this.innerDiv.scrollLeft=this.scrollDiv.scrollLeft;
+  },
+
+  /**
+   * Frozen columns scrolled due to user invoking browser find
+   */
+  handleScrollFrozen: function(e) {
+    this.scrollDiv.scrollTop=this.frozenTabs.scrollTop;
+  },
+  
+  /**
+   * Heading scrolled due to user invoking browser find
+   */
+  handleScrollHeading: function(e) {
+    this.scrollDiv.scrollLeft=this.innerDiv.scrollLeft;
   },
 
   /**
@@ -241,7 +262,7 @@ Rico.SimpleGrid.prototype = {
       }
       this.exportRows.push(exportText);
     }
-    this.exportFinish(exportType);
+    this.exportFinish();
   },
 
   /**