From f3958a113d7cb8eb3e3d31b3f05962e258960fa8 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Tue, 22 Feb 2011 15:40:44 +0100 Subject: [PATCH] select fragment on click --- wolnelektury/static/js/book.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/wolnelektury/static/js/book.js b/wolnelektury/static/js/book.js index b9ab6b1da..d6dfec9f8 100644 --- a/wolnelektury/static/js/book.js +++ b/wolnelektury/static/js/book.js @@ -40,4 +40,22 @@ $(function() { $(this).removeClass('selected'); $($(this).attr('href')).slideUp('fast'); }); + + + if (window.getSelection) { + $('.theme-begin').click(function() { + var selection = window.getSelection(); + selection.removeAllRanges(); + var range = document.createRange(); + + var e = $(".theme-end[fid='" + $(this).attr('fid') + "']")[0]; + + if (e) { + range.setStartAfter(this); + range.setEndBefore(e); + selection.addRange(range); + } + }); + } + }); -- 2.20.1