Skip to content

Commit

Permalink
dgs
Browse files Browse the repository at this point in the history
  • Loading branch information
sashadev-sky committed Jul 15, 2019
1 parent f8c4be5 commit 808151d
Show file tree
Hide file tree
Showing 15 changed files with 811 additions and 615 deletions.
69 changes: 35 additions & 34 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);

grunt.initConfig({
pkg: grunt.file.readJSON("package.json"),
pkg: grunt.file.readJSON('package.json'),

jshint: {
options: {
Expand Down Expand Up @@ -44,19 +44,19 @@ module.exports = function(grunt) {
}
},
source: {
src: ["src/**/*.js", "package.json"]
src: ['src/**/*.js', 'package.json']
},
grunt: {
src: ["Gruntfile.js"]
src: ['Gruntfile.js']
}
},

karma: {
development: {
configFile: "test/karma.conf.js"
configFile: 'test/karma.conf.js'
},
test: {
configFile: "test/karma.conf.js"
configFile: 'test/karma.conf.js'
}
},

Expand All @@ -65,12 +65,12 @@ module.exports = function(grunt) {
dist: {
files: [
{
attrs: "fill",
attrs: 'fill',
expand: true,
cwd: "assets/icons/svg",
src: ["*.svg"],
dest: "assets/icons/svg-min/",
ext: ".svg"
cwd: 'assets/icons/svg',
src: ['*.svg'],
dest: 'assets/icons/svg-min/',
ext: '.svg'
}
]
},
Expand All @@ -89,11 +89,11 @@ module.exports = function(grunt) {
},
dist: {
expand: true,
cwd: "assets/icons/svg-min/",
src: ["*.svg"],
dest: "assets/icons/",
cwd: 'assets/icons/svg-min/',
src: ['*.svg'],
dest: 'assets/icons/',
options: {
log: "info",
log: 'info',
shape: {
dimension: {
maxWidth: 18,
Expand All @@ -102,7 +102,7 @@ module.exports = function(grunt) {
},
mode: {
symbol: {
sprite: "sprite.symbol.svg",
sprite: 'sprite.symbol.svg',
example: true
}
}
Expand All @@ -115,32 +115,33 @@ module.exports = function(grunt) {
livereload: true
},
source: {
files: ["src/**/*.js", "test/**/*.js", "Gruntfile.js"],
tasks: ["build:js"]
files: ['src/**/*.js', 'test/**/*.js', 'Gruntfile.js'],
tasks: ['build:js']
}
},

concat: {
dist: {
src: [
"src/util/*.js",
"src/DistortableImageOverlay.js",
"src/DistortableCollection.js",
"src/edit/getEXIFdata.js",
"src/edit/EditHandle.js",
"src/edit/LockHandle.js",
"src/edit/DistortHandle.js",
"src/edit/RotateScaleHandle.js",
"src/edit/RotateHandle.js",
"src/edit/ScaleHandle.js",
"src/edit/tools/EditAction.js",
"src/edit/tools/DistortableImage.PopupBar.js",
"src/edit/tools/DistortableImage.ControlBar.js",
"src/edit/DistortableImage.Edit.js",
"src/edit/DistortableImage.Keymapper.js",
"src/edit/BoxSelector.js"
'src/util/*.js',
'src/DistortableImageOverlay.js',
'src/DistortableCollection.js',
'src/edit/getEXIFdata.js',
'src/edit/tools/L.Control.AffineToolbox.js',
'src/edit/EditHandle.js',
'src/edit/LockHandle.js',
'src/edit/DistortHandle.js',
'src/edit/RotateScaleHandle.js',
'src/edit/RotateHandle.js',
'src/edit/ScaleHandle.js',
'src/edit/tools/EditAction.js',
'src/edit/tools/DistortableImage.PopupBar.js',
'src/edit/tools/DistortableImage.ControlBar.js',
'src/edit/DistortableImage.Edit.js',
'src/edit/DistortableImage.Keymapper.js',
'src/edit/BoxSelector.js'
],
dest: "dist/leaflet.distortableimage.js"
dest: 'dist/leaflet.distortableimage.js'
}
}
});
Expand Down
2 changes: 1 addition & 1 deletion assets/icons/symbol/sprite.symbol.html
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ <h2>unlock</h2>

</section>
<footer>
<p>Generated at Sun, 30 Jun 2019 21:17:39 GMT by <a href="https://github.com/jkphl/svg-sprite" target="_blank">svg-sprite</a>.</p>
<p>Generated at Mon, 15 Jul 2019 10:33:52 GMT by <a href="https://github.com/jkphl/svg-sprite" target="_blank">svg-sprite</a>.</p>
</footer>
</body>
</html>
96 changes: 96 additions & 0 deletions dist/leaflet.distortableimage.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,8 @@ L.DistortableImageOverlay = L.ImageOverlay.extend({
);

this.fire('add');


},

onRemove: function(map) {
Expand Down Expand Up @@ -1174,6 +1176,79 @@ L.EXIF = function getEXIFdata(img) {
}
};

L.Control.AffineToolbox = L.Control.extend({
options: {
position: 'topright'
},

initialize: function (affineLayer) {
this._affineLayer = affineLayer;
},

onAdd: function (map) {
var $controlContainer = $(map._controlContainer);

if ($controlContainer.children('.leaflet-top.leaflet-right').length === 0) {
$controlContainer.append('<div class="leaflet-top leaflet-right"></div>');
map._controlCorners.topcenter = $controlContainer.children('.leaflet-top.leaflet-right').first()[0];
}

this._map = map;
this._toolbox = L.DomUtil.create('div', 'leaflet-affine-toolbox');
this._toolbox.id = 'affine-toolbox';
this._toolbox.className = 'leaflet-affine-toolbox';

var acceptBttn = document.createElement('a');
acceptBttn.className = 'accept-affine-image';
$(acceptBttn).on("click", $.proxy(function () {
this._affineLayer._map.removeLayer(this._affineLayer._resizersLayer);
this._affineLayer._removeToolbox();
},this));

var removeBttn = document.createElement('a');
removeBttn.className = 'remove-affine-image';
$(removeBttn).on("click", $.proxy(function () {
this._affineLayer._map.removeLayer(this._affineLayer._resizersLayer);
this._affineLayer._map.removeLayer(this._affineLayer);
this._affineLayer._removeToolbox();
},this));

var sliderBttn = document.createElement('a');
sliderBttn.id = 'opacity-slider';

$(this._toolbox).append(acceptBttn, removeBttn, sliderBttn);

this._slider = sliderBttn;

this.initSlider(sliderBttn);

return this._toolbox;
},

initSlider: function(){
var map = this._map;
var slider = this._slider;

$(slider).parent().removeClass('leaflet-bar-item');
$(slider).parent().addClass('leaflet-bar-item');

$(slider).slider({min: 10, max: 100}); //Setting range...
$(slider).slider( "option", "value", 70 ); //Initializing at middle

$(slider).on("mouseover", function(c) {
map.dragging.disable();
});

$(slider).on("mouseout", function(c) {
map.dragging.enable();
});
},

slider: function(){
return this._slider;
}

});
L.EditHandle = L.Marker.extend({
initialize: function(overlay, corner, options) {
var markerOptions,
Expand Down Expand Up @@ -1894,6 +1969,8 @@ L.DistortableImage.Edit = L.Handler.extend({

this._appendHandlesandDragable(this._mode);

this._addToolbox();

this.editActions = this.options.actions;

if (this._selected && !overlay.options.suppressToolbar) { this._addToolbar(); }
Expand Down Expand Up @@ -2020,6 +2097,23 @@ L.DistortableImage.Edit = L.Handler.extend({
}, this);
},

_addToolbox: function(){
// var params = this.params();

this._toolbox = new L.Control.AffineToolbox(this);
this._hasToolbox = true;
this._toolbox.addTo(this._map);

//Setting up render function to slider
var slider = this._toolbox.slider();


slider.on("slide", $.proxy(function () {
// this._renderFunc(params);
},this));

},

_rotateBy: function(angle) {
var overlay = this._overlay,
map = overlay._map,
Expand Down Expand Up @@ -2068,6 +2162,8 @@ L.DistortableImage.Edit = L.Handler.extend({
this._overlay.rotation = angle;
},



_scaleBy: function(scale) {
var overlay = this._overlay,
map = overlay._map,
Expand Down
Binary file added examples/img/resizer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions examples/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@
],
fullResolutionSrc: "large.jpg"
}).addTo(map);

L.Control.AffineToolbox
})();
</script>
</html>
2 changes: 2 additions & 0 deletions src/DistortableImageOverlay.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ L.DistortableImageOverlay = L.ImageOverlay.extend({
);

this.fire('add');


},

onRemove: function(map) {
Expand Down
21 changes: 21 additions & 0 deletions src/edit/DistortableImage.Edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ L.DistortableImage.Edit = L.Handler.extend({

this._appendHandlesandDragable(this._mode);

this._addToolbox();

this.editActions = this.options.actions;

if (this._selected && !overlay.options.suppressToolbar) { this._addToolbar(); }
Expand Down Expand Up @@ -182,6 +184,23 @@ L.DistortableImage.Edit = L.Handler.extend({
}, this);
},

_addToolbox: function(){
// var params = this.params();

this._toolbox = new L.Control.AffineToolbox(this);
this._hasToolbox = true;
this._toolbox.addTo(this._map);

//Setting up render function to slider
var slider = this._toolbox.slider();


slider.on("slide", $.proxy(function () {
// this._renderFunc(params);
},this));

},

_rotateBy: function(angle) {
var overlay = this._overlay,
map = overlay._map,
Expand Down Expand Up @@ -230,6 +249,8 @@ L.DistortableImage.Edit = L.Handler.extend({
this._overlay.rotation = angle;
},



_scaleBy: function(scale) {
var overlay = this._overlay,
map = overlay._map,
Expand Down
Loading

0 comments on commit 808151d

Please sign in to comment.