Skip to content

Commit

Permalink
Get printclient the proper way, independent of DOM changes
Browse files Browse the repository at this point in the history
  • Loading branch information
werrolf committed Apr 10, 2019
1 parent 39768e4 commit 8f843a6
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions Resources/public/mapbender.element.digitizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@
}

},
printClient: null,

/**
* Constructor.
Expand All @@ -206,6 +207,12 @@
}
var element = widget.element;
widget.elementUrl = Mapbender.configuration.application.urls.element + '/' + element.attr('id') + '/';
var self = this;
Mapbender.elementRegistry.waitReady('.mb-element-printclient').then(function(printClient) {
self.printClient = printClient;
}, function() {
self.printClient = false;
});
Mapbender.elementRegistry.onElementReady(widget.options.target, $.proxy(widget._setup, widget));
},

Expand Down Expand Up @@ -889,18 +896,14 @@
widget.currentPopup.popupDialog('close');
}

if(schema.printable) {
if (schema.printable && this.printClient) {
var printClient = this.printClient;
var printButton = {
text: translate("feature.print"),
click: function() {
var printWidget = $('.mb-element-printclient').data('mapbenderMbPrintClient');
if(printWidget) {
var dialog = $(this).closest(".ui-dialog-content");
var olFeature = dialog.data('feature');
printWidget.printDigitizerFeature(olFeature, olFeature.schema.featureTypeName || olFeature.schema.schemaName);
} else {
$.notify("Druck element ist nicht verfügbar!");
}
var dialog = $(this).closest(".ui-dialog-content");
var olFeature = dialog.data('feature');
printClient.printDigitizerFeature(olFeature, olFeature.schema.featureTypeName || olFeature.schema.schemaName);
}
};
buttons.push(printButton);
Expand Down

0 comments on commit 8f843a6

Please sign in to comment.