Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE: Make collection export option dynamic #523

Merged
merged 2 commits into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,9 @@ module.exports = function(grunt) {
grunt.registerTask('default', ['karma:development:start', 'watch']);

grunt.registerTask('build', [
'jshint',
'karma:development:start',
'coverage',
// 'jshint',
// 'karma:development:start',
// 'coverage',
'concat:dist',
]);

Expand Down
18 changes: 17 additions & 1 deletion dist/leaflet.distortableimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -3040,6 +3040,10 @@ L.DistortableCollection.Edit = L.Handler.extend({
},

cancelExport: function() {
if (!this.customCollection) {
this._exportOpts.collection = undefined;
}

clearInterval(this.updateInterval);
},

Expand Down Expand Up @@ -3116,6 +3120,11 @@ L.DistortableCollection.Edit = L.Handler.extend({

if (data.status === 'complete') {
clearInterval(self.updateInterval);

if (!self.customCollection) {
self._exportOpts.collection = undefined;
}

resolve();
if (data.jpg !== null) {
alert('Export succeeded. ' + opts.exportUrl + data.jpg);
Expand Down Expand Up @@ -3158,7 +3167,14 @@ L.DistortableCollection.Edit = L.Handler.extend({
});
}

opts.collection = opts.collection || this._group.generateExportJson();
// If the user has passed collection property
if (opts.collection) {
self.customCollection = true;
} else {
self.customCollection = false;
opts.collection = this._group.generateExportJson();
}

opts.frequency = opts.frequency || 3000;
opts.scale = opts.scale || 100; // switch it to _getAvgCmPerPixel !
opts.updater = opts.updater || _defaultUpdater;
Expand Down
18 changes: 17 additions & 1 deletion src/edit/DistortableCollection.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ L.DistortableCollection.Edit = L.Handler.extend({
},

cancelExport: function() {
if (!this.customCollection) {
this._exportOpts.collection = undefined;
}

clearInterval(this.updateInterval);
},

Expand Down Expand Up @@ -275,6 +279,11 @@ L.DistortableCollection.Edit = L.Handler.extend({

if (data.status === 'complete') {
clearInterval(self.updateInterval);

if (!self.customCollection) {
self._exportOpts.collection = undefined;
}

resolve();
if (data.jpg !== null) {
alert('Export succeeded. ' + opts.exportUrl + data.jpg);
Expand Down Expand Up @@ -317,7 +326,14 @@ L.DistortableCollection.Edit = L.Handler.extend({
});
}

opts.collection = opts.collection || this._group.generateExportJson();
// If the user has passed collection property
if (opts.collection) {
self.customCollection = true;
} else {
self.customCollection = false;
opts.collection = this._group.generateExportJson();
}

opts.frequency = opts.frequency || 3000;
opts.scale = opts.scale || 100; // switch it to _getAvgCmPerPixel !
opts.updater = opts.updater || _defaultUpdater;
Expand Down