Changeset 32832

Show
Ignore:
Timestamp:
01.03.2019 18:23:58 (8 months ago)
Author:
ak19
Message:

Zeddy map work. 1. Now supports saving when map editor is selected and key s is pressed.. The saved shapes are now reloaded on page (re)load. 2. If you make a change and didn't save it and try to leave the page, there's now a default warning (can't yet control the warning message, but it's helpful enough at this stage). 3. Some more fixes. 4. Some cleaning up of unused code. 5. Still some debugging statements left in, check for console.log() for instance. 6. Gone back to using javascript instead of jQuery for keyboard shortcuts so it will work for PDF docs too, but kept some additional changes made earlier so that things still work on Firefox besides Chrome.

Location:
main/trunk/greenstone3/web/interfaces/default
Files:
7 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/documentedit_scripts.js

    r32802 r32832  
    3636var multiValuedMetadata = new Array(); // eg ["xx.Person", "xx.Location"]; 
    3737var mvm_delimiter = ";"; 
    38 var mapsIdsArray = []; //An array for the IDs of all the maps created 
    3938 
    4039/************************ 
     
    163162        }); 
    164163    newLink.click(function () { 
    165         console.log("Show/Hide Map Editor"); 
    166  
    167         // Only if this 'id' element hasn't been initialied, then do the following 2 lines 
    168         if (mapEditor.map !== null) { 
    169             console.log(mapEditor.map.mapId); 
    170             console.log(mapsIdsArray.includes(id)); 
    171         } 
    172  
     164        //console.log(" Show/Hide Map Editor "); 
    173165        var clicked_mapEditor = gsmap_store["map-" + id]; 
    174166         
    175167        if (clicked_mapEditor.map == null) { 
    176             console.log("Initializing map for id: " + id); 
    177  
    178168            clicked_mapEditor.initMapEditorControls(); 
    179169            clicked_mapEditor.initMapEditor(); 
    180             //mapsIdsArray.push(clicked_mapEditor.map.mapId); 
    181         } /* 
    182         else if (mapsIdsArray.includes(id) == false) { 
    183             //mapEditor.initMapEditorControls(); 
    184             //mapEditor.initMapEditor(); 
    185             mapsIdsArray.push(mapEditor.map.mapId) 
    186         } 
    187 */ 
     170        } 
    188171        if (mapGPScontainer.css("display") == "none") { 
    189  
    190172            linkLabel.html(gs.text.de.hide_map_gps); 
    191173            linkIcon.attr("class", "ui-icon ui-icon-folder-open"); 
    192174            mapGPScontainer.css("display", "block"); 
    193  
    194175        } else { 
    195176            linkLabel.html(gs.text.de.edit_map_gps); 
    196  
    197177            linkIcon.attr("class", "ui-icon ui-icon-folder-collapsed"); 
    198178            mapGPScontainer.css("display", "none"); 
     
    396376    } 
    397377 
    398     /*var changes = null; 
    399     //var changes = de.Changes.getChangedEditableSections(); 
    400     for(var i = 0; i < changes.length; i++) { 
    401  
    402     var changedElem = changes[i]; 
    403  
    404     //Get metadata name 
    405     var row = changedElem.parentNode; 
    406     var cells = row.getElementsByTagName("TD"); 
    407     var nameCell = cells[0]; 
    408     var name = nameCell.innerHTML; 
    409     var value = changedElem.innerHTML; 
    410     value = value.replace(/&nbsp;/g, " "); 
    411  
    412     var orig = changedElem.originalValue; 
    413     if (orig) { 
    414     orig = orig.replace(/&nbsp;/g, " "); 
    415     } 
    416     metadataChanges.push({collection:collection, docID:docID, name:name, value:value, orig:orig}); 
    417     changedElem.originalValue = changedElem.innerHTML; 
    418  
    419     } 
    420      */ 
    421378    if (metadataChanges.length == 0) { 
    422379        console.log(gs.text.de.no_changes); 
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts-editor-history.js

    r32799 r32832  
    1010MapEditorHistory.prototype.undo = function () { 
    1111     
    12     for (var i = 0; i < this.mapEditor.overlays.length; i++) { 
    13         this.mapEditor.overlays[i].setMap(null); 
    14     } 
     12     
    1513    if (this.prevOverlays.length != 0) { 
     14        for (var i = 0; i < this.mapEditor.overlays.length; i++) { 
     15            this.mapEditor.overlays[i].setMap(null); 
     16        } 
     17         
    1618        this.mapEditor.selectedShapes = []; 
    1719        this.mapEditor.overlays = []; 
     
    3436 
    3537    if (this.undoneOverlays.length != 0) { 
    36         var draggableCB = document.querySelector("input[name=draggableCB]").checked = false; 
    37         this.mapEditor.selectedShapes = []; 
    38         for (var i = 0; i < this.mapEditor.overlays.length; i++) { 
    39             this.mapEditor.overlays[i].setMap(null); 
    40         } 
    41  
    42         this.mapEditor.overlays = []; 
    43         var lastEntry = this.undoneOverlays[this.undoneOverlays.length - 1]; 
    44         for (var i = 0; i < lastEntry.length; i++) { 
    45             this.mapEditor.overlays[i] = lastEntry[i]; 
    46             this.mapEditor.overlays[i].setMap(this.mapEditor.map); 
    47             this.mapEditor.overlays[i].draggable = true; 
    48         } 
    49  
    50         var conditionPrevious = this.presentOverlays[0]; 
    51         if (conditionPrevious !== undefined) { 
    52             if (conditionPrevious.length == 0) { 
    53                 this.prevOverlays.push(this.presentOverlays[0]); 
    54             } else { 
    55                 var overlays_copy = []; 
    56                 for (var i = 0; i < this.presentOverlays[0].length; i++) { 
    57                     var clone_shape = ShapesUtil.cloneShape(this.presentOverlays[0][i]); 
    58                     if (ShapesUtil.overlayItemIsShape(clone_shape)) { 
    59                         this.mapEditor.addShapeListeners(clone_shape, null); 
    60                     } else { 
    61                         this.mapEditor.addMarkerListeners(clone_shape, null); 
     38        if (this.undoneOverlays[this.undoneOverlays.length -1].length != 0) { 
     39            var draggableCB = document.querySelector("input[name=draggableCB]").checked = false; 
     40            this.mapEditor.selectedShapes = []; 
     41            for (var i = 0; i < this.mapEditor.overlays.length; i++) { 
     42                this.mapEditor.overlays[i].setMap(null); 
     43            } 
     44 
     45            this.mapEditor.overlays = []; 
     46            var lastEntry = this.undoneOverlays[this.undoneOverlays.length - 1]; 
     47            for (var i = 0; i < lastEntry.length; i++) { 
     48                this.mapEditor.overlays[i] = lastEntry[i]; 
     49                this.mapEditor.overlays[i].setMap(this.mapEditor.map); 
     50                this.mapEditor.overlays[i].draggable = true; 
     51            } 
     52 
     53            var conditionPrevious = this.presentOverlays[0]; 
     54            if (conditionPrevious !== undefined) { 
     55                if (conditionPrevious.length == 0) { 
     56                    this.prevOverlays.push(this.presentOverlays[0]); 
     57                } else { 
     58                    var overlays_copy = []; 
     59                    for (var i = 0; i < this.presentOverlays[0].length; i++) { 
     60                        var clone_shape = ShapesUtil.cloneShape(this.presentOverlays[0][i]); 
     61                        if (ShapesUtil.overlayItemIsShape(clone_shape)) { 
     62                            this.mapEditor.addShapeListeners(clone_shape, null); 
     63                        } else { 
     64                            this.mapEditor.addMarkerListeners(clone_shape, null); 
     65                        } 
     66                        overlays_copy[i] = clone_shape; 
    6267                    } 
    63                     overlays_copy[i] = clone_shape; 
     68                    this.prevOverlays.push(overlays_copy); 
    6469                } 
    65                 this.prevOverlays.push(overlays_copy); 
    66             } 
    67         } 
    68         this.presentOverlays = []; 
    69         this.presentOverlays.push(this.undoneOverlays[this.undoneOverlays.length - 1]); 
    70         this.undoneOverlays.pop(); 
     70            } 
     71            this.presentOverlays = []; 
     72            this.presentOverlays.push(this.undoneOverlays[this.undoneOverlays.length - 1]); 
     73            this.undoneOverlays.pop(); 
     74        } 
    7175    } 
    7276} 
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts-editor.js

    r32804 r32832  
    44    this.id = id; 
    55    this.shiftKeyPressed = false; 
     6    this.ctrlKeyPressed = false; 
    67    this.beingDragged = false; 
    78    this.allowDeselect = true; 
     
    1718    this.drawingManager; 
    1819    this.selectedShape; 
     20    this.savedOverlays = null; 
    1921    this.map = null; 
    2022    this.counter = 0; 
     
    8688    document.getElementById("thicknessRange" + "-" + this.id).addEventListener("mouseup", function () { that.shapeSpecsChangeMU() }); 
    8789    document.getElementById("colourOpacity" + "-" + this.id).addEventListener("mouseup", function() { that.shapeSpecsChangeMU() } ); 
    88     document.onmousemove = function (ev) { 
    89         //How can I know the state of mouse from here 
    90         if (that.mouseState == 'down') { 
    91             //console.log('mouse down state') 
    92         } 
    93         if (that.mouseState == 'up') { 
    94             //console.log('mouse up state') 
    95         } 
    96     } 
     90//  document.onmousemove = function (ev) { 
     91//      //How can I know the state of mouse from here 
     92//      if (that.mouseState == 'down') { 
     93//          //console.log('mouse down state') 
     94//      } 
     95//      if (that.mouseState == 'up') { 
     96//          //console.log('mouse up state') 
     97//      } 
     98//  } 
    9799 
    98100    document.onmousedown = function (ev) { 
     
    108110    } 
    109111     
    110     /* TODO: WORK IN PROGRESS 
     112     
     113    //prompts the user to save the changes before reloading/leaving the page 
    111114    window.onbeforeunload = function (e) { 
    112         var collection = gs.cgiParams.c; 
    113         var site_name = gs.xsltParams.site_name; 
    114         var documentID = this.id; 
    115         var metadataName = "MapOverlays"; 
     115        var currentOverlays = JSON.stringify(ShapesUtil.overlayToJSON(that.overlays)); 
     116        var enableMessage = currentOverlays !== that.savedOverlays; 
     117        var message = "Changes are not saved. Are you sure you want to leave?"; 
     118         
     119        console.log(currentOverlays); 
     120        console.log(that.savedOverlays); 
     121        console.log(enableMessage); 
    116122         
    117123         
    118         //functions.getArchivesMetadata = function(collection, site, documentID, metadataName, metadataPosition, responseFunction); 
    119          
    120          
    121         //responseFunction = console.log() 
    122          
    123         var savedOverlays = null; 
    124         var enableMessage = that.overlays == savedOverlays; 
    125         var enableMessage = true; 
    126         var message = "Your confirmation message goes here.", 
    127124        e = e || window.event; 
    128125        // For IE and Firefox 
    129126        if (e) { 
     127             
    130128            if(enableMessage){ 
    131                 e.returnValue = message; 
    132                 // For Safari 
    133                 return message;          
    134             } 
    135         } 
    136     }*/ 
    137      
     129                if(currentOverlays !== "[]") { 
     130                    alert(message); 
     131                    e.returnValue = message; 
     132                     
     133                    // For Safari 
     134                    return message;  
     135                } 
     136            }                
     137        } 
     138    } 
    138139} 
    139140 
     
    256257    // Add a style-selector control to the map. 
    257258    var styleControl = document.getElementById('style-selector-control' + "-" + this.id); 
    258     this.map.controls[google.maps.ControlPosition.TOP_LEFT].push(styleControl); 
     259    this.map.controls[google.maps.ControlPosition.TOP_RIGHT].push(styleControl); 
    259260 
    260261    // Set the map's style to the initial value of the selector. 
     
    316317            that.addMarkerListeners(newShape, e); 
    317318            that.setSelection(newShape, e); 
    318         } 
    319          
     319        }    
    320320    }); 
    321321 
     
    341341 
    342342    //Keyboard shortcuts             
    343     var mapAndControls = $("#map-and-controls-" + this.id); 
    344  
    345         // Shifted to using jQuery so that key mappings don't just work on Chrome but on Firefox too (and hopefully Edge, Safari, etc) 
    346     mapAndControls.keypress(function (event) {  //mapAndControls.keydown(function (event) {  
    347         // https://stackoverflow.com/questions/2220196/how-to-decode-character-pressed-from-jquerys-keydowns-event-handler 
    348         //var keyCode = String.fromCharCode(event.keyCode); // for keyDown 
     343    var mapAndControls = document.getElementById("map-and-controls-" + this.id);  
     344    console.log(mapAndControls); 
     345     
     346    //Sets shift as unpressed 
     347    mapAndControls.addEventListener('keyup', function (event) {      
     348        if (event.keyCode == '16') { 
     349            that.shiftKeyPressed = false; 
     350        } 
     351    }); 
     352     
     353    mapAndControls.addEventListener('keydown', function (event) {  
     354 
     355        // https://stackoverflow.com/questions/2220196/how-to-decode-character-pressed-from-jquerys-keydowns-event-handler   
    349356        var keyCode = String.fromCharCode(event.which); 
    350         //alert("Key pressed: " + keyCode); 
     357//      console.log("Key pressed: " + keyCode); 
    351358         
    352         if (event.keyCode == 'shiftKey') { 
     359        //Sets shift as pressed 
     360        if (event.keyCode == '16') { 
    353361            that.shiftKeyPressed = true; 
    354362        } 
    355         else if (keyCode == 'y' && (event.ctrlKey || event.metaKey) || 
    356             (keyCode == 'z' && keyCode == 'shiftKey' && (event.ctrlKey || event.metaKey))) { 
     363        else if (keyCode == 'Y' && (event.ctrlKey || event.metaKey)) { 
    357364            that.mapEditorHistory.redo(); 
    358365        } 
    359         else if (keyCode == 'z' && (event.ctrlKey || event.metaKey)) { 
     366        else if (keyCode == 'Z' && (event.ctrlKey || event.metaKey) ) { 
    360367            if (that.shiftKeyPressed == false) { 
    361                 that.mapEditorHistory.undo(); 
    362             } 
    363         } 
    364         else if (keyCode == 'a' && (event.ctrlKey || event.metaKey)) { 
     368            that.mapEditorHistory.undo(); 
     369            }    
     370        } 
     371         
     372        else if (keyCode == 'A' && (event.ctrlKey || event.metaKey)) { 
    365373            event.preventDefault(); 
    366374            that.drawingManager.setDrawingMode(null); 
    367             that.selectAll(); 
    368  
    369         } 
    370         else if (keyCode == 'd' && (event.ctrlKey || event.metaKey)) { 
     375            that.selectAll();        
     376        } 
     377        else if (keyCode == 'D' && (event.ctrlKey || event.metaKey)) { 
    371378            event.preventDefault(); 
    372379            that.deselectAll(); 
    373380        } 
    374         else if (keyCode == '0' || keyCode == '`') { 
     381        else if (keyCode == '0' || keyCode == 'À' || keyCode == 'G') { 
    375382 
    376383            that.drawingManager.setDrawingMode(null); 
     
    385392        } else if (keyCode == '5') { 
    386393            that.drawingManager.setDrawingMode('rectangle'); 
    387         } else if (keyCode == 's') { 
    388             that.saveToArchives();           
    389         } else if (keyCode == 'q') {             
     394        } else if (keyCode == 'S') { 
     395            that.saveToArchives();   
     396        } else if (keyCode == 'Q') {             
    390397            that.printHistory(); 
    391398        } 
    392         //                          console.log(keyCode); 
    393     }); 
    394  
    395     /* 
    396     var mapHtml = document.getElementById("map-" + this.id); 
    397     var controlHtml = document.getElementById("ControlPanel-" + this.id); 
    398     controlHtml.addEventListener('click', function () { 
    399         console.log("*** ControlPanel clicked"); 
    400         mapHtml.focus()  
    401     }); 
    402     */ 
    403      
    404     //Sets shift as pressed 
    405     mapAndControls.keydown(function (event) { 
    406         if (event.keyCode == 'shiftKey') { 
    407             that.shiftKeyPressed = true; 
    408  
    409         } 
    410  
    411     }); 
    412  
    413     //Sets shift as unpressed 
    414     mapAndControls.keyup(function (event) {      
    415         if (event.keyCode == 'shiftKey') { 
    416             that.shiftKeyPressed = false; 
    417         } 
    418  
    419     }); 
     399//                                  console.log(keyCode); 
     400    }); 
     401 
    420402 
    421403    this.buildColorPalette(); 
     
    434416             
    435417            // called when data has been retrieved from archives 
    436             var JSONString = responseText.getValue();            
    437             that.LOAD(JSONString); 
    438             //var json_overlays = ShapesUtil.overlayToJSON(this.overlays);   
     418            var JSONString = responseText.getValue(); 
     419            if(JSONString !== "") 
     420            { 
     421                that.LOAD(JSONString); 
     422                that.savedOverlays = JSONString; 
     423            } 
    439424        } 
    440425    ); // TODO: responseFunction in setMeta call 
    441      
    442      
    443426} 
    444427 
     
    468451    //cLICK EVENT IF A MARKER IS CREATED 
    469452    google.maps.event.addListener(newShape, 'click', function (e) { 
    470         that.setSelection(newShape, e); 
     453        if(that.shiftKeyPressed){ 
     454             
     455        } else { 
     456            that.mapEditorHistory.historyOverlayPush(); 
     457            newShape.setMap(null); 
     458            that.mapEditorHistory.presentOverlayPush();          
     459        } 
     460 
    471461    }); 
    472462 
     
    539529MapEditor.prototype.clearSelection = function () { 
    540530    if (this.selectedShape) { 
    541         if (this.selectedShape.type !== 'marker') { 
    542             this.selectedShape.setEditable(false); 
    543             if (this.shiftKeyPressed == false) { 
    544                 for (var i = 0; i < this.selectedShapes.length; i++) { 
    545                     this.selectedShapes[i].setEditable(false); 
     531        if (this.shiftKeyPressed == false) { 
     532            for (var i = 0; i < this.selectedShapes.length; i++) { 
     533                if(this.selectedShapes[i].type !== 'marker') { 
     534                    this.selectedShapes[i].setEditable(false);                       
    546535                } 
    547                 this.selectedShapes = []; 
    548             } 
     536            } 
     537            this.selectedShapes = []; 
    549538        } 
    550539        this.selectedShape = null; 
     
    589578 
    590579    } else if (shape.type == 'marker') { 
    591         this.clearSelection(); 
     580        this.allowDeselect = false; 
     581        this.selectedShapes.push(shape); 
    592582    } 
    593583    this.selectedShape = shape; 
     
    666656MapEditor.prototype.deselectAll = function () { 
    667657    for (var i = 0; i < this.selectedShapes.length; i++) { 
    668         this.selectedShapes[i].setEditable(false); 
     658        if (this.selectedShapes[i].type !== google.maps.drawing.OverlayType.MARKER) { 
     659            this.selectedShapes[i].setEditable(false); 
     660        } 
     661         
    669662    } 
    670663    this.selectedShapes = []; 
     
    673666 
    674667MapEditor.prototype.saveToArchives = function () { 
    675     alert("Save pressed"); 
     668    var that = this; 
     669    console.log("Save pressed"); 
    676670     
    677671    var json_overlays = ShapesUtil.overlayToJSON(this.overlays); 
     
    683677    // collection, site, documentID, metadataName, metadataPosition, metadataValue, prevMetadataValue, metamode, responseFunction    
    684678    gs.functions.setArchivesMetadata(collection, site_name, nodeID, metaname, 0, JSON.stringify(json_overlays), null, "override", function(){ 
    685             alert("SAVED"); 
     679            console.log("SAVED"); 
    686680        } 
    687681    ); 
     682     
     683    gs.functions.getArchivesMetadata(collection, site_name, nodeID, metaname, 0, function(responseText){ 
     684            var JSONString = responseText.getValue(); 
     685            that.savedOverlays = JSONString; 
     686        } 
     687    );   
     688     
    688689} 
    689690 
     
    693694    console.log("present ", this.mapEditorHistory.presentOverlays); 
    694695    console.log("undone ", this.mapEditorHistory.undoneOverlays); 
    695     //console.log(this.selectedShapes); 
    696     var collection = gs.cgiParams.c; 
    697     console.log(collection); 
    698     console.log(this.overlays); 
    699     var json_overlays = ShapesUtil.overlayToJSON(this.overlays); 
    700      
    701     console.log("JSON overlay:\n" + JSON.stringify(json_overlays)); 
    702      
    703     /* 
    704     this.LOAD('[{"strokeColor":"#32CD32","strokeWeight":1,"fillColor":"#32CD32","fillOpacity":0.4,"bounds":{"north":-37.78190971734986,"south":-37.787200748043546,"east":175.33850727431195,"west":175.3324991261186},"type":"rectangle"},{"strokeColor":"#FF8C00","strokeWeight":1,"fillColor":"#FF8C00","fillOpacity":0.4,"bounds":{"north":-37.78550494611987,"south":-37.791270513892385,"east":175.33764896742719,"west":175.3284650837602},"type":"rectangle"},{"strokeColor":"#000000","strokeWeight":1,"fillColor":"#000000","fillOpacity":0.4,"bounds":{"north":-37.793034009483115,"south":-37.79723909833998,"east":175.3225427662553,"west":175.31498966566937},"type":"rectangle"},{"strokeColor":"#4B0082","strokeWeight":5,"fillColor":"#4B0082","fillOpacity":0.62,"bounds":{"north":-37.78991395018121,"south":-37.79737474238258,"east":175.30846653334515,"west":175.2955060993852},"type":"rectangle"},{"strokeColor":"#000000","strokeWeight":1,"fillColor":"#000000","fillOpacity":0.4,"bounds":{"north":-37.79961283312584,"south":-37.80700483276894,"east":175.3281217610063,"west":175.31241474501508},"type":"rectangle"},{"geodesic":false,"strokeColor":"#FF8C00","strokeWeight":1,"path":[{"lat":-37.77824647420985,"lng":175.31842289320844},{"lat":-37.792627052698045,"lng":175.32425938002484},{"lat":-37.79079571942646,"lng":175.31061230055707},{"lat":-37.78597977458094,"lng":175.2910429035844},{"lat":-37.78055298179892,"lng":175.29413280836957},{"lat":-37.77912838266847,"lng":175.3034883534135},{"lat":-37.77668614885508,"lng":175.30537662856},{"lat":-37.78218106147165,"lng":175.3079515492143}],"type":"polygon","fillColor":"#FF8C00","fillOpacity":0.4},{"strokeColor":"#FF8C00","strokeWeight":1,"fillColor":"#FF8C00","fillOpacity":0.4,"center":{"lat":-37.7737689305036,"lng":175.33549693998134},"radius":811.9768269278177,"type":"circle"},{"position":{"lat":-37.77431167751719,"lng":175.3143825906161},"type":"marker"},{"position":{"lat":-37.782452404597294,"lng":175.3337803262118},"type":"marker"},{"geodesic":false,"strokeColor":"#4B0082","strokeOpacity":1,"strokeWeight":5,"path":[{"lat":-37.759203725669785,"lng":175.33033457820488},{"lat":-37.771688357854,"lng":175.35162058894707},{"lat":-37.79339574144619,"lng":175.3646668535955},{"lat":-37.81536797134891,"lng":175.35436717097832},{"lat":-37.819978597019684,"lng":175.32861796443535},{"lat":-37.81970739171663,"lng":175.2929123980291},{"lat":-37.806688365360884,"lng":175.26235667293145},{"lat":-37.795294834173575,"lng":175.25789347713066},{"lat":-37.78389954558992,"lng":175.2541169268377},{"lat":-37.77033143470697,"lng":175.26132670466973},{"lat":-37.760018005052494,"lng":175.27746287410332},{"lat":-37.75757514001425,"lng":175.31076518123223},{"lat":-37.759203725669785,"lng":175.33033457820488}],"type":"polyline"}]'); 
    705     */ 
    706       
     696    console.log(this.selectedShapes); 
     697     
     698    //var collection = gs.cgiParams.c; 
     699    //console.log(collection); 
     700    //console.log(this.overlays); 
     701    //var json_overlays = ShapesUtil.overlayToJSON(this.overlays); 
     702     
     703 
    707704} 
    708705 
     
    712709     
    713710    var map_editor = Object.values(gsmap_store)[0]; 
     711     
    714712    var new_overlays = ShapesUtil.JSONToOverlays(json_str); 
    715713    for (var i=0; i<map_editor.overlays.length; i++) { 
     
    725723    this.mapEditorHistory.presentOverlayPush(); 
    726724     
     725     
     726    //When the overlays are loaded from the metadate, they cannot be selected when clicked on them.  
     727    //One fix for this issue is to delete all the sapes present then bring them back by 'undo', then they can be normally selected 
     728    this.deleteAllShapes(); 
     729    this.mapEditorHistory.undo(); 
     730    this.mapEditorHistory.prevOverlays = [];         
    727731} 
    728732 
    729733MapEditor.prototype.deleteSelectedShapes = function () { 
    730     //console.log("this fires"); 
    731     this.mapEditorHistory.historyOverlayPush(); 
    732     for (var i = 0; i < this.selectedShapes.length; i++) { 
    733         this.selectedShapes[i].setMap(null); 
    734  
    735         if (this.overlays.includes(this.selectedShapes[i])) { 
    736             const index = this.overlays.indexOf(this.selectedShapes[i]); 
    737             this.overlays.splice(index, 1); 
    738             this.selectedShapes[i].setEditable(false); 
    739         } 
    740     } 
    741     this.selectedShapes = []; 
    742     //console.log("this fires"); 
    743     this.mapEditorHistory.presentOverlayPush(); 
     734    if(this.selectedShapes.length !== 0) { 
     735        this.mapEditorHistory.historyOverlayPush(); 
     736        for (var i = 0; i < this.selectedShapes.length; i++) { 
     737            this.selectedShapes[i].setMap(null); 
     738 
     739            if (this.overlays.includes(this.selectedShapes[i])) { 
     740                const index = this.overlays.indexOf(this.selectedShapes[i]); 
     741                this.overlays.splice(index, 1); 
     742//              this.selectedShapes[i].setEditable(false); 
     743            } 
     744        } 
     745        this.selectedShapes = []; 
     746        this.mapEditorHistory.presentOverlayPush();      
     747    } 
    744748} 
    745749 
     
    757761 
    758762MapEditor.prototype.deleteAllShapes = function () { 
    759     //console.log("deleteAllShape() this.id = " + this.id); 
    760     this.mapEditorHistory.historyOverlayPush(); 
    761     for (var i = 0; i < this.overlays.length; i++) { 
    762         this.overlays[i].setMap(null); 
    763     } 
    764     this.overlays = []; 
    765     this.mapEditorHistory.presentOverlayPush(); 
    766 } 
    767  
     763    if(this.overlays.length !== 0) { 
     764        //console.log("deleteAllShape() this.id = " + this.id); 
     765        this.mapEditorHistory.historyOverlayPush(); 
     766        for (var i = 0; i < this.overlays.length; i++) { 
     767            this.overlays[i].setMap(null); 
     768        } 
     769        this.overlays = []; 
     770        this.mapEditorHistory.presentOverlayPush(); 
     771    } 
     772} 
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts-shapes-util.js

    r32800 r32832  
    5757    var strokeWeight  = poly.strokeWeight; 
    5858 
    59     //var path = poly.getPath(); 
    6059    clone_path = ShapesUtil.mvcClonePath(path);  
    6160     
     
    7473            type: type 
    7574        }); 
    76  
    77         //clone_polyline.type = google.maps.drawing.OverlayType.POLYLINE; 
    7875    } 
    7976    else { 
     
    9491            type: type 
    9592        }); 
    96         //clone_polygon.type = google.maps.drawing.OverlayType.POLYGON; 
    9793    } 
    9894     
     
    200196            type: type 
    201197        }); 
    202  
    203     //clone_rect.type = google.maps.drawing.OverlayType.RECTANGLE; 
    204  
    205198    return clone_rect; 
    206199} 
     
    285278            type: type 
    286279        }); 
    287  
    288     //clone_circ.type = google.maps.drawing.OverlayType.CIRCLE; 
    289  
    290280    return clone_circ; 
    291281} 
     
    333323            clickable: true, 
    334324            draggable: true, 
    335             editable: false, 
     325            editable: true, 
    336326            type: google.maps.drawing.OverlayType.MARKER 
    337327        }) 
    338          
    339         //clone_marker.type = google.maps.drawing.OverlayType.MARKER; 
    340  
    341328    return clone_marker; 
    342329} 
     
    471458 
    472459ShapesUtil.JSONToOverlays = function (json_shapes_str) { 
    473      
    474460    var json_shapes = JSON.parse(json_shapes_str); 
    475461     
     
    477463     
    478464    for (var i=0; i<json_shapes.length; i++) { 
    479          
    480465        var json_shape = json_shapes[i]; 
    481466        var shape = ShapesUtil.JSONToShape(json_shape); 
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts.js

    r32801 r32832  
    8282function setUpMap() 
    8383{ 
     84 
     85     
    8486    var myOptions =  
    8587        { 
     
    335337 
    336338function attachClickHandler(marker, nodeID) 
    337 { 
    338  
    339      
     339{    
    340340    google.maps.event.addListener(marker, 'click', function() 
    341341    { 
    342342        document.location.href = gs.xsltParams.library_name + "?a=d&ed=1&c=" + gs.cgiParams.c + "&d=" + nodeID + "&dt=hierarchy&p.a=b&p.sa=&p.s=ClassifierBrowse"; 
     343         
    343344    }); 
    344345     
     
    348349            var lat = marker.getPosition().lat(); 
    349350            var lng = marker.getPosition().lng(); 
    350             var collection = gs.cgiParams.c;; 
     351            var collection = gs.cgiParams.c; 
    351352            var site_name = gs.xsltParams.site_name; 
    352353             
     
    362363            gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Latitude", null, lat, null, "override", function(){callbackFunction();}); 
    363364            gs.functions.setArchivesMetadata(collection, site_name, nodeID, "Longitude", null, lng, null, "override", function(){callbackFunction();}); 
    364              
     365            console.log(nodeID); 
     366            console.log("GPS Click handler in collection:" + collection + " in site: " + site_name + " for Doc: " + nodeID + "(" + lat + "," + lng + ")"); 
    365367        }); 
    366368    } 
     
    408410    // Don't allow dragging if either 1. docEdit not on OR 2. logout is in the cgiParams 
    409411    var draggable_val = (!docEdit || loggedOutVar) ? false : true; 
    410      
    411     console.log(gs.cgiParams); 
    412412     
    413413    var marker 
     
    433433        }); 
    434434    } 
    435  
    436     console.log("doc = " + JSON.stringify(doc)); 
    437435     
    438436    var docElement = gs.jqGet("div" + doc.nodeID); 
     
    465463    //console.log("Latitude " + newLat); 
    466464    //console.log("Longitude " + newLng); 
    467     NewLatLng(newLat, newLng); 
     465    //NewLatLng(newLat, newLng); 
     466     
    468467//  // Define the LatLng coordinates for the polygon's path. 
    469468//        var triangleCoords = [ 
  • main/trunk/greenstone3/web/interfaces/default/transform/layouts/header.xsl

    r32765 r32832  
    3030  <!-- is editing available for the collection? eg is there an archives folder? --> 
    3131  <xsl:variable name="isEditingAvailable"> 
    32   <xsl:choose><xsl:when test="/page/pageResponse/collection/@no_archives">0</xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose></xsl:variable> 
     32    <xsl:choose><xsl:when test="/page/pageResponse/collection/@no_archives">0</xsl:when><xsl:otherwise>1</xsl:otherwise></xsl:choose> 
     33  </xsl:variable> 
    3334  <!-- is a user logged in, and do they have editing rights for this collection? --> 
    3435  <xsl:variable name="userHasEditPermission"> 
     
    5758    <xsl:variable name="collection"><xsl:call-template name="collectionName"/></xsl:variable> 
    5859    <xsl:variable name="site"><xsl:call-template name="siteName"/></xsl:variable> 
     60      
    5961    <title><xsl:value-of select="$page"/><xsl:if test="$collection != '' and $page != $collection"> :: <xsl:value-of select="$collection"/></xsl:if><xsl:if test="$page != $site"> :: <xsl:value-of select="$site"/></xsl:if></title> 
    6062     
     
    109111    <xsl:if test="/page/pageRequest/userInformation and /page/pageRequest/userInformation/@editEnabled = 'true' and (util:contains(/page/pageRequest/userInformation/@groups, 'administrator') or util:contains(/page/pageRequest/userInformation/@groups, 'all-collections-editor') or util:contains(/page/pageRequest/userInformation/@groups, $thisCollectionEditor))"> 
    110112      <xsl:if test="/page/pageRequest/paramList/param[(@name='docEdit') and (@value='on' or @value='true' or @value='1')]"> 
     113        
     114          
    111115        <script type="text/javascript" src="interfaces/{$interface_name}/js/ckeditor/ckeditor.js" defer="true"><xsl:text> </xsl:text></script>   
    112         <!--            <xsl:call-template name="init-direct-edit"/> --> 
     116        <!--            <xsl:call-template name="init-direct-edit"/>    --> 
    113117         
    114          
    115         <xsl:if test="/page/pageResponse/format[@type='display']/gsf:option[not(@name='mapEnabled')] or (/page/pageResponse/format[@type='display']/gsf:option[@name='mapEnabled']  and /page/pageResponse/format[@type='display']/gsf:option[@name='mapEnabled']/@value = 'false')"> 
     118        <xsl:variable name="mapEnabled"><xsl:value-of select="/page/pageResponse/format[@type='display']/gsf:option[@name='mapEnabled']/@value"/></xsl:variable> 
     119        <xsl:if test="$mapEnabled = 'false' or $mapEnabled = ''"> 
    116120          <xsl:call-template name="map-scripts"/> 
    117121        </xsl:if> 
    118          
     122     
    119123      </xsl:if> 
    120124      <script type="text/javascript" src="interfaces/{$interface_name}/js/debug_scripts.js"><xsl:text> </xsl:text></script> 
  • main/trunk/greenstone3/web/interfaces/default/transform/pages/document.xsl

    r32781 r32832  
    231231                    </xsl:for-each> 
    232232                </table> 
    233                 <div id="map-and-controls-{@nodeID}"> 
     233                <div id="map-and-controls-{@nodeID}" tabindex="-1"> 
    234234                    <div id="map-{@nodeID}" style="height: 300px;"><xsl:text> </xsl:text></div> 
    235235                     
    236236 
    237                     <div id="ControlPanel-{@nodeID}" class="ControlPanel"> 
     237                    <div id="ControlPanel-{@nodeID}" class="ControlPanel" > 
    238238                        <div id="ControlButtons"> 
    239                             <script> 
    240                                //var myMapEditor = MapEditor('{@nodeID}'); 
    241                             </script> 
    242                             <button onclick="deleteAllShape('{@nodeID}')" accesskey="c">Clear All</button> 
    243                             <button onclick="deleteSelectedShape('{@nodeID}')" accesskey="b">Delete Selected</button> 
    244                             <button onclick="undo('{@nodeID}')" accesskey="n">Undo</button> 
    245 <!--                            <button onclick="myMapEditor.getHistory().undo('{@nodeID}')" accesskey="n">Undo</button> --> 
    246                             <button onclick="redo('{@nodeID}')" accesskey="n">Redo</button> 
     239     
     240                            <button onclick="gsmap_store['map-{@nodeID}'].deleteAllShapes()" >Clear All</button> 
     241                            <button onclick="gsmap_store['map-{@nodeID}'].deleteSelectedShapes()" >Delete Selected</button> 
     242                            <button onclick="gsmap_store['map-{@nodeID}'].mapEditorHistory.undo()" >Undo</button> 
     243                            <button onclick="gsmap_store['map-{@nodeID}'].mapEditorHistory.redo()" >Redo</button> 
    247244                            <input type="checkbox" name="draggableCB" id="draggableCB-{@nodeID}" value="false" /> Lock all shapes location <br/> 
    248245                        </div> 
     
    265262                        </div> 
    266263                    </div> 
    267                 - 
    268264                    <div id="style-selector-control-{@nodeID}"  class="map-control"> 
    269265                      <select id="style-selector-{@nodeID}" class="selector-control"> 
     
    326322            <script type="text/javascript" src="interfaces/{$interface_name}/js/documentedit_scripts.js"><xsl:text> </xsl:text></script> 
    327323            <script type="text/javascript" src="interfaces/{$interface_name}/js/documentedit_scripts_util.js"><xsl:text> </xsl:text></script> 
     324            <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-shapes-util.js"><xsl:text> </xsl:text></script> 
    328325            <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-history.js"><xsl:text> </xsl:text></script> 
    329326            <script type="text/javascript" src="interfaces/{$interface_name}/js/map-scripts-editor-themes.js"><xsl:text> </xsl:text></script>