From 5ec63bb9730dd6e26f63c546d7d503333352dbe8 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Wed, 29 Oct 2014 17:30:52 +0000 Subject: [PATCH] Move resultsBar according to scroll pos & panes scrollbarVisible now part of top.ICEcoder namespace Placement of resultsBar done in setLayout now and takes splitpane into account On change we set scrollbarVisible and set layout again --- lib/ice-coder.js | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 200a76d..e151fa2 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -23,6 +23,7 @@ var ICEcoder = { nextcMInstance: 1, // Next available CodeMirror instance no selectedFiles: [], // Array of selected files findMode: false, // States if we're in find/replace mode + scrollbarVisible: false, // Indicates if the main pane has a scrollbar lockedNav: true, // Nav is locked or not mouseDown: false, // If the mouse is down draggingFilesW: false, // If we're dragging the file manager width @@ -132,7 +133,14 @@ var ICEcoder = { top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]].setSize("100%",top.ICEcoder.content.style.height); top.ICEcoder.content.contentWindow['cM'+ICEcoder.cMInstances[i]+'diff'].setSize("0",top.ICEcoder.content.style.height); } - }},4); + } + // Place resultsBar to edge of pane or it's scrollbar + if (!top.ICEcoder.splitPane) { + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').style.right = !top.ICEcoder.scrollBarVisible ? "0" : "17px"; + } else { + top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').style.right = !top.ICEcoder.scrollBarVisible ? parseInt(parseInt(ICEcoder.content.style.width,10)/2,10)+"px" : (parseInt(parseInt(ICEcoder.content.style.width,10)/2,10)+17)+"px"; + } + },4); } }, @@ -269,6 +277,13 @@ var ICEcoder = { if (!top.ICEcoder.loadingFile) { top.ICEcoder.redoTabHighlight(top.ICEcoder.selectedTab); } + + // Detect if we have a scrollbar & set layout again + setTimeout(function() { + top.ICEcoder.scrollBarVisible = thisCM.getScrollInfo().height > thisCM.getScrollInfo().clientHeight; + top.ICEcoder.setLayout(); + },0); + top.ICEcoder.getCaretPosition(); top.ICEcoder.updateCharDisplay(); top.ICEcoder.updateByteDisplay(); @@ -1470,7 +1485,7 @@ var ICEcoder = { // Find & replace text according to user selections findReplace: function(findString,resultsOnly,buttonClick) { - var find, replace, results, cM, cMdiff, thisCM, content, scrollBarVisible, cursor, avgBlockH, addPadding, rBlocks, blockColor, replaceQS, targetQS, filesQS; + var find, replace, results, cM, cMdiff, thisCM, content, cursor, avgBlockH, addPadding, rBlocks, blockColor, replaceQS, targetQS, filesQS; // Determine our find & replace strings and results display find = findString.toLowerCase(); @@ -1514,8 +1529,6 @@ var ICEcoder = { // If we have results if (ICEcoder.results.length>0) { - // Detect if we have a scrollbar - scrollBarVisible = thisCM.getScrollInfo().height > thisCM.getScrollInfo().clientHeight; // Show results only if (resultsOnly) { @@ -1548,11 +1561,9 @@ var ICEcoder = { // Display the find results bar // The avg block is either line height or fraction of space available - avgBlockH = !scrollBarVisible ? thisCM.defaultTextHeight() : parseInt(top.ICEcoder.content.style.height,10)/thisCM.lineCount(); + avgBlockH = !top.ICEcoder.scrollBarVisible ? thisCM.defaultTextHeight() : parseInt(top.ICEcoder.content.style.height,10)/thisCM.lineCount(); // Need to add padding if there's no scrollbar, so current line highlighting lines up with it - addPadding = !scrollBarVisible ? thisCM.heightAtLine(0) : 0; - // Place to edge of screen or scrollbar - top.ICEcoder.content.contentWindow.document.getElementById('resultsBar').style.right = !scrollBarVisible ? "0" : "17px"; + addPadding = !top.ICEcoder.scrollBarVisible ? thisCM.heightAtLine(0) : 0; rBlocks = ""; for (var i=1; i<=thisCM.lineCount(); i++) { blockColor = ICEcoder.resultsLines.indexOf(i)>-1 ? thisCM.getCursor().line+1 == i ? "#b00" : "#888" : "transparent"