diff options
author | John McLear <john@mclear.co.uk> | 2013-03-17 23:16:23 +0000 |
---|---|---|
committer | John McLear <john@mclear.co.uk> | 2013-03-17 23:16:23 +0000 |
commit | 99ac407f089e83db3b1608bb4a9c7869f438c4c4 (patch) | |
tree | c47ad9d3fe2c2182b1b1e2b71f2526914c905450 /tests | |
parent | 81f0ef73abfb492841e83a4b87a293a2d2d71ebc (diff) | |
download | etherpad-lite-99ac407f089e83db3b1608bb4a9c7869f438c4c4.zip |
working caret position function
Diffstat (limited to 'tests')
-rw-r--r-- | tests/frontend/specs/caret.js | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/tests/frontend/specs/caret.js b/tests/frontend/specs/caret.js index fd479d5d..56964885 100644 --- a/tests/frontend/specs/caret.js +++ b/tests/frontend/specs/caret.js @@ -10,8 +10,14 @@ describe("As the caret is moved is the UI properly updated?", function(){ * Page up (33) / down (34) with and without special keys */ + /* Challenges + * How do we keep the authors focus on a line if the lines above the author are modified? We should only redraw the user to a location if they are typing and make sure shift and arrow keys aren't redrawing the UI else highlight - copy/paste would get broken + * How the fsk do I get + * + */ + it("Creates N rows, changes height of rows, updates UI by caret key events", function(done) { - var inner$ = helper.padInner$; + var inner$ = helper.padInner$; var chrome$ = helper.padChrome$; var numberOfRows = 50; @@ -29,6 +35,7 @@ describe("As the caret is moved is the UI properly updated?", function(){ $(this).css("height", random+"px"); }); + console.log(caretPosition(inner$)); var newDivHeight = inner$("div").first().css("height"); var heightHasChanged = originalDivHeight != newDivHeight; // has the new div height changed from the original div height expect(heightHasChanged).to.be(true); // expect the first line to be blank @@ -112,3 +119,12 @@ function isScrolledIntoView(elem, $){ // from http://stackoverflow.com/questions var elemBottom = elemTop + $(elem).height(); return ((elemBottom <= docViewBottom) && (elemTop >= docViewTop)); } + +function caretPosition($){ + var doc = $.window.document; + var pos = doc.getSelection(); + pos.y = pos.anchorNode.parentElement.offsetTop; + pos.x = pos.anchorNode.parentElement.offsetLeft; + console.log(pos); + return pos; +} |