-
Notifications
You must be signed in to change notification settings - Fork 368
Expand file tree
/
Copy pathselection.html
More file actions
101 lines (86 loc) · 2.54 KB
/
selection.html
File metadata and controls
101 lines (86 loc) · 2.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<title>selection</title>
<style type='text/css'>
body {font-family: verdana}
.error {border: solid 1px red;}
.error_text { color: red; font-size: 10px;}
td {padding: 3px;}
</style>
</head>
<body>
<table>
<tr>
<td> <a href="javascript://" id='select_textarea'>Select Textarea</a></td>
<td><textarea id=''>012
456</textarea></td>
</tr>
<tr>
<td><a href="javascript://" id='select_input'>Select Input</a></td>
<td><input text='text' value='0123456789'/></td>
</tr>
<tr>
<td><a href="javascript://" id='select_p'>Select Within One Element</a></td>
<td><p id='1'>0123456789</p></td>
</tr>
<tr>
<td><a href="javascript://" id='select_multi'>Select Across Multiple Elements</a></td>
<td><div id='2'>012<div>3<span>4</span>5</div></div></td>
</tr>
</table>
<div id='selectionArea'><p>Hello <b>World</b>! how are you today?</p>
<p>I am good, thank you.</p>
</div>
<script type='text/javascript'
src='../../../steal/steal.js?jquery/event/selection'>
(function(){
$.event.selection.preventDefault = true;
var selection = $("<div/>").css({
opacity: 0.5,
backgroundColor: 'blue',
position: 'absolute',
zIndex: 1000,
top: '0px',
left: '0px'
}).appendTo(document.body),
startRange,
highlight = function(entire){
var rects = entire.rects(),
childs = selection.children();
for(var i =0; i < rects.length; i++){
var child = childs.eq(i).length ? childs.eq(i) : $('<div/>').css({
backgroundColor: 'blue',
position: 'absolute',
zIndex: 1000
})
//.text(rects[i].left)
.appendTo(selection);
child.css({
left: rects[i].left+"px",
top: rects[i].top+"px"
}).width(rects[i].width)
.height(rects[i].height);
}
childs.slice(i).remove();
selection.show();
};
$(document.body).bind('mousedown', function(){
selection.hide();
})
.bind('selectionStart', function(ev, range){
highlight(range)
})
.bind('selectionMoving', function(){
selection.hide();
})
.bind('selectionMove', function(ev, range){
highlight(range);
})
})();
</script>
<script type='text/javascript'>
</script>
</body>
</html>