[32766] | 1 |
|
---|
[32799] | 2 | function MapEditorHistory(mapEditor) {
|
---|
[32766] | 3 | this.prevOverlays = [];
|
---|
| 4 | this.presentOverlays = [];
|
---|
| 5 | this.undoneOverlays = [];
|
---|
[32799] | 6 | this.cycleCompvare = true;
|
---|
| 7 | this.mapEditor = mapEditor;
|
---|
[32766] | 8 | }
|
---|
| 9 |
|
---|
[32799] | 10 | MapEditorHistory.prototype.undo = function () {
|
---|
| 11 |
|
---|
[32832] | 12 |
|
---|
[32766] | 13 | if (this.prevOverlays.length != 0) {
|
---|
[32832] | 14 | for (var i = 0; i < this.mapEditor.overlays.length; i++) {
|
---|
| 15 | this.mapEditor.overlays[i].setMap(null);
|
---|
| 16 | }
|
---|
| 17 |
|
---|
[32799] | 18 | this.mapEditor.selectedShapes = [];
|
---|
| 19 | this.mapEditor.overlays = [];
|
---|
[32766] | 20 | this.undoneOverlaysPush();
|
---|
[32799] | 21 | var prev_overlay = this.prevOverlays.pop();
|
---|
[32850] | 22 | var draggableCB = document.getElementById("draggableCB" + "-" + this.mapEditor.id).checked = false;
|
---|
| 23 |
|
---|
[32766] | 24 | if (prev_overlay.length > 0) {
|
---|
| 25 | for (var i = 0; i < prev_overlay.length; i++) {
|
---|
[32799] | 26 | this.mapEditor.overlays[i] = prev_overlay[i];
|
---|
| 27 | this.mapEditor.overlays[i].setMap(this.mapEditor.map);
|
---|
| 28 | this.mapEditor.overlays[i].draggable = true;
|
---|
[32766] | 29 | }
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
| 32 | };
|
---|
| 33 |
|
---|
[32799] | 34 | MapEditorHistory.prototype.redo = function () {
|
---|
[32766] | 35 |
|
---|
[32769] | 36 | if (this.undoneOverlays.length != 0) {
|
---|
[32832] | 37 | if (this.undoneOverlays[this.undoneOverlays.length -1].length != 0) {
|
---|
| 38 | this.mapEditor.selectedShapes = [];
|
---|
[32850] | 39 | var draggableCB = document.getElementById("draggableCB" + "-" + this.mapEditor.id).checked = false;
|
---|
| 40 |
|
---|
[32832] | 41 | for (var i = 0; i < this.mapEditor.overlays.length; i++) {
|
---|
| 42 | this.mapEditor.overlays[i].setMap(null);
|
---|
| 43 | }
|
---|
[32766] | 44 |
|
---|
[32832] | 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 | }
|
---|
[32766] | 52 |
|
---|
[32832] | 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;
|
---|
[32766] | 67 | }
|
---|
[32832] | 68 | this.prevOverlays.push(overlays_copy);
|
---|
[32766] | 69 | }
|
---|
| 70 | }
|
---|
[32832] | 71 | this.presentOverlays = [];
|
---|
| 72 | this.presentOverlays.push(this.undoneOverlays[this.undoneOverlays.length - 1]);
|
---|
| 73 | this.undoneOverlays.pop();
|
---|
[32766] | 74 | }
|
---|
| 75 | }
|
---|
| 76 | }
|
---|
| 77 |
|
---|
[32799] | 78 | MapEditorHistory.prototype.historyOverlayPush = function () {
|
---|
| 79 |
|
---|
| 80 |
|
---|
| 81 | if (this.cycleCompvare) {
|
---|
| 82 |
|
---|
[32766] | 83 | var overlays_copy = [];
|
---|
[32799] | 84 | for (var i = 0; i < this.mapEditor.overlays.length; i++) {
|
---|
| 85 | var clone_shape = ShapesUtil.cloneShape(this.mapEditor.overlays[i]);
|
---|
| 86 | if (ShapesUtil.overlayItemIsShape(clone_shape)) {
|
---|
| 87 | this.mapEditor.addShapeListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 88 | } else {
|
---|
[32799] | 89 | this.mapEditor.addMarkerListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 90 | }
|
---|
| 91 | overlays_copy[i] = clone_shape;
|
---|
| 92 | }
|
---|
[32799] | 93 | this.undoneOverlays = [];
|
---|
[32769] | 94 | this.prevOverlays.push(overlays_copy);
|
---|
[32766] | 95 | }
|
---|
| 96 |
|
---|
[32799] | 97 | this.cycleCompvare = false;
|
---|
[32766] | 98 | }
|
---|
| 99 |
|
---|
[32799] | 100 | MapEditorHistory.prototype.presentOverlayPush = function () {
|
---|
| 101 | // console.log("presentOverlayPush");
|
---|
| 102 |
|
---|
[32769] | 103 | this.presentOverlays = [];
|
---|
[32766] | 104 | var overlays_copy = [];
|
---|
[32799] | 105 | for (var i = 0; i < this.mapEditor.overlays.length; i++) {
|
---|
| 106 | var clone_shape = ShapesUtil.cloneShape(this.mapEditor.overlays[i]);
|
---|
| 107 | if (ShapesUtil.overlayItemIsShape(clone_shape)) {
|
---|
| 108 | this.mapEditor.addShapeListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 109 | } else {
|
---|
[32799] | 110 | this.mapEditor.addMarkerListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 111 | }
|
---|
| 112 | overlays_copy[i] = clone_shape;
|
---|
| 113 | }
|
---|
[32769] | 114 | this.presentOverlays.push(overlays_copy);
|
---|
[32799] | 115 | this.cycleCompvare = true;
|
---|
[32766] | 116 |
|
---|
[32799] | 117 |
|
---|
[32766] | 118 | }
|
---|
| 119 |
|
---|
[32799] | 120 | MapEditorHistory.prototype.undoneOverlaysPush = function () {
|
---|
| 121 |
|
---|
| 122 | var conditionUndone = this.presentOverlays[this.presentOverlays.length - 1] !== undefined;
|
---|
[32766] | 123 |
|
---|
| 124 | if (conditionUndone) {
|
---|
[32799] | 125 | var overlays_copy = [];
|
---|
| 126 | for (var i = 0; i < this.presentOverlays[0].length; i++) {
|
---|
| 127 | var clone_shape = ShapesUtil.cloneShape(this.presentOverlays[0][i]);
|
---|
| 128 | if (ShapesUtil.overlayItemIsShape(clone_shape)) {
|
---|
| 129 | this.mapEditor.addShapeListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 130 | } else {
|
---|
[32799] | 131 | this.mapEditor.addMarkerListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 132 | }
|
---|
| 133 | overlays_copy[i] = clone_shape;
|
---|
| 134 | }
|
---|
[32799] | 135 | this.undoneOverlays.push(overlays_copy);
|
---|
[32766] | 136 | }
|
---|
| 137 |
|
---|
[32799] | 138 | var conditionPresent = this.prevOverlays[this.prevOverlays.length - 1] !== undefined;
|
---|
[32766] | 139 |
|
---|
| 140 | if (conditionPresent) {
|
---|
[32799] | 141 | this.presentOverlays = [];
|
---|
[32766] | 142 | var overlays_copy = [];
|
---|
[32799] | 143 | for (var i = 0; i < this.prevOverlays[this.prevOverlays.length - 1].length; i++) {
|
---|
| 144 | var clone_shape = cloneShape(this.prevOverlays[this.prevOverlays.length - 1][i]);
|
---|
| 145 | if (ShapesUtil.overlayItemIsShape(clone_shape)) {
|
---|
| 146 | this.mapEditor.addShapeListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 147 | } else {
|
---|
[32799] | 148 | this.mapEditor.addMarkerListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 149 | }
|
---|
| 150 | overlays_copy[i] = clone_shape;
|
---|
| 151 | }
|
---|
[32799] | 152 | this.presentOverlays.push(overlays_copy);
|
---|
[32766] | 153 | }
|
---|
| 154 | }
|
---|
| 155 |
|
---|
[32799] | 156 | MapEditorHistory.prototype.undoneOverlaysPush = function () {
|
---|
[32766] | 157 |
|
---|
[32799] | 158 | var conditionUndone = this.presentOverlays[this.presentOverlays.length - 1] !== undefined;
|
---|
[32766] | 159 |
|
---|
| 160 | if (conditionUndone) {
|
---|
| 161 | var overlays_copy = [];
|
---|
| 162 | for (var i = 0; i < this.presentOverlays[0].length; i++) {
|
---|
[32799] | 163 | var clone_shape = ShapesUtil.cloneShape(this.presentOverlays[0][i]);
|
---|
| 164 | if (ShapesUtil.overlayItemIsShape(clone_shape)) {
|
---|
| 165 | this.mapEditor.addShapeListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 166 | } else {
|
---|
[32799] | 167 | this.mapEditor.addMarkerListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 168 | }
|
---|
| 169 | overlays_copy[i] = clone_shape;
|
---|
| 170 | }
|
---|
| 171 | this.undoneOverlays.push(overlays_copy);
|
---|
| 172 | }
|
---|
| 173 |
|
---|
[32799] | 174 | var conditionPresent = this.prevOverlays[this.prevOverlays.length - 1] !== undefined;
|
---|
[32766] | 175 |
|
---|
| 176 | if (conditionPresent) {
|
---|
| 177 | this.presentOverlays = [];
|
---|
| 178 | var overlays_copy = [];
|
---|
[32799] | 179 | for (var i = 0; i < this.prevOverlays[this.prevOverlays.length - 1].length; i++) {
|
---|
| 180 | var clone_shape = ShapesUtil.cloneShape(this.prevOverlays[this.prevOverlays.length - 1][i]);
|
---|
| 181 | if (ShapesUtil.overlayItemIsShape(clone_shape)) {
|
---|
| 182 | this.mapEditor.addShapeListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 183 | } else {
|
---|
[32799] | 184 | this.mapEditor.addMarkerListeners(clone_shape, null); // don't have an overlay event!
|
---|
[32766] | 185 | }
|
---|
| 186 | overlays_copy[i] = clone_shape;
|
---|
| 187 | }
|
---|
| 188 | this.presentOverlays.push(overlays_copy);
|
---|
| 189 | }
|
---|
[32799] | 190 | } |
---|