silverstripe-mapboxfield/client/src/bundles/bundle.js

31 lines
726 B
JavaScript
Raw Normal View History

2018-11-29 18:38:20 +01:00
import jQuery from 'jquery';
import MapboxField from 'components/MapboxField/MapboxField';
jQuery.entwine('ss', ($) => {
$('.cms-edit-form .mapbox').entwine({
MapboxField: null,
onmatch() {
if (!this.getMapboxField()) {
this.setMapboxField(new MapboxField(this));
}
}
});
// Render when tab containing field is selected
2018-11-29 18:38:20 +01:00
$('.cms-edit-form [aria-hidden="false"] .mapbox').entwine({
onmatch() {
this._super();
this.getMapboxField().render();
}
});
2018-11-29 18:38:20 +01:00
// Assume field not contained in a tabset is already visible
$('.cms-edit-form .mapbox:not(.tabset .mapbox)').entwine({
onmatch() {
this._super();
2018-11-29 18:38:20 +01:00
this.getMapboxField().render();
}
});
});