Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js =================================================================== diff -u -r6924 -r6938 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 6924) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 6938) @@ -23,12 +23,41 @@ return [curleft,curtop]; } +function getDimensions(obj) { + var style,correction,height + if (obj.currentStyle) { + style = obj.currentStyle; + } + else { + style = getComputedStyle(obj,''); + } + padding = [parseInt(style.paddingTop), parseInt(style.paddingRight), parseInt(style.paddingBottom), parseInt(style.paddingLeft)] + border = [parseInt(style.borderTopWidth), parseInt(style.borderRightWidth), parseInt(style.borderBottomWidth), parseInt(style.borderLeftWidth)] + for (var i in padding) if ( isNaN( padding[i] ) ) padding[i] = 0 + for (var i in border) if ( isNaN( border[i] ) ) border[i] = 0 + + correction = padding[0] + padding[2]; // + border[0] + border[2] + + height = obj.clientHeight - correction + + var result = new Object(); + result.innerHeight = obj.clientHeight - padding[0] - padding[2]; + result.innerWidth = obj.clientWidth - padding[1] - padding[3]; + + return result; +} + function GridScroller(grid_id, w, h) { this.GridId = grid_id - this.FrozenLeft = 0; - this.FrozenBottom = 0; + this.Footer = false; + + this.LeftCells = 0; + this.LeftWidth = 0; + + this.BottomOffset = 5; + this.Width = w; this.Height = h; @@ -72,20 +101,36 @@ this.MainScroller = document.getElementById('main_scroller_'+this.GridId) this.TheGrid = document.getElementById(this.GridId ); - this.DataTable = document.getElementById('data_'+this.GridId); this.HeadTable = document.getElementById('header_'+this.GridId); - this.FooterTable = document.getElementById('footer_'+this.GridId); this.HeadScroller = document.getElementById('inner_header_'+this.GridId); - this.DataScroller = document.getElementById('inner_data_'+this.GridId); - this.FooterScroller = document.getElementById('inner_footer_'+this.GridId); this.HeadOuter = document.getElementById('outer_header_'+this.GridId); + + this.DataTable = document.getElementById('data_'+this.GridId); + this.DataScroller = document.getElementById('inner_data_'+this.GridId); this.DataOuter = document.getElementById('outer_data_'+this.GridId); - this.FooterOuter = document.getElementById('outer_footer_'+this.GridId); - this.HeadSpacer = this.DataTable.rows[0].cells[this.HeadTable.rows[0].cells.length-1]; - this.DataSpacer = this.DataTable.rows[0].cells[this.DataTable.rows[0].cells.length-1]; - this.FooterSpacer = this.DataTable.rows[0].cells[this.FooterTable.rows[0].cells.length-1]; + if (this.HasFooter) { + this.FooterTable = document.getElementById('footer_'+this.GridId); + this.FooterScroller = document.getElementById('inner_footer_'+this.GridId); + this.FooterOuter = document.getElementById('outer_footer_'+this.GridId); + } + if (this.LeftCells != 0) { + this.LeftHeaderTable = document.getElementById('left_header_'+this.GridId); + this.LeftHeaderScroller = document.getElementById('inner_left_header_'+this.GridId); + this.LeftHeaderOuter = document.getElementById('outer_left_header_'+this.GridId); + + this.LeftDataTable = document.getElementById('left_data_'+this.GridId); + this.LeftDataScroller = document.getElementById('inner_left_data_'+this.GridId); + this.LeftDataOuter = document.getElementById('outer_left_data_'+this.GridId); + + if (this.HasFooter) { + this.LeftFooterTable = document.getElementById('left_footer_'+this.GridId); + this.LeftFooterScroller = document.getElementById('inner_left_footer_'+this.GridId); + this.LeftFooterOuter = document.getElementById('outer_left_footer_'+this.GridId); + } + } + this.DataScroller.TheGrid = this; this.MainInner.TheGrid = this; @@ -98,35 +143,81 @@ } GridScroller.prototype.UpdateColWidths = function() { + + var data_cf = 1; + var count = 1; + + var header_cf = 0.2; + var footer_cf = 0.2; + + var header_widths = this.GetWidths('header_'+this.GridId); + data_cf -= header_cf; + count++; + var data_widths = this.GetWidths('data_'+this.GridId); - var footer_widths = this.GetWidths('footer_'+this.GridId); + if (this.HasFooter()) { + var footer_widths = this.GetWidths('footer_'+this.GridId); + data_cf -= footer_cf; + count++; + } + var widths = new Array(); var total = 0; + for (var i=0; i' + table.rows[row].cells[col].innerHTML + '' + table.rows[row].cells[col].innerHTML = '
' + table.rows[row].cells[col].innerHTML + '
' table.rows[row].cells[col].style.width = widths[col]+'px'; // alert('set ('+col+')'+table.rows[0].cells[col].innerHTML+' to '+widths[col]) } } +GridScroller.prototype.SetHeights = function(table_id, heights) +{ + var table = document.getElementById(table_id); + for (var row=0; row' + table.rows[row].cells[0].innerHTML + '' + table.rows[row].cells[0].style.height = heights[row]+'px'; +// heights.push( table.rows[0].cells[0].offsetHeight ) +// alert('get ('+row+')'+table.rows[0].cells[0].innerHTML+' height '+table.rows[0].cells[0].offsetHeight) + } +// return heights; +} + GridScroller.prototype.SetWidths = function(table_id, widths, total) { - table = document.getElementById(table_id); + var table = document.getElementById(table_id); for (var row=0; row this.Width ? this.ScrollerH : 0; scroller_width = data_height > this.Height - scroller_height ? this.ScrollerW : 0; scroller_height = data_width > this.Width - scroller_width ? this.ScrollerH : 0; - pos = findPos(this.Dot) +// alert('min: '+this.MinDataWidth+' pos: '+pos[0]+','+pos[1]+' scroller W x H: '+scroller_width+' x '+scroller_height+' will resize to '+this.Width+' x '+this.Height+' data: '+data_width+' x '+data_height) - this.MainOuter.style.height = (this.Height)+'px' -// this.MainOuter.style.width = (this.Width)+'px' - - alert('pos: '+pos[0]+','+pos[1]+' scroller W x H: '+scroller_width+' x '+scroller_height+' will resize to '+this.Width+' x '+this.Height+' data: '+data_width+' x '+data_height) - this.TheGrid.style.width = (this.Width - scroller_width) + 'px'; this.TheGrid.style.height = (this.Height - scroller_height) + 'px'; this.TheGrid.style.left = (pos[0])+ 'px' this.TheGrid.style.top = (pos[1]) + 'px' - this.HeadOuter.style.width = (this.Width -scroller_width)+ 'px'; - this.DataOuter.style.width = (this.Width -scroller_width)+ 'px'; - this.FooterOuter.style.width = (this.Width -scroller_width)+ 'px'; + this.HeadOuter.style.width = (this.Width -scroller_width -this.LeftWidth)+ 'px'; + this.DataOuter.style.width = (this.Width -scroller_width -this.LeftWidth)+ 'px'; + if (this.LeftCells != 0) { + this.LeftHeaderOuter.style.width = (this.LeftWidth) + 'px' + this.LeftDataOuter.style.width = (this.LeftWidth) + 'px' + if (this.HasFooter()) { + this.LeftFooterOuter.style.width = (this.LeftWidth) + 'px' + } + } + + if (this.HasFooter()) { + this.FooterOuter.style.width = (this.Width -scroller_width -this.LeftWidth)+ 'px'; + } + if (data_height < this.Height - scroller_height) { - this.DataOuter.style.height = (data_height - this.HeadHeight - this.FooterHeight) + 'px' + var adjusted_data_height = data_height - this.HeadHeight - this.FooterHeight } else { - this.DataOuter.style.height = (this.Height - this.HeadHeight - this.FooterHeight - scroller_height) + 'px' + var adjusted_data_height = this.Height - this.HeadHeight - this.FooterHeight - scroller_height } + this.DataOuter.style.height = adjusted_data_height + 'px' + if (this.LeftCells != 0) { + this.LeftDataOuter.style.height = adjusted_data_height + 'px' + } - this.MainScroller.style.width = (this.HeadTable.offsetWidth)+'px' - this.MainScroller.style.height = ( this.DataTable.offsetHeight + this.HeadTable.offsetHeight + this.FooterTable.offsetHeight)+'px' + this.MainScroller.style.width = (this.HeadTable.offsetWidth + this.LeftWidth)+'px' + this.MainScroller.style.height = ( this.DataTable.offsetHeight + this.HeadHeight + this.FooterHeight)+'px' } GridScroller.prototype.SyncScroll = function() { this.HeadScroller.scrollLeft = this.MainInner.scrollLeft; this.DataScroller.scrollLeft = this.MainInner.scrollLeft; - this.FooterScroller.scrollLeft = this.MainInner.scrollLeft; + if (this.HasFooter()) { + this.FooterScroller.scrollLeft = this.MainInner.scrollLeft; + } this.DataScroller.scrollTop = this.MainInner.scrollTop; + if (this.LeftCells != 0) { + this.LeftDataScroller.scrollTop = this.MainInner.scrollTop; + } } GridScroller.prototype.GetHTML = function() @@ -287,16 +415,41 @@ var o = ''; o += this.CreateScroller( '


', 100, 100, 'main_'+this.GridId, false, 1 ); - o += '
'; + o += ''; return o } + +GridScroller.prototype.HasFooter = function() +{ + return (this.Footer != false) +} + GridScroller.prototype.CreateTable = function(content, id) { return ''+content+'
'; @@ -329,13 +482,55 @@ return o } +GridScroller.prototype.GetLeftHeader = function() +{ + var o = ''; + + o += '' + for (var col=0; col'+this.Header[col]+'' + } + o += '' + + return o +} + +GridScroller.prototype.GetLeftData = function() +{ + var o = ''; + var even = false; + for (var row in this.Data) { + o += even ? '' : '' + even = !even; + for (var col=0; col'+this.Data[row][col]+'' + } + o += '' + } + + return o +} + +GridScroller.prototype.GetLeftFooter = function() +{ + var o = ''; + if (this.HasFooter()) { + o += '' + for (var col=0; col'+this.Footer[col]+'' + } + o += '' + } + return o +} + GridScroller.prototype.GetHeaderCells = function() { var o = '' - for (var col=0; col' + for (var col=this.LeftCells; col'+this.Header[col]+'' } - o += 'H ' + o += '' o += '' return o } @@ -346,12 +541,12 @@ var o = ''; var even = false; for (var row in this.Data) { - o += even ? '' : '' + o += even ? '' : '' even = !even; - for (var col=0; col' + for (var col=this.LeftCells; col'+this.Data[row][col]+'' } - o += 'D ' + o += '' o += '' } return o @@ -360,10 +555,10 @@ GridScroller.prototype.GetFooterCells = function() { var o = '' - for (var col=0; col' + for (var col=this.LeftCells; col'+this.Footer[col]+'' } - o += 'F ' + o += '' o += '' return o }