Changeset 32850 for main/trunk/greenstone3
- Timestamp:
- 2019-03-04T16:30:56+13:00 (5 years ago)
- Location:
- main/trunk/greenstone3/web/interfaces/default/js
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts.js
r32840 r32850 81 81 }); 82 82 newLink.click(function () { 83 console.log(metaTable.metaNameField);84 83 if (metaTable.css("display") == "none") { 85 84 linkLabel.html(gs.text.de.hide_metadata); … … 137 136 if(!oldMapData && newMapData !== "[]" || oldMapData && oldMapData !== newMapData) { 138 137 var nodeID = map_editors_array[i].id; 139 console.log("old vs new mapdata for nodeID " + nodeID);140 console.log(oldMapData);141 console.log(newMapData);138 //console.log("old vs new mapdata for nodeID " + nodeID); 139 //console.log("OLD: " + oldMapData); 140 //console.log("NEW: " + newMapData); 142 141 143 142 modifiedMaps.push({ … … 149 148 }); 150 149 150 // Save the new overlay values as the old ones for the state after saving and rebuilding is done. 151 // Ideally this should be do after saveAndRebuild has completed successfully, since if saveAndRebuild goes wrong 152 // we'd not have saved newMapData AND because savedOverlays will contain the newMapData, we won't detect these unsaved 153 // values in future attempts to save. 154 // But for now, we're doing this here *because* this is the procedure with regular metadata (works out changes, 155 // then saves those changes as initStates BEFORE saveAndRebuild is called) 151 156 map_editor.savedOverlays = newMapData; 152 157 } -
main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts_util.js
r32838 r32850 34 34 // else the following pop up always ends up appearing when attempting 35 35 // to leave a doc view page in Doc Editing Mode (when not yet actually Doc Editing) 36 37 36 38 var changes = changesToUpdate(); 39 40 //console.log("#### CHANGES before page reload: ", changes); 37 41 38 42 if(changes.length > 0) { … … 548 552 // collection, site, documentID, metadataName, metadataPosition, metadataValue, prevMetadataValue, metamode, responseFunction 549 553 //console.log("@@@ metapos! change: ", change); 550 gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, change.metapos, change.value /*TODO: encodeDelimiters(change.value)*/, null, "override", function(){callbackFunction();});554 gs.functions.setArchivesMetadata(change.collection, gs.xsltParams.site_name, change.docID, change.name, change.metapos, encodeDelimiters(change.value), null, "override", function(){callbackFunction();}); 551 555 } 552 556 else if(change.orig) -
main/trunk/greenstone3/web/interfaces/default/js/map-scripts-editor-history.js
r32832 r32850 20 20 this.undoneOverlaysPush(); 21 21 var prev_overlay = this.prevOverlays.pop(); 22 var draggableCB = document.querySelector("input[name=draggableCB]").checked = false; 23 24 22 var draggableCB = document.getElementById("draggableCB" + "-" + this.mapEditor.id).checked = false; 23 25 24 if (prev_overlay.length > 0) { 26 25 for (var i = 0; i < prev_overlay.length; i++) { … … 37 36 if (this.undoneOverlays.length != 0) { 38 37 if (this.undoneOverlays[this.undoneOverlays.length -1].length != 0) { 39 var draggableCB = document.querySelector("input[name=draggableCB]").checked = false;40 38 this.mapEditor.selectedShapes = []; 39 var draggableCB = document.getElementById("draggableCB" + "-" + this.mapEditor.id).checked = false; 40 41 41 for (var i = 0; i < this.mapEditor.overlays.length; i++) { 42 42 this.mapEditor.overlays[i].setMap(null); … … 75 75 } 76 76 } 77 78 /*79 MapEditorHistory.prototype.clonePath = function (path) {80 var clone_path = [];81 82 for (var i = 0; i < path.length; i++) {83 var lati = path.getAt(i).lat();84 var lngi = path.getAt(i).lng();85 clone_lat_lng = {86 lat: lati,87 lng: lngi88 };89 clone_path.push(clone_lat_lng);90 }91 92 return clone_path;93 }94 95 MapEditorHistory.prototype.clonePolyline = function (polyline) {96 var geodesic = polyline.geodesic;97 var strokeColor = polyline.strokeColor;98 var strokeOpacity = polyline.strokeOpacity;99 var strokeWeight = polyline.strokeWeight;100 //var clone_path = clonePath(path);101 102 var clone_path = null;103 104 var JSONSave = typeof polyline.getPath !== "function";105 //console.log(JSONSave)106 if(JSONSave){107 var path = polyline.latLngs.j[0].j;108 clone_path = path;109 110 } else{111 var path = polyline.getPath();112 clone_path = this.clonePath(path);113 }114 var clone_polyline = new google.maps.Polyline({115 geodesic: geodesic,116 strokeColor: strokeColor,117 strokeOpacity: strokeOpacity,118 strokeWeight: strokeWeight,119 path: clone_path,120 draggable: true,121 editable: false122 });123 124 clone_polyline.type = google.maps.drawing.OverlayType.POLYLINE;125 126 return clone_polyline;127 }128 129 MapEditorHistory.prototype.clonePolygon = function (polygon) {130 var geodesic = polygon.geodesic;131 var strokeColor = polygon.strokeColor;132 var strokeOpacity = polygon.strokeOpacity;133 var strokeWeight = polygon.strokeWeight;134 var fillColor = polygon.fillColor;135 var fillOpacity = polygon.fillOpacity;136 137 var clone_path = null;138 var JSONSave = typeof polygon.getPath !== "function";139 //console.log(JSONSave)140 if(JSONSave){141 var path = polygon.latLngs.j[0].j;142 clone_path = path;143 144 } else{145 var path = polygon.getPath();146 clone_path = this.clonePath(path);147 console.log(path);148 }149 var clone_polygon = new google.maps.Polygon({150 geodesic: geodesic,151 strokeColor: strokeColor,152 strokeOpacity: strokeOpacity,153 strokeWeight: strokeWeight,154 fillColor: fillColor,155 fillOpacity: fillOpacity,156 path: clone_path,157 draggable: true,158 editable: false159 });160 clone_polygon.type = google.maps.drawing.OverlayType.POLYGON;161 return clone_polygon;162 }163 164 MapEditorHistory.prototype.cloneRectangle = function (rect) {165 var strokeColor = rect.strokeColor;166 var strokeOpacity = rect.strokeOpacity;167 var strokeWeight = rect.strokeWeight;168 var fillColor = rect.fillColor;169 var fillOpacity = rect.fillOpacity;170 //var bounds = rect.getBounds();171 var type = rect.type;172 173 var bounds = null;174 175 var JSONSave = typeof rect.getBounds !== "function";176 177 if(JSONSave){178 var north = rect.bounds.north;179 var south = rect.bounds.south;180 var east = rect.bounds.east;181 var west = rect.bounds.west;182 if (!isNaN(north) && !isNaN(south) && !isNaN(west) && !isNaN(east)) {183 var NE = new google.maps.LatLng(north, east);184 var SW = new google.maps.LatLng(south, west);185 bounds = new google.maps.LatLngBounds(SW, NE);186 }187 } else {188 bounds = rect.getBounds();189 }190 var clone_rect = new google.maps.Rectangle({191 strokeColor: strokeColor,192 strokeOpacity: strokeOpacity,193 strokeWeight: strokeWeight,194 fillColor: fillColor,195 fillOpacity: fillOpacity,196 bounds: bounds,197 draggable: true,198 editable: false,199 type: type200 });201 202 clone_rect.type = google.maps.drawing.OverlayType.RECTANGLE;203 return clone_rect;204 }205 206 MapEditorHistory.prototype.cloneCircle = function (circ) {207 var strokeColor = circ.strokeColor;208 var strokeOpacity = circ.strokeOpacity;209 var strokeWeight = circ.strokeWeight;210 var fillColor = circ.fillColor;211 var fillOpacity = circ.fillOpacity;212 var center = circ.center;213 var radius = circ.radius;214 215 var clone_circ = new google.maps.Circle({216 strokeColor: strokeColor,217 strokeOpacity: strokeOpacity,218 strokeWeight: strokeWeight,219 fillColor: fillColor,220 fillOpacity: fillOpacity,221 center: center,222 radius: radius,223 draggable: true,224 editable: false225 });226 227 clone_circ.type = google.maps.drawing.OverlayType.CIRCLE;228 229 return clone_circ;230 }231 232 MapEditorHistory.prototype.cloneMarker = function (marker) {233 var anchorPoint = marker.anchorPoint;234 var JSONSave = typeof marker.getPosition !== "function";235 if(JSONSave){236 var position = marker.position;237 } else{238 var position = marker.getPosition();239 }240 var clone_marker = new google.maps.Marker({241 anchorPoint: anchorPoint,242 position: position,243 clickable: true,244 draggable: true,245 editable: false246 })247 clone_marker.type = google.maps.drawing.OverlayType.MARKER;248 249 return clone_marker;250 }251 252 MapEditorHistory.prototype.cloneShape = function (shape) {253 if (shape.type === google.maps.drawing.OverlayType.POLYLINE) {254 var clone_polyline = this.clonePolyline(shape);255 return clone_polyline;256 } else if (shape.type === google.maps.drawing.OverlayType.POLYGON) {257 var clone_polygon = this.clonePolygon(shape);258 return clone_polygon;259 } else if (shape.type === google.maps.drawing.OverlayType.RECTANGLE) {260 var clone_rect = this.cloneRectangle(shape);261 return clone_rect;262 263 } else if (shape.type === google.maps.drawing.OverlayType.CIRCLE) {264 var clone_circ = this.cloneCircle(shape);265 return clone_circ;266 267 } else {268 var clone_marker = this.cloneMarker(shape);269 return clone_marker;270 }271 }272 273 MapEditorHistory.prototype.overlayItemIsShape = function (overlay_item) {274 var type = overlay_item.type;275 276 is_shape = (type === google.maps.drawing.OverlayType.POLYLINE)277 || (type === google.maps.drawing.OverlayType.POLYGON)278 || (type === google.maps.drawing.OverlayType.RECTANGLE)279 || (type === google.maps.drawing.OverlayType.CIRCLE);280 281 return is_shape;282 }283 284 */285 77 286 78 MapEditorHistory.prototype.historyOverlayPush = function () { -
main/trunk/greenstone3/web/interfaces/default/js/map-scripts-editor.js
r32840 r32850 25 25 this.resizable = false; 26 26 this.dontResize = false; 27 this.polyOptions = { 27 this.shapeOptions = { 28 suppressUndo: true, 28 29 fillColor: '#CA4A2F', 29 30 strokeWeight: this.thicknessValue, … … 36 37 } 37 38 39 //draggable checkbox control 38 40 MapEditor.prototype.initMapEditorControls = function () { 39 41 var that = this; 40 42 41 42 var draggableCB = document.querySelector("input[name=draggableCB]"); 43 var draggableCB = document.getElementById("draggableCB-"+ this.id); 43 44 draggableCB.addEventListener('change', function () { 44 45 if (this.checked) { 45 46 for (var i = 0; i < that.overlays.length; i++) { 46 console.log("checked");47 47 that.overlays[i].draggable = false; 48 that. polyOptions.draggable = false;48 that.shapeOptions.draggable = false; 49 49 } 50 50 } else { 51 51 for (var i = 0; i < that.overlays.length; i++) { 52 console.log("not checked");53 52 that.overlays[i].draggable = true; 54 that. polyOptions.draggable = true;53 that.shapeOptions.draggable = true; 55 54 } 56 55 } … … 67 66 thicknessSliderOutput.innerHTML = ((this.value / 20) * 100) / 100; 68 67 that.thicknessValue = this.value / 20; 69 that. polyOptions.strokeWeight = that.thicknessValue;68 that.shapeOptions.strokeWeight = that.thicknessValue; 70 69 that.setSelectedThickness(that.thicknessValue); 71 70 … … 80 79 opacitySliderOutput.innerHTML = "% " + Math.round(this.value * 100) / 100; 81 80 that.opacityValue = this.value / 100; 82 that. polyOptions.fillOpacity = that.opacityValue;81 that.shapeOptions.fillOpacity = that.opacityValue; 83 82 that.setSelectedOpacity(that.opacityValue); 84 83 } … … 106 105 var enableMessage = currentOverlays !== that.savedOverlays; 107 106 var message = "Changes are not saved. Are you sure you want to leave?"; 108 109 console.log("@@@ onbeforeunload. currentOverlays: " + currentOverlays); 110 console.log(that.savedOverlays); 111 console.log(enableMessage); 107 112 108 113 109 // Comment out following section in entirety -- from "e = e || window.event" to end of "if(e)" -- if … … 150 146 that.resizable = true; 151 147 that.shapeResize(); 148 152 149 } 153 150 }); … … 277 274 draggable: true 278 275 }, 279 circleOptions: this. polyOptions,280 polylineOptions: this. polyOptions,281 polygonOptions: this. polyOptions,282 rectangleOptions: this. polyOptions,276 circleOptions: this.shapeOptions, 277 polylineOptions: this.shapeOptions, 278 polygonOptions: this.shapeOptions, 279 rectangleOptions: this.shapeOptions, 283 280 }); 284 281 … … 333 330 334 331 //Keyboard shortcuts 335 var mapAndControls = document.getElementById("map-and-controls-" + this.id); 336 console.log("@@@@ initMapEditor. mapAndControls: ", mapAndControls); 332 var mapAndControls = document.getElementById("map-and-controls-" + this.id); 337 333 338 334 //Sets shift as unpressed … … 361 357 } 362 358 } 363 364 359 else if (keyCode == 'A' && (event.ctrlKey || event.metaKey)) { 365 360 event.preventDefault(); … … 371 366 that.deselectAll(); 372 367 } 373 else if (keyCode == '0' || keyCode == 'Ã' || keyCode == 'G') {374 368 else if (keyCode == '0' || keyCode == 'Ã' || (keyCode == 'G'&& (event.ctrlKey || event.metaKey))) { 369 event.preventDefault(); 375 370 that.drawingManager.setDrawingMode(null); 376 371 } else if (keyCode == '1') { … … 384 379 } else if (keyCode == '5') { 385 380 that.drawingManager.setDrawingMode('rectangle'); 386 } else if (keyCode == 'S') { 387 that.saveToArchives(); 388 } else if (keyCode == 'Q') { 381 } 382 //else if (keyCode == 'S') { 383 // that.saveToArchives(); 384 //} 385 else if (keyCode == 'Q') { // for debugging information, press Q (easy to hit key) 389 386 that.printHistory(); 387 } 388 else if (keyCode == '.') { 389 that.deleteSelectedShapes(); 390 390 } 391 391 // console.log(keyCode); … … 471 471 // mouses down on it. 472 472 google.maps.event.addListener(newShape, 'click', function (e) { 473 474 473 that.vertexAndPolyDel(e, newShape); 475 476 474 }); 477 475 … … 689 687 console.log("present ", this.mapEditorHistory.presentOverlays); 690 688 console.log("undone ", this.mapEditorHistory.undoneOverlays); 691 console.log("@@@@ selectedShapes: " + this.selectedShapes); 689 console.log("@@@@ allShapes: ", this.overlays); 690 console.log("@@@@ selectedShapes: ", this.selectedShapes); 692 691 } 693 692 … … 711 710 712 711 for (var i=0; i<map_editor.overlays.length; i++) { 713 map_editor.overlays[i].setMap(map_editor.map); 714 } 715 716 this.mapEditorHistory.presentOverlayPush(); 717 718 719 //When the overlays are loaded from the metadate, they cannot be selected when clicked on them. 720 //One fix for this issue is to delete all the sapes present then bring them back by 'undo', then they can be normally selected 721 this.deleteAllShapes(); 722 this.mapEditorHistory.undo(); 723 this.mapEditorHistory.prevOverlays = []; 712 var shape = map_editor.overlays[i]; 713 if (ShapesUtil.overlayItemIsShape(shape)) { 714 map_editor.addShapeListeners(shape, null); // don't have an overlay event! 715 } else { 716 map_editor.addMarkerListeners(shape, null); // don't have an overlay event! 717 } 718 shape.setMap(map_editor.map); 719 } 720 721 this.mapEditorHistory.presentOverlayPush(); 724 722 } 725 723 -
main/trunk/greenstone3/web/interfaces/default/js/map-scripts-shapes-util.js
r32832 r32850 64 64 65 65 clone_poly = new google.maps.Polyline({ 66 suppressUndo: true, 66 67 geodesic: geodesic, 67 68 strokeColor: strokeColor, … … 80 81 81 82 clone_poly = new google.maps.Polygon({ 83 suppressUndo: true, 82 84 geodesic: geodesic, 83 85 strokeColor: strokeColor, … … 186 188 187 189 var clone_rect = new google.maps.Rectangle({ 188 strokeColor: strokeColor, 189 strokeOpacity: strokeOpacity, 190 strokeWeight: strokeWeight, 191 fillColor: fillColor, 192 fillOpacity: fillOpacity, 193 bounds: bounds, 194 draggable: true, 195 editable: false, 196 type: type 197 }); 190 suppressUndo: true, 191 strokeColor: strokeColor, 192 strokeOpacity: strokeOpacity, 193 strokeWeight: strokeWeight, 194 fillColor: fillColor, 195 fillOpacity: fillOpacity, 196 bounds: bounds, 197 draggable: true, 198 editable: false, 199 type: type 200 }); 198 201 return clone_rect; 199 202 } … … 267 270 268 271 var clone_circ = new google.maps.Circle({ 269 strokeColor: strokeColor, 270 strokeOpacity: strokeOpacity, 271 strokeWeight: strokeWeight, 272 fillColor: fillColor, 273 fillOpacity: fillOpacity, 274 center: center, 275 radius: radius, 276 draggable: true, 277 editable: false, 278 type: type 279 }); 272 suppressUndo: true, 273 strokeColor: strokeColor, 274 strokeOpacity: strokeOpacity, 275 strokeWeight: strokeWeight, 276 fillColor: fillColor, 277 fillOpacity: fillOpacity, 278 center: center, 279 radius: radius, 280 draggable: true, 281 editable: false, 282 type: type 283 }); 280 284 return clone_circ; 281 285 } … … 320 324 321 325 var clone_marker = new google.maps.Marker({ 322 position: position, 323 clickable: true, 324 draggable: true, 325 editable: true, 326 type: google.maps.drawing.OverlayType.MARKER 327 }) 326 suppressUndo: true, 327 position: position, 328 clickable: true, 329 draggable: true, 330 editable: true, 331 type: google.maps.drawing.OverlayType.MARKER 332 }) 328 333 return clone_marker; 329 334 }
Note:
See TracChangeset
for help on using the changeset viewer.