Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js =================================================================== diff -u -r7089 -r7102 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 7089) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 7102) @@ -147,17 +147,26 @@ } var profile = 0; +var profile_total = 0; var startTime = new Date().getTime(); function Profile(message,force) { if (profile || force) { endTime = new Date().getTime(); - alert(message+' took '+(endTime-startTime)+' ms?') + var tmp = (endTime-startTime); + profile_total += tmp; + alert(message+' took '+tmp+' ms of '+profile_total) startTime = new Date().getTime(); } } +function ResetStart() +{ + startTime = new Date().getTime(); + profile_total = 0; +} + function GridScroller(grid_id, w, h) { this.GridId = grid_id @@ -181,13 +190,20 @@ this.IDs = []; this.Rendered = false; + + this.PickerCRC = ''; } GridScroller.prototype.Render = function(id) { -// alert('rendering '+( id ? id : 'defulat')) - startTime = new Date().getTime(); - html = this.GetHTML(); + ResetStart(); + +// var widths = this.PrepareWidths(); +// this.MinWidths = [40,null,null,250] + this.MinWidths = this.PrepareWidths(); // [50,70,90,150,150,110,70,111]; + + html = this.AltHTML(); +// Profile('Getting HTML',1); if (id && id != '') { document.getElementById(id).innerHTML = '
'+html+'
'; execJS(document.getElementById(id)) @@ -200,17 +216,26 @@ document.write('
'+html+'
'); } this.Rendered = true; - Profile('Preparing HTML and writing it') + this.SetReferences() + document.body.style.height = '100%'; document.body.style.overflow = 'hidden'; document.body.scroll = 'no' - this.SetReferences() - this.ScrollerW = this.MainInner.offsetWidth - this.MainInner.clientWidth - this.ScrollerH = this.MainInner.offsetHeight - this.MainInner.clientHeight + if (getFrame('head').ScrollerW) { + this.ScrollerW = getFrame('head').ScrollerW; + this.ScrollerH = getFrame('head').ScrollerH; + } + else { + this.ScrollerW = this.MainInner.offsetWidth - this.MainInner.clientWidth + this.ScrollerH = this.MainInner.offsetHeight - this.MainInner.clientHeight + getFrame('head').ScrollerW = this.ScrollerW + getFrame('head').ScrollerH = this.ScrollerH + } + +// Profile('Up to col widths',1); if (!this.UpdateColWidths()) return; -// Profile('UpdateColWidths'); if (this.Width == 'auto') { this.Resize( this.GetAutoSize() ); @@ -219,18 +244,30 @@ this.Resize(); } -// Profile('Resizing'); - this.TheGrid.style.visibility = 'visible' this.MainScroller.style.visibility = 'visible' +// Profile('Finalizng', 1); var the_grid = this; if (document.all) { $status = window.attachEvent('onresize', function(ev) { the_grid.AutoResize() }); } else { $status = window.addEventListener('resize', function(ev) { the_grid.AutoResize() }, true); } - Profile('Finalizng', 0); + if (document.all) { + this.DataScroller.onmousewheel = function(ev) { + var e = document.all ? window.event : ev; + this.TheGrid.MainInner.scrollTop += -e.wheelDelta/2 + this.TheGrid.SyncScroll(); + } + } + else { + this.DataScroller.addEventListener("DOMMouseScroll", function(ev) { + var e = document.all ? window.event : ev; + this.TheGrid.MainInner.scrollTop += e.detail*10 + this.TheGrid.SyncScroll(); + }, false); + } } @@ -272,20 +309,18 @@ this.DataScroller.TheGrid = this; this.MainInner.TheGrid = this; - this.Dot = document.getElementById('dot_'+this.GridId) - // this.MainOuter.style.border = '5px solid red'; - // this.MainOuter.style.padding = '30px'; - this.MainOuter.className = 'grid-scrollable' if (!is.ie) { this.MainOuter.style.marginLeft = '-1px'; } - } GridScroller.prototype.UpdateColWidths = function() { + pos = findPos(this.Dot) + this.TheGrid.style.left = (pos[0])+ 'px' + this.TheGrid.style.top = (pos[1]) + 'px' var data_cf = 1; var count = 1; @@ -309,7 +344,9 @@ } var header_widths = this.GetWidths('header_'+this.GridId); +// print_pre(header_widths) var data_widths = this.GetWidths('data_'+this.GridId); +// print_pre(data_widths) /*if (this.HasFooter()) { var footer_widths = this.GetWidths('footer_'+this.GridId); @@ -320,63 +357,34 @@ for (var i=0; i' + table.rows[row].cells[col].innerHTML + '' -// alert('setting '+widths[col]+' for col '+col) -// if (isNaN(final_width)) { -// alert('set '+table_id+'col '+col+' '+table.rows[0].cells[col].innerHTML+' to '+widths[col]) -// } - table.rows[row].cells[col].style.width = final_width+'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].innerHTML = '
' + 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, from, to) -{ - var table = document.getElementById(table_id); - table.style.layout = 'fixed' - for (var row=0; row<1; row++) - { - this.SetRowWidths(table_id, widths, row, from, to) - } - table.style.width = '100%' -} - GridScroller.prototype.GetHeights = function(table_id) { var table = document.getElementById(table_id); @@ -506,16 +450,19 @@ { var table = document.getElementById(table_id); table.style.width = 'auto' - if (table.offsetWidth < document.body.clientWidth * 0.8) { - table.style.width = Math.round( document.body.clientWidth * 0.8 ) + 'px' + var w = document.all ? window.document.body.offsetWidth : window.innerWidth + if (table.offsetWidth < screen.width * 0.8) { + table.style.width = Math.round( screen.width * 0.8 ) + 'px' } var widths = new Array(); var style; if (!table.rows[0]) return []; for (var col=0; col this.Width ? this.ScrollerH : 0; + scroller_width = this.DataTotalHeight > this.Height - scroller_height ? this.ScrollerW : 0; + scroller_height = this.HeaderWidth > this.Width - scroller_width ? this.ScrollerH : 0; - scroller_height = data_width > 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; +// 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: '+this.HeaderWidth+' x '+this.DataHeight) -// 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.TheGrid.style.left = (pos[0])+ 'px' - this.TheGrid.style.top = (pos[1]) + 'px' - this.HeadOuter.style.width = (this.Width -scroller_width -this.LeftWidth)+ 'px'; this.DataOuter.style.width = (this.Width -scroller_width -this.LeftWidth)+ 'px'; - Profile('Resize 0.3') - if (this.LeftCells != 0) { this.LeftHeaderOuter.style.width = (this.LeftWidth) + 'px' this.LeftDataOuter.style.width = (this.LeftWidth) + 'px' @@ -591,42 +526,27 @@ } } - Profile('Resize 1') - if (this.HasFooter()) { this.FooterOuter.style.width = (this.Width -scroller_width -this.LeftWidth)+ 'px'; } - Profile('Resize 1.1') - - if (data_height < this.Height - scroller_height) { - var adjusted_data_height = data_height - this.HeadHeight - this.FooterHeight + if (this.DataTotalHeight < this.Height - scroller_height) { + var adjusted_data_height = this.DataTotalHeight - this.HeadHeight - this.FooterHeight } else { var adjusted_data_height = this.Height - this.HeadHeight - this.FooterHeight - scroller_height } - Profile('Resize 1.2') - this.DataOuter.style.height = adjusted_data_height + 'px' if (this.LeftCells != 0) { this.LeftDataOuter.style.height = adjusted_data_height + 'px' } - Profile('Resize 2') - this.MainScroller.style.width = (this.HeadTable.offsetWidth + this.LeftWidth)+'px' - this.MainScroller.style.height = ( this.DataTable.offsetHeight + this.HeadHeight + this.FooterHeight)+'px' + this.MainScroller.style.height = ( this.DataHeight + this.HeadHeight + this.FooterHeight)+'px' - - Profile('Resize 0.1') - this.TheGrid.style.width = (this.Width - scroller_width) + 'px'; this.TheGrid.style.height = (this.Height - scroller_height) + 'px'; - - Profile('Resize 0.2') - - Profile('Full resize') } GridScroller.prototype.SyncScroll = function() @@ -643,28 +563,37 @@ } } -GridScroller.prototype.GetHTML = function() +GridScroller.prototype.AltHTML = function() { - w = this.Width; - h = this.Height; var o = ''; - o += this.CreateScroller( '


', 100, 100, 'main_'+this.GridId, false, 1 ); + o += this.CreateScroller( '


', 100, 100, 'main_'+this.GridId, false, 1 ); + o += '']; + } + else { + var cursor_workaround = ['',''] + } + width = this.MinWidths[col] ? this.MinWidths[col] + 'px' : 'auto'; + total_width += this.MinWidths[col]; + if (no_inner_div) { + rh += ''+cursor_workaround[0]+source[row][col]+cursor_workaround[1]+'' + } + else { + rh += ''+cursor_workaround[0]+'
'+source[row][col]+cursor_workaround[1]+'
' + } + } + if (needs_last) { + rh += '' + } + rh += '' + o += rh; + } + return [o, total_width]; } + +GridScroller.prototype.HasFooter = function() +{ + return (this.Footer != false) +} + GridScroller.prototype.CreateScroller = function(content, w, h, id, hidden, z) { if (hidden) { @@ -717,108 +735,6 @@ return o } -GridScroller.prototype.GetLeftHeader = function() -{ - var o = ''; - for (var row in this.Header) { - o +='' - for (var col=0; col
'+this.Header[row][col]+'
' - } - o += '' - } - return o -} - -GridScroller.prototype.GetLeftData = function() -{ - var o = ''; - var even = false; - for (var row in this.Data) { - var id = this.IDs[row] ? 'id="left_'+this.IDs[row]+'"' : ''; - 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 row in this.Header) { - o +='' - for (var col=this.LeftCells; col
'+this.Header[row][col]+'
' - } - o += '' - o += '' - } - return o - - /*var o = '' - for (var col=this.LeftCells; col'+this.Header[col]+'' - } - o += '' - o += '' - return o*/ -} - - -GridScroller.prototype.GetDataCells = function() -{ - var o = ''; - var even = false; - var width; - - for (var row in this.Data) { - var id = this.IDs[row] ? 'id="'+this.IDs[row]+'"' : ''; - o += even ? '' : '' - even = !even; - for (var col=this.LeftCells; col
'+this.Data[row][col]+'
' - } - o += '' - o += '' - } - return o -} - -GridScroller.prototype.GetFooterCells = function() -{ - var o = '' - for (var col=this.LeftCells; col'+this.Footer[col]+'' - } - o += '' - o += '' - return o -} - GridScroller.prototype.SetData = function(a_data) { this.Data = a_data;