comparison views/Extractapp/TaggingText.php @ 78:960ba96efce1 extractapp

Update: click to popup remove-tag-window; select to popup tag-window
author Zoe Hong <zhong@mpiwg-berlin.mpg.de>
date Mon, 20 Apr 2015 15:44:54 +0200
parents 97c1e5102a22
children e6e213b26454
comparison
equal deleted inserted replaced
77:97c1e5102a22 78:960ba96efce1
1 <?php 1 <?php
2 /*! \file 2 /*! \file
3 * This is the view for TaggingText. 3 * This is the view for TaggingText.
4 * It shows the extraction-interface application itself. 4 * It shows the extraction-interface application itself.
5 * It contains the tagging area and toolbox on the right side. 5 * It contains the tagging area and toolbox on the right side.
6 * 6 *
7 */ 7 */
8 8
9 // --- initialize config file and input text --- 9 // --- initialize config file and input text ---
10 $stringInput = $viewmodel['stringInput']; 10 $stringInput = $viewmodel['stringInput'];
11 $wordlistArray = $viewmodel['wordlistArray']; 11 $wordlistArray = $viewmodel['wordlistArray'];
90 90
91 91
92 92
93 function reloadText() { 93 function reloadText() {
94 /** 94 /**
95 * Reload the text when there is a new version of this branch. 95 * Reload the text when there is a new version of this branch.
96 */ 96 */
97 // confirm to reload 97 // confirm to reload
98 var r = confirm("Are you sure you want to load the latest version (in a new tab)?"); 98 var r = confirm("Are you sure you want to load the latest version (in a new tab)?");
99 if (r != true) { 99 if (r != true) {
100 return; 100 return;
132 } 132 }
133 return; 133 return;
134 134
135 } 135 }
136 136
137 // on click on tagged words, call removeTagNewDiv() for the popup window
138 // popup-window overlapping issue
139 var pop_remove_tag_window = true;
140 var taglistArray = JSON.parse('<?php echo json_encode($taglistArray) ?>');
141 for (var i = 0; i < taglistArray.length; i++) {
142 var taglistValue = taglistArray[i];
143
144 $(document).on("click", taglistValue[2], function (e) {
145 if ($("#editTextId").html() != "Edit the text") return 0;
146 var tagName = $(this).prop("tagName").toLowerCase();
147 /*
148 if ($(this).prop("tagName").toLowerCase() != taglistValue[2]) {
149 return 0;
150 }
151 */
152 if (pop_remove_tag_window) {
153 removeTagNewDiv( e, tagName , $(this));
154 };
155 });
156 };
157
158 /*
137 <?php 159 <?php
138 foreach ( $taglistArray as $taglistValue ) { 160 foreach ( $taglistArray as $taglistValue ) {
139 echo '$(document).on("click", "'.$taglistValue[2].'", function (e) {'."\n"; 161 echo '$(document).on("click", "'.$taglistValue[2].'", function (e) {'."\n";
140 echo "\t".'if ( $(this).prop("tagName").toLowerCase() != "'.$taglistValue[2].'" ) return 0;'."\n"; 162 echo "\t".'if ( $(this).prop("tagName").toLowerCase() != "'.$taglistValue[2].'" ) return 0;'."\n";
141 echo "\t".'if ( $("#editTextId").html() != "Edit the text" ) return 0;'."\n"; 163 echo "\t".'if ( $("#editTextId").html() != "Edit the text" ) return 0;'."\n";
142 echo "\tremoveTagNewDiv( e, \"".$taglistValue[2]."\", $(this) );\n"; 164 echo "\tremoveTagNewDiv( e, \"".$taglistValue[2]."\", $(this) );\n";
143 echo "});\n"; 165 echo "});\n";
144 } 166 }
145 ?> 167 ?>
168 */
146 169
147 $(document).ready(function(){ 170 $(document).ready(function(){
148 171
149 // --- for sidebar--- 172 // --- for sidebar---
150 //run once 173 //run once
223 246
224 247
225 }); 248 });
226 249
227 $(document).on("mouseup", '#editable-area', function (e) { 250 $(document).on("mouseup", '#editable-area', function (e) {
228
229 $('.questionMarkClass').remove(); 251 $('.questionMarkClass').remove();
230 $('.tagItemDivClass').remove(); 252 $('.tagItemDivClass').remove();
231 253
232 if ( $("#editTextId").html() != "Edit the text" ) return 0; 254 if ( $("#editTextId").html() != "Edit the text" ) return 0;
233 var selection = getSelected(); 255 var selection = getSelected();
242 var newdiv = document.createElement("div"); 264 var newdiv = document.createElement("div");
243 newdiv.id = "tagItemDivId"; 265 newdiv.id = "tagItemDivId";
244 newdiv.setAttribute("class", "tagItemDivClass"); 266 newdiv.setAttribute("class", "tagItemDivClass");
245 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px; z-index:4'; 267 newdiv.style.cssText = 'top:'+e.pageY+'; left:'+e.pageX+'; position:absolute; background-color: white; border:1px solid black; padding: 5px; z-index:4';
246 268
247
248 //console.log(selection.getRangeAt(0).cloneContents()); 269 //console.log(selection.getRangeAt(0).cloneContents());
249 if ( container.innerHTML.indexOf( "br" ) != -1 ) { 270 if ( container.innerHTML.indexOf( "br" ) != -1 ) {
250 var newselect = document.createElement("select"); 271 var newselect = document.createElement("select");
251 newselect.id = "TitletagType"; 272 newselect.id = "TitletagType";
252 //console.log(JSON.parse('<?php echo json_encode($taglistArray) ?>')); 273 //console.log(JSON.parse('<?php echo json_encode($taglistArray) ?>'));
339 //$('#tagItemDivId').addClass(); // tagItemDivId is newdiv's id 360 //$('#tagItemDivId').addClass(); // tagItemDivId is newdiv's id
340 $('body').append(newdiv); 361 $('body').append(newdiv);
341 362
342 $('#TitletagType').val(lastAddTag); 363 $('#TitletagType').val(lastAddTag);
343 364
344 } 365 // selected some words, so hide popping up remove-tag-window
366 pop_remove_tag_window = false; // questionMarkID
367
368 } else {
369 // without selecting any word, so pop up remove-tag-window
370 pop_remove_tag_window = true;
371 }
372
373
345 374
346 //e.stopPropagation(); 375 //e.stopPropagation();
347 376
348 377
349 378