diff --git a/framework/yii/views/errorHandler/callStackItem.php b/framework/yii/views/errorHandler/callStackItem.php index 696c0b7..c59473e 100644 --- a/framework/yii/views/errorHandler/callStackItem.php +++ b/framework/yii/views/errorHandler/callStackItem.php @@ -13,7 +13,8 @@ */ $context = $this->context; ?> -
  • +
  • . @@ -30,12 +31,10 @@ $context = $this->context;
    -
    - -
    - +
    +
    - '; ?> +
    
     window.onload = function() {
    -	var i, imax,
    -		codeBlocks = Sizzle('pre'),
    +	var codeBlocks = Sizzle('pre'),
     		callStackItems = Sizzle('.call-stack-item');
     
     	// highlight code blocks
    -	for (i = 0, imax = codeBlocks.length; i < imax; ++i) {
    +	for (var i = 0, imax = codeBlocks.length; i < imax; ++i) {
     		hljs.highlightBlock(codeBlocks[i], '    ');
     	}
     
     	// code block hover line
     	document.onmousemove = function(e) {
    -		var lines, i, imax, j, jmax, k, kmax,
    -			event = e || window.event,
    -			y = event.clientY,
    -			lineFound = false;
    -		for (i = 0, imax = codeBlocks.length; i < imax; ++i) {
    -			lines = codeBlocks[i].getClientRects();
    -			for (j = 0, jmax = lines.length; j < jmax; ++j) {
    -				if (y > lines[j].top && y < lines[j].bottom) {
    +		var event = e || window.event,
    +			clientY = event.clientY,
    +			lineFound = false,
    +			hoverLines = Sizzle('.hover-line');
    +
    +		for (var i = 0, imax = codeBlocks.length; i < imax; ++i) {
    +			var lines = codeBlocks[i].getClientRects();
    +			for (var j = 0, jmax = lines.length; j < jmax; ++j) {
    +				if (clientY > lines[j].top && clientY < lines[j].bottom) {
     					lineFound = true;
     					break;
     				}
    @@ -442,8 +433,8 @@ window.onload = function() {
     				break;
     			}
     		}
    -		var hoverLines = Sizzle('.hover-line');
    -		for (k = 0, kmax = hoverLines.length; k < kmax; ++k) {
    +
    +		for (var k = 0, kmax = hoverLines.length; k < kmax; ++k) {
     			hoverLines[k].className = 'hover-line';
     		}
     		if (lineFound) {
    @@ -452,13 +443,34 @@ window.onload = function() {
     				line[0].className = 'hover-line hover';
     			}
     		}
    -	}
    +	};
    +
    +	var refreshCallStackItemCode = function(callStackItem) {
    +		var top = callStackItem.offsetTop - window.scrollY,
    +			lines = Sizzle('pre', callStackItem)[0].getClientRects(),
    +			lineNumbers = Sizzle('.lines-item', callStackItem),
    +			errorLine = Sizzle('.error-line', callStackItem)[0],
    +			hoverLines = Sizzle('.hover-line', callStackItem);
    +		for (var i = 0, imax = lines.length; i < imax; ++i) {
    +			lineNumbers[i].style.top = parseInt(lines[i].top - top) + 'px';
    +			hoverLines[i].style.top = parseInt(lines[i].top - top) + 'px';
    +			hoverLines[i].style.height = parseInt(lines[i].bottom - lines[i].top) + 'px';
    +			if (parseInt(callStackItem.getAttribute('data-line')) == i) {
    +				errorLine.style.top = parseInt(lines[i].top - top) + 'px';
    +				errorLine.style.height = parseInt(lines[i].bottom - lines[i].top) + 'px';
    +			}
    +		}
    +	};
    +
    +	for (var i = 0, imax = callStackItems.length; i < imax; ++i) {
    +		refreshCallStackItemCode(callStackItems[i]);
     
    -	// toggle code block visibility
    -	for (i = 0, imax = callStackItems.length; i < imax; i++) {
    +		// toggle code block visibility
     		Sizzle('.element-wrap', callStackItems[i])[0].addEventListener('click', function() {
    -			var code = Sizzle('.code-wrap', this.parentNode)[0];
    +			var callStackItem = this.parentNode,
    +				code = Sizzle('.code-wrap', callStackItem)[0];
     			code.style.display = window.getComputedStyle(code).display == 'block' ? 'none' : 'block';
    +			refreshCallStackItemCode(callStackItem);
     		});
     	}
     };