Print draggable object text - Javascript works in HTML5, not Flash
Dec 07, 2017
By
Jason Kramer
Fellow designers,
I'm hoping someone with better javascript skills than I can find an issue with the following code. Basically speaking, the Print button will bring up a print window with the text of the draggable objects that were dropped, and only those that were dropped onto the target.
This works in HTML5, but not Flash. I have tried the flash version via web server and Review - no go.
Help! :) Any assistance is very much appreciated! Thanks!
var FinalAnswers = [];
var arr = [];
$('.draggable').each(function(i, e) {
if (parseInt(e.style.zIndex) > 1000) {
arr.push($(e).offset().top);
arr = arr.sort(function(a, b) {
return (a - b)
});
}
});
arr.forEach(function(pos, inx) {
$('.draggable').each(function(i, e) {
if (parseInt(e.style.zIndex) > 1000 && $(e).offset().top == pos) {
FinalAnswers.push($(e).attr('aria-label'))
}
});
});
var $toDoList = "";
FinalAnswers.forEach(function(ans,inx){
$toDoList += '<li><p>'+ans+'</p></li>';
})
var g_html = '<!DOCTYPE html><html><head><title>Cultural Competence To-Do List</title></head><body onload="window.print()"><h3>Cultural Competence To-Do List</h3><hr><ul>'+$toDoList+'</ul></body></html>';
var printWindow = window.open('','Print-Window');
printWindow.document.open();
printWindow.document.write(g_html);
printWindow.document.close();
setTimeout(function(){printWindow.close();},10);
4 Replies
Without a file or link to published output, it's a little tough to troubleshoot. But at first glance, I'd guess it's because the draggable objects (which are html nodes) don't exist in the Flash version.
A good way to troubleshoot is use the Developer Tools/Console to view any errors. In Chrome you can bring this up, by pressing Ctrl+Shift+I
Jason, Erin makes a good point about the Flash version. An easy workaround might be to set a variable or variables in Storyline when your objects are dragged, and then just print the variable.
Erin and Michael, thank you for the responses!
I ended up going the route Michael mentioned, which worked just fine. Cheers!
That's great to hear that it worked out for you Jason.
This discussion is closed. You can start a new discussion or contact Articulate Support.