appscms-tools-theme 2.2.2 → 2.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/_data/calculators/en/biology-calc/bulb-spacing.json +79 -1
- data/_data/calculators/en/biology-calc/cat-chocolate-toxicity.json +53 -1
- data/_data/calculators/en/chemistry-calc/activation-energy.json +45 -1
- data/_data/feature/en/allele-frequency.json +242 -242
- data/_data/feature/en/batch-conversion.json +78 -0
- data/_data/feature/en/compress-pdf.json +11 -5
- data/_data/feature/en/theframe.json +64 -64
- data/_data/photo-categories.json +10 -10
- data/_includes/batch-conversion.html +70 -0
- data/_includes/monumetric/ads.html +57 -57
- data/_includes/monumetric/profitablecpmgate.html +51 -51
- data/_layouts/batch.html +97 -0
- data/_layouts/calculator.html +69 -69
- data/_layouts/frame.html +128 -128
- data/assets/css/batch.css +423 -0
- data/assets/css/calculators.css +40 -40
- data/assets/css/frame.css +431 -431
- data/assets/images/add-image.png +0 -0
- data/assets/images/add.png +0 -0
- data/assets/images/cloud-computing.png +0 -0
- data/assets/images/convert.png +0 -0
- data/assets/images/download.png +0 -0
- data/assets/images/file.png +0 -0
- data/assets/images/safeimagekit. (2).png +0 -0
- data/assets/images/safeimagekit. (3).png +0 -0
- data/assets/images/safeimagekit..png +0 -0
- data/assets/images/safeimagekit.png +0 -0
- data/assets/images/spinner.gif +0 -0
- data/assets/images/trust.svg +1 -0
- data/assets/images/vectorpaint.svg +6 -0
- data/assets/js/ads.js +8 -8
- data/assets/js/append-div.js +10 -10
- data/assets/js/batch.js +190 -0
- data/assets/js/frame.js +251 -251
- data/assets/js/photo-effects.json +55 -55
- data/assets/js/testing-batch.js +36 -0
- data/assets/js/theme.js +11 -11
- metadata +26 -7
data/assets/js/frame.js
CHANGED
|
@@ -1,251 +1,251 @@
|
|
|
1
|
-
const getScript = document.currentScript
|
|
2
|
-
const pageTool = getScript.dataset.tool
|
|
3
|
-
const lang = getScript.dataset.lang
|
|
4
|
-
const inputBox = document.querySelector('#Inputbox')
|
|
5
|
-
const fileDropBox = document.querySelector('.custom-box')
|
|
6
|
-
const cropModal = document.querySelector('.crop-image-modal-container')
|
|
7
|
-
const workspace = document.getElementById('workspace')
|
|
8
|
-
const canvasPanel = document.getElementById('canvas-panel')
|
|
9
|
-
const download = document.querySelector('#download-button')
|
|
10
|
-
const form = document.querySelector('#effect-form')
|
|
11
|
-
let files = []
|
|
12
|
-
let cropWidth = null
|
|
13
|
-
let cropHeight = null
|
|
14
|
-
let cropper = null
|
|
15
|
-
let cropInputWidth = null
|
|
16
|
-
let index = 0
|
|
17
|
-
let cropInputHeight = null
|
|
18
|
-
let image = null
|
|
19
|
-
const showLoader = () => {
|
|
20
|
-
showLoading()
|
|
21
|
-
}
|
|
22
|
-
const closeLoader = () => {}
|
|
23
|
-
const clickInput = (e) => {
|
|
24
|
-
console.log(`#file-${e.dataset.index}`)
|
|
25
|
-
document.querySelector(`#file-${e.dataset.index}`).click()
|
|
26
|
-
}
|
|
27
|
-
let featureData = null
|
|
28
|
-
|
|
29
|
-
fetch('/assets/js/photo-effects.json')
|
|
30
|
-
.then((response) => response.json())
|
|
31
|
-
.then((data) => {
|
|
32
|
-
featureData = data.find((i) => i.name === form.dataset.featureName)
|
|
33
|
-
console.log(featureData)
|
|
34
|
-
})
|
|
35
|
-
const fileOnChange = (e) => {
|
|
36
|
-
index = Number(e.dataset.index)
|
|
37
|
-
let reader = new FileReader()
|
|
38
|
-
reader.onload = (event) => {
|
|
39
|
-
cropModal.style.display = 'flex'
|
|
40
|
-
if (cropper === null) {
|
|
41
|
-
cropImage(event.target.result, e.id)
|
|
42
|
-
} else {
|
|
43
|
-
updateCropper(event.target.result, e.id)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
reader.readAsDataURL(e.files[0])
|
|
47
|
-
}
|
|
48
|
-
const closeModal = () => {
|
|
49
|
-
cropModal.style.display = 'none'
|
|
50
|
-
}
|
|
51
|
-
form.addEventListener('submit', (e) => {
|
|
52
|
-
e.preventDefault()
|
|
53
|
-
drawImage()
|
|
54
|
-
})
|
|
55
|
-
const drawInputImage = (ctx, item, indexValue, canvas, image) => {
|
|
56
|
-
return new Promise((resolve, reject) => {
|
|
57
|
-
let image = document.createElement('img')
|
|
58
|
-
image.src = files[indexValue]
|
|
59
|
-
image.onload = () => {
|
|
60
|
-
image.width = Number(item.width)
|
|
61
|
-
image.height = Number(item.height)
|
|
62
|
-
if (item.filter) {
|
|
63
|
-
ctx.filter = item.filter
|
|
64
|
-
}
|
|
65
|
-
ctx.drawImage(
|
|
66
|
-
image,
|
|
67
|
-
Number(item.x),
|
|
68
|
-
Number(item.y),
|
|
69
|
-
image.width,
|
|
70
|
-
image.height
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
const drawRotated = (degrees, ctx, canvas, image, item) => {
|
|
81
|
-
console.log(image)
|
|
82
|
-
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
83
|
-
|
|
84
|
-
// save the unrotatedctx of the canvas so we can restore it later
|
|
85
|
-
// the alternative is to untranslate & unrotate after drawing
|
|
86
|
-
ctx.save()
|
|
87
|
-
|
|
88
|
-
// move to the center of the canvas
|
|
89
|
-
ctx.translate(item.x, item.y)
|
|
90
|
-
|
|
91
|
-
// rotate the canvas to the specified degrees
|
|
92
|
-
ctx.rotate((degrees * Math.PI) / 180)
|
|
93
|
-
|
|
94
|
-
// draw the image
|
|
95
|
-
// since thectx is rotated, the image will be rotated also
|
|
96
|
-
ctx.drawImage(image, -image.width / 2, -image.width / 2)
|
|
97
|
-
|
|
98
|
-
// we’re done with the rotating so restore the unrotatedctx
|
|
99
|
-
ctx.restore()
|
|
100
|
-
}
|
|
101
|
-
const drawImage = () => {
|
|
102
|
-
let img = new Image()
|
|
103
|
-
img.src = featureData.effectImagePath
|
|
104
|
-
var canvas = document.createElement('canvas')
|
|
105
|
-
var ctx = canvas.getContext('2d')
|
|
106
|
-
img.onload = () => {
|
|
107
|
-
canvas.width = img.width
|
|
108
|
-
canvas.height = img.height
|
|
109
|
-
Promise.all(
|
|
110
|
-
featureData.elements.map((item, indexValue) => {
|
|
111
|
-
if (item.type === 'image') {
|
|
112
|
-
return new Promise((resolve, reject) => {
|
|
113
|
-
drawInputImage(ctx, item, indexValue, canvas).then(() => {
|
|
114
|
-
resolve()
|
|
115
|
-
})
|
|
116
|
-
})
|
|
117
|
-
}
|
|
118
|
-
})
|
|
119
|
-
).then(() => {
|
|
120
|
-
ctx.filter = 'none'
|
|
121
|
-
ctx.drawImage(img, 0, 0, canvas.width, canvas.height)
|
|
122
|
-
featureData.elements.map((item, indexValue) => {
|
|
123
|
-
if (item.type === 'text') {
|
|
124
|
-
let myFont = new FontFace(item.font, `url(${item.fontPath})`)
|
|
125
|
-
myFont.load().then(function (font) {
|
|
126
|
-
document.fonts.add(font)
|
|
127
|
-
ctx.font = `${item.fontSize}px ${item.font}`
|
|
128
|
-
if (item.shadowColor) {
|
|
129
|
-
ctx.shadowColor = `${item.shadowColor}`
|
|
130
|
-
}
|
|
131
|
-
console.log(item)
|
|
132
|
-
console.log((item.rotate * Math.PI) / 180)
|
|
133
|
-
if (item.rotate) {
|
|
134
|
-
ctx.rotate((item.rotate * Math.PI) / 180)
|
|
135
|
-
}
|
|
136
|
-
if (item.shadowOffsetX) {
|
|
137
|
-
ctx.shadowOffsetX = 3
|
|
138
|
-
}
|
|
139
|
-
if (item.shadowOffsetY) {
|
|
140
|
-
ctx.shadowOffsetY = 3
|
|
141
|
-
}
|
|
142
|
-
if (item.shadowBlur) {
|
|
143
|
-
ctx.shadowBlur = 2
|
|
144
|
-
}
|
|
145
|
-
ctx.textAlign = 'center'
|
|
146
|
-
ctx.fillStyle = `${item.color}`
|
|
147
|
-
ctx.save()
|
|
148
|
-
ctx.fillText(
|
|
149
|
-
document.querySelector(`#${item.id}`).value,
|
|
150
|
-
item.x,
|
|
151
|
-
item.y
|
|
152
|
-
)
|
|
153
|
-
ctx.restore()
|
|
154
|
-
})
|
|
155
|
-
}
|
|
156
|
-
if (item.type === 'rectangle') {
|
|
157
|
-
}
|
|
158
|
-
})
|
|
159
|
-
canvasPanel.innerHTML = ''
|
|
160
|
-
canvasPanel.appendChild(canvas)
|
|
161
|
-
workspace.style.display = 'block'
|
|
162
|
-
})
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
const cropImage = (result, id) => {
|
|
166
|
-
let image = new Image()
|
|
167
|
-
image.onload = () => {
|
|
168
|
-
let img = document.createElement('img')
|
|
169
|
-
img.src = result
|
|
170
|
-
img.id = 'image'
|
|
171
|
-
document.querySelector('.crop-image-modal-body').appendChild(img)
|
|
172
|
-
cropper = new Cropper(img, {
|
|
173
|
-
viewMode: 3,
|
|
174
|
-
ready() {
|
|
175
|
-
console.log(id)
|
|
176
|
-
let find = featureData.elements.find((i) => i.id === id)
|
|
177
|
-
console.log(find)
|
|
178
|
-
cropper.setAspectRatio(Number(find.width) / Number(find.height))
|
|
179
|
-
cropModal.style.display = 'flex'
|
|
180
|
-
this.cropper.crop()
|
|
181
|
-
},
|
|
182
|
-
crop(event) {
|
|
183
|
-
cropWidth = Math.round(event.detail.width)
|
|
184
|
-
cropHeight = Math.round(event.detail.height)
|
|
185
|
-
},
|
|
186
|
-
})
|
|
187
|
-
}
|
|
188
|
-
image.src = result
|
|
189
|
-
}
|
|
190
|
-
const updateCropper = (result, id) => {
|
|
191
|
-
cropper.destroy()
|
|
192
|
-
document.querySelector('.crop-image-modal-body').innerHTML = ''
|
|
193
|
-
cropImage(result, id)
|
|
194
|
-
}
|
|
195
|
-
document.querySelector('#crop').addEventListener('click', () => {
|
|
196
|
-
let cropperImg = cropper
|
|
197
|
-
.getCroppedCanvas({
|
|
198
|
-
width: cropWidth,
|
|
199
|
-
height: cropHeight,
|
|
200
|
-
})
|
|
201
|
-
.toDataURL()
|
|
202
|
-
files[index - 1] = cropperImg
|
|
203
|
-
cropModal.style.display = 'none'
|
|
204
|
-
})
|
|
205
|
-
let inputFile = ''
|
|
206
|
-
const handleFile = (file) => {
|
|
207
|
-
cropModal.style.display = 'flex'
|
|
208
|
-
document.querySelector('#file-loader').style.display = 'flex'
|
|
209
|
-
document.querySelector('.file-input').style.display = 'none'
|
|
210
|
-
inputFile = file
|
|
211
|
-
if (file) {
|
|
212
|
-
const reader = new FileReader()
|
|
213
|
-
reader.onload = (e) => {
|
|
214
|
-
if (e.target.result) {
|
|
215
|
-
cropImage(e.target.result)
|
|
216
|
-
}
|
|
217
|
-
}
|
|
218
|
-
reader.readAsDataURL(file)
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
const showLoading = () => {
|
|
222
|
-
document.querySelector('#file-loader').style.display = 'flex'
|
|
223
|
-
document.querySelector('.file-input').style.display = 'none'
|
|
224
|
-
}
|
|
225
|
-
const stopLoading = () => {
|
|
226
|
-
fileDropBox.style.display = 'none'
|
|
227
|
-
}
|
|
228
|
-
download.addEventListener('click', () => {
|
|
229
|
-
let canvas = document.querySelector('canvas')
|
|
230
|
-
let url = canvas.toDataURL(`image/png`)
|
|
231
|
-
let a = document.createElement('a')
|
|
232
|
-
a.href = url
|
|
233
|
-
a.download = `safeimagekit-border-image.${inputFile.type.split('/')[1]}`
|
|
234
|
-
document.body.appendChild(a)
|
|
235
|
-
a.click()
|
|
236
|
-
if (lang === 'en') {
|
|
237
|
-
window.location.href = `/download?tool=${pageTool}`
|
|
238
|
-
} else {
|
|
239
|
-
window.location.href = `/${lang}/download?tool=${pageTool}`
|
|
240
|
-
}
|
|
241
|
-
})
|
|
242
|
-
|
|
243
|
-
//
|
|
244
|
-
// fonts
|
|
245
|
-
// font rotation
|
|
246
|
-
// font position
|
|
247
|
-
// font transform
|
|
248
|
-
|
|
249
|
-
//images
|
|
250
|
-
//image rotation
|
|
251
|
-
// image rectangle with text
|
|
1
|
+
const getScript = document.currentScript
|
|
2
|
+
const pageTool = getScript.dataset.tool
|
|
3
|
+
const lang = getScript.dataset.lang
|
|
4
|
+
const inputBox = document.querySelector('#Inputbox')
|
|
5
|
+
const fileDropBox = document.querySelector('.custom-box')
|
|
6
|
+
const cropModal = document.querySelector('.crop-image-modal-container')
|
|
7
|
+
const workspace = document.getElementById('workspace')
|
|
8
|
+
const canvasPanel = document.getElementById('canvas-panel')
|
|
9
|
+
const download = document.querySelector('#download-button')
|
|
10
|
+
const form = document.querySelector('#effect-form')
|
|
11
|
+
let files = []
|
|
12
|
+
let cropWidth = null
|
|
13
|
+
let cropHeight = null
|
|
14
|
+
let cropper = null
|
|
15
|
+
let cropInputWidth = null
|
|
16
|
+
let index = 0
|
|
17
|
+
let cropInputHeight = null
|
|
18
|
+
let image = null
|
|
19
|
+
const showLoader = () => {
|
|
20
|
+
showLoading()
|
|
21
|
+
}
|
|
22
|
+
const closeLoader = () => { }
|
|
23
|
+
const clickInput = (e) => {
|
|
24
|
+
console.log(`#file-${e.dataset.index}`)
|
|
25
|
+
document.querySelector(`#file-${e.dataset.index}`).click()
|
|
26
|
+
}
|
|
27
|
+
let featureData = null
|
|
28
|
+
|
|
29
|
+
fetch('/assets/js/photo-effects.json')
|
|
30
|
+
.then((response) => response.json())
|
|
31
|
+
.then((data) => {
|
|
32
|
+
featureData = data.find((i) => i.name === form.dataset.featureName)
|
|
33
|
+
console.log(featureData)
|
|
34
|
+
})
|
|
35
|
+
const fileOnChange = (e) => {
|
|
36
|
+
index = Number(e.dataset.index)
|
|
37
|
+
let reader = new FileReader()
|
|
38
|
+
reader.onload = (event) => {
|
|
39
|
+
cropModal.style.display = 'flex'
|
|
40
|
+
if (cropper === null) {
|
|
41
|
+
cropImage(event.target.result, e.id)
|
|
42
|
+
} else {
|
|
43
|
+
updateCropper(event.target.result, e.id)
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
reader.readAsDataURL(e.files[0])
|
|
47
|
+
}
|
|
48
|
+
const closeModal = () => {
|
|
49
|
+
cropModal.style.display = 'none'
|
|
50
|
+
}
|
|
51
|
+
form.addEventListener('submit', (e) => {
|
|
52
|
+
e.preventDefault()
|
|
53
|
+
drawImage()
|
|
54
|
+
})
|
|
55
|
+
const drawInputImage = (ctx, item, indexValue, canvas, image) => {
|
|
56
|
+
return new Promise((resolve, reject) => {
|
|
57
|
+
let image = document.createElement('img')
|
|
58
|
+
image.src = files[indexValue]
|
|
59
|
+
image.onload = () => {
|
|
60
|
+
image.width = Number(item.width)
|
|
61
|
+
image.height = Number(item.height)
|
|
62
|
+
if (item.filter) {
|
|
63
|
+
ctx.filter = item.filter
|
|
64
|
+
}
|
|
65
|
+
ctx.drawImage(
|
|
66
|
+
image,
|
|
67
|
+
Number(item.x),
|
|
68
|
+
Number(item.y),
|
|
69
|
+
image.width,
|
|
70
|
+
image.height
|
|
71
|
+
)
|
|
72
|
+
if (item.rotate) {
|
|
73
|
+
drawRotated(item.rotate, ctx, canvas, image, item)
|
|
74
|
+
}
|
|
75
|
+
resolve()
|
|
76
|
+
}
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const drawRotated = (degrees, ctx, canvas, image, item) => {
|
|
81
|
+
console.log(image)
|
|
82
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height)
|
|
83
|
+
|
|
84
|
+
// save the unrotatedctx of the canvas so we can restore it later
|
|
85
|
+
// the alternative is to untranslate & unrotate after drawing
|
|
86
|
+
ctx.save()
|
|
87
|
+
|
|
88
|
+
// move to the center of the canvas
|
|
89
|
+
ctx.translate(item.x, item.y)
|
|
90
|
+
|
|
91
|
+
// rotate the canvas to the specified degrees
|
|
92
|
+
ctx.rotate((degrees * Math.PI) / 180)
|
|
93
|
+
|
|
94
|
+
// draw the image
|
|
95
|
+
// since thectx is rotated, the image will be rotated also
|
|
96
|
+
ctx.drawImage(image, -image.width / 2, -image.width / 2)
|
|
97
|
+
|
|
98
|
+
// we’re done with the rotating so restore the unrotatedctx
|
|
99
|
+
ctx.restore()
|
|
100
|
+
}
|
|
101
|
+
const drawImage = () => {
|
|
102
|
+
let img = new Image()
|
|
103
|
+
img.src = featureData.effectImagePath
|
|
104
|
+
var canvas = document.createElement('canvas')
|
|
105
|
+
var ctx = canvas.getContext('2d')
|
|
106
|
+
img.onload = () => {
|
|
107
|
+
canvas.width = img.width
|
|
108
|
+
canvas.height = img.height
|
|
109
|
+
Promise.all(
|
|
110
|
+
featureData.elements.map((item, indexValue) => {
|
|
111
|
+
if (item.type === 'image') {
|
|
112
|
+
return new Promise((resolve, reject) => {
|
|
113
|
+
drawInputImage(ctx, item, indexValue, canvas).then(() => {
|
|
114
|
+
resolve()
|
|
115
|
+
})
|
|
116
|
+
})
|
|
117
|
+
}
|
|
118
|
+
})
|
|
119
|
+
).then(() => {
|
|
120
|
+
ctx.filter = 'none'
|
|
121
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height)
|
|
122
|
+
featureData.elements.map((item, indexValue) => {
|
|
123
|
+
if (item.type === 'text') {
|
|
124
|
+
let myFont = new FontFace(item.font, `url(${item.fontPath})`)
|
|
125
|
+
myFont.load().then(function (font) {
|
|
126
|
+
document.fonts.add(font)
|
|
127
|
+
ctx.font = `${item.fontSize}px ${item.font}`
|
|
128
|
+
if (item.shadowColor) {
|
|
129
|
+
ctx.shadowColor = `${item.shadowColor}`
|
|
130
|
+
}
|
|
131
|
+
console.log(item)
|
|
132
|
+
console.log((item.rotate * Math.PI) / 180)
|
|
133
|
+
if (item.rotate) {
|
|
134
|
+
ctx.rotate((item.rotate * Math.PI) / 180)
|
|
135
|
+
}
|
|
136
|
+
if (item.shadowOffsetX) {
|
|
137
|
+
ctx.shadowOffsetX = 3
|
|
138
|
+
}
|
|
139
|
+
if (item.shadowOffsetY) {
|
|
140
|
+
ctx.shadowOffsetY = 3
|
|
141
|
+
}
|
|
142
|
+
if (item.shadowBlur) {
|
|
143
|
+
ctx.shadowBlur = 2
|
|
144
|
+
}
|
|
145
|
+
ctx.textAlign = 'center'
|
|
146
|
+
ctx.fillStyle = `${item.color}`
|
|
147
|
+
ctx.save()
|
|
148
|
+
ctx.fillText(
|
|
149
|
+
document.querySelector(`#${item.id}`).value,
|
|
150
|
+
item.x,
|
|
151
|
+
item.y
|
|
152
|
+
)
|
|
153
|
+
ctx.restore()
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
if (item.type === 'rectangle') {
|
|
157
|
+
}
|
|
158
|
+
})
|
|
159
|
+
canvasPanel.innerHTML = ''
|
|
160
|
+
canvasPanel.appendChild(canvas)
|
|
161
|
+
workspace.style.display = 'block'
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
const cropImage = (result, id) => {
|
|
166
|
+
let image = new Image()
|
|
167
|
+
image.onload = () => {
|
|
168
|
+
let img = document.createElement('img')
|
|
169
|
+
img.src = result
|
|
170
|
+
img.id = 'image'
|
|
171
|
+
document.querySelector('.crop-image-modal-body').appendChild(img)
|
|
172
|
+
cropper = new Cropper(img, {
|
|
173
|
+
viewMode: 3,
|
|
174
|
+
ready() {
|
|
175
|
+
console.log(id)
|
|
176
|
+
let find = featureData.elements.find((i) => i.id === id)
|
|
177
|
+
console.log(find)
|
|
178
|
+
cropper.setAspectRatio(Number(find.width) / Number(find.height))
|
|
179
|
+
cropModal.style.display = 'flex'
|
|
180
|
+
this.cropper.crop()
|
|
181
|
+
},
|
|
182
|
+
crop(event) {
|
|
183
|
+
cropWidth = Math.round(event.detail.width)
|
|
184
|
+
cropHeight = Math.round(event.detail.height)
|
|
185
|
+
},
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
image.src = result
|
|
189
|
+
}
|
|
190
|
+
const updateCropper = (result, id) => {
|
|
191
|
+
cropper.destroy()
|
|
192
|
+
document.querySelector('.crop-image-modal-body').innerHTML = ''
|
|
193
|
+
cropImage(result, id)
|
|
194
|
+
}
|
|
195
|
+
document.querySelector('#crop').addEventListener('click', () => {
|
|
196
|
+
let cropperImg = cropper
|
|
197
|
+
.getCroppedCanvas({
|
|
198
|
+
width: cropWidth,
|
|
199
|
+
height: cropHeight,
|
|
200
|
+
})
|
|
201
|
+
.toDataURL()
|
|
202
|
+
files[index - 1] = cropperImg
|
|
203
|
+
cropModal.style.display = 'none'
|
|
204
|
+
})
|
|
205
|
+
let inputFile = ''
|
|
206
|
+
const handleFile = (file) => {
|
|
207
|
+
cropModal.style.display = 'flex'
|
|
208
|
+
document.querySelector('#file-loader').style.display = 'flex'
|
|
209
|
+
document.querySelector('.file-input').style.display = 'none'
|
|
210
|
+
inputFile = file
|
|
211
|
+
if (file) {
|
|
212
|
+
const reader = new FileReader()
|
|
213
|
+
reader.onload = (e) => {
|
|
214
|
+
if (e.target.result) {
|
|
215
|
+
cropImage(e.target.result)
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
reader.readAsDataURL(file)
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
const showLoading = () => {
|
|
222
|
+
document.querySelector('#file-loader').style.display = 'flex'
|
|
223
|
+
document.querySelector('.file-input').style.display = 'none'
|
|
224
|
+
}
|
|
225
|
+
const stopLoading = () => {
|
|
226
|
+
fileDropBox.style.display = 'none'
|
|
227
|
+
}
|
|
228
|
+
download.addEventListener('click', () => {
|
|
229
|
+
let canvas = document.querySelector('canvas')
|
|
230
|
+
let url = canvas.toDataURL(`image/png`)
|
|
231
|
+
let a = document.createElement('a')
|
|
232
|
+
a.href = url
|
|
233
|
+
a.download = `safeimagekit-border-image.${inputFile.type.split('/')[1]}`
|
|
234
|
+
document.body.appendChild(a)
|
|
235
|
+
a.click()
|
|
236
|
+
if (lang === 'en') {
|
|
237
|
+
window.location.href = `/download?tool=${pageTool}`
|
|
238
|
+
} else {
|
|
239
|
+
window.location.href = `/${lang}/download?tool=${pageTool}`
|
|
240
|
+
}
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
//
|
|
244
|
+
// fonts
|
|
245
|
+
// font rotation
|
|
246
|
+
// font position
|
|
247
|
+
// font transform
|
|
248
|
+
|
|
249
|
+
//images
|
|
250
|
+
//image rotation
|
|
251
|
+
// image rectangle with text
|
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"name": "together_forever",
|
|
4
|
-
"effectImagePath": "/assets/images/together_forever.png",
|
|
5
|
-
"elements": [
|
|
6
|
-
{
|
|
7
|
-
"type": "image",
|
|
8
|
-
"filter": "",
|
|
9
|
-
"perspective": "",
|
|
10
|
-
"height": 300,
|
|
11
|
-
"width": 300,
|
|
12
|
-
"x": 200,
|
|
13
|
-
"y": 200,
|
|
14
|
-
"id": "file-1"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"label": "",
|
|
18
|
-
"id": "text-1",
|
|
19
|
-
"type": "text",
|
|
20
|
-
"x": "100",
|
|
21
|
-
"rotate": 0,
|
|
22
|
-
"y": "100",
|
|
23
|
-
"color": "red",
|
|
24
|
-
"fontFamily": "Calligraphy",
|
|
25
|
-
"fontPath": "/assets/fonts/Calligraphy.ttf",
|
|
26
|
-
"fontWeight": "bold",
|
|
27
|
-
"fontSize": 50
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"type": "image",
|
|
31
|
-
"imagePath": "",
|
|
32
|
-
"filter": "grayscale(100%)",
|
|
33
|
-
"perspective": "",
|
|
34
|
-
"rotate": 40,
|
|
35
|
-
"height": 300,
|
|
36
|
-
"width": 300,
|
|
37
|
-
"x": 100,
|
|
38
|
-
"y": 200,
|
|
39
|
-
"id": "file-3"
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
"label": "",
|
|
43
|
-
"id": "text-2",
|
|
44
|
-
"type": "text",
|
|
45
|
-
"x": "200",
|
|
46
|
-
"y": "200",
|
|
47
|
-
"rotate": 40,
|
|
48
|
-
"color": "red",
|
|
49
|
-
"fontFamily": "Calligraphy",
|
|
50
|
-
"fontPath": "/assets/fonts/Calligraphy.ttf",
|
|
51
|
-
"fontWeight": "bold",
|
|
52
|
-
"fontSize": 50
|
|
53
|
-
}
|
|
54
|
-
]
|
|
55
|
-
}
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"name": "together_forever",
|
|
4
|
+
"effectImagePath": "/assets/images/together_forever.png",
|
|
5
|
+
"elements": [
|
|
6
|
+
{
|
|
7
|
+
"type": "image",
|
|
8
|
+
"filter": "",
|
|
9
|
+
"perspective": "",
|
|
10
|
+
"height": 300,
|
|
11
|
+
"width": 300,
|
|
12
|
+
"x": 200,
|
|
13
|
+
"y": 200,
|
|
14
|
+
"id": "file-1"
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
"label": "",
|
|
18
|
+
"id": "text-1",
|
|
19
|
+
"type": "text",
|
|
20
|
+
"x": "100",
|
|
21
|
+
"rotate": 0,
|
|
22
|
+
"y": "100",
|
|
23
|
+
"color": "red",
|
|
24
|
+
"fontFamily": "Calligraphy",
|
|
25
|
+
"fontPath": "/assets/fonts/Calligraphy.ttf",
|
|
26
|
+
"fontWeight": "bold",
|
|
27
|
+
"fontSize": 50
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
"type": "image",
|
|
31
|
+
"imagePath": "",
|
|
32
|
+
"filter": "grayscale(100%)",
|
|
33
|
+
"perspective": "",
|
|
34
|
+
"rotate": 40,
|
|
35
|
+
"height": 300,
|
|
36
|
+
"width": 300,
|
|
37
|
+
"x": 100,
|
|
38
|
+
"y": 200,
|
|
39
|
+
"id": "file-3"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"label": "",
|
|
43
|
+
"id": "text-2",
|
|
44
|
+
"type": "text",
|
|
45
|
+
"x": "200",
|
|
46
|
+
"y": "200",
|
|
47
|
+
"rotate": 40,
|
|
48
|
+
"color": "red",
|
|
49
|
+
"fontFamily": "Calligraphy",
|
|
50
|
+
"fontPath": "/assets/fonts/Calligraphy.ttf",
|
|
51
|
+
"fontWeight": "bold",
|
|
52
|
+
"fontSize": 50
|
|
53
|
+
}
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
56
|
]
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const batchConversion = async (file, indexValue) => {
|
|
2
|
+
return new Promise((resolve, reject) => {
|
|
3
|
+
if (file) {
|
|
4
|
+
const reader = new FileReader()
|
|
5
|
+
reader.readAsDataURL(file)
|
|
6
|
+
reader.onload = (e) => {
|
|
7
|
+
if (e.target.result) {
|
|
8
|
+
let image = new Image()
|
|
9
|
+
let canvas = document.createElement('canvas')
|
|
10
|
+
canvas.setAttribute('id', 'canvas-img')
|
|
11
|
+
let ctx = canvas.getContext('2d')
|
|
12
|
+
image.onload = () => {
|
|
13
|
+
canvas.width = image.width
|
|
14
|
+
canvas.height = image.height
|
|
15
|
+
// counter.innerHTML = e.target.value + "%"
|
|
16
|
+
let filters = document.querySelector('#applyFilter')
|
|
17
|
+
if (filters.getAttribute('data-filter') === "opacity") {
|
|
18
|
+
ctx.globalAlpha = filters.value
|
|
19
|
+
ctx.drawImage(image, 0, 0, canvas.width, canvas.height)
|
|
20
|
+
resolve([indexValue, canvas.toDataURL('image/png'), "image"])
|
|
21
|
+
} else {
|
|
22
|
+
ctx.filter = filters.getAttribute('data-filter') + '(' + filters.value + filters.getAttribute('data-scale') + ') '
|
|
23
|
+
ctx.drawImage(image, 0, 0, canvas.width, canvas.height)
|
|
24
|
+
resolve([indexValue, canvas.toDataURL('image/png'), "image"])
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
image.src = e.target.result
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
data/assets/js/theme.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
$(document).ready(function () {
|
|
2
|
-
var safuiAlert = $('#safeui-alert')
|
|
3
|
-
if (safuiAlert) {
|
|
4
|
-
safuiAlert
|
|
5
|
-
.first()
|
|
6
|
-
.delay(10000)
|
|
7
|
-
.slideUp(1000, function () {
|
|
8
|
-
$(this).remove()
|
|
9
|
-
})
|
|
10
|
-
}
|
|
11
|
-
})
|
|
1
|
+
$(document).ready(function () {
|
|
2
|
+
var safuiAlert = $('#safeui-alert')
|
|
3
|
+
if (safuiAlert) {
|
|
4
|
+
safuiAlert
|
|
5
|
+
.first()
|
|
6
|
+
.delay(10000)
|
|
7
|
+
.slideUp(1000, function () {
|
|
8
|
+
$(this).remove()
|
|
9
|
+
})
|
|
10
|
+
}
|
|
11
|
+
})
|