Index: branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js =================================================================== diff -u -r7036 -r7063 --- branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 7036) +++ branches/unlabeled/unlabeled-1.1.2/core/admin_templates/js/grid_scroller.js (.../grid_scroller.js) (revision 7063) @@ -1,3 +1,58 @@ +var sheetRules; // all rules in stylesheet Set by initStyleChange() +var currentRule; // which rule are we editing? Set by assignRule() +var defaultStyles = new Array(); + + +function StyleManager() {} + +StyleManager.InitStyles = function() { + if (!document.styleSheets) return; + var sheets = document.styleSheets; + + this.Map = new Object(); +// alert('total '+sheets.length+' sheets') + for (var i=0;i'+html+''; } else { - document.write(html); + if (this.Rendered) { + this.Render('main_div_'+this.GridId); + return; + } + document.write('
'+html+'
'); } + this.Rendered = true; + Profile('Preparing HTML and writing it') document.body.style.height = '100%'; document.body.style.overflow = 'hidden'; document.body.scroll = 'no' @@ -88,14 +168,18 @@ this.ScrollerW = this.MainInner.offsetWidth - this.MainInner.clientWidth this.ScrollerH = this.MainInner.offsetHeight - this.MainInner.clientHeight - this.UpdateColWidths(); + if (!this.UpdateColWidths()) return; +// Profile('UpdateColWidths'); + if (this.Width == 'auto') { this.Resize( this.GetAutoSize() ); } else { this.Resize(); } +// Profile('Resizing'); + this.TheGrid.style.visibility = 'visible' this.MainScroller.style.visibility = 'visible' @@ -105,8 +189,10 @@ } else { $status = window.addEventListener('resize', function(ev) { the_grid.AutoResize() }, true); } + Profile('Finalizng', 0); } + GridScroller.prototype.SetReferences = function() { this.MainOuter = document.getElementById('outer_main_'+this.GridId ); this.MainInner = document.getElementById('inner_main_'+this.GridId) @@ -152,50 +238,87 @@ // this.MainOuter.style.padding = '30px'; this.MainOuter.className = 'grid-scrollable' + if (!is.ie) { + this.MainOuter.style.marginLeft = '-1px'; + } + } GridScroller.prototype.UpdateColWidths = function() { var data_cf = 1; var count = 1; - var header_cf = 0.2; + var header_cf = 0; var footer_cf = 0.2; +// alert('MinWidths: '+this.MinWidths.length + ' vs Data ' + this.Header[0].length) + if (this.MinWidths.length < this.Header[0].length) { + var widths = new Array(); + var total = 0; - var header_widths = this.GetWidths('header_'+this.GridId); - data_cf -= header_cf; - count++; + StyleManager.ChangeStyle('td.grid-header-last-cell', 'width', '123px') + StyleManager.ChangeStyle('td.grid-data-last-cell', 'width', 'auto') + if (this.HasFooter()) { + StyleManager.ChangeStyle('td.grid-footer-last-cell', 'width', 'auto') + } - var data_widths = this.GetWidths('data_'+this.GridId); + if (this.LeftCells) { + widths.push(this.LeftHeaderTable.clientWidth) + } - if (this.HasFooter()) { - var footer_widths = this.GetWidths('footer_'+this.GridId); - data_cf -= footer_cf; - count++; - } + var header_widths = this.GetWidths('header_'+this.GridId); + var data_widths = this.GetWidths('data_'+this.GridId); - var widths = new Array(); - var total = 0; + /*if (this.HasFooter()) { + var footer_widths = this.GetWidths('footer_'+this.GridId); + data_cf -= footer_cf; + count++; + }*/ - for (var i=0; i' + table.rows[row].cells[col].innerHTML + '' + table.rows[row].cells[col].innerHTML = '
' + 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]) @@ -301,7 +426,8 @@ var table = document.getElementById(table_id); for (var row=0; row' + table.rows[row].cells[0].innerHTML + '' + var width = this.MinWidths[0] ? this.MinWidths[0] + 'px' : 'auto'; + 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) @@ -312,7 +438,8 @@ GridScroller.prototype.SetWidths = function(table_id, widths, from, to) { var table = document.getElementById(table_id); - for (var row=0; row this.Width ? this.ScrollerH : 0; @@ -406,15 +534,14 @@ // 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.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 -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' @@ -423,23 +550,42 @@ } } + 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 } 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' + + + 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() @@ -473,7 +619,7 @@ var left_data = this.CreateScroller( this.CreateTable( this.GetLeftData(), 'left_data_'+this.GridId), 20, 10, 'left_data_'+this.GridId, true, 5 ) var left_footer = this.CreateScroller( this.CreateTable( this.GetLeftFooter(), 'left_footer_'+this.GridId), 20, 10, 'left_footer_'+this.GridId, true, 5 ) o += '' - o += '' + o += '' o += '' o += '' o += '' @@ -500,7 +646,7 @@ GridScroller.prototype.CreateTable = function(content, id) { - return '
' + left_header + '
' + left_header + '' + header + '
' + left_data + '' + data + '
'+content+'
'; + return ''+content+'
'; } GridScroller.prototype.CreateScroller = function(content, w, h, id, hidden, z) @@ -536,22 +682,12 @@ for (var row in this.Header) { o +='' for (var col=0; col'+this.Header[row][col]+'' + width = this.MinWidths[col] ? this.MinWidths[col] + 'px' : 'auto'; + o += '
'+this.Header[row][col]+'
' } - o += '' o += '' } return o - - var o = ''; - - o += '' - for (var col=0; col'+this.Header[col]+'' - } - o += '' - - return o } GridScroller.prototype.GetLeftData = function() @@ -563,7 +699,8 @@ o += even ? '' : '' even = !even; for (var col=0; col'+this.Data[row][col]+'' + width = this.MinWidths[col] ? this.MinWidths[col] + 'px' : 'auto'; + o += '
'+this.Data[row][col]+'
' } o += '' } @@ -577,7 +714,8 @@ if (this.HasFooter()) { o += '' for (var col=0; col'+this.Footer[col]+'' + width = this.MinWidths[col] ? this.MinWidths[col] + 'px' : 'auto'; + o += '
'+this.Footer[col]+'
' } o += '' } @@ -590,9 +728,10 @@ for (var row in this.Header) { o +='' for (var col=this.LeftCells; col'+this.Header[row][col]+'' + width = this.MinWidths[col] ? this.MinWidths[col] + 'px' : 'auto'; + o += '
'+this.Header[row][col]+'
' } - o += '' + o += '' o += '' } return o @@ -611,14 +750,17 @@ { 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]+'' + width = this.MinWidths[col] ? this.MinWidths[col] + 'px' : 'auto'; + o += '
'+this.Data[row][col]+'
' } - o += '' + o += '' o += '' } return o @@ -628,9 +770,10 @@ { var o = '' for (var col=this.LeftCells; col'+this.Footer[col]+'' } - o += '' + o += '' o += '' return o }