Ignore:
Timestamp:
2019-03-01T18:23:58+13:00 (5 years 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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}
Note: See TracChangeset for help on using the changeset viewer.