diff options
| author | Lex Neva <github.com@lexneva.name> | 2018-04-21 16:23:13 -0400 |
|---|---|---|
| committer | Lex Neva <github.com@lexneva.name> | 2018-04-29 21:28:48 -0400 |
| commit | d4c95e080ffb80ceb6f10b663c7547b25689a840 (patch) | |
| tree | b68785ee216cd229a54c74dbcd359fbce32a6339 /print/resources | |
| parent | 378f079e6d15757ed6cb0b2e04f50642b5adaaac (diff) | |
assign thread color names in printout
Diffstat (limited to 'print/resources')
| -rw-r--r-- | print/resources/inkstitch.js | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 498b1211..4a4e4456 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -24,17 +24,17 @@ function setPageNumbers() { // Scale SVG (fit || full size) function scaleSVG(element, scale = 'fit') { - + // always center svg transform = "translate(-50%, -50%)"; - + if(scale == 'fit') { var scale = Math.min( - element.width() / element.find('svg').width(), + element.width() / element.find('svg').width(), element.height() / element.find('svg').height() ); } - + transform += " scale(" + scale + ")"; var label = parseInt(scale*100); @@ -71,17 +71,17 @@ function setSVGTransform(figure, transform) { $(function() { setTimeout(ping, 1000); setPageNumbers(); - + /* SCALING AND MOVING SVG */ - + /* Mousewheel scaling */ $('figure.inksimulation').on( 'DOMMouseScroll mousewheel', function (e) { if(e.ctrlKey == true) { - + var svg = $(this).find('svg'); var transform = svg.css('transform').match(/-?[\d\.]+/g); var scale = parseFloat(transform[0]); - + if (e.originalEvent.detail > 0 || e.originalEvent.wheelDelta < 0) { // scroll down = zoom out scale *= 0.97; @@ -91,7 +91,7 @@ $(function() { //scroll up scale *= 1.03; } - + // set modified scale transform[0] = scale; transform[3] = scale; @@ -102,19 +102,19 @@ $(function() { return false; } }); - + /* Fit SVG */ $('button.svg-fit').click(function() { var svgfigure = $(this).closest('figure'); scaleSVG(svgfigure, 'fit'); }); - + /* Full Size SVG */ $('button.svg-full').click(function() { var svgfigure = $(this).closest('figure'); scaleSVG(svgfigure, '1'); }); - + /* Drag SVG */ $('figure.inksimulation').on('mousedown', function(e) { var p0 = { x: e.pageX, y: e.pageY }; @@ -141,7 +141,7 @@ $(function() { // 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'); @@ -154,7 +154,7 @@ $(function() { $('[contenteditable="true"]').on('focusout', function() { /* change svg scale */ - var content = $(this).html(); + var content = $.trim($(this).text()); var field_name = $(this).attr('data-field-name'); if(field_name == 'svg-scale') { var scale = parseInt(content); @@ -295,4 +295,3 @@ $(function() { $.postJSON('/defaults', {'value': settings}); }); }); - |
