Skip to content

Commit b36e6e3

Browse files
authored
Merge pull request #175 from RE-QDA/update_js
JS updated with listeners for key and touch events in the Annotate tab - enables changing selection with shift+arrow - enables selection on mobile/touch devices
2 parents f352432 + 04c4fbc commit b36e6e3

File tree

4 files changed

+15
-7
lines changed

4 files changed

+15
-7
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: requal
22
Title: Shiny Application for Computer-Assisted Qualitative Data Analysis
3-
Version: 1.2.4.9005
3+
Version: 1.2.4.9006
44
Authors@R:
55
c(
66
person(given = "Radim",

NEWS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
- foreign keys now enforced in SQLite
2525
- default document encoding is now processed explicitly
2626
- other minor fixes
27+
- selecting segments on smartphones/tablets and by combination of mouse and keyboard now works
2728

2829
# requal 1.1.3 Rieppeleon
2930

R/mod_document_code.R

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ mod_document_code_ui <- function(id) {
6767
tags$article(
6868
id = "article",
6969
class = "scrollable80",
70+
tabindex = 0,
7071
.noWS = "outside"
7172
),
7273
.noWS = "outside"

inst/app/www/document_code_js.js

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,9 @@ function getCaretCharacterOffsetWithin(element) {
3636
return caretOffset;
3737
}
3838

39-
// Function to send calculated positions to Shiny
40-
$( document ).ready(function() {
41-
document.addEventListener('mouseup', function () {
42-
var sel = window.getSelection();
43-
// if(window.getSelection().baseNode.parentNode.id != "document_code_ui_1-focal_text") return;
39+
function updateSelection() {
40+
var sel = window.getSelection();
41+
if(window.getSelection().anchorNode.parentNode.closest('article') == null) return;
4442

4543
if(sel.rangeCount > 0){
4644
var range = sel.getRangeAt(0);
@@ -68,8 +66,16 @@ document.addEventListener('mouseup', function () {
6866
console.log("tag_position" + tag_position_value)
6967
Shiny.setInputValue('document_code_ui_1-tag_position', tag_position_value);
7068
}
71-
}, false);
69+
}
70+
71+
// Function to send calculated positions to Shiny
72+
$( document ).ready(function() {
73+
var el = document.getElementById("document_code_ui_1-focal_text")
74+
el.addEventListener('mouseup', updateSelection);
75+
el.addEventListener('keyup', updateSelection);
76+
el.addEventListener('touchend', updateSelection);
7277
})
78+
7379
// Obtain information from iframe and send to Shiny
7480
$(document).ready(function() {
7581
var iframe = document.getElementsByTagName('iframe')[0];

0 commit comments

Comments
 (0)