Anyone have an example Wrapper they would like to share?
I’d like to develop a couple of them, but the documentation is a bit sparse.
Thanks,
Randy
Anyone have an example Wrapper they would like to share?
I’d like to develop a couple of them, but the documentation is a bit sparse.
Thanks,
Randy
Hi Randy,
My name is Mark and I’m a Platform Solution Developer here at MatsSoft. I’m here to help you. Could you please be a little more specific with what you are looking for and I’ll do what I can to help you out.
Regards - MP
Hi Randy
There is not a huge amount you can do with wrappers but I have attached a simple one. (Cannot upload, so split out below)
It goes around a link property and redirects after a set period of time. As you will see you cannot pass any parameters to a wrapper, so there is a bit of a kludge on the css classes to get a value through.
Caveat: This was written to prove a point so may not be 100% correct.
Richard
Main.js (needs to be present even though it doesn’t do anything)
/* Main server-side wrapper code */
return {
get_template_data: function() {
return {}
}
}
main.htm
<div class="col-sm-12 font-xs-3xl p-0 auto-redirect" v-html="mats.html_presenter"></div>
And the main piece is in frontend.js (although this is probably the piece you will have to write!)
/* frontend JS */
export default {
methods: {},
mounted: function(){
if ((window.location.pathname.startsWith (“/b”)) || (window.location.pathname.startsWith (“/c”))) {
return; // We don’t want to redirect in build studio or code studio
}
var delay = 30; // Default unless specified in CSS Class of fragment.
var t = this.$el.parentElement.classList;
for (var i =0; i < t.length; i++) {
if (t.item(i).startsWith(‘delay-’)) {
delay = parseInt (t.item(i).substring(6), 10);
}
}var l = this.$el.getElementsByTagName('a'); if (l.length === 0) { return; // There is no link present } var dest = l[0].getAttribute('href');
// console.log (“Redirection to " + dest + " in " + delay + " seconds”);
delay *= 1000; // Convert to millisecondsvar v = window.location.href; setTimeout (function() { window.location = dest; }, delay);
}
}