From e3a3d3aa0aa1806e20bffb0ff4c307ec6cc89964 Mon Sep 17 00:00:00 2001 From: linux-man Date: Sun, 21 May 2017 19:00:12 +0100 Subject: Better Search Open/close with Control+Shift+f Find words inside SPAN Don't duplicate findings --- plugin/search/search.js | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) (limited to 'plugin') diff --git a/plugin/search/search.js b/plugin/search/search.js index ae6582e..28c2c5f 100644 --- a/plugin/search/search.js +++ b/plugin/search/search.js @@ -21,7 +21,7 @@ function Hilitor(id, tag) var targetNode = document.getElementById(id) || document.body; var hiliteTag = tag || "EM"; - var skipTags = new RegExp("^(?:" + hiliteTag + "|SCRIPT|FORM|SPAN)$"); + var skipTags = new RegExp("^(?:" + hiliteTag + "|SCRIPT|FORM)$"); var colors = ["#ff6", "#a0ffff", "#9f9", "#f99", "#f6f"]; var wordColor = []; var colorIdx = 0; @@ -53,11 +53,11 @@ function Hilitor(id, tag) if(node.nodeType == 3) { // NODE_TEXT if((nv = node.nodeValue) && (regs = matchRegex.exec(nv))) { //find the slide's section element and save it in our list of matching slides - var secnode = node.parentNode; - while (secnode.nodeName != 'SECTION') { + var secnode = node; + while (secnode != null && secnode.nodeName != 'SECTION') { secnode = secnode.parentNode; } - + var slideIndex = Reveal.getIndices(secnode); var slidelen = matchingSlides.length; var alreadyAdded = false; @@ -69,7 +69,7 @@ function Hilitor(id, tag) if (! alreadyAdded) { matchingSlides.push(slideIndex); } - + if(!wordColor[regs[0].toLowerCase()]) { wordColor[regs[0].toLowerCase()] = colors[colorIdx++ % colors.length]; } @@ -110,20 +110,26 @@ function Hilitor(id, tag) function openSearch() { //ensure the search term input dialog is visible and has focus: + var inputboxdiv = document.getElementById("searchinputdiv"); var inputbox = document.getElementById("searchinput"); - inputbox.style.display = "inline"; + inputboxdiv.style.display = "inline"; inputbox.focus(); inputbox.select(); } + function closeSearch() { + var inputboxdiv = document.getElementById("searchinputdiv"); + inputboxdiv.style.display = "none"; + if(myHilitor) myHilitor.remove(); + } + function toggleSearch() { - var inputbox = document.getElementById("searchinput"); - if (inputbox.style.display !== "inline") { + var inputboxdiv = document.getElementById("searchinputdiv"); + if (inputboxdiv.style.display !== "inline") { openSearch(); } else { - inputbox.style.display = "none"; - myHilitor.remove(); + closeSearch(); } } @@ -157,7 +163,8 @@ function Hilitor(id, tag) searchElement.classList.add( 'searchdiv' ); searchElement.style.position = 'absolute'; searchElement.style.top = '10px'; - searchElement.style.left = '10px'; + searchElement.style.right = '10px'; + searchElement.style.zIndex = 10; //embedded base64 search icon Designed by Sketchdock - http://www.sketchdock.com/: searchElement.innerHTML = ''; dom.wrapper.appendChild( searchElement ); @@ -179,18 +186,12 @@ function Hilitor(id, tag) } }, false ); - // Open the search when the 's' key is hit (yes, this conflicts with the notes plugin, disabling for now) - /* document.addEventListener( 'keydown', function( event ) { - // Disregard the event if the target is editable or a - // modifier is present - if ( document.querySelector( ':focus' ) !== null || event.shiftKey || event.altKey || event.ctrlKey || event.metaKey ) return; - - if( event.keyCode === 83 ) { + if( event.key == "F" && (event.ctrlKey || event.metaKey) ) {//Control+Shift+f event.preventDefault(); - openSearch(); + toggleSearch(); } }, false ); -*/ + closeSearch(); return { open: openSearch }; })(); -- cgit v1.2.3 From 9c3a65744ccd45a0e1673b5a1ead6842b6b64f2e Mon Sep 17 00:00:00 2001 From: linux-man Date: Sun, 21 May 2017 19:13:41 +0100 Subject: Modified Zoom Block dimension calculation is not accurate, so zoom is made on mouse coordinates Change default modifier to ctrl - alt don't work on Linux New parameter zoomLevel: default 2 --- plugin/zoom-js/zoom.js | 29 ++++++----------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'plugin') diff --git a/plugin/zoom-js/zoom.js b/plugin/zoom-js/zoom.js index 8738083..41fd15d 100644 --- a/plugin/zoom-js/zoom.js +++ b/plugin/zoom-js/zoom.js @@ -3,31 +3,17 @@ var isEnabled = true; document.querySelector( '.reveal .slides' ).addEventListener( 'mousedown', function( event ) { - var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'alt' ) + 'Key'; - - var zoomPadding = 20; - var revealScale = Reveal.getScale(); + var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'ctrl' ) + 'Key';//cl + var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 ); if( event[ modifier ] && isEnabled ) { event.preventDefault(); - var bounds; - var originalDisplay = event.target.style.display; - - // Get the bounding rect of the contents, not the containing box - if( window.getComputedStyle( event.target ).display === 'block' ) { - event.target.style.display = 'inline-block'; - bounds = event.target.getBoundingClientRect(); - event.target.style.display = originalDisplay; - } else { - bounds = event.target.getBoundingClientRect(); - } - zoom.to({ - x: ( bounds.left * revealScale ) - zoomPadding, - y: ( bounds.top * revealScale ) - zoomPadding, - width: ( bounds.width * revealScale ) + ( zoomPadding * 2 ), - height: ( bounds.height * revealScale ) + ( zoomPadding * 2 ), + x: event.clientX - window.innerWidth / (zoomLevel * 2),//cl + y: event.clientY - window.innerHeight / (zoomLevel * 2), + width: window.innerWidth / zoomLevel, + height: window.innerHeight / zoomLevel, pan: false }); } @@ -283,6 +269,3 @@ var zoom = (function(){ } })(); - - - -- cgit v1.2.3 From ce467b53bc44325424787858c59bb134ed53f8b6 Mon Sep 17 00:00:00 2001 From: linux-man Date: Sun, 21 May 2017 19:49:07 +0100 Subject: Remove comment --- plugin/zoom-js/zoom.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugin') diff --git a/plugin/zoom-js/zoom.js b/plugin/zoom-js/zoom.js index 41fd15d..9e8629f 100644 --- a/plugin/zoom-js/zoom.js +++ b/plugin/zoom-js/zoom.js @@ -3,14 +3,14 @@ var isEnabled = true; document.querySelector( '.reveal .slides' ).addEventListener( 'mousedown', function( event ) { - var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'ctrl' ) + 'Key';//cl + var modifier = ( Reveal.getConfig().zoomKey ? Reveal.getConfig().zoomKey : 'ctrl' ) + 'Key'; var zoomLevel = ( Reveal.getConfig().zoomLevel ? Reveal.getConfig().zoomLevel : 2 ); if( event[ modifier ] && isEnabled ) { event.preventDefault(); zoom.to({ - x: event.clientX - window.innerWidth / (zoomLevel * 2),//cl + x: event.clientX - window.innerWidth / (zoomLevel * 2), y: event.clientY - window.innerHeight / (zoomLevel * 2), width: window.innerWidth / zoomLevel, height: window.innerHeight / zoomLevel, -- cgit v1.2.3