From e4c4eec55f34215c188325eb669c6cb524503007 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 8 Apr 2018 17:34:35 +0200 Subject: Update inkstitch.js A first start: zooming and dragging the SVG --- print/resources/inkstitch.js | 45 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 454c9ae2..e804e325 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -26,9 +26,9 @@ function scaleInksimulation() { if(scale <= 1) { transform += " scale(" + scale + ")"; - label = parseInt(scale*100) + '%'; + label = parseInt(scale*100); } else { - label = "100%"; + label = "100"; } $(this).find('svg').css({ transform: transform }); @@ -41,6 +41,47 @@ $(function() { setPageNumbers(); scaleInksimulation(); + /* Mousewheel scaling */ + $('figure.inksimulation').on( 'DOMMouseScroll mousewheel', function ( event ) { + var transform = $(this).find('svg').css('transform').match(/-?[\d\.]+/g); + var scale = parseFloat(transform[0]); + if( scale > 0.01 && (event.originalEvent.detail > 0 || event.originalEvent.wheelDelta < 0)) { + // scroll down + scale -= 0.01; + } else { + //scroll up + scale += 0.01; + } + // set modified scale + transform[0] = scale; + transform[3] = scale; + $(this).find('svg').css({ transform: 'matrix(' + transform + ')' }); + + // set scale caption text + $(this).find("span").text(parseInt(scale*100)); + + //prevent page fom scrolling + return false; + }); + + /* Drag SVG */ + $('figure.inksimulation').on('mousedown', function(e) { + $(this).data('p0', { x: e.pageX, y: e.pageY }); + $(this).css({cursor: 'move'}); + }).on('mouseup', function(e) { + var p0 = $(this).data('p0'), + p1 = { x: e.pageX, y: e.pageY }, + d = Math.sqrt(Math.pow(p1.x - p0.x, 2) + Math.pow(p1.y - p0.y, 2)); + if (d > 4) { + var transform = $(this).find('svg').css('transform').match(/-?[\d\.]+/g); + transform[4] = parseFloat(transform[4]) + parseFloat(p1.x-p0.x); + transform[5] = parseFloat(transform[5]) + parseFloat(p1.y-p0.y); + // set modified translate + $(this).find('svg').css({ transform: 'matrix(' + transform + ')' }); + $(this).css({cursor: 'auto'}); + } + }) + /* Contendeditable Fields */ // When we focus out from a contenteditable field, we want to -- cgit v1.2.3 From 6e1f4969e154343b458bad9f3b9cc0c0eb8203a4 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 8 Apr 2018 17:35:24 +0200 Subject: Update operator_overview.html --- print/templates/operator_overview.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'print') diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html index 25048ab7..c9706dbe 100644 --- a/print/templates/operator_overview.html +++ b/print/templates/operator_overview.html @@ -27,7 +27,7 @@
{{ svg_overview|safe }} -
{{ _('Scale') }} {{ svg_scale }}
+
{{ _('Scale') }} {{ svg_scale }}%
{% include 'footer.html' %} -- cgit v1.2.3 From 29d62264328e88ec8b1e45704aad85304441e8f3 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 8 Apr 2018 17:35:40 +0200 Subject: Update print_detail.html --- print/templates/print_detail.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'print') diff --git a/print/templates/print_detail.html b/print/templates/print_detail.html index 18a70bba..2453faa4 100644 --- a/print/templates/print_detail.html +++ b/print/templates/print_detail.html @@ -17,7 +17,7 @@
{{color_block.svg_preview|safe}} -
{{ _('Scale') }} {{ svg_scale }}
+
{{ _('Scale') }} {{ svg_scale }}%
-- cgit v1.2.3 From 3e00ba26da77add9bdb1315b6a1993c0b53135f2 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sun, 8 Apr 2018 17:35:54 +0200 Subject: Update print_overview.html --- print/templates/print_overview.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'print') diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index f5632ceb..dd2a1358 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -27,7 +27,7 @@
{{ svg_overview|safe }} -
{{ _('Scale') }} {{ svg_scale }}
+
{{ _('Scale') }} {{ svg_scale }}%
-- cgit v1.2.3 From 15222ed4c39bab5e19b622e9179f7abc88c5b1da Mon Sep 17 00:00:00 2001 From: kalleen Date: Mon, 9 Apr 2018 19:20:02 +0200 Subject: add buttons to quickly adjust svg size --- print/resources/inkstitch.js | 90 ++++++++++++++++++++++++---------- print/resources/style.css | 11 +++++ print/templates/operator_overview.html | 8 ++- print/templates/print_detail.html | 4 ++ print/templates/print_overview.html | 4 ++ 5 files changed, 89 insertions(+), 28 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index e804e325..26e88f38 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -13,49 +13,64 @@ function setPageNumbers() { }); } -// set preview svg scale to fit into its box -function scaleInksimulation() { - $('.inksimulation').each(function() { +// Scale SVG (fit || full size) +function scaleSVG(element, scale = 'fit') { + + // always center svg + transform = "translate(-50%, -50%)"; + + if(scale == 'fit') { var scale = Math.min( - $(this).width() / $(this).find('svg').width(), - $(this).height() / $(this).find('svg').height() + element.width() / element.find('svg').width(), + element.height() / element.find('svg').height() ); + // Do not scale to more than 100% + scale = (scale <= 1) ? scale : 1; + } + + transform += " scale(" + scale + ")"; + var label = parseInt(scale*100); - // center the SVG - transform = "translate(-50%, -50%)"; + element.find('svg').css({ transform: transform }); + element.find('figcaption span').text(label); +} - if(scale <= 1) { - transform += " scale(" + scale + ")"; - label = parseInt(scale*100); - } else { - label = "100"; - } +// set preview svg scale to fit into its box +function scaleAllSvg(element = "") { - $(this).find('svg').css({ transform: transform }); - $(this).find('figcaption span').text(label); - }); + if(element == "") { + $('.inksimulation').each(function() { + scaleSVG($(this)); + }); + } } $(function() { setTimeout(ping, 1000); setPageNumbers(); - scaleInksimulation(); + scaleAllSvg(); - /* Mousewheel scaling */ - $('figure.inksimulation').on( 'DOMMouseScroll mousewheel', function ( event ) { - var transform = $(this).find('svg').css('transform').match(/-?[\d\.]+/g); - var scale = parseFloat(transform[0]); - if( scale > 0.01 && (event.originalEvent.detail > 0 || event.originalEvent.wheelDelta < 0)) { + /* SCALING AND MOVING SVG */ + + /* Mousewheel scaling */ + $('figure.inksimulation').on( 'DOMMouseScroll mousewheel', function (e) { + + var svg = $(this).find('svg'); + var transform = svg.css('transform').match(/-?[\d\.]+/g); + var scale = parseFloat(transform[0]); + + if( scale > 0.01 && (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0)) { // scroll down scale -= 0.01; } else { //scroll up scale += 0.01; } + // set modified scale transform[0] = scale; transform[3] = scale; - $(this).find('svg').css({ transform: 'matrix(' + transform + ')' }); + svg.css({ transform: 'matrix(' + transform + ')' }); // set scale caption text $(this).find("span").text(parseInt(scale*100)); @@ -64,6 +79,18 @@ $(function() { return false; }); + /* Fit SVG */ + $('button.svg-fit').click(function() { + var svgfigure = $(this).closest('figure'); + scaleSVG(svgfigure, 'fit'); + }); + + /* Fit SVG */ + $('button.svg-full').click(function() { + var svgfigure = $(this).closest('figure'); + scaleSVG(svgfigure, '1'); + }); + /* Drag SVG */ $('figure.inksimulation').on('mousedown', function(e) { $(this).data('p0', { x: e.pageX, y: e.pageY }); @@ -88,9 +115,21 @@ $(function() { // set the same content to all fields with the same classname document.querySelectorAll('[contenteditable="true"]').forEach(function(elem) { elem.addEventListener('focusout', function() { - var content = $(this).html(); + var content = $(this).html(); var field_name = $(this).attr('data-field-name'); $('[data-field-name="' + field_name + '"]').html(content); + + /* change svg scale */ + if(field_name == 'svg-scale') { + var scale = parseInt(content); + var svg = $(this).parent().siblings('svg'); + var transform = svg.css('transform').match(/-?[\d\.]+/g); + + transform[0] = scale / 100; + transform[3] = scale / 100; + svg.css({ transform: 'matrix(' + transform + ')' }); + } + }); }); @@ -98,7 +137,6 @@ $(function() { if (e.which == 13) { // pressing enter defocuses the element this.blur(); - // also suppress the enter keystroke to avoid adding a new line return false; } else { @@ -145,7 +183,7 @@ $(function() { $(':checkbox').change(function() { $('.' + this.id).toggle(); setPageNumbers(); - scaleInksimulation(); + scaleAllSvg(); }); }); diff --git a/print/resources/style.css b/print/resources/style.css index 824f8dce..146cfacc 100644 --- a/print/resources/style.css +++ b/print/resources/style.css @@ -69,6 +69,10 @@ page-break-after: always; margin: 0 !important; } + + figure.inksimulation div { + display: none; + } .ui { display: none; @@ -390,6 +394,13 @@ body { line-height: 12pt; margin: 2.5mm; } + + figure.inksimulation div { + position: absolute; + bottom: 0; + left: 0; + right: 0; + } /* Color Swatches */ diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html index c9706dbe..ce28ae8e 100644 --- a/print/templates/operator_overview.html +++ b/print/templates/operator_overview.html @@ -25,9 +25,13 @@
-
+
{{ svg_overview|safe }} -
{{ _('Scale') }} {{ svg_scale }}%
+
{{ _('Scale') }} {{ svg_scale }}%
+
+ + +
{% include 'footer.html' %} diff --git a/print/templates/print_detail.html b/print/templates/print_detail.html index 2453faa4..b8b748b3 100644 --- a/print/templates/print_detail.html +++ b/print/templates/print_detail.html @@ -18,6 +18,10 @@
{{color_block.svg_preview|safe}}
{{ _('Scale') }} {{ svg_scale }}%
+
+ + +
diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index dd2a1358..d32cf1e9 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -28,6 +28,10 @@
{{ svg_overview|safe }}
{{ _('Scale') }} {{ svg_scale }}%
+
+ + +
-- cgit v1.2.3 From 75aa656c2cfb7ee4189c31a6c7a0d23d83b4d03a Mon Sep 17 00:00:00 2001 From: kalleen Date: Wed, 11 Apr 2018 18:57:55 +0200 Subject: add apply to all button for svg transforms --- print/resources/inkstitch.js | 96 +++++++++++++++++++++------------- print/resources/style.css | 11 ++++ print/templates/operator_overview.html | 7 +-- print/templates/print_detail.html | 5 +- print/templates/print_overview.html | 5 +- 5 files changed, 80 insertions(+), 44 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 26e88f38..c6e88e52 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -35,14 +35,23 @@ function scaleSVG(element, scale = 'fit') { element.find('figcaption span').text(label); } -// set preview svg scale to fit into its box -function scaleAllSvg(element = "") { - - if(element == "") { - $('.inksimulation').each(function() { - scaleSVG($(this)); +// set preview svg scale to fit into its box if transform is not set +function scaleAllSvg() { + $('.page').each(function() { + if( $(this).css('display') != 'none' ) { + if( $(this).find('.inksimulation svg').css('transform') == 'none') { + if( $(this).find('.inksimulation span').text() == '') { + scaleSVG($(this).find('.inksimulation')); + } + else { + var transform = $(this).find('.inksimulation span').text(); + var scale = transform.match(/-?[\d\.]+/g)[0]; + $(this).find('.inksimulation svg').css({ transform: transform }); + $(this).find('.inksimulation span').text(parseInt(scale*100)); + } + } + } }); - } } $(function() { @@ -54,29 +63,31 @@ $(function() { /* Mousewheel scaling */ $('figure.inksimulation').on( 'DOMMouseScroll mousewheel', function (e) { + if(event.ctrlKey == true) { - var svg = $(this).find('svg'); - var transform = svg.css('transform').match(/-?[\d\.]+/g); - var scale = parseFloat(transform[0]); - - if( scale > 0.01 && (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0)) { - // scroll down - scale -= 0.01; - } else { - //scroll up - scale += 0.01; - } - - // set modified scale - transform[0] = scale; - transform[3] = scale; - svg.css({ transform: 'matrix(' + transform + ')' }); - - // set scale caption text - $(this).find("span").text(parseInt(scale*100)); + var svg = $(this).find('svg'); + var transform = svg.css('transform').match(/-?[\d\.]+/g); + var scale = parseFloat(transform[0]); + + if( scale > 0.01 && (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0)) { + // scroll down + scale -= 0.01; + } else { + //scroll up + scale += 0.01; + } + + // set modified scale + transform[0] = scale; + transform[3] = scale; + svg.css({ transform: 'matrix(' + transform + ')' }); + + // set scale caption text + $(this).find("span").text(parseInt(scale*100)); - //prevent page fom scrolling - return false; + //prevent page fom scrolling + return false; + } }); /* Fit SVG */ @@ -85,7 +96,7 @@ $(function() { scaleSVG(svgfigure, 'fit'); }); - /* Fit SVG */ + /* Full Size SVG */ $('button.svg-full').click(function() { var svgfigure = $(this).closest('figure'); scaleSVG(svgfigure, '1'); @@ -96,6 +107,7 @@ $(function() { $(this).data('p0', { x: e.pageX, y: e.pageY }); $(this).css({cursor: 'move'}); }).on('mouseup', function(e) { + $(this).css({cursor: 'auto'}); var p0 = $(this).data('p0'), p1 = { x: e.pageX, y: e.pageY }, d = Math.sqrt(Math.pow(p1.x - p0.x, 2) + Math.pow(p1.y - p0.y, 2)); @@ -105,21 +117,27 @@ $(function() { transform[5] = parseFloat(transform[5]) + parseFloat(p1.y-p0.y); // set modified translate $(this).find('svg').css({ transform: 'matrix(' + transform + ')' }); - $(this).css({cursor: 'auto'}); } - }) + }) + + /* Apply transforms to All */ + $('button.svg-apply').click(function() { + var transform = $(this).parent().siblings('svg').css('transform'); + var scale = transform.match(/-?[\d\.]+/g)[0]; + $('.inksimulation').each(function() { + $(this).find('svg').css({ transform: transform }); + $(this).find("span").text(parseInt(scale*100)); + + }) + }); /* Contendeditable Fields */ - // When we focus out from a contenteditable field, we want to - // set the same content to all fields with the same classname document.querySelectorAll('[contenteditable="true"]').forEach(function(elem) { elem.addEventListener('focusout', function() { + /* change svg scale */ var content = $(this).html(); var field_name = $(this).attr('data-field-name'); - $('[data-field-name="' + field_name + '"]').html(content); - - /* change svg scale */ if(field_name == 'svg-scale') { var scale = parseInt(content); var svg = $(this).parent().siblings('svg'); @@ -129,7 +147,11 @@ $(function() { transform[3] = scale / 100; svg.css({ transform: 'matrix(' + transform + ')' }); } - + /* When we focus out from a contenteditable field, we want to + set the same content to all fields with the same classname */ + else { + $('[data-field-name="' + field_name + '"]').html(content); + } }); }); diff --git a/print/resources/style.css b/print/resources/style.css index 146cfacc..333af7aa 100644 --- a/print/resources/style.css +++ b/print/resources/style.css @@ -393,6 +393,8 @@ body { font-weight: bold; line-height: 12pt; margin: 2.5mm; + background: rgba(255, 255, 255, 0.73); + padding: 5px; } figure.inksimulation div { @@ -400,6 +402,15 @@ body { bottom: 0; left: 0; right: 0; + margin-left: auto; + margin-right: auto; + width: fit-content; + } + + figure.inksimulation button { + border: none; + background: grey; + color: white; } /* Color Swatches */ diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html index ce28ae8e..38da7746 100644 --- a/print/templates/operator_overview.html +++ b/print/templates/operator_overview.html @@ -25,12 +25,13 @@
-
+
{{ svg_overview|safe }} -
{{ _('Scale') }} {{ svg_scale }}%
+
{{ _('Scale') }} {{ svg_transform }}%
- + +
diff --git a/print/templates/print_detail.html b/print/templates/print_detail.html index b8b748b3..eddcf36f 100644 --- a/print/templates/print_detail.html +++ b/print/templates/print_detail.html @@ -15,12 +15,13 @@
-
+
{{color_block.svg_preview|safe}} -
{{ _('Scale') }} {{ svg_scale }}%
+
{{ _('Scale') }} {{ svg_transform }}%
+
diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index d32cf1e9..7a396b4a 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -25,12 +25,13 @@
-
+
{{ svg_overview|safe }} -
{{ _('Scale') }} {{ svg_scale }}%
+
{{ _('Scale') }} {{ svg_transform }}%
+
-- cgit v1.2.3 From 85a8b6b1cfe008eed49c678bc0af9e2bea931f3c Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 13 Apr 2018 21:23:00 -0400 Subject: inkstitch metadata framework --- print/resources/inkstitch.js | 31 +++++++++++++++---------------- print/templates/headline.html | 6 +++--- 2 files changed, 18 insertions(+), 19 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 454c9ae2..ed26d367 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -40,19 +40,18 @@ $(function() { setTimeout(ping, 1000); setPageNumbers(); scaleInksimulation(); - + /* Contendeditable Fields */ - + // When we focus out from a contenteditable field, we want to // set the same content to all fields with the same classname - document.querySelectorAll('[contenteditable="true"]').forEach(function(elem) { - elem.addEventListener('focusout', function() { - var content = $(this).html(); - var field_name = $(this).attr('data-field-name'); - $('[data-field-name="' + field_name + '"]').html(content); - }); + $('[contenteditable="true"]').on('focusout', function() { + var content = $(this).html(); + var field_name = $(this).attr('data-field-name'); + $('[data-field-name="' + field_name + '"]').html(content); + $.post('/metadata/' + field_name + '/set', {value: content}); }); - + $('[contenteditable="true"]').keypress(function(e) { if (e.which == 13) { // pressing enter defocuses the element @@ -64,10 +63,10 @@ $(function() { return true; } }); - - + + /* Settings Bar */ - + $('button.close').click(function() { $.post('/shutdown', {}) .done(function(data) { @@ -92,20 +91,20 @@ $(function() { $('#close-settings').click(function(){ $('#settings-ui').hide(); }); - + /* Settings */ - + // Paper Size $('select#printing-size').change(function(){ $('.page').toggleClass('a4'); }); - + //Checkbox $(':checkbox').change(function() { $('.' + this.id).toggle(); setPageNumbers(); scaleInksimulation(); }); - + }); diff --git a/print/templates/headline.html b/print/templates/headline.html index 649c02ea..cbc9c43a 100644 --- a/print/templates/headline.html +++ b/print/templates/headline.html @@ -3,9 +3,9 @@
-

{{ job.title }}

-

{{ client }}

-

{{ purchase_order }}

+

+

+

{{ date|datetimeformat(_('%Y.%m.%d')) }}
-- cgit v1.2.3 From 78532e8efec1b39d8f7b9286508cc10e5050fe69 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 13 Apr 2018 23:39:49 -0400 Subject: populate fields on load --- print/resources/inkstitch.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index ed26d367..15cf494a 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -48,10 +48,17 @@ $(function() { $('[contenteditable="true"]').on('focusout', function() { var content = $(this).html(); var field_name = $(this).attr('data-field-name'); - $('[data-field-name="' + field_name + '"]').html(content); + $('[data-field-name="' + field_name + '"]').text(content); $.post('/metadata/' + field_name + '/set', {value: content}); }); + // load up initial metadata values + $.getJSON('/metadata', function(metadata) { + $.each(metadata, function(field_name, value) { + $('[data-field-name="' + field_name + '"]').text(value); + }); + }); + $('[contenteditable="true"]').keypress(function(e) { if (e.which == 13) { // pressing enter defocuses the element -- cgit v1.2.3 From f9b90d31b7730103e296b0c2509885b07000eac4 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 14 Apr 2018 20:39:59 -0400 Subject: round-trip editable fields and checkboxes --- print/resources/inkstitch.js | 29 ++++++++++++++++++++++++++--- print/templates/ui.html | 8 ++++---- 2 files changed, 30 insertions(+), 7 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 15cf494a..8123a31f 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -1,3 +1,12 @@ +$.postJSON = function(url, data, success=null) { + return $.ajax(url, { + type: 'POST', + data: JSON.stringify(data), + contentType: 'application/json', + success: success + }); +}; + function ping() { $.get("/ping") .done(function() { setTimeout(ping, 1000) }) @@ -49,13 +58,22 @@ $(function() { var content = $(this).html(); var field_name = $(this).attr('data-field-name'); $('[data-field-name="' + field_name + '"]').text(content); - $.post('/metadata/' + field_name + '/set', {value: content}); + $.postJSON('/metadata/' + field_name + '/set', {value: content}); }); // load up initial metadata values $.getJSON('/metadata', function(metadata) { $.each(metadata, function(field_name, value) { - $('[data-field-name="' + field_name + '"]').text(value); + $('[data-field-name="' + field_name + '"]').each(function(i, item) { + console.log(item); + if ($(item).is(':checkbox')) { + console.log("is a checkbox"); + $(item).prop('checked', value).trigger('change'); + } else { + console.log("is not a checkbox"); + $(item).text(value); + } + }); }); }); @@ -108,9 +126,14 @@ $(function() { //Checkbox $(':checkbox').change(function() { - $('.' + this.id).toggle(); + var checked = $(this).prop('checked'); + var field_name = $(this).attr('data-field-name'); + + $('.' + field_name).toggle(checked); setPageNumbers(); scaleInksimulation(); + + $.postJSON('/metadata/' + field_name + '/set', {value: checked}); }); }); diff --git a/print/templates/ui.html b/print/templates/ui.html index 078f1a4c..9acdd1bc 100644 --- a/print/templates/ui.html +++ b/print/templates/ui.html @@ -24,10 +24,10 @@
{{ ('Print Layouts') }}: -

-

-

-

+

+

+

+

-- cgit v1.2.3 From 7b0804562e4ce3b440e67de6cb001ac021326990 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 16 Apr 2018 20:17:07 -0400 Subject: add 'save as defaults' button --- print/resources/inkstitch.js | 54 ++++++++++++++++++++++++++++++++++--------- print/resources/style.css | 25 +++++++++++++++++++- print/templates/headline.html | 5 +++- print/templates/ui.html | 5 ++-- 4 files changed, 74 insertions(+), 15 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 8123a31f..ab0b587d 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -58,20 +58,22 @@ $(function() { var content = $(this).html(); var field_name = $(this).attr('data-field-name'); $('[data-field-name="' + field_name + '"]').text(content); - $.postJSON('/metadata/' + field_name + '/set', {value: content}); + $.postJSON('/settings/' + field_name, {value: content}); }); // load up initial metadata values - $.getJSON('/metadata', function(metadata) { - $.each(metadata, function(field_name, value) { + $.getJSON('/settings', function(settings) { + $.each(settings, function(field_name, value) { $('[data-field-name="' + field_name + '"]').each(function(i, item) { - console.log(item); - if ($(item).is(':checkbox')) { - console.log("is a checkbox"); - $(item).prop('checked', value).trigger('change'); + var item = $(item); + if (item.is(':checkbox')) { + item.prop('checked', value).trigger('change'); + } else if (item.is('img')) { + item.attr('src', value); + } else if (item.is('select')) { + item.val(value).trigger('change'); } else { - console.log("is not a checkbox"); - $(item).text(value); + item.text(value); } }); }); @@ -121,7 +123,9 @@ $(function() { // Paper Size $('select#printing-size').change(function(){ - $('.page').toggleClass('a4'); + var size = $(this).find(':selected').val(); + $('.page').toggleClass('a4', size == 'a4'); + $.postJSON('/settings/paper-size', {value: size}); }); //Checkbox @@ -133,8 +137,36 @@ $(function() { setPageNumbers(); scaleInksimulation(); - $.postJSON('/metadata/' + field_name + '/set', {value: checked}); + $.postJSON('/settings/' + field_name, {value: checked}); }); + // Logo + $('#logo-picker').change(function(e) { + var file = e.originalEvent.srcElement.files[0]; + var reader = new FileReader(); + reader.onloadend = function() { + var data = reader.result; + $('figure.brandlogo img').attr('src', data); + $.postJSON('/settings/logo', {value: data}); + }; + reader.readAsDataURL(file); + }); + + // "save as defaults" button + $('#save-settings').click(function(e) { + var settings = {}; + settings["client-overview"] = $("[data-field-name='client-overview']").is(':checked'); + settings["client-detailedview"] = $("[data-field-name='client-detailedview']").is(':checked'); + settings["operator-overview"] = $("[data-field-name='operator-overview']").is(':checked'); + settings["operator-detailedview"] = $("[data-field-name='operator-detailedview']").is(':checked'); + settings["paper-size"] = $('select#printing-size').find(':selected').val(); + + var logo = $("figure.brandlogo img").attr('src'); + if (logo.startsWith("data:")) { + settings["logo"] = logo; + } + + $.postJSON('/defaults', {'value': settings}); + }); }); diff --git a/print/resources/style.css b/print/resources/style.css index 824f8dce..8be2370d 100644 --- a/print/resources/style.css +++ b/print/resources/style.css @@ -226,6 +226,10 @@ body { cursor: pointer; } + #settings-ui fieldset { + margin-bottom: 1em; + } + /* Header */ @@ -247,11 +251,30 @@ body { margin: 2.5mm; } + figure.brandlogo label { + display: block; + width: 100%; + height: 100%; + line-height: 30mm; + text-align: center; + } + figure.brandlogo img { max-width: 30mm; max-height: 30mm; + display: inline; + vertical-align: middle; } - + + /* hide the actual file picker control, since we just want them to click the + * image instead + */ + #logo-picker { + width: 0px; + height: 0px; + opacity: 0%; + } + .operator-detailedview figure.brandlogo { height: 20mm; width: 30mm; diff --git a/print/templates/headline.html b/print/templates/headline.html index cbc9c43a..421202e4 100644 --- a/print/templates/headline.html +++ b/print/templates/headline.html @@ -1,5 +1,8 @@
diff --git a/print/templates/ui.html b/print/templates/ui.html index 9acdd1bc..f7246962 100644 --- a/print/templates/ui.html +++ b/print/templates/ui.html @@ -15,7 +15,7 @@

{{ _('Settings') }}

{{ _('Printing Size') }}: - @@ -23,11 +23,12 @@

- {{ ('Print Layouts') }}: + {{ _('Print Layouts') }}:

+
-- cgit v1.2.3 From 51c7febb4ab845f609c2613d3180f8456f38b285 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 16 Apr 2018 21:15:39 -0400 Subject: scale proportionally rather than an absolute amount --- print/resources/inkstitch.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 253e9243..2323ec7a 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -78,12 +78,14 @@ $(function() { var transform = svg.css('transform').match(/-?[\d\.]+/g); var scale = parseFloat(transform[0]); - if( scale > 0.01 && (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0)) { - // scroll down - scale -= 0.01; + if (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) { + // scroll down = zoom out + scale *= 0.97; + if (scale < 0.01) + scale = 0.01; } else { //scroll up - scale += 0.01; + scale *= 1.03; } // set modified scale -- cgit v1.2.3 From 32af3d4f89d7f3bcc26e231223ce64bcd7d22122 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 17 Apr 2018 15:01:38 -0400 Subject: tidy up drag code and update continuously --- print/resources/inkstitch.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 2323ec7a..497b87d4 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -115,21 +115,24 @@ $(function() { /* Drag SVG */ $('figure.inksimulation').on('mousedown', function(e) { - $(this).data('p0', { x: e.pageX, y: e.pageY }); - $(this).css({cursor: 'move'}); + var p0 = { x: e.pageX, y: e.pageY }; + var start_transform = $(this).find('svg').css('transform').match(/-?[\d\.]+/g); + var start_offset = { x: parseFloat(start_transform[4]), y: parseFloat(start_transform[5]) }; + + $(this).css({cursor: 'move'}); + $(this).on('mousemove', function(e) { + var p1 = { x: e.pageX, y: e.pageY }; + // set modified translate + var transform = $(this).find('svg').css('transform').match(/-?[\d\.]+/g); + transform[4] = start_offset.x + (p1.x - p0.x); + transform[5] = start_offset.y + (p1.y - p0.y); + $(this).find('svg').css({ transform: 'matrix(' + transform + ')' }); + }); }).on('mouseup', function(e) { - $(this).css({cursor: 'auto'}); - var p0 = $(this).data('p0'), - p1 = { x: e.pageX, y: e.pageY }, - d = Math.sqrt(Math.pow(p1.x - p0.x, 2) + Math.pow(p1.y - p0.y, 2)); - if (d > 4) { - var transform = $(this).find('svg').css('transform').match(/-?[\d\.]+/g); - transform[4] = parseFloat(transform[4]) + parseFloat(p1.x-p0.x); - transform[5] = parseFloat(transform[5]) + parseFloat(p1.y-p0.y); - // set modified translate - $(this).find('svg').css({ transform: 'matrix(' + transform + ')' }); - } - }) + $(this).css({cursor: 'auto'}); + $(this).data('p0', null); + $(this).off('mousemove'); + }); /* Apply transforms to All */ $('button.svg-apply').click(function() { -- cgit v1.2.3 From cb1b3756d8d029c7f92e1748e9eb42a78d89b5a2 Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Wed, 18 Apr 2018 19:20:33 +0200 Subject: Update inkstitch.js fixed scrolling function event variable --- print/resources/inkstitch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 497b87d4..0571f432 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -72,7 +72,7 @@ $(function() { /* Mousewheel scaling */ $('figure.inksimulation').on( 'DOMMouseScroll mousewheel', function (e) { - if(event.ctrlKey == true) { + if(e.ctrlKey == true) { var svg = $(this).find('svg'); var transform = svg.css('transform').match(/-?[\d\.]+/g); -- cgit v1.2.3 From 540bf2062a87da5629c7ed98300b39caeffe397f Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 17 Apr 2018 15:16:50 -0400 Subject: fit scales up svg if necessary --- print/resources/inkstitch.js | 2 -- 1 file changed, 2 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 0571f432..8c5e8fa6 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -33,8 +33,6 @@ function scaleSVG(element, scale = 'fit') { element.width() / element.find('svg').width(), element.height() / element.find('svg').height() ); - // Do not scale to more than 100% - scale = (scale <= 1) ? scale : 1; } transform += " scale(" + scale + ")"; -- cgit v1.2.3 From 51741745b0bb691a55b642a2ea938ac74324da2d Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 17 Apr 2018 15:48:38 -0400 Subject: don't get transform from html --- print/resources/inkstitch.js | 53 ++++++++++++++-------------------- print/templates/operator_overview.html | 2 +- print/templates/print_detail.html | 2 +- print/templates/print_overview.html | 2 +- 4 files changed, 25 insertions(+), 34 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 8c5e8fa6..825130c8 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -39,24 +39,14 @@ function scaleSVG(element, scale = 'fit') { var label = parseInt(scale*100); element.find('svg').css({ transform: transform }); - element.find('figcaption span').text(label); + element.find('.scale').text(label); } // set preview svg scale to fit into its box if transform is not set function scaleAllSvg() { $('.page').each(function() { - if( $(this).css('display') != 'none' ) { - if( $(this).find('.inksimulation svg').css('transform') == 'none') { - if( $(this).find('.inksimulation span').text() == '') { - scaleSVG($(this).find('.inksimulation')); - } - else { - var transform = $(this).find('.inksimulation span').text(); - var scale = transform.match(/-?[\d\.]+/g)[0]; - $(this).find('.inksimulation svg').css({ transform: transform }); - $(this).find('.inksimulation span').text(parseInt(scale*100)); - } - } + if( $(this).find('.inksimulation svg').css('transform') == 'none') { + scaleSVG($(this).find('.inksimulation'), 'fit'); } }); } @@ -64,7 +54,6 @@ function scaleAllSvg() { $(function() { setTimeout(ping, 1000); setPageNumbers(); - scaleAllSvg(); /* SCALING AND MOVING SVG */ @@ -92,7 +81,7 @@ $(function() { svg.css({ transform: 'matrix(' + transform + ')' }); // set scale caption text - $(this).find("span").text(parseInt(scale*100)); + $(this).find(".scale").text(parseInt(scale*100)); //prevent page fom scrolling return false; @@ -138,7 +127,7 @@ $(function() { var scale = transform.match(/-?[\d\.]+/g)[0]; $('.inksimulation').each(function() { $(this).find('svg').css({ transform: transform }); - $(this).find("span").text(parseInt(scale*100)); + $(this).find(".scale").text(parseInt(scale*100)); }) }); @@ -167,20 +156,22 @@ $(function() { // load up initial metadata values $.getJSON('/settings', function(settings) { - $.each(settings, function(field_name, value) { - $('[data-field-name="' + field_name + '"]').each(function(i, item) { - var item = $(item); - if (item.is(':checkbox')) { - item.prop('checked', value).trigger('change'); - } else if (item.is('img')) { - item.attr('src', value); - } else if (item.is('select')) { - item.val(value).trigger('change'); - } else { - item.text(value); - } - }); - }); + $.each(settings, function(field_name, value) { + $('[data-field-name="' + field_name + '"]').each(function(i, item) { + var item = $(item); + if (item.is(':checkbox')) { + item.prop('checked', value).trigger('change'); + } else if (item.is('img')) { + item.attr('src', value); + } else if (item.is('select')) { + item.val(value).trigger('change'); + } else { + item.text(value); + } + }); + }); + // wait until page size is set (if they've specified one) and then scale SVGs to fit + setTimeout(function() { scaleAllSvg() }, 500); }); $('[contenteditable="true"]').keypress(function(e) { @@ -229,6 +220,7 @@ $(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}); }); @@ -239,7 +231,6 @@ $(function() { $('.' + field_name).toggle(checked); setPageNumbers(); - scaleAllSvg(); $.postJSON('/settings/' + field_name, {value: checked}); }); diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html index 38da7746..8615c42a 100644 --- a/print/templates/operator_overview.html +++ b/print/templates/operator_overview.html @@ -27,7 +27,7 @@
{{ svg_overview|safe }} -
{{ _('Scale') }} {{ svg_transform }}%
+
{{ _('Scale') }} %
diff --git a/print/templates/print_detail.html b/print/templates/print_detail.html index eddcf36f..d3b064a5 100644 --- a/print/templates/print_detail.html +++ b/print/templates/print_detail.html @@ -17,7 +17,7 @@
{{color_block.svg_preview|safe}} -
{{ _('Scale') }} {{ svg_transform }}%
+
{{ _('Scale') }} %
diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index 7a396b4a..f876ad70 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -27,7 +27,7 @@
{{ svg_overview|safe }} -
{{ _('Scale') }} {{ svg_transform }}%
+
{{ _('Scale') }} %
-- cgit v1.2.3 From b5968dc11ff479f2c7cd5217c47a872fe04295e4 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 17 Apr 2018 15:55:52 -0400 Subject: fix formatting of dimensions --- print/templates/operator_detailedview.html | 2 +- print/templates/operator_overview.html | 2 +- print/templates/print_overview.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) (limited to 'print') diff --git a/print/templates/operator_detailedview.html b/print/templates/operator_detailedview.html index 633b9286..92c3445f 100644 --- a/print/templates/operator_detailedview.html +++ b/print/templates/operator_detailedview.html @@ -25,7 +25,7 @@ {{ _('Color Blocks') }}: {{ job.num_color_blocks }}

- {{ _('Design box size') }}: {{ job.dimensions }} + {{ _('Design box size') }}: {{ "%0.1fmm X %0.1fmm" | format(*job.dimensions) }} {{ _('Total thread used') }}: {{job.estimated_thread }} {{ _('Total stitch count') }}: {{job.num_stitches }}

diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html index 8615c42a..59b2e028 100644 --- a/print/templates/operator_overview.html +++ b/print/templates/operator_overview.html @@ -11,7 +11,7 @@
-

{{ _('Design box size') }}:{{ job.dimensions }}

+

{{ _('Design box size') }}:{{ "%0.1fmm X %0.1fmm" | format(*job.dimensions) }}

{{ _('Total stitch count') }}:{{job.num_stitches }}

{{ _('Total thread used') }}:{{job.estimated_thread }}

diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index f876ad70..62d2982c 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -11,7 +11,7 @@
-

{{ _('Design box size') }}:{{ job.dimensions }}

+

{{ _('Design box size') }}:{{ "%0.1fmm X %0.1fmm" | format(*job.dimensions) }}

{{ _('Total stitch count') }}:{{job.num_stitches }}

{{ _('Total thread used') }}:{{job.estimated_thread }}

-- cgit v1.2.3 From a5900865c76b4b65c712ef6d39fda9eaae2c5007 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 18 Apr 2018 16:09:43 -0400 Subject: save and restore zoom and pan --- print/resources/inkstitch.js | 38 ++++++++++++++++++++++++++-------- print/templates/operator_overview.html | 2 +- print/templates/print_detail.html | 2 +- print/templates/print_overview.html | 2 +- 4 files changed, 32 insertions(+), 12 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 825130c8..25a5354e 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -51,6 +51,23 @@ function scaleAllSvg() { }); } +var saveTimerHandles = {}; + +function setSVGTransform(figure, transform) { + var field_name = $(figure).data('field-name'); + var scale = transform.match(/-?[\d\.]+/g)[0]; + figure.find('svg').css({ transform: transform }); + figure.find(".scale").text(parseInt(scale*100)); + + // avoid spamming updates + if (saveTimerHandles[field_name] != null) + clearTimeout(saveTimerHandles[field_name]); + + saveTimerHandles[field_name] = setTimeout(function() { + $.postJSON('/settings/' + field_name, {value: transform}); + }, 250); +} + $(function() { setTimeout(ping, 1000); setPageNumbers(); @@ -78,10 +95,8 @@ $(function() { // set modified scale transform[0] = scale; transform[3] = scale; - svg.css({ transform: 'matrix(' + transform + ')' }); - - // set scale caption text - $(this).find(".scale").text(parseInt(scale*100)); + + setSVGTransform($(this), 'matrix(' + transform + ')'); //prevent page fom scrolling return false; @@ -113,22 +128,25 @@ $(function() { var transform = $(this).find('svg').css('transform').match(/-?[\d\.]+/g); transform[4] = start_offset.x + (p1.x - p0.x); transform[5] = start_offset.y + (p1.y - p0.y); - $(this).find('svg').css({ transform: 'matrix(' + transform + ')' }); + + // I'd ike to use setSVGTransform() here but this code runs many + // times per second and it's just too CPU-intensive. + $(this).find('svg').css({transform: 'matrix(' + transform + ')'}); }); }).on('mouseup', function(e) { $(this).css({cursor: 'auto'}); $(this).data('p0', null); $(this).off('mousemove'); + + // set it using setSVGTransform() to ensure that it's saved to the server + setSVGTransform($(this), $(this).find('svg').css('transform')); }); /* Apply transforms to All */ $('button.svg-apply').click(function() { var transform = $(this).parent().siblings('svg').css('transform'); - var scale = transform.match(/-?[\d\.]+/g)[0]; $('.inksimulation').each(function() { - $(this).find('svg').css({ transform: transform }); - $(this).find(".scale").text(parseInt(scale*100)); - + setSVGTransform($(this), transform); }) }); @@ -165,6 +183,8 @@ $(function() { item.attr('src', value); } else if (item.is('select')) { item.val(value).trigger('change'); + } else if (item.is('figure.inksimulation')) { + setSVGTransform(item, value); } else { item.text(value); } diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html index 59b2e028..367d6d2b 100644 --- a/print/templates/operator_overview.html +++ b/print/templates/operator_overview.html @@ -25,7 +25,7 @@
-
+
{{ svg_overview|safe }}
{{ _('Scale') }} %
diff --git a/print/templates/print_detail.html b/print/templates/print_detail.html index d3b064a5..714d33a2 100644 --- a/print/templates/print_detail.html +++ b/print/templates/print_detail.html @@ -15,7 +15,7 @@
-
+
{{color_block.svg_preview|safe}}
{{ _('Scale') }} %
diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index 62d2982c..efcf5b2e 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -25,7 +25,7 @@
-
+
{{ svg_overview|safe }}
{{ _('Scale') }} %
-- cgit v1.2.3 From aea5919c63796efd748d724752a86773b79b7c3b Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 18 Apr 2018 16:29:06 -0400 Subject: add notes in operator detailed view switch to 12 color blocks per page to give more room for detailed notes --- print/templates/index.html | 2 +- print/templates/operator_detailedview.html | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'print') diff --git a/print/templates/index.html b/print/templates/index.html index 21ca74ab..0c9cedfd 100644 --- a/print/templates/index.html +++ b/print/templates/index.html @@ -23,7 +23,7 @@
{% include 'operator_overview.html' %}
{# operator detailed view #} - {% for color_block_part in color_blocks | batch(13) %} + {% for color_block_part in color_blocks | batch(12) %} {% set outer_loop = loop %}
{% include 'operator_detailedview.html' %}
{% endfor %} diff --git a/print/templates/operator_detailedview.html b/print/templates/operator_detailedview.html index 92c3445f..f78028d7 100644 --- a/print/templates/operator_detailedview.html +++ b/print/templates/operator_detailedview.html @@ -10,7 +10,7 @@

{{ _('Color') }}

{{ _('Thread Consumption') }}

{{ _('Stops and Trims') }}

-

{{ _('Estimated Time') }}

+

{{ _('Notes') }}

{% if outer_loop.index == 1 %}
@@ -34,7 +34,7 @@ {{ _('Total nr trims') }}: {{ job.num_trims }}

- {{ job.estimated_time }} +

{% endif %} @@ -45,7 +45,7 @@ - #{{ loop.index + outer_loop.index0 * 13 }} + #{{ loop.index + outer_loop.index0 * 12 }}

@@ -65,7 +65,7 @@ {{ _('# trims') }}: {{ color_block.num_trims }}

- {{ color_block.estimatedtime }} +

{% endfor %} -- cgit v1.2.3 From dc547108e1d85c2dd241d329e0858dced90bf92c Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 18 Apr 2018 22:30:26 -0400 Subject: handle firefox's window.close() permission denied --- print/resources/inkstitch.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'print') 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("" + data + ""); + 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}); }); -- cgit v1.2.3 From 8e3dd74a286d4549fdb1dd9cc7a9fcfadb85bb9e Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Sat, 28 Apr 2018 13:36:03 -0400 Subject: add hint about clicking logo --- print/resources/style.css | 99 +++++++++++++++++++++++++------------------ print/templates/headline.html | 3 +- 2 files changed, 59 insertions(+), 43 deletions(-) (limited to 'print') diff --git a/print/resources/style.css b/print/resources/style.css index 013f567c..97dee6a8 100644 --- a/print/resources/style.css +++ b/print/resources/style.css @@ -69,7 +69,7 @@ page-break-after: always; margin: 0 !important; } - + figure.inksimulation div { display: none; } @@ -81,7 +81,7 @@ #settings-ui { display: none !important; } - + #errors { display: none !important; } @@ -90,6 +90,10 @@ content: attr(data-label); padding-right: 0.5em; } + + span.logo-instructions { + display: none; + } } @page { @@ -113,7 +117,7 @@ body { .page { width: 210mm; height: 275mm; - padding: 5mm; + padding: 5mm; background: #fff; margin: 0 auto; vertical-align: text-bottom; @@ -167,13 +171,13 @@ body { .ui button.close { border: 1px solid rgb(197,5,5); - + } .ui button.close:hover { background: rgb(197,5,5); color: white; - + } .ui button.settings { @@ -211,7 +215,7 @@ body { border-bottom: 1px solid rgba(129, 129, 129, 0.5); box-shadow: 0 1px 1px 1px rgba(194, 191, 191, 0.5); } - + #settings-ui div { text-align: left; font-size: 12pt; @@ -279,13 +283,24 @@ body { opacity: 0%; } + .logo-instructions { + white-space: nowrap; + + /* chrome ignores this :( + text-align: center; + */ + + font-size: 10px; + color: rgb(192, 192, 192); + } + .operator-detailedview figure.brandlogo { height: 20mm; width: 30mm; margin: 0 2.5mm; text-align: left; } - + .operator-detailedview figure.brandlogo img { max-width: 30mm; max-height: 20mm; @@ -341,15 +356,15 @@ body { div.job-details p span:first-child { font-weight: bold; - padding-right: 1mm; + padding-right: 1mm; } div.job-details p span:last-child { - text-align: left; + text-align: left; } div.job-details > div:last-child span { - text-align: right !important; + text-align: right !important; } div.client-detailedview .job-details { @@ -374,16 +389,16 @@ body { font-size: 12pt; font-weight: bold; } - + /* client dedailed view header */ .client-detailedview div.job-details p span:first-child { - width: 20mm; + width: 20mm; } - + .client-detailedview div.job-details p span:last-child { - max-width: 60mm; + max-width: 60mm; } - + /* SVG Preview Image */ @@ -397,7 +412,7 @@ body { position: relative; overflow: hidden; } - + .client-overview-main figure.inksimulation { height: 155mm; } @@ -419,7 +434,7 @@ body { background: rgba(255, 255, 255, 0.73); padding: 5px; } - + figure.inksimulation div { position: absolute; bottom: 0; @@ -429,7 +444,7 @@ body { margin-right: auto; width: fit-content; } - + figure.inksimulation button { border: none; background: grey; @@ -460,7 +475,7 @@ body { font-weight: 700; font-size: 12pt; color: black; - background: white; + background: white; border: 0.5mm solid white; margin: 0px; padding: 0px; @@ -491,44 +506,44 @@ body { line-height: 30mm; text-align: center; } - + /* detailedview color swatch */ - + .color-palette.detailed > div { height: 100%; position: relative; } - + .color-palette.detailed .color-info { position: absolute; top: 2mm; left: 45mm; } - + .color-palette.detailed .color-info > div { display: table; } - + .color-palette.detailed .color-info p { display: table-row; } - + .color-palette.detailed .color-info span { display: table-cell; padding-right: 5mm; } - + /* Operator Detailed View */ .operator-detailedview header { height: 25mm; } - + .operator-detailedveiw figure.brandlogo{ height: 15mm; width: 15mm; } - + .operator-detailedveiw figure.brandlogo img { max-width: 12.5mm; max-height: 12.5mm; @@ -542,21 +557,21 @@ body { display: table; width: 100%; } - + .operator-job-info div { display: table-row; } - + div.job-headline { display: table-header-group; font-size: 9pt; font-weight: bold; } - + div.job-headline p { height: 1em; } - + .operator-job-info p { height: 15mm; max-width: 15mm; @@ -566,11 +581,11 @@ body { overflow: hidden; border: 1px solid rgb(239,239,239); } - + .operator-job-info span { display: block; } - + .operator-job-info span.color-index { position: absolute; top: 0; @@ -578,17 +593,17 @@ body { line-height: 15mm; width: 10mm; } - + .operator-svg.operator-colorswatch { width: 15mm; } - + .operator-svg.operator-preview { min-width: 15mm; max-width: 20mm; height: 15mm; } - + .operator-svg svg { position: absolute; top: 0; @@ -597,7 +612,7 @@ body { max-width: 30mm; height: 100%; } - + /* Footer */ @@ -610,7 +625,7 @@ body { white-space: wrap; text-align: center; padding-top: 2mm; - + } footer p.num_pages { @@ -670,7 +685,7 @@ body { /* five items */ .color-swatch:first-child:nth-last-child(n+5), .color-swatch:first-child:nth-last-child(n+5) ~ .color-swatch { - font-size: 9pt; + font-size: 9pt; width: calc(100% / 5); } @@ -710,7 +725,7 @@ body { /* fourteen items */ .color-swatch:first-child:nth-last-child(n+14), .color-swatch:first-child:nth-last-child(n+14) ~ .color-swatch { - width: calc(100% / 5); + width: calc(100% / 5); } /* sixteen items */ @@ -762,7 +777,7 @@ body { .color-swatch:first-child:nth-last-child(n+40) ~ .color-swatch { width: calc(100% / 12); } - + /* fourty-nine items */ .color-swatch:first-child:nth-last-child(n+49), .color-swatch:first-child:nth-last-child(n+40) ~ .color-swatch { diff --git a/print/templates/headline.html b/print/templates/headline.html index 421202e4..7a7059b9 100644 --- a/print/templates/headline.html +++ b/print/templates/headline.html @@ -3,6 +3,7 @@ {{ logo.title }} + {{ _("Click to choose another logo") }}
@@ -10,6 +11,6 @@

- +
{{ date|datetimeformat(_('%Y.%m.%d')) }}
-- cgit v1.2.3