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/templates/operator_overview.html') 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.3.1 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/templates/operator_overview.html') 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.3.1 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 --- embroider_print.py | 2 +- 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 +- 6 files changed, 81 insertions(+), 45 deletions(-) (limited to 'print/templates/operator_overview.html') diff --git a/embroider_print.py b/embroider_print.py index 96c3255d..c0b49bf2 100644 --- a/embroider_print.py +++ b/embroider_print.py @@ -295,7 +295,7 @@ class Print(InkstitchExtension): 'estimated_thread': '', # TODO }, svg_overview = overview_svg, - svg_scale = '100%', + svg_transform = '', # Format: matrix(0.2, 0, 0, 0.2, 0, 0) color_blocks = stitch_plan.color_blocks, ) 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.3.1 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 --- embroider_print.py | 1 - print/resources/inkstitch.js | 53 ++++++++++++++-------------------- print/templates/operator_overview.html | 2 +- print/templates/print_detail.html | 2 +- print/templates/print_overview.html | 2 +- 5 files changed, 25 insertions(+), 35 deletions(-) (limited to 'print/templates/operator_overview.html') diff --git a/embroider_print.py b/embroider_print.py index bc96b2cd..2aa76ec6 100644 --- a/embroider_print.py +++ b/embroider_print.py @@ -343,7 +343,6 @@ class Print(InkstitchExtension): 'estimated_thread': '', # TODO }, svg_overview = overview_svg, - svg_transform = '', # Format: matrix(0.2, 0, 0, 0.2, 0, 0) color_blocks = stitch_plan.color_blocks, ) 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.3.1 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/templates/operator_overview.html') 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.3.1 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/templates/operator_overview.html') 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.3.1