Ignore:
Timestamp:
2019-02-12T12:44:28+13:00 (5 years ago)
Author:
ak19
Message:

Map editor history changed into an object prototype (class).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone3/web/interfaces/default/js/map-scripts-editor.js

    r32766 r32769  
    176176            if (resizable) {
    177177                if(dontResize == false){
    178                     historyOverlayPush();
     178                    mapEditorHistory.historyOverlayPush();
    179179                }
    180180               
     
    187187
    188188    if (selectedShapes.length > 0) {
    189         historyOverlayPush();
     189        mapEditorHistory.historyOverlayPush();
    190190    }
    191191}
     
    193193function shapeSpecsChangeMU() {
    194194    if (selectedShapes.length > 0) {
    195         presentOverlayPush();
     195        mapEditorHistory.presentOverlayPush ();
    196196    }
    197197}
     
    309309    google.maps.event.addListener(drawingManager, 'overlaycomplete', function (e) {
    310310        allowDeselect = true;
    311         historyOverlayPush();
     311        mapEditorHistory.historyOverlayPush();
    312312        overlays.push(e.overlay); // store reference to added overlay
    313313        var newShape = e.overlay;
    314314        newShape.type = e.type;
    315         presentOverlayPush();
     315        mapEditorHistory.presentOverlayPush();
    316316
    317317        if (e.type !== google.maps.drawing.OverlayType.MARKER) {
     
    348348    document.addEventListener('keydown', function () {
    349349        if (event.code == 'KeyY' && (event.ctrlKey || event.metaKey) || (event.code == 'KeyZ' && event.code == 'ShiftLeft' && (event.ctrlKey || event.metaKey))) {
    350             redo();
     350            mapEditorHistory.redo();
    351351        }
    352352        if (event.code == 'KeyZ' && (event.ctrlKey || event.metaKey)) {
    353353            if (shiftKeyPressed == false) {
    354                 undo();
    355                 mapEditorHistory.undo(overlays); // ***** when we only have MapEditorHistory as a class
     354                //undo();
     355                mapEditorHistory.undo();
     356                //mapEditorHistory.undo(overlays, draggableState); // ***** when we only have MapEditorHistory as a class
    356357                //that.mapEditorHistory.undo(that.overlays); // ***** when we have both MapEditorHistory and MapEditor as classes
    357358               
     
    436437    google.maps.event.addListener(newShape, 'dragstart', function (e) {
    437438        beingDragged = true;
    438         historyOverlayPush();
     439        mapEditorHistory.historyOverlayPush();
    439440
    440441    });
     
    442443    google.maps.event.addListener(newShape, 'dragend', function () {
    443444        beingDragged = false;
    444         presentOverlayPush();
     445        mapEditorHistory.presentOverlayPush ();
    445446        allowDeselect = false;
    446447    });
     
    458459    google.maps.event.addListener(newShape, 'dragstart', function (e) {
    459460        allowDeselect = false;
    460         historyOverlayPush();
     461        mapEditorHistory.historyOverlayPush();
    461462    });
    462463
     
    465466    google.maps.event.addListener(newShape, 'dragend', function () {
    466467        beingDragged = false;
    467         presentOverlayPush();
     468        mapEditorHistory.presentOverlayPush ();
    468469        settingThePath();
    469470       
     
    475476    google.maps.event.addListener(newShape, 'bounds_changed', function (e) {
    476477        if (beingDragged == false) {
    477             presentOverlayPush();
     478            mapEditorHistory.presentOverlayPush ();
    478479        }
    479480    });
     
    485486        }
    486487        if (e.vertex !== undefined || e.edge !== undefined) {
    487             historyOverlayPush()
     488            mapEditorHistory.historyOverlayPush()
    488489        }
    489490        if (drawingManager.drawingMode == null) {
     
    494495    google.maps.event.addListener(newShape, 'mouseup', function (e) {
    495496        if (e.vertex !== undefined || e.edge !== undefined) {
    496             presentOverlayPush()
     497            mapEditorHistory.presentOverlayPush ()
    497498        } else {
    498499            //setSelection(newShape, e);
     
    572573function setSelectedThickness(sWeight) {
    573574    if (selectedShapes.length > 0) {
    574         //historyOverlayPush();
     575        //mapEditorHistory.historyOverlayPush();
    575576        for (var i = 0; i < selectedShapes.length; i++) {
    576577            selectedShapes[i].set('strokeWeight', sWeight);
     
    636637
    637638function printHistory() {
    638     console.log("prev", prevOverlays);
    639     console.log("present ", presentOverlays);
    640     console.log("undone ", undoneOverlays);
     639    console.log("prev", mapEditorHistory.prevOverlays);
     640    console.log("present ", mapEditorHistory.presentOverlays);
     641    console.log("undone ", mapEditorHistory.undoneOverlays);
    641642    console.log(mouseState);
    642643}
     
    668669function deleteSelectedShape() {
    669670    //console.log("this fires");
    670     historyOverlayPush();
     671    mapEditorHistory.historyOverlayPush();
    671672    for (var i = 0; i < selectedShapes.length; i++) {
    672673        selectedShapes[i].setMap(null);
     
    680681    selectedShapes = [];
    681682    //console.log("this fires");
    682     presentOverlayPush();
     683    mapEditorHistory.presentOverlayPush ();
    683684}
    684685
     
    686687    console.log(nId);
    687688    //console.log("this fires");
    688     historyOverlayPush();
     689    mapEditorHistory.historyOverlayPush();
    689690    for (var i = 0; i < overlays.length; i++) {
    690691        overlays[i].setMap(null);
     
    692693    overlays = [];
    693694    //console.log("this fires");
    694     presentOverlayPush();
    695 }
     695    mapEditorHistory.presentOverlayPush ();
     696}
Note: See TracChangeset for help on using the changeset viewer.