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
|
'estimated_thread': '', # TODO
|
||||||
},
|
},
|
||||||
svg_overview = overview_svg,
|
svg_overview = overview_svg,
|
||||||
svg_transform = '', # Format: matrix(0.2, 0, 0, 0.2, 0, 0)
|
|
||||||
color_blocks = stitch_plan.color_blocks,
|
color_blocks = stitch_plan.color_blocks,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -39,24 +39,14 @@ function scaleSVG(element, scale = 'fit') {
|
||||||
var label = parseInt(scale*100);
|
var label = parseInt(scale*100);
|
||||||
|
|
||||||
element.find('svg').css({ transform: transform });
|
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
|
// set preview svg scale to fit into its box if transform is not set
|
||||||
function scaleAllSvg() {
|
function scaleAllSvg() {
|
||||||
$('.page').each(function() {
|
$('.page').each(function() {
|
||||||
if( $(this).css('display') != 'none' ) {
|
if( $(this).find('.inksimulation svg').css('transform') == 'none') {
|
||||||
if( $(this).find('.inksimulation svg').css('transform') == 'none') {
|
scaleSVG($(this).find('.inksimulation'), 'fit');
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -64,7 +54,6 @@ function scaleAllSvg() {
|
||||||
$(function() {
|
$(function() {
|
||||||
setTimeout(ping, 1000);
|
setTimeout(ping, 1000);
|
||||||
setPageNumbers();
|
setPageNumbers();
|
||||||
scaleAllSvg();
|
|
||||||
|
|
||||||
/* SCALING AND MOVING SVG */
|
/* SCALING AND MOVING SVG */
|
||||||
|
|
||||||
|
@ -92,7 +81,7 @@ $(function() {
|
||||||
svg.css({ transform: 'matrix(' + transform + ')' });
|
svg.css({ transform: 'matrix(' + transform + ')' });
|
||||||
|
|
||||||
// set scale caption text
|
// set scale caption text
|
||||||
$(this).find("span").text(parseInt(scale*100));
|
$(this).find(".scale").text(parseInt(scale*100));
|
||||||
|
|
||||||
//prevent page fom scrolling
|
//prevent page fom scrolling
|
||||||
return false;
|
return false;
|
||||||
|
@ -138,7 +127,7 @@ $(function() {
|
||||||
var scale = transform.match(/-?[\d\.]+/g)[0];
|
var scale = transform.match(/-?[\d\.]+/g)[0];
|
||||||
$('.inksimulation').each(function() {
|
$('.inksimulation').each(function() {
|
||||||
$(this).find('svg').css({ transform: transform });
|
$(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
|
// load up initial metadata values
|
||||||
$.getJSON('/settings', function(settings) {
|
$.getJSON('/settings', function(settings) {
|
||||||
$.each(settings, function(field_name, value) {
|
$.each(settings, function(field_name, value) {
|
||||||
$('[data-field-name="' + field_name + '"]').each(function(i, item) {
|
$('[data-field-name="' + field_name + '"]').each(function(i, item) {
|
||||||
var item = $(item);
|
var item = $(item);
|
||||||
if (item.is(':checkbox')) {
|
if (item.is(':checkbox')) {
|
||||||
item.prop('checked', value).trigger('change');
|
item.prop('checked', value).trigger('change');
|
||||||
} else if (item.is('img')) {
|
} else if (item.is('img')) {
|
||||||
item.attr('src', value);
|
item.attr('src', value);
|
||||||
} else if (item.is('select')) {
|
} else if (item.is('select')) {
|
||||||
item.val(value).trigger('change');
|
item.val(value).trigger('change');
|
||||||
} else {
|
} else {
|
||||||
item.text(value);
|
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) {
|
$('[contenteditable="true"]').keypress(function(e) {
|
||||||
|
@ -229,6 +220,7 @@ $(function() {
|
||||||
$('select#printing-size').change(function(){
|
$('select#printing-size').change(function(){
|
||||||
var size = $(this).find(':selected').val();
|
var size = $(this).find(':selected').val();
|
||||||
$('.page').toggleClass('a4', size == 'a4');
|
$('.page').toggleClass('a4', size == 'a4');
|
||||||
|
console.log("" + Date.now() + "paper size changed");
|
||||||
$.postJSON('/settings/paper-size', {value: size});
|
$.postJSON('/settings/paper-size', {value: size});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -239,7 +231,6 @@ $(function() {
|
||||||
|
|
||||||
$('.' + field_name).toggle(checked);
|
$('.' + field_name).toggle(checked);
|
||||||
setPageNumbers();
|
setPageNumbers();
|
||||||
scaleAllSvg();
|
|
||||||
|
|
||||||
$.postJSON('/settings/' + field_name, {value: checked});
|
$.postJSON('/settings/' + field_name, {value: checked});
|
||||||
});
|
});
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<main>
|
<main>
|
||||||
<figure class="inksimulation operator" style="height: 210mm;" title="{{ _('Ctrl + Scroll to Zoom') }}">
|
<figure class="inksimulation operator" style="height: 210mm;" title="{{ _('Ctrl + Scroll to Zoom') }}">
|
||||||
{{ svg_overview|safe }}
|
{{ 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>
|
<div>
|
||||||
<button class="svg-fit">{{ _('Fit') }}</button>
|
<button class="svg-fit">{{ _('Fit') }}</button>
|
||||||
<button class="svg-full">100%</button>
|
<button class="svg-full">100%</button>
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<main>
|
<main>
|
||||||
<figure class="inksimulation" title="{{ _('Ctrl + Scroll to Zoom') }}">
|
<figure class="inksimulation" title="{{ _('Ctrl + Scroll to Zoom') }}">
|
||||||
{{color_block.svg_preview|safe}}
|
{{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>
|
<div>
|
||||||
<button class="svg-fit">Fit</button>
|
<button class="svg-fit">Fit</button>
|
||||||
<button class="svg-full">100%</button>
|
<button class="svg-full">100%</button>
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
<main class="client-overview-main">
|
<main class="client-overview-main">
|
||||||
<figure class="inksimulation" title="{{ _('Ctrl + Scroll to Zoom') }}">
|
<figure class="inksimulation" title="{{ _('Ctrl + Scroll to Zoom') }}">
|
||||||
{{ svg_overview|safe }}
|
{{ 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>
|
<div>
|
||||||
<button class="svg-fit">Fit</button>
|
<button class="svg-fit">Fit</button>
|
||||||
<button class="svg-full">100%</button>
|
<button class="svg-full">100%</button>
|
||||||
|
|
Ładowanie…
Reference in New Issue