-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfuncoes.js
163 lines (129 loc) · 4.71 KB
/
funcoes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
// function getFileName(elm) {
// var fn = $(elm).val();
// var filename = fn.match(/[^\\/]*$/)[0]; // remove C:\fakename
// //$('.figurinha__foto').css('background-image', 'url(' + filename + ')');
// $('.figurinha__foto').attr('src', filename);
// //$('#fileName').attr('value', filename);
// }
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$('.figurinha__foto').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}
$(document).ready(function () {
var element = $(".a3"); // global variable
var elementF = $(".figurinha"); // global variable
var getCanvas; // global variable
$("#btn-Preview-Image").on('click', function () {
var nome = $('#nome').val();
var tipo = $('#tipo').val();
html2canvas(elementF, {
onrendered: function (canvas) {
//$("#previewImage").append(canvas);
// var w = window.open();
// $(w.document.body).html(getCanvas);
var imgData = canvas.toDataURL("image/jpeg", 1.0);
var pdf = new jsPDF();
pdf.addImage(imgData, 'JPEG', 0, 0);
// imgData.save("figu.jpg");
pdf.save(tipo+"_"+nome+".pdf");
}
});
});
$("#pdfDown1").on('click', function () {
var nome = $('#nome').val();
var tipo = $('#tipo').val();
kendo.drawing
.drawDOM(".figurinha",
{
paperSize: "A5",
margin: { top: "0.5cm", left: "0.5cm", bottom: "0.5cm", right: "0.5cm" },
scale: 1,
height: 500,
landscape: false,
//template: $(".a3").html(),
})
.then(function (group) {
kendo.drawing.pdf.saveAs(group, "fig_" + tipo + "_" + nome + ".pdf")
});
});
$('#save_image_locally').click(function(){
var nome = $('#nome').val();
var tipo = $('#tipo').val();
html2canvas($('.figurinha1'), {
onrendered: function (canvas) {
$('#download').attr('href', canvas.toDataURL("image/png"))
$('#download').attr('download',"fig_" + tipo + "_" + nome + ".png");
$('#download')[0].click();
// a.href = canvas.toDataURL("image/jpeg").replace("image/jpeg", "image/octet-stream");
// a.download = 'somefilename.jpg';
// a.click();
}
});
});
$(".draggable").draggable({
drag: function () {
var top = $(this).css('top');
$('.draggable_copy').css('top', top);
var left = $(this).css('left');
$('.draggable_copy').css('left', left);
}
});
$("#pdfDown").on('click', function () {
var nome = $('#nome').val();
var tipo = $('#tipo').val();
html2canvas(element, {
onrendered: function (canvas) {
//$("#previewImage").append(canvas);
getCanvas = canvas;
}
});
kendo.drawing
.drawDOM(".a3",
{
paperSize: "A3",
margin: { top: "0.5cm", left: "0.5cm", bottom: "0.5cm", right: "0.5cm" },
scale: 0.38,
height: 500,
landscape: true,
//template: $(".a3").html(),
})
.then(function (group) {
kendo.drawing.pdf.saveAs(group, "fig_" + tipo + "_" + nome + ".pdf")
});
});
$('.action').hide();
$(".bottomItem").click(function(){
if ($(this).hasClass("clicked")) {
$(this).removeClass('clicked');
$('.action').hide();
}else{
$(".bottomItem").removeClass('clicked');
$(this).addClass('clicked');
$('.action').hide();
if ($(this).hasClass("itemText")) {
$('.actText').show();
}
if ($(this).hasClass("itemTeam")) {
$('.actTeam').show();
}
if ($(this).hasClass("itemSize")) {
$('.actSize').show();
}
if ($(this).hasClass("itemMove")) {
$('.actMove').show();
}
if ($(this).hasClass("itemRotate")) {
$('.actRotate').show();
}
if ($(this).hasClass("itemPhoto")) {
$('#file').trigger('click');
$(this).removeClass('clicked');
}
}
})
});