|
4 | 4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
|
5 | 5 | <title>Drag & Drop Text</title>
|
6 | 6 |
|
7 |
| - |
8 |
| - |
9 | 7 | <script type="text/javascript" src="/javascripts/jquery-1.4.min.js"></script>
|
10 | 8 | <script type="text/javascript" src="/javascripts/jquery.highlight.js"></script>
|
11 |
| -<script type="text/javascript"> |
12 |
| - var highlights = []; |
13 |
| - |
14 |
| - $(document).ready(function(){ |
| 9 | +<script type="text/javascript" src="/javascripts/jquery.autocomplete.js"></script> |
| 10 | +<script type="text/javascript" src="/javascripts/jquery.annotation.js"></script> |
15 | 11 |
|
16 |
| - $("#dropzone .insight .trash").live("click", function(){ |
17 |
| - insightDiv = $(this).parents(".insight") |
18 |
| - spanId = insightDiv.data("highlight"); |
19 |
| - highlightSpan = document.getElementById(spanId); |
20 |
| - // console.log(highlightSpan); |
21 |
| - $("#post").removeHighlight_with_id(spanId); |
22 |
| - $(insightDiv).fadeOut(); |
23 |
| - }); |
24 |
| - |
25 |
| - $("#dropzone .insight").live("mouseover", function(){ |
26 |
| - selection = $(this).find(".excerpt").html() |
27 |
| - $("#post").highlight(selection); |
28 |
| - }); |
29 |
| - |
30 |
| - $("#dropzone .insight").live("mouseout", function(){ |
31 |
| - // selection = $(this).html(); |
32 |
| - $("#post").removeHighlight(); |
33 |
| - }); |
34 |
| - |
35 |
| - |
36 |
| - $('#post').mouseup(function(e){ |
37 |
| - var selection = getSelected(); |
38 |
| - // console.log(selection); |
39 |
| - if (selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) { |
40 |
| - // highlights.push(selection); |
41 |
| - insightDiv = $('<div>').attr({id: "insight_" + highlights.length, class: "insight"}).hide(); |
42 |
| - insightExcerpt = $('<span>').html(selection).attr({class: "excerpt"}); |
43 |
| - insightDiv.append(insightExcerpt); |
44 |
| - // insightDiv.data("highlight", "highlight_" + highlights.length); |
45 |
| - toolsDiv = $('<div>').attr({class: "actions"}); |
46 |
| - toolsDiv.append($('<span>').attr({class: "edit", title: "Edit this excerpt"})); |
47 |
| - toolsDiv.append($('<span>').attr({class: "trash", title: "Delete this excerpt"})); |
48 |
| - toolsDiv.append($('<span>').attr({class: "comment", title: "Comment on this excerpt"})); |
49 |
| - insightDiv.append(toolsDiv); |
50 |
| - $("#dropzone").append(insightDiv); |
51 |
| - insightDiv.fadeIn(); |
52 |
| - // $("#post").highlight_with_id(selection, "highlight_" + highlights.length); |
53 |
| - } |
54 |
| - }); |
| 12 | +<script type="text/javascript"> |
| 13 | + |
| 14 | + var system_insights = eval(['black', 'white', 'red', 'green', 'blue', 'yellow', 'purple', 'brown', 'silver', 'magenta', 'cyan', 'gold', 'goldenrod']); |
55 | 15 |
|
56 |
| - }); |
57 |
| - |
58 | 16 | function getSelected() {
|
59 |
| - if(window.getSelection) { return window.getSelection(); } |
60 |
| - else if(document.getSelection) { return document.getSelection(); } |
61 |
| - else { |
| 17 | + if (window.getSelection) { |
| 18 | + return window.getSelection(); |
| 19 | + } else if(document.getSelection) { |
| 20 | + return document.getSelection(); |
| 21 | + } else { |
62 | 22 | var selection = document.selection && document.selection.createRange();
|
63 | 23 | if(selection.text) { return selection.text; }
|
64 | 24 | return false;
|
65 | 25 | }
|
66 | 26 | return false;
|
67 | 27 | }
|
68 | 28 |
|
69 |
| - |
| 29 | + function hilite(excerpt){ |
| 30 | + $("#post").highlight(excerpt); |
| 31 | + } |
| 32 | + |
| 33 | + function unHilite(){ |
| 34 | + $("#post").removeHighlight(); |
| 35 | + } |
| 36 | + |
| 37 | + $(document).ready(function(){ |
| 38 | + var tmp_note = $('#hidden_templates .annotation'); |
| 39 | + |
| 40 | + $('#post').mouseup(function(e){ |
| 41 | + var selection = getSelected(); |
| 42 | + if (selection && (selection = new String(selection).replace(/^\s+|\s+$/g,''))) { |
| 43 | + $("#dropzone").append($('<div>').annotation(selection,{template: tmp_note, available_insights: "tokens.js", onMouseOver: hilite, onMouseOut: unHilite }).fadeIn()); |
| 44 | + } |
| 45 | + }); |
| 46 | + }); |
| 47 | + |
70 | 48 | </script>
|
71 | 49 |
|
| 50 | +<link rel="stylesheet" href="../stylesheets/jquery.autocomplete.css" type="text/css" media="screen" title="no title" charset="utf-8"> |
| 51 | + |
72 | 52 | <style type="text/css">
|
73 |
| - #post{width:75%;float:left;} |
74 |
| - #sidebar{width:25%;float:right;} |
75 |
| - #dropzone{height:300px;border:3px double red;margin:10px;padding:10px;} |
| 53 | + body{font-family:arial;font-size:10pt;} |
| 54 | + .clr{clear:both;} |
| 55 | + #page{width:1000px;} |
| 56 | + #post{width:600px;float:left;padding:20px 10px 10px;} |
| 57 | + #sidebar{width:350px;float:right;} |
| 58 | + #dropzone{min-height:300px;border:1px dashed red;margin:10px;} |
76 | 59 |
|
77 |
| - .insight{border:1px dashed #ccc;padding:5px;margin:5px;} |
| 60 | + .annotation{background:#fafafa;border:1px solid #ccc;margin:5px 5px 10px;} |
78 | 61 |
|
79 | 62 | .highlight { background-color: yellow; padding:auto 3px;}
|
| 63 | + .excerpt_holder{padding:5px;} |
80 | 64 | .excerpt{margin-right:5px;}
|
81 | 65 | .actions{display:inline-block;}
|
82 |
| - .actions span{display:inline-block;width:12px;height:14px;vertical-align:middle;margin:0px 3px 2px;} |
83 |
| - .actions .edit{background:url(/images/insights/edit.gif) no-repeat 1px 0px;} |
84 |
| - .actions .trash{background:url(/images/insights/trash.gif) no-repeat 1px 2px;} |
85 |
| - .actions .comment{background:url(/images/insights/comment.gif) no-repeat 1px 2px;} |
| 66 | + .actions span{display:inline-block;width:12px;height:14px;vertical-align:middle;margin:0px 3px 2px;cursor:pointer;} |
| 67 | + .actions span.edit{background:url(/images/insights/edit.gif) no-repeat 1px 0px;} |
| 68 | + .actions span.trash{background:url(/images/insights/trash.gif) no-repeat 1px 2px;} |
| 69 | + .actions span.comment{background:url(/images/insights/comment.gif) no-repeat 1px 2px;} |
| 70 | + .actions span.attach{background:url(/images/insights/briefcase.gif) no-repeat 1px 2px;} |
| 71 | + |
| 72 | + .insight_form{border-top:1px dashed #ccc;padding:5px;} |
| 73 | + |
| 74 | + .insights{background:#fff;border-top:1px dashed #ccc;padding:2px 5px;} |
| 75 | + .insight{float:left;margin-right:5px;padding:3px;} |
| 76 | + .insight a{cursor:pointer;display:inline-block;color:transparent;width:10px;margin-right:3px;background:url("/images/insights/x-ind.gif") no-repeat 0px 5px;} |
| 77 | + .insight a:hover{background:url("/images/insights/x-ind.gif") no-repeat -10px 5px;} |
| 78 | + |
| 79 | + div.comment{border-top:1px dashed #ccc;padding:5px 8px 5px 6px;text-align:right;} |
| 80 | + div.comment textarea{width:100%;height:50px;margin-bottom:5px;padding:1px;} |
| 81 | + div.comment .comment_button{} |
86 | 82 | </style>
|
87 | 83 | </head>
|
88 | 84 |
|
89 | 85 | <body id="home">
|
90 |
| - <div id="post"> |
91 |
| - <p>My experiences have all been awful. There has been no "light at the end of the tunnel," no blessing in disguise and no valuable learning experience. It's all very negative. It has been a terrible, terrible experience. This disease is really one of the worst. It hits during the dead center of the prime of life and just slowly destroys us. The old term of creeping paralysis is very appropriate. I spend hours thinking about all this disease has stolen from me and worse yet, I wonder about the things I don't realize that I've lost. What would life be like had this not happened? What experiences have I missed? There's a whole world out there and I can scarcely take part in it.</p> |
92 |
| - <p>If I had to find a specific experience, or set of experiences, that defined my MS struggle it would be the month I spent in Baltimore being treated. It took part in a risky, difficult trial involving high doses of chemotherapy. This is an example of the lengths I was willing to go to preserve functioning. I told the doctor at JH that I'd drink a gallon of gasoline if it would preserve the use of my body.</p> |
| 86 | + <div id="page"> |
| 87 | + <div id="post"> |
| 88 | + <p>My experiences have all been awful. There has been no "light at the end of the tunnel," no blessing in disguise and no valuable learning experience. It's all very negative. It has been a terrible, terrible experience. This disease is really one of the worst. It hits during the dead center of the prime of life and just slowly destroys us. The old term of creeping paralysis is very appropriate. I spend hours thinking about all this disease has stolen from me and worse yet, I wonder about the things I don't realize that I've lost. What would life be like had this not happened? What experiences have I missed? There's a whole world out there and I can scarcely take part in it.</p> |
| 89 | + <p>If I had to find a specific experience, or set of experiences, that defined my MS struggle it would be the month I spent in Baltimore being treated. It took part in a risky, difficult trial involving high doses of chemotherapy. This is an example of the lengths I was willing to go to preserve functioning. I told the doctor at JH that I'd drink a gallon of gasoline if it would preserve the use of my body.</p> |
| 90 | + </div> |
| 91 | + <div id="sidebar"> |
| 92 | + <div id="clicker">Click</div> |
| 93 | + <div id="dropzone"> |
| 94 | + |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + <div class="clr"></div> |
93 | 98 | </div>
|
94 |
| - <div id="sidebar"> |
95 |
| - <div id="dropzone"> |
| 99 | + |
| 100 | + <div id="hidden_templates" style="display:none;"> |
96 | 101 |
|
| 102 | + <div class="annotation"> |
| 103 | + <div class="excerpt_holder"> |
| 104 | + <span class="excerpt"></span> |
| 105 | + <div class="actions"> |
| 106 | + <span title="Delete this excerpt" class="trash"></span> |
| 107 | + <span title="Comment on this excerpt" class="comment"></span> |
| 108 | + <span title="Attach an Insight to this excerpt" class="attach"></span> |
| 109 | + </div> |
| 110 | + </div> |
| 111 | + <div> |
| 112 | + <div class="insight_form" style="display:none;"> |
| 113 | + <input type="text" class="insight_field"> |
| 114 | + <input type="button" class="insight_button" value="Add Insight"> |
| 115 | + </div> |
| 116 | + <div class="insights" style="display:none;"> |
| 117 | + <span class="empty_message">no insights attached</span> |
| 118 | + <div class="clr"></div> |
| 119 | + </div> |
| 120 | + <div class="comment" style="display:none;"> |
| 121 | + <textarea></textarea> |
| 122 | + <input type="button" class="comment_button" value="Submit Comment"> |
| 123 | + </div> |
| 124 | + </div> |
97 | 125 | </div>
|
| 126 | + |
98 | 127 | </div>
|
| 128 | + |
99 | 129 | </body>
|
100 | 130 | </html>
|
101 | 131 |
|
| 132 | +<script> |
| 133 | + |
| 134 | + $("#clicker").click(function(){ |
| 135 | + $("#dropzone").append($('<div>').annotation("MS struggle it would be the month I spent in Baltimore being treated",{insights: ["pain","misery"], comment: "This is a comment", template: $('#hidden_templates .annotation'), available_insights: system_insights,onMouseOver: hilite, onMouseOut: unHilite})); |
| 136 | + }); |
| 137 | + |
| 138 | +</script> |
| 139 | + |
0 commit comments