Skip to content

Commit

Permalink
Only update editor after edits (closes #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
tschaub committed Jun 14, 2013
1 parent 844fc38 commit 7861b6c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ if (window.location.pathname.match(/^(\/[^\/]+){2}\/edit\/.*\.geojson$/)) {
}
});

var map, vector, control;
var map, vector, control, dirty;

function showMap() {
var editor = $('#ace-editor').hide();
Expand Down Expand Up @@ -113,12 +113,18 @@ if (window.location.pathname.match(/^(\/[^\/]+){2}\/edit\/.*\.geojson$/)) {

map.addControl(control);
control.activate();
dirty = false;
vector.events.on({featuremodified: function() {
dirty = true;
}});

}

function updateEditor() {
var code = format.write(vector.features, true);
unsafeWindow.editor.setCode(code);
if (dirty) {
var code = format.write(vector.features, true);
unsafeWindow.editor.setCode(code);
}
}

function hideMap() {
Expand Down

0 comments on commit 7861b6c

Please sign in to comment.