summaryrefslogtreecommitdiff
path: root/print
diff options
context:
space:
mode:
Diffstat (limited to 'print')
-rw-r--r--print/resources/inkstitch.js40
-rw-r--r--print/resources/style.css2
-rw-r--r--print/templates/ui.html1
3 files changed, 32 insertions, 11 deletions
diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js
index 382ced3b..540ed7f0 100644
--- a/print/resources/inkstitch.js
+++ b/print/resources/inkstitch.js
@@ -11,6 +11,12 @@ var realistic_rendering = {};
var realistic_cache = {};
var normal_rendering = {};
+function ping() {
+ $.get("/ping")
+ .done(function() { setTimeout(ping, 1000) })
+ .fail(function() { $('#errors').attr('class', 'show') });
+}
+
//function to chunk opd view into pieces
// source: https://stackoverflow.com/questions/3366529/wrap-every-3-divs-in-a-div
$.fn.chunk = function(size) {
@@ -203,6 +209,7 @@ function setSVGTransform(figure, transform) {
}
$(function() {
+ setTimeout(ping, 1000);
/* SCALING AND MOVING SVG */
/* Mousewheel scaling */
@@ -372,20 +379,35 @@ $(function() {
/* Settings Bar */
$('button.close').click(function() {
- window.close();
+ $.post('/shutdown', {})
+ .always(function(data) {
+ window.close();
+
+ /* Chrome and Firefox both have a rule: scripts can only close windows
+ * that they opened. Chrome seems to have an exception for windows that
+ * were opened by an outside program, so the above works fine. Firefox
+ * steadfastly refuses to allow us to close the window, so we'll tell
+ * the user (in their language) that they can close it.
+ */
+ setTimeout(function() {
+ document.open();
+ document.write("<html><body>" + data + "</body></html>");
+ document.close();
+ }, 1000);
+ });
});
$('button.print').click(function() {
- var pageSize = $('select#printing-size').find(':selected').text();
- window.inkstitchAPI.openpdf(pageSize)
+ // printing halts all javascript activity, so we need to tell the backend
+ // not to shut down until we're done.
+ $.get("/printing/start")
+ .done(function() {
+ window.print();
+ $.get("/printing/end");
+ });
});
- $('button.save-pdf').click(function() {
- var pageSize = $('select#printing-size').find(':selected').text();
- window.inkstitchAPI.savepdf(pageSize)
- });
-
- $('button.settings').click(function(){
+$('button.settings').click(function(){
$('#settings-ui').show();
});
diff --git a/print/resources/style.css b/print/resources/style.css
index db5ba603..a3200744 100644
--- a/print/resources/style.css
+++ b/print/resources/style.css
@@ -125,7 +125,7 @@ body {
color: white;
}
- .ui button.print, .ui button.save-pdf {
+ .ui button.print {
border: 1px solid rgb(50,132,50);
}
diff --git a/print/templates/ui.html b/print/templates/ui.html
index 4282838d..846b7b49 100644
--- a/print/templates/ui.html
+++ b/print/templates/ui.html
@@ -2,7 +2,6 @@
<p class="header">{{ _('Ink/Stitch Print Preview') }}</p>
<div class="buttons">
<button class="print">{{ _('Print') }}</button>
- <button class="save-pdf">{{ _('Save PDF') }}</button>
<button class="settings">{{ _('Settings') }}</button>
<button class="close">{{ _('Close') }}</button>
</div>