blacklight-spotlight 0.33.3 → 0.34.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -9
- data/app/assets/javascripts/spotlight/application.js +2 -1
- data/app/assets/javascripts/spotlight/crop.es6 +189 -111
- data/app/assets/javascripts/spotlight/croppable.js +3 -1
- data/app/assets/stylesheets/spotlight/_browse.scss +10 -2
- data/app/assets/stylesheets/spotlight/_croppable.scss +0 -7
- data/app/jobs/spotlight/add_uploads_from_csv.rb +1 -2
- data/app/views/spotlight/browse/show.html.erb +3 -1
- data/app/views/spotlight/filters/_form.html.erb +2 -1
- data/config/locales/spotlight.en.yml +3 -0
- data/lib/generators/spotlight/templates/spotlight.scss +0 -1
- data/lib/migration/iiif.rb +5 -2
- data/lib/spotlight/version.rb +1 -1
- data/spec/examples.txt +14 -13
- data/spec/jobs/spotlight/add_uploads_from_csv_spec.rb +5 -4
- data/spec/lib/migration/iiif_spec.rb +8 -11
- data/spec/views/spotlight/browse/show.html.erb_spec.rb +8 -1
- data/vendor/assets/javascripts/Leaflet.Editable.js +1906 -0
- data/vendor/assets/javascripts/Path.Drag.js +137 -0
- metadata +4 -3
- data/vendor/assets/javascripts/leaflet-areaselect.js +0 -184
@@ -0,0 +1,137 @@
|
|
1
|
+
'use strict';
|
2
|
+
|
3
|
+
/* A Draggable that does not update the element position
|
4
|
+
and takes care of only bubbling to targetted path in Canvas mode. */
|
5
|
+
L.PathDraggable = L.Draggable.extend({
|
6
|
+
|
7
|
+
initialize: function (path) {
|
8
|
+
this._path = path;
|
9
|
+
this._canvas = (path._map.getRenderer(path) instanceof L.Canvas);
|
10
|
+
var element = this._canvas ? this._path._map.getRenderer(this._path)._container : this._path._path;
|
11
|
+
L.Draggable.prototype.initialize.call(this, element, element, true);
|
12
|
+
},
|
13
|
+
|
14
|
+
_updatePosition: function () {
|
15
|
+
var e = {originalEvent: this._lastEvent};
|
16
|
+
this.fire('drag', e);
|
17
|
+
},
|
18
|
+
|
19
|
+
_onDown: function (e) {
|
20
|
+
var first = e.touches ? e.touches[0] : e;
|
21
|
+
this._startPoint = new L.Point(first.clientX, first.clientY);
|
22
|
+
if (this._canvas && !this._path._containsPoint(this._path._map.mouseEventToLayerPoint(first))) { return; }
|
23
|
+
L.Draggable.prototype._onDown.call(this, e);
|
24
|
+
}
|
25
|
+
|
26
|
+
});
|
27
|
+
|
28
|
+
|
29
|
+
L.Handler.PathDrag = L.Handler.extend({
|
30
|
+
|
31
|
+
initialize: function (path) {
|
32
|
+
this._path = path;
|
33
|
+
},
|
34
|
+
|
35
|
+
getEvents: function () {
|
36
|
+
return {
|
37
|
+
dragstart: this._onDragStart,
|
38
|
+
drag: this._onDrag,
|
39
|
+
dragend: this._onDragEnd
|
40
|
+
};
|
41
|
+
},
|
42
|
+
|
43
|
+
addHooks: function () {
|
44
|
+
if (!this._draggable) { this._draggable = new L.PathDraggable(this._path); }
|
45
|
+
this._draggable.on(this.getEvents(), this).enable();
|
46
|
+
L.DomUtil.addClass(this._draggable._element, 'leaflet-path-draggable');
|
47
|
+
},
|
48
|
+
|
49
|
+
removeHooks: function () {
|
50
|
+
this._draggable.off(this.getEvents(), this).disable();
|
51
|
+
L.DomUtil.removeClass(this._draggable._element, 'leaflet-path-draggable');
|
52
|
+
},
|
53
|
+
|
54
|
+
moved: function () {
|
55
|
+
return this._draggable && this._draggable._moved;
|
56
|
+
},
|
57
|
+
|
58
|
+
_onDragStart: function () {
|
59
|
+
this._startPoint = this._draggable._startPoint;
|
60
|
+
this._path
|
61
|
+
.closePopup()
|
62
|
+
.fire('movestart')
|
63
|
+
.fire('dragstart');
|
64
|
+
},
|
65
|
+
|
66
|
+
_onDrag: function (e) {
|
67
|
+
var path = this._path,
|
68
|
+
event = (e.originalEvent.touches && e.originalEvent.touches.length === 1 ? e.originalEvent.touches[0] : e.originalEvent),
|
69
|
+
newPoint = L.point(event.clientX, event.clientY),
|
70
|
+
latlng = path._map.layerPointToLatLng(newPoint);
|
71
|
+
|
72
|
+
this._offset = newPoint.subtract(this._startPoint);
|
73
|
+
this._startPoint = newPoint;
|
74
|
+
|
75
|
+
this._path.eachLatLng(this.updateLatLng, this);
|
76
|
+
path.redraw();
|
77
|
+
|
78
|
+
e.latlng = latlng;
|
79
|
+
e.offset = this._offset;
|
80
|
+
path.fire('move', e)
|
81
|
+
.fire('drag', e);
|
82
|
+
},
|
83
|
+
|
84
|
+
_onDragEnd: function (e) {
|
85
|
+
if (this._path._bounds) this.resetBounds();
|
86
|
+
this._path.fire('moveend')
|
87
|
+
.fire('dragend', e);
|
88
|
+
},
|
89
|
+
|
90
|
+
latLngToLayerPoint: function (latlng) {
|
91
|
+
// Same as map.latLngToLayerPoint, but without the round().
|
92
|
+
var projectedPoint = this._path._map.project(L.latLng(latlng));
|
93
|
+
return projectedPoint._subtract(this._path._map.getPixelOrigin());
|
94
|
+
},
|
95
|
+
|
96
|
+
updateLatLng: function (latlng) {
|
97
|
+
var oldPoint = this.latLngToLayerPoint(latlng);
|
98
|
+
oldPoint._add(this._offset);
|
99
|
+
var newLatLng = this._path._map.layerPointToLatLng(oldPoint);
|
100
|
+
latlng.lat = newLatLng.lat;
|
101
|
+
latlng.lng = newLatLng.lng;
|
102
|
+
},
|
103
|
+
|
104
|
+
resetBounds: function () {
|
105
|
+
this._path._bounds = new L.LatLngBounds();
|
106
|
+
this._path.eachLatLng(function (latlng) {
|
107
|
+
this._bounds.extend(latlng);
|
108
|
+
});
|
109
|
+
}
|
110
|
+
|
111
|
+
});
|
112
|
+
|
113
|
+
L.Path.include({
|
114
|
+
|
115
|
+
eachLatLng: function (callback, context) {
|
116
|
+
context = context || this;
|
117
|
+
var loop = function (latlngs) {
|
118
|
+
for (var i = 0; i < latlngs.length; i++) {
|
119
|
+
if (L.Util.isArray(latlngs[i])) loop(latlngs[i]);
|
120
|
+
else callback.call(context, latlngs[i]);
|
121
|
+
}
|
122
|
+
};
|
123
|
+
loop(this.getLatLngs ? this.getLatLngs() : [this.getLatLng()]);
|
124
|
+
}
|
125
|
+
|
126
|
+
});
|
127
|
+
|
128
|
+
L.Path.addInitHook(function () {
|
129
|
+
|
130
|
+
this.dragging = new L.Handler.PathDrag(this);
|
131
|
+
if (this.options.draggable) {
|
132
|
+
this.once('add', function () {
|
133
|
+
this.dragging.enable();
|
134
|
+
});
|
135
|
+
}
|
136
|
+
|
137
|
+
});
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blacklight-spotlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.34.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Beer
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2017-02-
|
14
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -1433,12 +1433,13 @@ files:
|
|
1433
1433
|
- spec/views/spotlight/sites/edit_exhibits.html.erb_spec.rb
|
1434
1434
|
- spec/views/spotlight/tags/index.html.erb_spec.rb
|
1435
1435
|
- vendor/assets/images/sir-trevor-icons.svg
|
1436
|
+
- vendor/assets/javascripts/Leaflet.Editable.js
|
1437
|
+
- vendor/assets/javascripts/Path.Drag.js
|
1436
1438
|
- vendor/assets/javascripts/bootstrap-tagsinput.js
|
1437
1439
|
- vendor/assets/javascripts/eventable.js
|
1438
1440
|
- vendor/assets/javascripts/handlebars-v1.3.0.js
|
1439
1441
|
- vendor/assets/javascripts/jquery.serializejson.js
|
1440
1442
|
- vendor/assets/javascripts/jquery.waitforimages.min.js
|
1441
|
-
- vendor/assets/javascripts/leaflet-areaselect.js
|
1442
1443
|
- vendor/assets/javascripts/leaflet-iiif.js
|
1443
1444
|
- vendor/assets/javascripts/leaflet.js
|
1444
1445
|
- vendor/assets/javascripts/nestable.js
|
@@ -1,184 +0,0 @@
|
|
1
|
-
L.AreaSelect = L.Class.extend({
|
2
|
-
includes: L.Mixin.Events,
|
3
|
-
|
4
|
-
options: {
|
5
|
-
width: 200,
|
6
|
-
height: 300,
|
7
|
-
keepAspectRatio: false,
|
8
|
-
},
|
9
|
-
|
10
|
-
initialize: function(options) {
|
11
|
-
L.Util.setOptions(this, options);
|
12
|
-
|
13
|
-
this._width = this.options.width;
|
14
|
-
this._height = this.options.height;
|
15
|
-
},
|
16
|
-
|
17
|
-
addTo: function(map) {
|
18
|
-
this.map = map;
|
19
|
-
this._createElements();
|
20
|
-
this._render();
|
21
|
-
return this;
|
22
|
-
},
|
23
|
-
|
24
|
-
getBounds: function() {
|
25
|
-
var size = this.map.getSize();
|
26
|
-
var topRight = new L.Point();
|
27
|
-
var bottomLeft = new L.Point();
|
28
|
-
|
29
|
-
bottomLeft.x = Math.round((size.x - this._width) / 2);
|
30
|
-
topRight.y = Math.round((size.y - this._height) / 2);
|
31
|
-
topRight.x = size.x - bottomLeft.x;
|
32
|
-
bottomLeft.y = size.y - topRight.y;
|
33
|
-
|
34
|
-
var sw = this.map.containerPointToLatLng(bottomLeft);
|
35
|
-
var ne = this.map.containerPointToLatLng(topRight);
|
36
|
-
|
37
|
-
return new L.LatLngBounds(sw, ne);
|
38
|
-
},
|
39
|
-
|
40
|
-
remove: function() {
|
41
|
-
this.map.off("moveend", this._onMapChange);
|
42
|
-
this.map.off("zoomend", this._onMapChange);
|
43
|
-
this.map.off("resize", this._onMapResize);
|
44
|
-
|
45
|
-
this._container.parentNode.removeChild(this._container);
|
46
|
-
},
|
47
|
-
|
48
|
-
|
49
|
-
setDimensions: function(dimensions) {
|
50
|
-
if (!dimensions)
|
51
|
-
return;
|
52
|
-
|
53
|
-
this._height = parseInt(dimensions.height) || this._height;
|
54
|
-
this._width = parseInt(dimensions.width) || this._width;
|
55
|
-
this._render();
|
56
|
-
this.fire("change");
|
57
|
-
},
|
58
|
-
|
59
|
-
|
60
|
-
_createElements: function() {
|
61
|
-
if (!!this._container)
|
62
|
-
return;
|
63
|
-
|
64
|
-
this._container = L.DomUtil.create("div", "leaflet-areaselect-container", this.map._controlContainer)
|
65
|
-
this._topShade = L.DomUtil.create("div", "leaflet-areaselect-shade leaflet-control", this._container);
|
66
|
-
this._bottomShade = L.DomUtil.create("div", "leaflet-areaselect-shade leaflet-control", this._container);
|
67
|
-
this._leftShade = L.DomUtil.create("div", "leaflet-areaselect-shade leaflet-control", this._container);
|
68
|
-
this._rightShade = L.DomUtil.create("div", "leaflet-areaselect-shade leaflet-control", this._container);
|
69
|
-
|
70
|
-
this._nwHandle = L.DomUtil.create("div", "leaflet-areaselect-handle leaflet-control", this._container);
|
71
|
-
this._swHandle = L.DomUtil.create("div", "leaflet-areaselect-handle leaflet-control", this._container);
|
72
|
-
this._neHandle = L.DomUtil.create("div", "leaflet-areaselect-handle leaflet-control", this._container);
|
73
|
-
this._seHandle = L.DomUtil.create("div", "leaflet-areaselect-handle leaflet-control", this._container);
|
74
|
-
|
75
|
-
this._setUpHandlerEvents(this._nwHandle);
|
76
|
-
this._setUpHandlerEvents(this._neHandle, -1, 1);
|
77
|
-
this._setUpHandlerEvents(this._swHandle, 1, -1);
|
78
|
-
this._setUpHandlerEvents(this._seHandle, -1, -1);
|
79
|
-
|
80
|
-
this.map.on("moveend", this._onMapChange, this);
|
81
|
-
this.map.on("zoomend", this._onMapChange, this);
|
82
|
-
this.map.on("resize", this._onMapResize, this);
|
83
|
-
|
84
|
-
this.fire("change");
|
85
|
-
},
|
86
|
-
|
87
|
-
_setUpHandlerEvents: function(handle, xMod, yMod) {
|
88
|
-
xMod = xMod || 1;
|
89
|
-
yMod = yMod || 1;
|
90
|
-
|
91
|
-
var self = this;
|
92
|
-
function onMouseDown(event) {
|
93
|
-
event.stopPropagation();
|
94
|
-
self.map.dragging.disable();
|
95
|
-
L.DomEvent.removeListener(this, "mousedown", onMouseDown);
|
96
|
-
var curX = event.pageX;
|
97
|
-
var curY = event.pageY;
|
98
|
-
var ratio = self._width / self._height;
|
99
|
-
var size = self.map.getSize();
|
100
|
-
|
101
|
-
function onMouseMove(event) {
|
102
|
-
if (self.options.keepAspectRatio) {
|
103
|
-
var maxHeight = (self._height >= self._width ? size.y : (size.x / ratio) ) - 30;
|
104
|
-
self._height += (curY - event.originalEvent.pageY) * 2 * yMod;
|
105
|
-
self._height = Math.max(30, self._height);
|
106
|
-
self._height = Math.min(maxHeight, self._height);
|
107
|
-
self._width = self._height * ratio;
|
108
|
-
} else {
|
109
|
-
self._width += (curX - event.originalEvent.pageX) * 2 * xMod;
|
110
|
-
self._height += (curY - event.originalEvent.pageY) * 2 * yMod;
|
111
|
-
self._width = Math.max(30, self._width);
|
112
|
-
self._height = Math.max(30, self._height);
|
113
|
-
self._width = Math.min(size.x-30, self._width);
|
114
|
-
self._height = Math.min(size.y-30, self._height);
|
115
|
-
|
116
|
-
}
|
117
|
-
|
118
|
-
curX = event.originalEvent.pageX;
|
119
|
-
curY = event.originalEvent.pageY;
|
120
|
-
self._render();
|
121
|
-
}
|
122
|
-
function onMouseUp(event) {
|
123
|
-
self.map.dragging.enable();
|
124
|
-
L.DomEvent.removeListener(self.map, "mouseup", onMouseUp);
|
125
|
-
L.DomEvent.removeListener(self.map, "mousemove", onMouseMove);
|
126
|
-
L.DomEvent.addListener(handle, "mousedown", onMouseDown);
|
127
|
-
self.fire("change");
|
128
|
-
}
|
129
|
-
|
130
|
-
L.DomEvent.addListener(self.map, "mousemove", onMouseMove);
|
131
|
-
L.DomEvent.addListener(self.map, "mouseup", onMouseUp);
|
132
|
-
}
|
133
|
-
L.DomEvent.addListener(handle, "mousedown", onMouseDown);
|
134
|
-
},
|
135
|
-
|
136
|
-
_onMapResize: function() {
|
137
|
-
this._render();
|
138
|
-
},
|
139
|
-
|
140
|
-
_onMapChange: function() {
|
141
|
-
this.fire("change");
|
142
|
-
},
|
143
|
-
|
144
|
-
_render: function() {
|
145
|
-
var size = this.map.getSize();
|
146
|
-
var handleOffset = Math.round(this._nwHandle.offsetWidth/2);
|
147
|
-
|
148
|
-
var topBottomHeight = Math.round((size.y-this._height)/2);
|
149
|
-
var leftRightWidth = Math.round((size.x-this._width)/2);
|
150
|
-
|
151
|
-
function setDimensions(element, dimension) {
|
152
|
-
element.style.width = dimension.width + "px";
|
153
|
-
element.style.height = dimension.height + "px";
|
154
|
-
element.style.top = dimension.top + "px";
|
155
|
-
element.style.left = dimension.left + "px";
|
156
|
-
element.style.bottom = dimension.bottom + "px";
|
157
|
-
element.style.right = dimension.right + "px";
|
158
|
-
}
|
159
|
-
|
160
|
-
setDimensions(this._topShade, {width:size.x, height:topBottomHeight, top:0, left:0});
|
161
|
-
setDimensions(this._bottomShade, {width:size.x, height:topBottomHeight, bottom:0, left:0});
|
162
|
-
setDimensions(this._leftShade, {
|
163
|
-
width: leftRightWidth,
|
164
|
-
height: size.y-(topBottomHeight*2),
|
165
|
-
top: topBottomHeight,
|
166
|
-
left: 0
|
167
|
-
});
|
168
|
-
setDimensions(this._rightShade, {
|
169
|
-
width: leftRightWidth,
|
170
|
-
height: size.y-(topBottomHeight*2),
|
171
|
-
top: topBottomHeight,
|
172
|
-
right: 0
|
173
|
-
});
|
174
|
-
|
175
|
-
setDimensions(this._nwHandle, {left:leftRightWidth-handleOffset, top:topBottomHeight-7});
|
176
|
-
setDimensions(this._neHandle, {right:leftRightWidth-handleOffset, top:topBottomHeight-7});
|
177
|
-
setDimensions(this._swHandle, {left:leftRightWidth-handleOffset, bottom:topBottomHeight-7});
|
178
|
-
setDimensions(this._seHandle, {right:leftRightWidth-handleOffset, bottom:topBottomHeight-7});
|
179
|
-
}
|
180
|
-
});
|
181
|
-
|
182
|
-
L.areaSelect = function(options) {
|
183
|
-
return new L.AreaSelect(options);
|
184
|
-
}
|