summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLex Neva <github.com@lexneva.name>2018-04-18 22:30:26 -0400
committerLex Neva <github.com@lexneva.name>2018-04-18 22:30:26 -0400
commitdc547108e1d85c2dd241d329e0858dced90bf92c (patch)
tree01d2b1530c426d71a80aac9393cb93f58aafc962
parentaea5919c63796efd748d724752a86773b79b7c3b (diff)
handle firefox's window.close() permission denied
-rw-r--r--embroider_print.py2
-rw-r--r--messages.po8
-rw-r--r--print/resources/inkstitch.js13
3 files changed, 20 insertions, 3 deletions
diff --git a/embroider_print.py b/embroider_print.py
index 0dbff929..cbdaeb09 100644
--- a/embroider_print.py
+++ b/embroider_print.py
@@ -133,7 +133,7 @@ class PrintPreviewServer(Thread):
def shutdown():
self.shutting_down = True
request.environ.get('werkzeug.server.shutdown')()
- return 'Server shutting down...'
+ return _('Closing...') + '<br/><br/>' + _('It is safe to close this window now.')
@self.app.route('/resources/<path:resource>', methods=['GET'])
def resources(resource):
diff --git a/messages.po b/messages.po
index ce85878d..27a25d3e 100644
--- a/messages.po
+++ b/messages.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PROJECT VERSION\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
-"POT-Creation-Date: 2018-04-18 16:29-0400\n"
+"POT-Creation-Date: 2018-04-18 22:30-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -98,6 +98,12 @@ msgid ""
"\"Overwrite\""
msgstr ""
+msgid "Closing..."
+msgstr ""
+
+msgid "It is safe to close this window now."
+msgstr ""
+
msgid ""
"A print preview has been opened in your web browser. This window will "
"stay open in order to communicate with the JavaScript code running in "
diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js
index 25a5354e..498b1211 100644
--- a/print/resources/inkstitch.js
+++ b/print/resources/inkstitch.js
@@ -213,6 +213,18 @@ $(function() {
$.post('/shutdown', {})
.done(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);
});
});
@@ -240,7 +252,6 @@ $(function() {
$('select#printing-size').change(function(){
var size = $(this).find(':selected').val();
$('.page').toggleClass('a4', size == 'a4');
- console.log("" + Date.now() + "paper size changed");
$.postJSON('/settings/paper-size', {value: size});
});