@nextgis/control-container
Advanced tools
Comparing version 1.0.0-alpha.6 to 1.0.0-alpha.7
@@ -6,2 +6,10 @@ # Change Log | ||
# [1.0.0-alpha.7](https://github.com/nextgis/nextgis_frontend/compare/v1.0.0-alpha.6...v1.0.0-alpha.7) (2020-09-22) | ||
**Note:** Version bump only for package @nextgis/control-container | ||
# [1.0.0-alpha.6](https://github.com/nextgis/nextgis_frontend/compare/v1.0.0-alpha.5...v1.0.0-alpha.6) (2020-09-09) | ||
@@ -8,0 +16,0 @@ |
@@ -0,3 +1,4 @@ | ||
/** Bundle of @nextgis/control-container; version: 1.0.0-alpha.7; author: NextGIS */ | ||
function create(tagName, className, container) { | ||
var el = window.document.createElement(tagName); | ||
const el = window.document.createElement(tagName); | ||
if (className !== undefined && className !== null) { | ||
@@ -23,3 +24,3 @@ el.className = className; | ||
if (typeof el === 'string') { | ||
var el_ = document.getElementById(el); | ||
let el_ = document.getElementById(el); | ||
if (!el_) { | ||
@@ -29,3 +30,3 @@ try { | ||
} | ||
catch (_a) { | ||
catch { | ||
// ignore | ||
@@ -39,7 +40,7 @@ } | ||
function remove(element) { | ||
var el = getElement(element); | ||
const el = getElement(element); | ||
if (el) { | ||
var parent_1 = el.parentElement; | ||
if (parent_1) { | ||
parent_1.removeChild(el); | ||
const parent = el.parentElement; | ||
if (parent) { | ||
parent.removeChild(el); | ||
} | ||
@@ -49,6 +50,4 @@ } | ||
var ZoomControl = /** @class */ (function () { | ||
function ZoomControl() { | ||
} | ||
ZoomControl.prototype.onAdd = function (map) { | ||
class ZoomControl { | ||
onAdd(map) { | ||
if (!this.map) { | ||
@@ -58,3 +57,3 @@ this.map = map; | ||
if (!this._container) { | ||
var container = create('div', 'webmap-ctrl webmap-ctrl-group'); | ||
const container = create('div', 'webmap-ctrl webmap-ctrl-group'); | ||
this._container = container; | ||
@@ -64,4 +63,4 @@ this._createContent(); | ||
return this._container; | ||
}; | ||
ZoomControl.prototype.onRemove = function () { | ||
} | ||
onRemove() { | ||
this.map = undefined; | ||
@@ -71,4 +70,4 @@ if (this._container) { | ||
} | ||
}; | ||
ZoomControl.prototype.zoomIn = function () { | ||
} | ||
zoomIn() { | ||
if (this.map) { | ||
@@ -79,5 +78,5 @@ if (this.map.zoomIn) { | ||
else { | ||
var zoom = this.map.getZoom(); | ||
const zoom = this.map.getZoom(); | ||
if (zoom) { | ||
var toZoom = zoom + 1; | ||
const toZoom = zoom + 1; | ||
this.map.setZoom(toZoom); | ||
@@ -87,4 +86,4 @@ } | ||
} | ||
}; | ||
ZoomControl.prototype.zoomOut = function () { | ||
} | ||
zoomOut() { | ||
if (this.map) { | ||
@@ -95,5 +94,5 @@ if (this.map.zoomOut) { | ||
else { | ||
var zoom = this.map.getZoom(); | ||
const zoom = this.map.getZoom(); | ||
if (zoom) { | ||
var toZoom = zoom - 1; | ||
const toZoom = zoom - 1; | ||
this.map.setZoom(toZoom); | ||
@@ -103,26 +102,24 @@ } | ||
} | ||
}; | ||
ZoomControl.prototype._createContent = function () { | ||
var _this = this; | ||
} | ||
_createContent() { | ||
if (this._container) { | ||
var zoomInBtn = create('button', 'webmap-ctrl-zoom-in', this._container); | ||
const zoomInBtn = create('button', 'webmap-ctrl-zoom-in', this._container); | ||
zoomInBtn.innerHTML = | ||
'<span class="webmap-ctrl-icon" aria-hidden="true"></span>'; | ||
var zoomOutBtn = create('button', 'webmap-ctrl-zoom-out', this._container); | ||
const zoomOutBtn = create('button', 'webmap-ctrl-zoom-out', this._container); | ||
zoomOutBtn.innerHTML = | ||
'<span class="webmap-ctrl-icon" aria-hidden="true"></span>'; | ||
this.__onZoomInBtnClick = function () { return _this._onZoomInBtnClick(); }; | ||
this.__onZoomInBtnClick = () => this._onZoomInBtnClick(); | ||
zoomInBtn.addEventListener('click', this.__onZoomInBtnClick); | ||
this.__onZoomOutBtnClick = function () { return _this._onZoomOutBtnClick(); }; | ||
this.__onZoomOutBtnClick = () => this._onZoomOutBtnClick(); | ||
zoomOutBtn.addEventListener('click', this.__onZoomOutBtnClick); | ||
} | ||
}; | ||
ZoomControl.prototype._onZoomInBtnClick = function () { | ||
} | ||
_onZoomInBtnClick() { | ||
this.zoomIn(); | ||
}; | ||
ZoomControl.prototype._onZoomOutBtnClick = function () { | ||
} | ||
_onZoomOutBtnClick() { | ||
this.zoomOut(); | ||
}; | ||
return ZoomControl; | ||
}()); | ||
} | ||
} | ||
@@ -132,5 +129,4 @@ /** | ||
*/ | ||
var ControlContainer = /** @class */ (function () { | ||
function ControlContainer(opt) { | ||
if (opt === void 0) { opt = {}; } | ||
class ControlContainer { | ||
constructor(opt = {}) { | ||
this.classPrefix = 'webmap'; | ||
@@ -148,4 +144,4 @@ this._positionsContainers = { | ||
} | ||
ControlContainer.prototype.addTo = function (el) { | ||
var el_ = getElement(el); | ||
addTo(el) { | ||
const el_ = getElement(el); | ||
if (el_) { | ||
@@ -155,22 +151,22 @@ el_.appendChild(this._container); | ||
return this; | ||
}; | ||
ControlContainer.prototype.detach = function () { | ||
var parent = this._container.parentElement; | ||
} | ||
detach() { | ||
const parent = this._container.parentElement; | ||
if (parent) { | ||
parent.removeChild(this._container); | ||
} | ||
}; | ||
ControlContainer.prototype.getContainer = function () { | ||
} | ||
getContainer() { | ||
return this._container; | ||
}; | ||
ControlContainer.prototype.getPositionContainer = function (position) { | ||
var positionContainer = this._positionsContainers[position]; | ||
} | ||
getPositionContainer(position) { | ||
const positionContainer = this._positionsContainers[position]; | ||
if (positionContainer) { | ||
return positionContainer; | ||
} | ||
}; | ||
ControlContainer.prototype.newPositionContainer = function (position) { | ||
var positionContainer = this.getPositionContainer(position); | ||
} | ||
newPositionContainer(position) { | ||
const positionContainer = this.getPositionContainer(position); | ||
if (positionContainer) { | ||
var newContainer = document.createElement('div'); | ||
const newContainer = document.createElement('div'); | ||
newContainer.className = 'openlayers-ctrl'; | ||
@@ -187,14 +183,14 @@ // reserve place for async loaded containers | ||
} | ||
}; | ||
ControlContainer.prototype.addControl = function (control, position) { | ||
var controlContainer = control.onAdd(this.map); | ||
} | ||
addControl(control, position) { | ||
const controlContainer = control.onAdd(this.map); | ||
if (controlContainer instanceof HTMLElement) { | ||
this.append(controlContainer, position); | ||
} | ||
}; | ||
ControlContainer.prototype.append = function (element, position) { | ||
var positionContainer = this._positionsContainers[position]; | ||
} | ||
append(element, position) { | ||
const positionContainer = this._positionsContainers[position]; | ||
if (positionContainer) { | ||
if (typeof element === 'string') { | ||
var el = document.createElement('div'); | ||
const el = document.createElement('div'); | ||
el.outerHTML = element; | ||
@@ -205,10 +201,9 @@ element = el; | ||
} | ||
}; | ||
ControlContainer.prototype.createContainerElement = function () { | ||
var _this = this; | ||
var element = document.createElement('div'); | ||
} | ||
createContainerElement() { | ||
const element = document.createElement('div'); | ||
element.className = | ||
this.classPrefix + "-control-container" + | ||
`${this.classPrefix}-control-container` + | ||
(this.addClass ? ' ' + this.addClass : ''); | ||
var positions = [ | ||
const positions = [ | ||
'top-right', | ||
@@ -219,20 +214,19 @@ 'top-left', | ||
]; | ||
positions.forEach(function (x) { | ||
var positionContainer = _this._createPositionContainer(x); | ||
_this._positionsContainers[x] = positionContainer; | ||
positions.forEach((x) => { | ||
const positionContainer = this._createPositionContainer(x); | ||
this._positionsContainers[x] = positionContainer; | ||
element.appendChild(positionContainer); | ||
}); | ||
return element; | ||
}; | ||
ControlContainer.prototype._createPositionContainer = function (position) { | ||
var positionContainer = document.createElement('div'); | ||
positionContainer.className = this.classPrefix + "-ctrl-" + position; | ||
} | ||
_createPositionContainer(position) { | ||
const positionContainer = document.createElement('div'); | ||
positionContainer.className = `${this.classPrefix}-ctrl-${position}`; | ||
return positionContainer; | ||
}; | ||
ControlContainer.controls = { | ||
ZOOM: ZoomControl, | ||
}; | ||
return ControlContainer; | ||
}()); | ||
} | ||
} | ||
ControlContainer.controls = { | ||
ZOOM: ZoomControl, | ||
}; | ||
export default ControlContainer; |
@@ -1,1 +0,1 @@ | ||
function t(t,n,o){var i=window.document.createElement(t);return null!=n&&(i.className=n),o&&o.appendChild(i),i}function n(t){if("string"==typeof t){var n=document.getElementById(t);if(!n)try{n=document.querySelector(t)}catch(t){}return n||void 0}return t}var o=function(){function o(){}return o.prototype.onAdd=function(n){if(this.map||(this.map=n),!this._container){var o=t("div","webmap-ctrl webmap-ctrl-group");this._container=o,this._createContent()}return this._container},o.prototype.onRemove=function(){this.map=void 0,this._container&&function(t){var o=n(t);if(o){var i=o.parentElement;i&&i.removeChild(o)}}(this._container)},o.prototype.zoomIn=function(){if(this.map)if(this.map.zoomIn)this.map.zoomIn();else{var t=this.map.getZoom();if(t)this.map.setZoom(t+1)}},o.prototype.zoomOut=function(){if(this.map)if(this.map.zoomOut)this.map.zoomOut();else{var t=this.map.getZoom();if(t)this.map.setZoom(t-1)}},o.prototype._createContent=function(){var n=this;if(this._container){var o=t("button","webmap-ctrl-zoom-in",this._container);o.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>';var i=t("button","webmap-ctrl-zoom-out",this._container);i.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>',this.__onZoomInBtnClick=function(){return n._onZoomInBtnClick()},o.addEventListener("click",this.__onZoomInBtnClick),this.__onZoomOutBtnClick=function(){return n._onZoomOutBtnClick()},i.addEventListener("click",this.__onZoomOutBtnClick)}},o.prototype._onZoomInBtnClick=function(){this.zoomIn()},o.prototype._onZoomOutBtnClick=function(){this.zoomOut()},o}(),i=function(){function t(t){void 0===t&&(t={}),this.classPrefix="webmap",this._positionsContainers={"bottom-left":null,"bottom-right":null,"top-left":null,"top-right":null},this.classPrefix=t.classPrefix||this.classPrefix,this.addClass=t.addClass,this.map=t.map,this._container=this.createContainerElement()}return t.prototype.addTo=function(t){var o=n(t);return o&&o.appendChild(this._container),this},t.prototype.detach=function(){var t=this._container.parentElement;t&&t.removeChild(this._container)},t.prototype.getContainer=function(){return this._container},t.prototype.getPositionContainer=function(t){var n=this._positionsContainers[t];if(n)return n},t.prototype.newPositionContainer=function(t){var n=this.getPositionContainer(t);if(n){var o=document.createElement("div");return o.className="openlayers-ctrl",-1!==t.indexOf("bottom")&&n.childElementCount?n.insertBefore(o,n.firstChild):n.appendChild(o),o}},t.prototype.addControl=function(t,n){var o=t.onAdd(this.map);o instanceof HTMLElement&&this.append(o,n)},t.prototype.append=function(t,n){var o=this._positionsContainers[n];if(o){if("string"==typeof t){var i=document.createElement("div");i.outerHTML=t,t=i}o.appendChild(t)}},t.prototype.createContainerElement=function(){var t=this,n=document.createElement("div");n.className=this.classPrefix+"-control-container"+(this.addClass?" "+this.addClass:"");return["top-right","top-left","bottom-right","bottom-left"].forEach((function(o){var i=t._createPositionContainer(o);t._positionsContainers[o]=i,n.appendChild(i)})),n},t.prototype._createPositionContainer=function(t){var n=document.createElement("div");return n.className=this.classPrefix+"-ctrl-"+t,n},t.controls={ZOOM:o},t}();export default i; | ||
function t(t,n,o){const i=window.document.createElement(t);return null!=n&&(i.className=n),o&&o.appendChild(i),i}function n(t){if("string"==typeof t){let n=document.getElementById(t);if(!n)try{n=document.querySelector(t)}catch{}return n||void 0}return t}class o{constructor(t={}){this.classPrefix="webmap",this._positionsContainers={"bottom-left":null,"bottom-right":null,"top-left":null,"top-right":null},this.classPrefix=t.classPrefix||this.classPrefix,this.addClass=t.addClass,this.map=t.map,this._container=this.createContainerElement()}addTo(t){const o=n(t);return o&&o.appendChild(this._container),this}detach(){const t=this._container.parentElement;t&&t.removeChild(this._container)}getContainer(){return this._container}getPositionContainer(t){const n=this._positionsContainers[t];if(n)return n}newPositionContainer(t){const n=this.getPositionContainer(t);if(n){const o=document.createElement("div");return o.className="openlayers-ctrl",-1!==t.indexOf("bottom")&&n.childElementCount?n.insertBefore(o,n.firstChild):n.appendChild(o),o}}addControl(t,n){const o=t.onAdd(this.map);o instanceof HTMLElement&&this.append(o,n)}append(t,n){const o=this._positionsContainers[n];if(o){if("string"==typeof t){const n=document.createElement("div");n.outerHTML=t,t=n}o.appendChild(t)}}createContainerElement(){const t=document.createElement("div");t.className=this.classPrefix+"-control-container"+(this.addClass?" "+this.addClass:"");return["top-right","top-left","bottom-right","bottom-left"].forEach(n=>{const o=this._createPositionContainer(n);this._positionsContainers[n]=o,t.appendChild(o)}),t}_createPositionContainer(t){const n=document.createElement("div");return n.className=`${this.classPrefix}-ctrl-${t}`,n}}o.controls={ZOOM:class{onAdd(n){if(this.map||(this.map=n),!this._container){const n=t("div","webmap-ctrl webmap-ctrl-group");this._container=n,this._createContent()}return this._container}onRemove(){this.map=void 0,this._container&&function(t){const o=n(t);if(o){const t=o.parentElement;t&&t.removeChild(o)}}(this._container)}zoomIn(){if(this.map)if(this.map.zoomIn)this.map.zoomIn();else{const t=this.map.getZoom();if(t){this.map.setZoom(t+1)}}}zoomOut(){if(this.map)if(this.map.zoomOut)this.map.zoomOut();else{const t=this.map.getZoom();if(t){this.map.setZoom(t-1)}}}_createContent(){if(this._container){const n=t("button","webmap-ctrl-zoom-in",this._container);n.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>';const o=t("button","webmap-ctrl-zoom-out",this._container);o.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>',this.__onZoomInBtnClick=()=>this._onZoomInBtnClick(),n.addEventListener("click",this.__onZoomInBtnClick),this.__onZoomOutBtnClick=()=>this._onZoomOutBtnClick(),o.addEventListener("click",this.__onZoomOutBtnClick)}}_onZoomInBtnClick(){this.zoomIn()}_onZoomOutBtnClick(){this.zoomOut()}}};export default o; |
@@ -0,7 +1,6 @@ | ||
/** Bundle of @nextgis/control-container; version: 1.0.0-alpha.7; author: NextGIS */ | ||
import { create, remove, getElement } from '@nextgis/dom'; | ||
var ZoomControl = /** @class */ (function () { | ||
function ZoomControl() { | ||
} | ||
ZoomControl.prototype.onAdd = function (map) { | ||
class ZoomControl { | ||
onAdd(map) { | ||
if (!this.map) { | ||
@@ -11,3 +10,3 @@ this.map = map; | ||
if (!this._container) { | ||
var container = create('div', 'webmap-ctrl webmap-ctrl-group'); | ||
const container = create('div', 'webmap-ctrl webmap-ctrl-group'); | ||
this._container = container; | ||
@@ -17,4 +16,4 @@ this._createContent(); | ||
return this._container; | ||
}; | ||
ZoomControl.prototype.onRemove = function () { | ||
} | ||
onRemove() { | ||
this.map = undefined; | ||
@@ -24,4 +23,4 @@ if (this._container) { | ||
} | ||
}; | ||
ZoomControl.prototype.zoomIn = function () { | ||
} | ||
zoomIn() { | ||
if (this.map) { | ||
@@ -32,5 +31,5 @@ if (this.map.zoomIn) { | ||
else { | ||
var zoom = this.map.getZoom(); | ||
const zoom = this.map.getZoom(); | ||
if (zoom) { | ||
var toZoom = zoom + 1; | ||
const toZoom = zoom + 1; | ||
this.map.setZoom(toZoom); | ||
@@ -40,4 +39,4 @@ } | ||
} | ||
}; | ||
ZoomControl.prototype.zoomOut = function () { | ||
} | ||
zoomOut() { | ||
if (this.map) { | ||
@@ -48,5 +47,5 @@ if (this.map.zoomOut) { | ||
else { | ||
var zoom = this.map.getZoom(); | ||
const zoom = this.map.getZoom(); | ||
if (zoom) { | ||
var toZoom = zoom - 1; | ||
const toZoom = zoom - 1; | ||
this.map.setZoom(toZoom); | ||
@@ -56,26 +55,24 @@ } | ||
} | ||
}; | ||
ZoomControl.prototype._createContent = function () { | ||
var _this = this; | ||
} | ||
_createContent() { | ||
if (this._container) { | ||
var zoomInBtn = create('button', 'webmap-ctrl-zoom-in', this._container); | ||
const zoomInBtn = create('button', 'webmap-ctrl-zoom-in', this._container); | ||
zoomInBtn.innerHTML = | ||
'<span class="webmap-ctrl-icon" aria-hidden="true"></span>'; | ||
var zoomOutBtn = create('button', 'webmap-ctrl-zoom-out', this._container); | ||
const zoomOutBtn = create('button', 'webmap-ctrl-zoom-out', this._container); | ||
zoomOutBtn.innerHTML = | ||
'<span class="webmap-ctrl-icon" aria-hidden="true"></span>'; | ||
this.__onZoomInBtnClick = function () { return _this._onZoomInBtnClick(); }; | ||
this.__onZoomInBtnClick = () => this._onZoomInBtnClick(); | ||
zoomInBtn.addEventListener('click', this.__onZoomInBtnClick); | ||
this.__onZoomOutBtnClick = function () { return _this._onZoomOutBtnClick(); }; | ||
this.__onZoomOutBtnClick = () => this._onZoomOutBtnClick(); | ||
zoomOutBtn.addEventListener('click', this.__onZoomOutBtnClick); | ||
} | ||
}; | ||
ZoomControl.prototype._onZoomInBtnClick = function () { | ||
} | ||
_onZoomInBtnClick() { | ||
this.zoomIn(); | ||
}; | ||
ZoomControl.prototype._onZoomOutBtnClick = function () { | ||
} | ||
_onZoomOutBtnClick() { | ||
this.zoomOut(); | ||
}; | ||
return ZoomControl; | ||
}()); | ||
} | ||
} | ||
@@ -85,5 +82,4 @@ /** | ||
*/ | ||
var ControlContainer = /** @class */ (function () { | ||
function ControlContainer(opt) { | ||
if (opt === void 0) { opt = {}; } | ||
class ControlContainer { | ||
constructor(opt = {}) { | ||
this.classPrefix = 'webmap'; | ||
@@ -101,4 +97,4 @@ this._positionsContainers = { | ||
} | ||
ControlContainer.prototype.addTo = function (el) { | ||
var el_ = getElement(el); | ||
addTo(el) { | ||
const el_ = getElement(el); | ||
if (el_) { | ||
@@ -108,22 +104,22 @@ el_.appendChild(this._container); | ||
return this; | ||
}; | ||
ControlContainer.prototype.detach = function () { | ||
var parent = this._container.parentElement; | ||
} | ||
detach() { | ||
const parent = this._container.parentElement; | ||
if (parent) { | ||
parent.removeChild(this._container); | ||
} | ||
}; | ||
ControlContainer.prototype.getContainer = function () { | ||
} | ||
getContainer() { | ||
return this._container; | ||
}; | ||
ControlContainer.prototype.getPositionContainer = function (position) { | ||
var positionContainer = this._positionsContainers[position]; | ||
} | ||
getPositionContainer(position) { | ||
const positionContainer = this._positionsContainers[position]; | ||
if (positionContainer) { | ||
return positionContainer; | ||
} | ||
}; | ||
ControlContainer.prototype.newPositionContainer = function (position) { | ||
var positionContainer = this.getPositionContainer(position); | ||
} | ||
newPositionContainer(position) { | ||
const positionContainer = this.getPositionContainer(position); | ||
if (positionContainer) { | ||
var newContainer = document.createElement('div'); | ||
const newContainer = document.createElement('div'); | ||
newContainer.className = 'openlayers-ctrl'; | ||
@@ -140,14 +136,14 @@ // reserve place for async loaded containers | ||
} | ||
}; | ||
ControlContainer.prototype.addControl = function (control, position) { | ||
var controlContainer = control.onAdd(this.map); | ||
} | ||
addControl(control, position) { | ||
const controlContainer = control.onAdd(this.map); | ||
if (controlContainer instanceof HTMLElement) { | ||
this.append(controlContainer, position); | ||
} | ||
}; | ||
ControlContainer.prototype.append = function (element, position) { | ||
var positionContainer = this._positionsContainers[position]; | ||
} | ||
append(element, position) { | ||
const positionContainer = this._positionsContainers[position]; | ||
if (positionContainer) { | ||
if (typeof element === 'string') { | ||
var el = document.createElement('div'); | ||
const el = document.createElement('div'); | ||
el.outerHTML = element; | ||
@@ -158,10 +154,9 @@ element = el; | ||
} | ||
}; | ||
ControlContainer.prototype.createContainerElement = function () { | ||
var _this = this; | ||
var element = document.createElement('div'); | ||
} | ||
createContainerElement() { | ||
const element = document.createElement('div'); | ||
element.className = | ||
this.classPrefix + "-control-container" + | ||
`${this.classPrefix}-control-container` + | ||
(this.addClass ? ' ' + this.addClass : ''); | ||
var positions = [ | ||
const positions = [ | ||
'top-right', | ||
@@ -172,20 +167,19 @@ 'top-left', | ||
]; | ||
positions.forEach(function (x) { | ||
var positionContainer = _this._createPositionContainer(x); | ||
_this._positionsContainers[x] = positionContainer; | ||
positions.forEach((x) => { | ||
const positionContainer = this._createPositionContainer(x); | ||
this._positionsContainers[x] = positionContainer; | ||
element.appendChild(positionContainer); | ||
}); | ||
return element; | ||
}; | ||
ControlContainer.prototype._createPositionContainer = function (position) { | ||
var positionContainer = document.createElement('div'); | ||
positionContainer.className = this.classPrefix + "-ctrl-" + position; | ||
} | ||
_createPositionContainer(position) { | ||
const positionContainer = document.createElement('div'); | ||
positionContainer.className = `${this.classPrefix}-ctrl-${position}`; | ||
return positionContainer; | ||
}; | ||
ControlContainer.controls = { | ||
ZOOM: ZoomControl, | ||
}; | ||
return ControlContainer; | ||
}()); | ||
} | ||
} | ||
ControlContainer.controls = { | ||
ZOOM: ZoomControl, | ||
}; | ||
export default ControlContainer; |
@@ -1,1 +0,1 @@ | ||
import{create as t,remove as n,getElement as o}from"@nextgis/dom";var i=function(){function o(){}return o.prototype.onAdd=function(n){if(this.map||(this.map=n),!this._container){var o=t("div","webmap-ctrl webmap-ctrl-group");this._container=o,this._createContent()}return this._container},o.prototype.onRemove=function(){this.map=void 0,this._container&&n(this._container)},o.prototype.zoomIn=function(){if(this.map)if(this.map.zoomIn)this.map.zoomIn();else{var t=this.map.getZoom();if(t)this.map.setZoom(t+1)}},o.prototype.zoomOut=function(){if(this.map)if(this.map.zoomOut)this.map.zoomOut();else{var t=this.map.getZoom();if(t)this.map.setZoom(t-1)}},o.prototype._createContent=function(){var n=this;if(this._container){var o=t("button","webmap-ctrl-zoom-in",this._container);o.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>';var i=t("button","webmap-ctrl-zoom-out",this._container);i.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>',this.__onZoomInBtnClick=function(){return n._onZoomInBtnClick()},o.addEventListener("click",this.__onZoomInBtnClick),this.__onZoomOutBtnClick=function(){return n._onZoomOutBtnClick()},i.addEventListener("click",this.__onZoomOutBtnClick)}},o.prototype._onZoomInBtnClick=function(){this.zoomIn()},o.prototype._onZoomOutBtnClick=function(){this.zoomOut()},o}(),e=function(){function t(t){void 0===t&&(t={}),this.classPrefix="webmap",this._positionsContainers={"bottom-left":null,"bottom-right":null,"top-left":null,"top-right":null},this.classPrefix=t.classPrefix||this.classPrefix,this.addClass=t.addClass,this.map=t.map,this._container=this.createContainerElement()}return t.prototype.addTo=function(t){var n=o(t);return n&&n.appendChild(this._container),this},t.prototype.detach=function(){var t=this._container.parentElement;t&&t.removeChild(this._container)},t.prototype.getContainer=function(){return this._container},t.prototype.getPositionContainer=function(t){var n=this._positionsContainers[t];if(n)return n},t.prototype.newPositionContainer=function(t){var n=this.getPositionContainer(t);if(n){var o=document.createElement("div");return o.className="openlayers-ctrl",-1!==t.indexOf("bottom")&&n.childElementCount?n.insertBefore(o,n.firstChild):n.appendChild(o),o}},t.prototype.addControl=function(t,n){var o=t.onAdd(this.map);o instanceof HTMLElement&&this.append(o,n)},t.prototype.append=function(t,n){var o=this._positionsContainers[n];if(o){if("string"==typeof t){var i=document.createElement("div");i.outerHTML=t,t=i}o.appendChild(t)}},t.prototype.createContainerElement=function(){var t=this,n=document.createElement("div");n.className=this.classPrefix+"-control-container"+(this.addClass?" "+this.addClass:"");return["top-right","top-left","bottom-right","bottom-left"].forEach((function(o){var i=t._createPositionContainer(o);t._positionsContainers[o]=i,n.appendChild(i)})),n},t.prototype._createPositionContainer=function(t){var n=document.createElement("div");return n.className=this.classPrefix+"-ctrl-"+t,n},t.controls={ZOOM:i},t}();export default e; | ||
import{create as t,remove as n,getElement as o}from"@nextgis/dom";class i{constructor(t={}){this.classPrefix="webmap",this._positionsContainers={"bottom-left":null,"bottom-right":null,"top-left":null,"top-right":null},this.classPrefix=t.classPrefix||this.classPrefix,this.addClass=t.addClass,this.map=t.map,this._container=this.createContainerElement()}addTo(t){const n=o(t);return n&&n.appendChild(this._container),this}detach(){const t=this._container.parentElement;t&&t.removeChild(this._container)}getContainer(){return this._container}getPositionContainer(t){const n=this._positionsContainers[t];if(n)return n}newPositionContainer(t){const n=this.getPositionContainer(t);if(n){const o=document.createElement("div");return o.className="openlayers-ctrl",-1!==t.indexOf("bottom")&&n.childElementCount?n.insertBefore(o,n.firstChild):n.appendChild(o),o}}addControl(t,n){const o=t.onAdd(this.map);o instanceof HTMLElement&&this.append(o,n)}append(t,n){const o=this._positionsContainers[n];if(o){if("string"==typeof t){const n=document.createElement("div");n.outerHTML=t,t=n}o.appendChild(t)}}createContainerElement(){const t=document.createElement("div");t.className=this.classPrefix+"-control-container"+(this.addClass?" "+this.addClass:"");return["top-right","top-left","bottom-right","bottom-left"].forEach(n=>{const o=this._createPositionContainer(n);this._positionsContainers[n]=o,t.appendChild(o)}),t}_createPositionContainer(t){const n=document.createElement("div");return n.className=`${this.classPrefix}-ctrl-${t}`,n}}i.controls={ZOOM:class{onAdd(n){if(this.map||(this.map=n),!this._container){const n=t("div","webmap-ctrl webmap-ctrl-group");this._container=n,this._createContent()}return this._container}onRemove(){this.map=void 0,this._container&&n(this._container)}zoomIn(){if(this.map)if(this.map.zoomIn)this.map.zoomIn();else{const t=this.map.getZoom();if(t){this.map.setZoom(t+1)}}}zoomOut(){if(this.map)if(this.map.zoomOut)this.map.zoomOut();else{const t=this.map.getZoom();if(t){this.map.setZoom(t-1)}}}_createContent(){if(this._container){const n=t("button","webmap-ctrl-zoom-in",this._container);n.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>';const o=t("button","webmap-ctrl-zoom-out",this._container);o.innerHTML='<span class="webmap-ctrl-icon" aria-hidden="true"></span>',this.__onZoomInBtnClick=()=>this._onZoomInBtnClick(),n.addEventListener("click",this.__onZoomInBtnClick),this.__onZoomOutBtnClick=()=>this._onZoomOutBtnClick(),o.addEventListener("click",this.__onZoomOutBtnClick)}}_onZoomInBtnClick(){this.zoomIn()}_onZoomOutBtnClick(){this.zoomOut()}}};export default i; |
@@ -0,1 +1,2 @@ | ||
/** Bundle of @nextgis/control-container; version: 1.0.0-alpha.7; author: NextGIS */ | ||
var ControlContainer = (function () { | ||
@@ -2,0 +3,0 @@ 'use strict'; |
{ | ||
"name": "@nextgis/control-container", | ||
"version": "1.0.0-alpha.6", | ||
"version": "1.0.0-alpha.7", | ||
"description": "Placing control elements in the corners of the map container", | ||
@@ -11,11 +11,11 @@ "main": "lib/control-container.global.prod.js", | ||
"dependencies": { | ||
"@nextgis/dom": "^1.0.0-alpha.6", | ||
"@nextgis/utils": "^1.0.0-alpha.6", | ||
"@nextgis/webmap": "^1.0.0-alpha.6", | ||
"@nextgis/dom": "^1.0.0-alpha.7", | ||
"@nextgis/utils": "^1.0.0-alpha.7", | ||
"@nextgis/webmap": "^1.0.0-alpha.7", | ||
"events": "^3.2.0" | ||
}, | ||
"devDependencies": { | ||
"@nextgis/build-tools": "^1.0.0-alpha.6", | ||
"@nextgis/build-tools": "^1.0.0-alpha.7", | ||
"install": "^0.13.0", | ||
"mini-css-extract-plugin": "^0.11.1", | ||
"mini-css-extract-plugin": "^0.11.2", | ||
"npm": "^6.14.8" | ||
@@ -56,3 +56,3 @@ }, | ||
}, | ||
"gitHead": "09398fcf869301e8d6628120e54256f17805bdf6" | ||
"gitHead": "d90c7d5a2bc01143221e8ec768ab5d0467fb5530" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
78679
663