Skip to content

Commit

Permalink
[BUILD] + lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Viglino committed Mar 21, 2024
1 parent 58c781e commit ff263ab
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 21 deletions.
74 changes: 63 additions & 11 deletions dist/ol-ext.js
Original file line number Diff line number Diff line change
Expand Up @@ -13126,6 +13126,7 @@ ol.control.PrintDialog = class olcontrolPrintDialog extends ol.control.Control {
parent: li
})
ol.ext.element.create('OPTION', {
html: this.i18n('saveas'),
style: { display: 'none' },
value: '',
parent: save
Expand Down Expand Up @@ -13770,7 +13771,39 @@ ol.control.PrintDialog2x = class olcontrolPrintDialog2x extends ol.control.Print
printCtrl2.on(['print', 'error', 'printing'], function (e) {
if (e.type === 'print') {
var canvas = document.createElement('canvas');
if (this.getOrientation() === 'landscape') {
// Get clipping (ol/control/SwipeMap or ol/control/ClipMap)
var clipDiv = printMap.querySelector('.ol-layers');
var clip = clipDiv.style.clipPath || clipDiv.style.clip
// Print in canvas
if (clip) {
var param = clip.replace(/^(.*)\((.*)\)/, '$2');
clip = {
type: clip.replace(/^(.*)\(.*/, '$1'),
}
switch(clip.type) {
case 'circle': {
param = param.split(' ')
clip.radius = parseFloat(param[0]);
clip.x = parseFloat(param[2]);
clip.y = parseFloat(param[3]);
break;
}
case 'rect': {
param = param.split(',')
clip.top = parseFloat(param[0]);
clip.right = parseFloat(param[1]);
clip.bottom = parseFloat(param[2]);
clip.left = parseFloat(param[3]);
break;
}
default: {
console.warn('no clip (' + clip.type + ')')
break;
}
}
canvas.width = this._canvas1.width;
canvas.height = this._canvas1.height;
} else if (this.getOrientation() === 'landscape') {
canvas.width = this._canvas1.width + e.canvas.width;
canvas.height = this._canvas1.height;
} else {
Expand All @@ -13779,10 +13812,29 @@ ol.control.PrintDialog2x = class olcontrolPrintDialog2x extends ol.control.Print
}
var ctx = canvas.getContext('2d');
ctx.drawImage(this._canvas1, 0, 0);
ctx.drawImage(e.canvas,
(this.getOrientation() === 'landscape' ? this._canvas1.width : 0),
(this.getOrientation() !== 'landscape' ? this._canvas1.height : 0),
);
if (clip) {
ctx.save()
switch (clip.type) {
case 'rect': {
ctx.beginPath();
ctx.rect(clip.left, clip.top, clip.right - clip.left, clip.bottom - clip.top)
break;
}
case 'circle': {
ctx.beginPath();
ctx.arc(clip.x, clip.y, clip.radius, 0, Math.PI * 2);
break;
}
}
ctx.clip()
ctx.drawImage(e.canvas, 0, 0);
ctx.restore()
} else {
ctx.drawImage(e.canvas,
(this.getOrientation() === 'landscape' ? this._canvas1.width : 0),
(this.getOrientation() !== 'landscape' ? this._canvas1.height : 0)
);
}
e.canvas = canvas;
e.image = canvas.toDataURL(e.imageType, e.quality);
var w = canvas.width / 96 * 25.4
Expand Down Expand Up @@ -13896,7 +13948,7 @@ ol.control.PrintDialog2x = class olcontrolPrintDialog2x extends ol.control.Print
/** Prevent first copy
* @private
*/
_copyMap(format) {
_copyMap(/* format */) {
/* prevent first copy */
return false
}
Expand Down Expand Up @@ -29819,11 +29871,11 @@ ol.interaction.Transform = class olinteractionTransform extends ol.interaction.P
super.setActive(b)
}
/** Set default sketch style
* @param {Object|undefined} options
* @param {ol.style.Stroke} stroke stroke style for selection rectangle
* @param {ol.style.Fill} fill fill style for selection rectangle
* @param {ol.style.Stroke} pointStroke stroke style for handles
* @param {ol.style.Fill} pointFill fill style for handles
* @param {Object} [options]
* @param {ol.style.Stroke} [stroke] stroke style for selection rectangle, default red dash
* @param {ol.style.Fill} [fill] fill style for selection rectangle, default red
* @param {ol.style.Stroke} [pointStroke] stroke style for handles, default red
* @param {ol.style.Fill} [pointFill] fill style for handles, default white
*/
setDefaultStyle(options) {
options = options || {}
Expand Down
2 changes: 1 addition & 1 deletion dist/ol-ext.min.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/control/PrintDialog2x.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ var ol_control_PrintDialog2x = class olcontrolPrintDialog2x extends ol_control_P
}
switch(clip.type) {
case 'circle': {
var param = param.split(' ')
param = param.split(' ')
clip.radius = parseFloat(param[0]);
clip.x = parseFloat(param[2]);
clip.y = parseFloat(param[3]);
break;
}
case 'rect': {
var param = param.split(',')
param = param.split(',')
clip.top = parseFloat(param[0]);
clip.right = parseFloat(param[1]);
clip.bottom = parseFloat(param[2]);
Expand Down Expand Up @@ -89,7 +89,7 @@ var ol_control_PrintDialog2x = class olcontrolPrintDialog2x extends ol_control_P
} else {
ctx.drawImage(e.canvas,
(this.getOrientation() === 'landscape' ? this._canvas1.width : 0),
(this.getOrientation() !== 'landscape' ? this._canvas1.height : 0),
(this.getOrientation() !== 'landscape' ? this._canvas1.height : 0)
);
}
e.canvas = canvas;
Expand Down Expand Up @@ -208,7 +208,7 @@ var ol_control_PrintDialog2x = class olcontrolPrintDialog2x extends ol_control_P
/** Prevent first copy
* @private
*/
_copyMap(format) {
_copyMap(/* format */) {
/* prevent first copy */
return false
}
Expand Down
10 changes: 5 additions & 5 deletions src/interaction/Transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ var ol_interaction_Transform = class olinteractionTransform extends ol_interacti
super.setActive(b)
}
/** Set default sketch style
* @param {Object|undefined} options
* @param {ol_style_Stroke} stroke stroke style for selection rectangle
* @param {ol_style_Fill} fill fill style for selection rectangle
* @param {ol_style_Stroke} pointStroke stroke style for handles
* @param {ol_style_Fill} pointFill fill style for handles
* @param {Object} [options]
* @param {ol_style_Stroke} [stroke] stroke style for selection rectangle, default red dash
* @param {ol_style_Fill} [fill] fill style for selection rectangle, default red
* @param {ol_style_Stroke} [pointStroke] stroke style for handles, default red
* @param {ol_style_Fill} [pointFill] fill style for handles, default white
*/
setDefaultStyle(options) {
options = options || {}
Expand Down

0 comments on commit ff263ab

Please sign in to comment.