appscms-tools-theme 2.2.0 → 2.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +4 -4
  2. data/_data/calculators/en/biology-calc/bulb-spacing.json +79 -1
  3. data/_data/calculators/en/biology-calc/cat-chocolate-toxicity.json +53 -1
  4. data/_data/calculators/en/chemistry-calc/activation-energy.json +45 -1
  5. data/_data/feature/en/allele-frequency.json +242 -242
  6. data/_data/feature/en/batch-conversion.json +78 -0
  7. data/_data/feature/en/compress-pdf.json +11 -5
  8. data/_data/feature/en/theframe.json +64 -57
  9. data/_data/photo-categories.json +10 -10
  10. data/_includes/batch-conversion.html +70 -0
  11. data/_includes/custom-head.html +57 -1
  12. data/_includes/monumetric/ads.html +57 -57
  13. data/_includes/monumetric/profitablecpmgate.html +51 -51
  14. data/_layouts/batch.html +97 -0
  15. data/_layouts/calculator.html +69 -69
  16. data/_layouts/frame.html +128 -128
  17. data/assets/css/batch.css +423 -0
  18. data/assets/css/calculators.css +40 -40
  19. data/assets/css/frame.css +431 -435
  20. data/assets/images/add-image.png +0 -0
  21. data/assets/images/add.png +0 -0
  22. data/assets/images/cloud-computing.png +0 -0
  23. data/assets/images/convert.png +0 -0
  24. data/assets/images/download.png +0 -0
  25. data/assets/images/file.png +0 -0
  26. data/assets/images/safeimagekit. (2).png +0 -0
  27. data/assets/images/safeimagekit. (3).png +0 -0
  28. data/assets/images/safeimagekit..png +0 -0
  29. data/assets/images/safeimagekit.png +0 -0
  30. data/assets/images/spinner.gif +0 -0
  31. data/assets/images/trust.svg +1 -0
  32. data/assets/images/vectorpaint.svg +6 -0
  33. data/assets/js/ads.js +8 -8
  34. data/assets/js/append-div.js +10 -10
  35. data/assets/js/batch.js +190 -0
  36. data/assets/js/frame.js +251 -228
  37. data/assets/js/photo-effects.json +55 -55
  38. data/assets/js/testing-batch.js +36 -0
  39. data/assets/js/theme.js +11 -11
  40. metadata +26 -7
data/assets/js/frame.js CHANGED
@@ -1,228 +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.readAsDataURL(e.files[0])
39
- reader.onload = (event) => {
40
- if (cropper === null) {
41
- cropImage(event.target.result, e.id)
42
- } else {
43
- updateCropper(event.target.result, e.id)
44
- }
45
- }
46
- }
47
- const closeModal = () => {
48
- cropModal.style.display = 'none'
49
- }
50
- form.addEventListener('submit', (e) => {
51
- e.preventDefault()
52
- drawImage()
53
- })
54
- const drawInputImage = (ctx, item, indexValue, canvas, image) => {
55
- console.log(ctx)
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
- ctx.drawImage(
63
- image,
64
- Number(item.x),
65
- Number(item.y),
66
- image.width,
67
- image.height
68
- )
69
- if (item.rotate) {
70
- drawRotated(item.rotate, ctx, canvas, image)
71
- }
72
- resolve()
73
- }
74
- })
75
- }
76
- const drawRotated = (degrees, ctx, canvas, image) => {
77
- console.log(image)
78
- ctx.clearRect(0, 0, canvas.width, canvas.height)
79
-
80
- // save the unrotatedctx of the canvas so we can restore it later
81
- // the alternative is to untranslate & unrotate after drawing
82
- ctx.save()
83
-
84
- // move to the center of the canvas
85
- ctx.translate(canvas.width / 2, canvas.height / 2)
86
-
87
- // rotate the canvas to the specified degrees
88
- ctx.rotate((degrees * Math.PI) / 180)
89
-
90
- // draw the image
91
- // since thectx is rotated, the image will be rotated also
92
- ctx.drawImage(image, -image.width / 2, -image.width / 2)
93
-
94
- // we’re done with the rotating so restore the unrotatedctx
95
- ctx.restore()
96
- }
97
- const drawImage = () => {
98
- let img = new Image()
99
- img.src = featureData.effectImagePath
100
- var canvas = document.createElement('canvas')
101
- var ctx = canvas.getContext('2d')
102
- img.onload = () => {
103
- canvas.width = img.width
104
- canvas.height = img.height
105
- Promise.all(
106
- featureData.elements.map((item, indexValue) => {
107
- if (item.type === 'image') {
108
- return new Promise((resolve, reject) => {
109
- drawInputImage(ctx, item, indexValue, canvas).then(() => {
110
- resolve()
111
- })
112
- })
113
- }
114
- })
115
- ).then(() => {
116
- ctx.drawImage(img, 0, 0, canvas.width, canvas.height)
117
- featureData.elements.map((item, indexValue) => {
118
- if (item.type === 'text') {
119
- let myFont = new FontFace(item.font, `url(${item.fontPath})`)
120
- myFont.load().then(function (font) {
121
- document.fonts.add(font)
122
- ctx.font = `${item.fontSize}px ${item.fontWeight} ${item.font}`
123
- if (item.shadowColor) {
124
- ctx.shadowColor = `${item.shadowColor}`
125
- }
126
- if (item.shadowOffsetX) {
127
- ctx.shadowOffsetX = 3
128
- }
129
- if (item.shadowOffsetY) {
130
- ctx.shadowOffsetY = 3
131
- }
132
- if (item.shadowBlur) {
133
- ctx.shadowBlur = 2
134
- }
135
- ctx.fillStyle = `${item.color}`
136
- ctx.fillText(
137
- document.querySelector(`#${item.id}`).value,
138
- item.x,
139
- item.y
140
- )
141
- })
142
- }
143
- if (item.type === 'rectangle') {
144
- }
145
- })
146
- canvasPanel.innerHTML = ''
147
- canvasPanel.appendChild(canvas)
148
- workspace.style.display = 'block'
149
- })
150
- }
151
- }
152
- const cropImage = (result, id) => {
153
- let image = new Image()
154
- image.onload = () => {
155
- let img = document.createElement('img')
156
- img.src = result
157
- img.id = 'image'
158
- document.querySelector('.crop-image-modal-body').appendChild(img)
159
- cropper = new Cropper(img, {
160
- viewMode: 3,
161
- ready() {
162
- console.log(id)
163
- let find = featureData.elements.find((i) => i.id === id)
164
- console.log(find)
165
- cropper.setAspectRatio(Number(find.width) / Number(find.height))
166
- cropModal.style.display = 'flex'
167
- this.cropper.crop()
168
- },
169
- crop(event) {
170
- cropWidth = Math.round(event.detail.width)
171
- cropHeight = Math.round(event.detail.height)
172
- },
173
- })
174
- }
175
- image.src = result
176
- }
177
- const updateCropper = (result, id) => {
178
- cropper.destroy()
179
- document.querySelector('.crop-image-modal-body').innerHTML = ''
180
- cropImage(result, id)
181
- }
182
- document.querySelector('#crop').addEventListener('click', () => {
183
- let cropperImg = cropper
184
- .getCroppedCanvas({
185
- width: cropWidth,
186
- height: cropHeight,
187
- })
188
- .toDataURL()
189
- files[index - 1] = cropperImg
190
- cropModal.style.display = 'none'
191
- })
192
- let inputFile = ''
193
- const handleFile = (file) => {
194
- cropModal.style.display = 'flex'
195
- document.querySelector('#file-loader').style.display = 'flex'
196
- document.querySelector('.file-input').style.display = 'none'
197
- inputFile = file
198
- if (file) {
199
- const reader = new FileReader()
200
- reader.onload = (e) => {
201
- if (e.target.result) {
202
- cropImage(e.target.result)
203
- }
204
- }
205
- reader.readAsDataURL(file)
206
- }
207
- }
208
- const showLoading = () => {
209
- document.querySelector('#file-loader').style.display = 'flex'
210
- document.querySelector('.file-input').style.display = 'none'
211
- }
212
- const stopLoading = () => {
213
- fileDropBox.style.display = 'none'
214
- }
215
- download.addEventListener('click', () => {
216
- let canvas = document.querySelector('canvas')
217
- let url = canvas.toDataURL(`image/png`)
218
- let a = document.createElement('a')
219
- a.href = url
220
- a.download = `safeimagekit-border-image.${inputFile.type.split('/')[1]}`
221
- document.body.appendChild(a)
222
- a.click()
223
- if (lang === 'en') {
224
- window.location.href = `/download?tool=${pageTool}`
225
- } else {
226
- window.location.href = `/${lang}/download?tool=${pageTool}`
227
- }
228
- })
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
- "imagePath": "",
9
- "filter": "",
10
- "perspective": "",
11
- "rotate": 45,
12
- "height": 300,
13
- "width": 300,
14
- "x": 200,
15
- "y": 200,
16
- "id": "file-1"
17
- },
18
- {
19
- "label": "",
20
- "id": "text-1",
21
- "type": "text",
22
- "x": "100",
23
- "y": "100",
24
- "color": "red",
25
- "fontFamily": "Calligraphy",
26
- "fontPath": "/assets/fonts/Calligraphy.ttf",
27
- "fontWeight": "bold",
28
- "fontSize": 50
29
- },
30
- {
31
- "type": "image",
32
- "imagePath": "",
33
- "filter": "",
34
- "perspective": "",
35
- "rotate": "",
36
- "height": 300,
37
- "width": 300,
38
- "x": 100,
39
- "y": 200,
40
- "id": "file-3"
41
- },
42
- {
43
- "id": "text-2",
44
- "label": "",
45
- "type": "text",
46
- "x": 100,
47
- "y": 100,
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
+ })