diff --git a/lib/extensions/print_pdf.py b/lib/extensions/print_pdf.py index 91562c09b..3dcb27438 100644 --- a/lib/extensions/print_pdf.py +++ b/lib/extensions/print_pdf.py @@ -206,10 +206,10 @@ class PrintPreviewServer(Thread): @self.app.route('/realistic', methods=['GET']) def get_realistic(): - return jsonify({ - 'overview': self.realistic_overview_svg, - 'color_blocks': self.realistic_color_block_svgs - }) + realistic = { 'overview': self.realistic_overview_svg } + for i, svg in enumerate(self.realistic_color_block_svgs): + realistic["block%d" % i] = svg + return jsonify(realistic) def stop(self): # for whatever reason, shutting down only seems possible in diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index e5065fe6e..bb1407050 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -7,6 +7,9 @@ $.postJSON = function(url, data, success=null) { }); }; +var realistic_rendering = {}; +var normal_rendering = {}; + function ping() { $.get("/ping") .done(function() { setTimeout(ping, 1000) }) @@ -142,6 +145,11 @@ $(function() { setSVGTransform($(this), $(this).find('svg').css('transform')); }); + // ignore mouse events on the buttons (Fill, 100%, Apply to All) + $('figure.inksimulation div').on('mousedown mouseup', function(e) { + e.stopPropagation(); + }); + /* Apply transforms to All */ $('button.svg-apply').click(function() { var transform = $(this).parent().siblings('svg').css('transform'); @@ -190,6 +198,12 @@ $(function() { } }); }); + + $.getJSON('/realistic', function(realistic_data) { + // realistic_rendering is global + realistic_rendering = realistic_data; + }); + // wait until page size is set (if they've specified one) and then scale SVGs to fit setTimeout(function() { scaleAllSvg() }, 500); }); @@ -288,8 +302,8 @@ $(function() { $('.modal').hide(); }); - //Checkbox - $(':checkbox').on('change initialize', function() { + // View selection checkboxes + $(':checkbox.view').on('change initialize', function() { var field_name = $(this).attr('data-field-name'); $('.' + field_name).toggle($(this).prop('checked')); @@ -299,6 +313,42 @@ $(function() { $.postJSON('/settings/' + field_name, {value: $(this).prop('checked')}); }); + // Realistic rendering checkboxes + $(':checkbox.realistic').on('change', function(e) { + console.log("realistic rendering checkbox"); + + var item = $(this).data('field-name'); + var figure = $(this).closest('figure'); + var svg = figure.find('svg'); + var transform = svg.css('transform'); + var checked = $(this).prop('checked'); + + console.log("" + item + " " + transform); + + // do this later to allow this event handler to return now, + // which will cause the checkbox to be checked or unchecked + // immediately even if SVG rendering takes awhile + setTimeout(function() { + if (checked) { + if (!(item in normal_rendering)) { + normal_rendering[item] = svg[0].outerHTML; + } + svg[0].outerHTML = realistic_rendering[item]; + } else { + svg[0].outerHTML = normal_rendering[item]; + } + // can't use the svg variable here because setting outerHTML created a new tag + figure.find('svg').css({transform: transform}); + }, 100); + + e.stopPropagation(); + return true; + }); + + $('button.svg-realistic').click(function(e){ + $(this).find('input').click(); + }); + // Logo $('#logo-picker').change(function(e) { var file = e.originalEvent.currentTarget.files[0]; diff --git a/print/resources/style.css b/print/resources/style.css index 58ec8714b..716934a86 100644 --- a/print/resources/style.css +++ b/print/resources/style.css @@ -473,6 +473,28 @@ body { border: none; background: grey; color: white; + display: inline-block; + font-size: 16px; + font-family: "Barlow", sans-serif; + padding-left: 3px; + padding-right: 3px; + margin: 0px 1px 0px 1px; + } + + input.realistic { + position: absolute; + transform: scale(0.7); + margin-left: 2px; + } + + label.realistic { + margin-left: 20px; + } + + /* prevents Chrome from sending a double event for the checkbox + and the containing + diff --git a/print/templates/print_detail.html b/print/templates/print_detail.html index 714d33a24..e73fe918b 100644 --- a/print/templates/print_detail.html +++ b/print/templates/print_detail.html @@ -22,9 +22,12 @@ + - - +
{% include 'color_swatch.html' %}
diff --git a/print/templates/print_overview.html b/print/templates/print_overview.html index efcf5b2eb..b42ab7a99 100644 --- a/print/templates/print_overview.html +++ b/print/templates/print_overview.html @@ -32,14 +32,18 @@ + - - + +
{% for color_block in color_blocks %} {% include 'color_swatch.html' %} - {% endfor %} - + {% endfor %} +
{{ _('Client Signature') }}
diff --git a/print/templates/ui.html b/print/templates/ui.html index b09dc9414..3b11f3456 100644 --- a/print/templates/ui.html +++ b/print/templates/ui.html @@ -26,10 +26,10 @@
{{ _('Print Layouts') }} -

-

-

-

+

+

+

+