kopia lustrzana https://github.com/inkstitch/inkstitch
				
				
				
			don't get transform from html
							rodzic
							
								
									540bf2062a
								
							
						
					
					
						commit
						51741745b0
					
				|  | @ -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, | ||||
|         ) | ||||
| 
 | ||||
|  |  | |||
|  | @ -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)); | ||||
|           } | ||||
|         } | ||||
|         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)); | ||||
|        | ||||
|     }) | ||||
|   }); | ||||
|  | @ -181,6 +170,8 @@ $(function() { | |||
|             } | ||||
|         }); | ||||
|     }); | ||||
|     // 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}); | ||||
|   }); | ||||
|  |  | |||
|  | @ -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> | ||||
|  |  | |||
|  | @ -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> | ||||
|  |  | |||
|  | @ -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> | ||||
|  |  | |||
		Ładowanie…
	
		Reference in New Issue
	
	 Lex Neva
						Lex Neva