diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-04-17 15:48:38 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-04-18 15:26:33 -0400 |
| commit | 51741745b0bb691a55b642a2ea938ac74324da2d (patch) | |
| tree | 1b8c5f9d6533d2f2058c419f935546f961cb8037 | |
| parent | 540bf2062a87da5629c7ed98300b39caeffe397f (diff) | |
don't get transform from html
| -rw-r--r-- | embroider_print.py | 1 | ||||
| -rw-r--r-- | print/resources/inkstitch.js | 53 | ||||
| -rw-r--r-- | print/templates/operator_overview.html | 2 | ||||
| -rw-r--r-- | print/templates/print_detail.html | 2 | ||||
| -rw-r--r-- | print/templates/print_overview.html | 2 |
5 files changed, 25 insertions, 35 deletions
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 @@ <main> <figure class="inksimulation operator" style="height: 210mm;" title="{{ _('Ctrl + Scroll to Zoom') }}"> {{ svg_overview|safe }} - <figcaption>{{ _('Scale') }} <span data-field-name="svg-scale" contenteditable="true" data-placeholder="Enter scale...">{{ svg_transform }}</span>%</figcaption> + <figcaption>{{ _('Scale') }} <span class="scale" data-field-name="svg-scale" contenteditable="true" data-placeholder=""></span>%</figcaption> <div> <button class="svg-fit">{{ _('Fit') }}</button> <button class="svg-full">100%</button> 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 @@ <main> <figure class="inksimulation" title="{{ _('Ctrl + Scroll to Zoom') }}"> {{color_block.svg_preview|safe}} - <figcaption>{{ _('Scale') }} <span data-field-name="svg-scale" contenteditable="true" data-placeholder="Enter scale...">{{ svg_transform }}</span>%</figcaption> + <figcaption>{{ _('Scale') }} <span class="scale" data-field-name="svg-scale" contenteditable="true" data-placeholder=""></span>%</figcaption> <div> <button class="svg-fit">Fit</button> <button class="svg-full">100%</button> 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 @@ <main class="client-overview-main"> <figure class="inksimulation" title="{{ _('Ctrl + Scroll to Zoom') }}"> {{ svg_overview|safe }} - <figcaption>{{ _('Scale') }} <span data-field-name="svg-scale" contenteditable="true" data-placeholder="Enter scale...">{{ svg_transform }}</span>%</figcaption> + <figcaption>{{ _('Scale') }} <span class="scale" data-field-name="svg-scale" contenteditable="true" data-placeholder=""></span>%</figcaption> <div> <button class="svg-fit">Fit</button> <button class="svg-full">100%</button> |
