textselection
This commit is contained in:
parent
240a1f999a
commit
84535957c8
22
selText.js
22
selText.js
@ -1,13 +1,15 @@
|
|||||||
$(function(){
|
var selText = function(callback){
|
||||||
$(document.body).bind('mouseup', function(e){
|
document.body.addEventListener('mouseup', function(e){
|
||||||
var selection;
|
var selection;
|
||||||
|
|
||||||
if (window.getSelection) {
|
if (window.getSelection) {
|
||||||
selection = window.getSelection();
|
selection = window.getSelection();
|
||||||
} else if (document.selection) {
|
} else if (document.selection) {
|
||||||
selection = document.selection.createRange();
|
selection = document.selection.createRange();
|
||||||
}
|
}
|
||||||
|
|
||||||
selection.toString() !== '' && alert('"' + selection.toString() + '" was selected at ' + e.pageX + '/' + e.pageY);
|
if(selection.toString() !== '') {
|
||||||
|
callback(selection.toString(),e.pageX, e.pageY);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
};
|
||||||
2
selText.min.js
vendored
Normal file
2
selText.min.js
vendored
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
var selText=function(callback){document.body.addEventListener("mouseup",(function(e){var selection;window.getSelection?selection=window.getSelection():document.selection&&(selection=document.selection.createRange()),""!==selection.toString()&&callback(selection.toString(),e.pageX,e.pageY)}))};
|
||||||
|
//# sourceMappingURL=selText.min.js.map
|
||||||
23
selText.min.js.map
Normal file
23
selText.min.js.map
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"version": 3,
|
||||||
|
"sources": [
|
||||||
|
"selText.js"
|
||||||
|
],
|
||||||
|
"names": [
|
||||||
|
"selText",
|
||||||
|
"callback",
|
||||||
|
"document",
|
||||||
|
"body",
|
||||||
|
"addEventListener",
|
||||||
|
"e",
|
||||||
|
"selection",
|
||||||
|
"window",
|
||||||
|
"getSelection",
|
||||||
|
"createRange",
|
||||||
|
"toString",
|
||||||
|
"pageX",
|
||||||
|
"pageY"
|
||||||
|
],
|
||||||
|
"mappings": "AAAA,IAAIA,QAAU,SAASC,UACrBC,SAASC,KAAKC,iBAAiB,WAAW,SAASC,GACjD,IAAIC,UAEAC,OAAOC,aACTF,UAAYC,OAAOC,eACVN,SAASI,YAClBA,UAAYJ,SAASI,UAAUG,eAGL,KAAzBH,UAAUI,YACXT,SAASK,UAAUI,WAAWL,EAAEM,MAAON,EAAEO",
|
||||||
|
"file": "selText.js"
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user