able to select words.
This commit is contained in:
parent
d96e3aefd1
commit
a88474de56
1 changed files with 46 additions and 21 deletions
|
@ -1,25 +1,50 @@
|
|||
$(document).ready(function () {
|
||||
console.log('hello world!');
|
||||
|
||||
var popoverContent;
|
||||
|
||||
$.get('test-menu-content.html', function (data) {
|
||||
popoverContent = data;
|
||||
contentReady();
|
||||
});
|
||||
|
||||
function contentReady () {
|
||||
$('.selected').popover({
|
||||
title: "Please select a semantic tag",
|
||||
|
||||
content: popoverContent,
|
||||
|
||||
html: true,
|
||||
|
||||
placement: 'auto'
|
||||
|
||||
});
|
||||
|
||||
$('.selected').popover('show');
|
||||
function processSelection () {
|
||||
var focused = document.activeElement;
|
||||
var selectedText;
|
||||
if (focused) {
|
||||
try {
|
||||
selectedText = focused.value.substring(
|
||||
focused.selectionStart, focused.selectionEnd);
|
||||
} catch (err) {
|
||||
}
|
||||
}
|
||||
if (selectedText == undefined) {
|
||||
var sel = window.getSelection();
|
||||
var selectedText = sel.toString();
|
||||
}
|
||||
console.log(selectedText);
|
||||
}
|
||||
|
||||
document.addEventListener('click', function(evt) {
|
||||
if (!document.hasFocus()) {
|
||||
return true;
|
||||
}
|
||||
processSelection();
|
||||
// evt.stopPropagation();
|
||||
// evt.preventDefault();
|
||||
}, false);
|
||||
|
||||
// var popoverContent;
|
||||
|
||||
// $.get('test-menu-content.html', function (data) {
|
||||
// popoverContent = data;
|
||||
// contentReady();
|
||||
// });
|
||||
|
||||
// function contentReady () {
|
||||
// $('.selected').popover({
|
||||
// title: "Please select a semantic tag",
|
||||
|
||||
// content: popoverContent,
|
||||
|
||||
// html: true,
|
||||
|
||||
// placement: 'auto'
|
||||
|
||||
// });
|
||||
|
||||
// $('.selected').popover('show');
|
||||
// }
|
||||
});
|
Loading…
Reference in a new issue