yh-hiprint 2.2.6 → 2.2.7
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.
- package/CHANGE.md +0 -0
- package/HiprintDesigner.vue +77 -65
- package/README.md +0 -0
- package/column-field.js +0 -0
- package/font-size.js +42 -42
- package/hiprint.js +0 -0
- package/hiprint.vue +0 -0
- package/hiprintPreview.vue +0 -0
- package/hooks/useHiprint.js +0 -0
- package/index.d.ts +0 -0
- package/index.js +0 -0
- package/libs/css/hiprint.css +996 -996
- package/libs/css/image/jquery.minicolors.png +0 -0
- package/libs/css/image/l_img.svg +0 -0
- package/libs/css/image/v_img.svg +0 -0
- package/libs/css/print-lock.css +339 -339
- package/libs/etypes/default-etyps-provider.js +157 -157
- package/libs/hiprint.bundle.js +0 -0
- package/libs/hiprint.config.js +1802 -1802
- package/libs/plugins/jquery.hiwprint.js +110 -110
- package/libs/plugins/qrcode.js +617 -617
- package/libs/plugins/watermark.js +199 -199
- package/package.json +1 -1
- package/panel.js +18 -18
- package/scale.js +42 -42
- package/z-index.js +0 -0
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @Description: canvas 简单的水印工具
|
|
3
|
-
* @Author: CcSimple
|
|
4
|
-
* @Github: https://github.com/CcSimple
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* @Description: 时间格式化
|
|
9
|
-
* @param date
|
|
10
|
-
* @param format
|
|
11
|
-
* @returns {string|null}
|
|
12
|
-
*/
|
|
13
|
-
function timeFormat(date, format = 'YYYY-MM-DD') {
|
|
14
|
-
if (!date) return null;
|
|
15
|
-
if (typeof date === 'number') {
|
|
16
|
-
date = new Date(date);
|
|
17
|
-
}
|
|
18
|
-
const year = date.getFullYear();
|
|
19
|
-
const month = date.getMonth();
|
|
20
|
-
const day = date.getDate();
|
|
21
|
-
const hours24 = date.getHours();
|
|
22
|
-
const hours = hours24 % 12 === 0 ? 12 : hours24 % 12;
|
|
23
|
-
const minutes = date.getMinutes();
|
|
24
|
-
const seconds = date.getSeconds();
|
|
25
|
-
const dd = t => `0${t}`.slice(-2);
|
|
26
|
-
const map = {
|
|
27
|
-
YYYY: year,
|
|
28
|
-
MM: dd(month + 1),
|
|
29
|
-
MMMM: `${month + 1}月`,
|
|
30
|
-
M: month + 1,
|
|
31
|
-
DD: dd(day),
|
|
32
|
-
D: day,
|
|
33
|
-
HH: dd(hours24),
|
|
34
|
-
H: hours24,
|
|
35
|
-
hh: dd(hours),
|
|
36
|
-
h: hours,
|
|
37
|
-
mm: dd(minutes),
|
|
38
|
-
m: minutes,
|
|
39
|
-
ss: dd(seconds),
|
|
40
|
-
s: seconds
|
|
41
|
-
};
|
|
42
|
-
return format.replace(/Y+|M+|D+|H+|h+|m+|s+|S+|Q/g, str => String(map[str]));
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// 水印参数
|
|
46
|
-
const defaultOption = {
|
|
47
|
-
id: 'watermark', // 水印id
|
|
48
|
-
watch: false,
|
|
49
|
-
content: 'vue-plugin-hiprint', // 水印内容
|
|
50
|
-
container: '.hiprint-printPaper', // 水印容器
|
|
51
|
-
width: 200, // 水印宽度
|
|
52
|
-
height: 200, // 水印高度
|
|
53
|
-
textAlign: 'center', // 水印文字水平对齐方式
|
|
54
|
-
textBaseline: 'middle', // 水印文字垂直对齐方式
|
|
55
|
-
fontSize: '14px', // 水印文字大小
|
|
56
|
-
fontFamily: 'Microsoft Yahei', // 水印文字字体
|
|
57
|
-
fillStyle: 'rgba(184, 184, 184, 0.3)', // 水印文字颜色
|
|
58
|
-
rotate: 25,// 水印文字旋转角度
|
|
59
|
-
timestamp: false, // 是否显示时间戳
|
|
60
|
-
format: 'YYYY-MM-DD HH:mm', // 时间戳格式
|
|
61
|
-
zIndex: 0
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
// 监听器
|
|
65
|
-
let observerMap = {};
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* @Description: 创建水印
|
|
69
|
-
* @param param
|
|
70
|
-
* @private
|
|
71
|
-
*/
|
|
72
|
-
function _createWatermark(param) {
|
|
73
|
-
const {
|
|
74
|
-
id,
|
|
75
|
-
watch,
|
|
76
|
-
content,
|
|
77
|
-
container,
|
|
78
|
-
width,
|
|
79
|
-
height,
|
|
80
|
-
textAlign,
|
|
81
|
-
textBaseline,
|
|
82
|
-
fontSize,
|
|
83
|
-
fontFamily,
|
|
84
|
-
fillStyle,
|
|
85
|
-
rotate,
|
|
86
|
-
timestamp,
|
|
87
|
-
format,
|
|
88
|
-
zIndex
|
|
89
|
-
} = param;
|
|
90
|
-
|
|
91
|
-
observerMap[id] = {
|
|
92
|
-
wmMo: null, // MutationObserver
|
|
93
|
-
wmTimer: null // timestamp
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
const canvas = document.createElement('canvas');
|
|
97
|
-
canvas.setAttribute('width', `${width}px`);
|
|
98
|
-
canvas.setAttribute('height', `${height}px`);
|
|
99
|
-
|
|
100
|
-
let containerDom = typeof container === 'string' ? document.querySelector(container) : container;
|
|
101
|
-
|
|
102
|
-
const ctx = canvas.getContext('2d');
|
|
103
|
-
ctx.textAlign = textAlign;
|
|
104
|
-
ctx.textBaseline = textBaseline;
|
|
105
|
-
ctx.font = `${fontSize} ${fontFamily}`;
|
|
106
|
-
ctx.fillStyle = fillStyle;
|
|
107
|
-
ctx.translate(width / 2, height / 2);
|
|
108
|
-
ctx.rotate(-(Math.PI / 180) * rotate);
|
|
109
|
-
ctx.fillText(`${content}`, 0, 0);
|
|
110
|
-
timestamp && ctx.fillText(`${timeFormat(new Date(), format)}`, 0, parseInt(fontSize) + 5);
|
|
111
|
-
|
|
112
|
-
let __vm = containerDom.querySelector('.__vm__' + id);
|
|
113
|
-
const watermarkDiv = __vm || document.createElement('div');
|
|
114
|
-
const withHeightStr = containerDom.getAttribute('style');
|
|
115
|
-
const styleStr = `position:absolute;user-select:none;top:0;left:0;${withHeightStr};z-index:${zIndex};pointer-events:none !important;background-repeat:repeat;background-image:url('${canvas.toDataURL()}')`;
|
|
116
|
-
|
|
117
|
-
watermarkDiv.setAttribute('style', styleStr);
|
|
118
|
-
watermarkDiv.classList.add('__vm__' + id);
|
|
119
|
-
|
|
120
|
-
if (!__vm) {
|
|
121
|
-
containerDom.insertBefore(watermarkDiv, containerDom.firstChild);
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
if (watch) {
|
|
125
|
-
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
|
126
|
-
if (MutationObserver) {
|
|
127
|
-
observerMap[id]["wmMo"] = new MutationObserver((e) => {
|
|
128
|
-
let change = e.some(item => item.target.className == containerDom.className && item.type == 'attributes');
|
|
129
|
-
__vm = containerDom.querySelector('.__vm__' + id);
|
|
130
|
-
if ((__vm && __vm.getAttribute('style') !== styleStr) || !__vm || change) {
|
|
131
|
-
// 避免一直触发
|
|
132
|
-
observerMap[id]["wmMo"].disconnect();
|
|
133
|
-
observerMap[id]["wmMo"] = null;
|
|
134
|
-
delete observerMap[id]["wmMo"];
|
|
135
|
-
_createWatermark(param);
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
observerMap[id]["wmMo"].observe(containerDom, {
|
|
139
|
-
attributes: true, subtree: true, childList: true
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
if (format) {
|
|
145
|
-
let timeout = 1000 * 60 * 60 * 24;
|
|
146
|
-
if (format.includes('s')) {
|
|
147
|
-
timeout = 1000;
|
|
148
|
-
} else if (format.includes('m')) {
|
|
149
|
-
timeout = 1000 * 60;
|
|
150
|
-
} else if (format.includes('h') || format.includes('H')) {
|
|
151
|
-
timeout = 1000 * 60 * 60;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
observerMap[id]["wmTimer"] = window.setTimeout(() => {
|
|
155
|
-
// 触发 MutationObserver
|
|
156
|
-
watermarkDiv.style.bottom = '0';
|
|
157
|
-
}, timeout);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* @Description: 销毁水印
|
|
163
|
-
*/
|
|
164
|
-
const destroyWatermark = function (options) {
|
|
165
|
-
const {
|
|
166
|
-
id,
|
|
167
|
-
watch,
|
|
168
|
-
container,
|
|
169
|
-
} = options;
|
|
170
|
-
if (watch) {
|
|
171
|
-
let containerDom = typeof container === 'string' ? document.querySelector(container) : container;
|
|
172
|
-
// 监听器关闭
|
|
173
|
-
if (observerMap[id]) {
|
|
174
|
-
observerMap[id]["wmMo"] && observerMap[id]["wmMo"].disconnect();
|
|
175
|
-
observerMap[id]["wmMo"] = null;
|
|
176
|
-
observerMap[id]["wmTimer"] && window.clearTimeout(observerMap[id]["wmTimer"]);
|
|
177
|
-
observerMap[id]["wmTimer"] = null;
|
|
178
|
-
delete observerMap[id];
|
|
179
|
-
}
|
|
180
|
-
// 删除水印元素
|
|
181
|
-
const __vm = containerDom.querySelector('.__vm__' + id);
|
|
182
|
-
__vm && __vm.parentNode.removeChild(__vm);
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* @Description: 创建水印
|
|
188
|
-
* @param option
|
|
189
|
-
*/
|
|
190
|
-
const createWatermark = function (option) {
|
|
191
|
-
let options = Object.assign({}, defaultOption, option);
|
|
192
|
-
destroyWatermark(options);
|
|
193
|
-
_createWatermark(options);
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
// 暴露接口
|
|
197
|
-
export default {
|
|
198
|
-
createWatermark, destroyWatermark
|
|
199
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* @Description: canvas 简单的水印工具
|
|
3
|
+
* @Author: CcSimple
|
|
4
|
+
* @Github: https://github.com/CcSimple
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @Description: 时间格式化
|
|
9
|
+
* @param date
|
|
10
|
+
* @param format
|
|
11
|
+
* @returns {string|null}
|
|
12
|
+
*/
|
|
13
|
+
function timeFormat(date, format = 'YYYY-MM-DD') {
|
|
14
|
+
if (!date) return null;
|
|
15
|
+
if (typeof date === 'number') {
|
|
16
|
+
date = new Date(date);
|
|
17
|
+
}
|
|
18
|
+
const year = date.getFullYear();
|
|
19
|
+
const month = date.getMonth();
|
|
20
|
+
const day = date.getDate();
|
|
21
|
+
const hours24 = date.getHours();
|
|
22
|
+
const hours = hours24 % 12 === 0 ? 12 : hours24 % 12;
|
|
23
|
+
const minutes = date.getMinutes();
|
|
24
|
+
const seconds = date.getSeconds();
|
|
25
|
+
const dd = t => `0${t}`.slice(-2);
|
|
26
|
+
const map = {
|
|
27
|
+
YYYY: year,
|
|
28
|
+
MM: dd(month + 1),
|
|
29
|
+
MMMM: `${month + 1}月`,
|
|
30
|
+
M: month + 1,
|
|
31
|
+
DD: dd(day),
|
|
32
|
+
D: day,
|
|
33
|
+
HH: dd(hours24),
|
|
34
|
+
H: hours24,
|
|
35
|
+
hh: dd(hours),
|
|
36
|
+
h: hours,
|
|
37
|
+
mm: dd(minutes),
|
|
38
|
+
m: minutes,
|
|
39
|
+
ss: dd(seconds),
|
|
40
|
+
s: seconds
|
|
41
|
+
};
|
|
42
|
+
return format.replace(/Y+|M+|D+|H+|h+|m+|s+|S+|Q/g, str => String(map[str]));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// 水印参数
|
|
46
|
+
const defaultOption = {
|
|
47
|
+
id: 'watermark', // 水印id
|
|
48
|
+
watch: false,
|
|
49
|
+
content: 'vue-plugin-hiprint', // 水印内容
|
|
50
|
+
container: '.hiprint-printPaper', // 水印容器
|
|
51
|
+
width: 200, // 水印宽度
|
|
52
|
+
height: 200, // 水印高度
|
|
53
|
+
textAlign: 'center', // 水印文字水平对齐方式
|
|
54
|
+
textBaseline: 'middle', // 水印文字垂直对齐方式
|
|
55
|
+
fontSize: '14px', // 水印文字大小
|
|
56
|
+
fontFamily: 'Microsoft Yahei', // 水印文字字体
|
|
57
|
+
fillStyle: 'rgba(184, 184, 184, 0.3)', // 水印文字颜色
|
|
58
|
+
rotate: 25,// 水印文字旋转角度
|
|
59
|
+
timestamp: false, // 是否显示时间戳
|
|
60
|
+
format: 'YYYY-MM-DD HH:mm', // 时间戳格式
|
|
61
|
+
zIndex: 0
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
// 监听器
|
|
65
|
+
let observerMap = {};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* @Description: 创建水印
|
|
69
|
+
* @param param
|
|
70
|
+
* @private
|
|
71
|
+
*/
|
|
72
|
+
function _createWatermark(param) {
|
|
73
|
+
const {
|
|
74
|
+
id,
|
|
75
|
+
watch,
|
|
76
|
+
content,
|
|
77
|
+
container,
|
|
78
|
+
width,
|
|
79
|
+
height,
|
|
80
|
+
textAlign,
|
|
81
|
+
textBaseline,
|
|
82
|
+
fontSize,
|
|
83
|
+
fontFamily,
|
|
84
|
+
fillStyle,
|
|
85
|
+
rotate,
|
|
86
|
+
timestamp,
|
|
87
|
+
format,
|
|
88
|
+
zIndex
|
|
89
|
+
} = param;
|
|
90
|
+
|
|
91
|
+
observerMap[id] = {
|
|
92
|
+
wmMo: null, // MutationObserver
|
|
93
|
+
wmTimer: null // timestamp
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
const canvas = document.createElement('canvas');
|
|
97
|
+
canvas.setAttribute('width', `${width}px`);
|
|
98
|
+
canvas.setAttribute('height', `${height}px`);
|
|
99
|
+
|
|
100
|
+
let containerDom = typeof container === 'string' ? document.querySelector(container) : container;
|
|
101
|
+
|
|
102
|
+
const ctx = canvas.getContext('2d');
|
|
103
|
+
ctx.textAlign = textAlign;
|
|
104
|
+
ctx.textBaseline = textBaseline;
|
|
105
|
+
ctx.font = `${fontSize} ${fontFamily}`;
|
|
106
|
+
ctx.fillStyle = fillStyle;
|
|
107
|
+
ctx.translate(width / 2, height / 2);
|
|
108
|
+
ctx.rotate(-(Math.PI / 180) * rotate);
|
|
109
|
+
ctx.fillText(`${content}`, 0, 0);
|
|
110
|
+
timestamp && ctx.fillText(`${timeFormat(new Date(), format)}`, 0, parseInt(fontSize) + 5);
|
|
111
|
+
|
|
112
|
+
let __vm = containerDom.querySelector('.__vm__' + id);
|
|
113
|
+
const watermarkDiv = __vm || document.createElement('div');
|
|
114
|
+
const withHeightStr = containerDom.getAttribute('style');
|
|
115
|
+
const styleStr = `position:absolute;user-select:none;top:0;left:0;${withHeightStr};z-index:${zIndex};pointer-events:none !important;background-repeat:repeat;background-image:url('${canvas.toDataURL()}')`;
|
|
116
|
+
|
|
117
|
+
watermarkDiv.setAttribute('style', styleStr);
|
|
118
|
+
watermarkDiv.classList.add('__vm__' + id);
|
|
119
|
+
|
|
120
|
+
if (!__vm) {
|
|
121
|
+
containerDom.insertBefore(watermarkDiv, containerDom.firstChild);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (watch) {
|
|
125
|
+
const MutationObserver = window.MutationObserver || window.WebKitMutationObserver;
|
|
126
|
+
if (MutationObserver) {
|
|
127
|
+
observerMap[id]["wmMo"] = new MutationObserver((e) => {
|
|
128
|
+
let change = e.some(item => item.target.className == containerDom.className && item.type == 'attributes');
|
|
129
|
+
__vm = containerDom.querySelector('.__vm__' + id);
|
|
130
|
+
if ((__vm && __vm.getAttribute('style') !== styleStr) || !__vm || change) {
|
|
131
|
+
// 避免一直触发
|
|
132
|
+
observerMap[id]["wmMo"].disconnect();
|
|
133
|
+
observerMap[id]["wmMo"] = null;
|
|
134
|
+
delete observerMap[id]["wmMo"];
|
|
135
|
+
_createWatermark(param);
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
observerMap[id]["wmMo"].observe(containerDom, {
|
|
139
|
+
attributes: true, subtree: true, childList: true
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
if (format) {
|
|
145
|
+
let timeout = 1000 * 60 * 60 * 24;
|
|
146
|
+
if (format.includes('s')) {
|
|
147
|
+
timeout = 1000;
|
|
148
|
+
} else if (format.includes('m')) {
|
|
149
|
+
timeout = 1000 * 60;
|
|
150
|
+
} else if (format.includes('h') || format.includes('H')) {
|
|
151
|
+
timeout = 1000 * 60 * 60;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
observerMap[id]["wmTimer"] = window.setTimeout(() => {
|
|
155
|
+
// 触发 MutationObserver
|
|
156
|
+
watermarkDiv.style.bottom = '0';
|
|
157
|
+
}, timeout);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* @Description: 销毁水印
|
|
163
|
+
*/
|
|
164
|
+
const destroyWatermark = function (options) {
|
|
165
|
+
const {
|
|
166
|
+
id,
|
|
167
|
+
watch,
|
|
168
|
+
container,
|
|
169
|
+
} = options;
|
|
170
|
+
if (watch) {
|
|
171
|
+
let containerDom = typeof container === 'string' ? document.querySelector(container) : container;
|
|
172
|
+
// 监听器关闭
|
|
173
|
+
if (observerMap[id]) {
|
|
174
|
+
observerMap[id]["wmMo"] && observerMap[id]["wmMo"].disconnect();
|
|
175
|
+
observerMap[id]["wmMo"] = null;
|
|
176
|
+
observerMap[id]["wmTimer"] && window.clearTimeout(observerMap[id]["wmTimer"]);
|
|
177
|
+
observerMap[id]["wmTimer"] = null;
|
|
178
|
+
delete observerMap[id];
|
|
179
|
+
}
|
|
180
|
+
// 删除水印元素
|
|
181
|
+
const __vm = containerDom.querySelector('.__vm__' + id);
|
|
182
|
+
__vm && __vm.parentNode.removeChild(__vm);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* @Description: 创建水印
|
|
188
|
+
* @param option
|
|
189
|
+
*/
|
|
190
|
+
const createWatermark = function (option) {
|
|
191
|
+
let options = Object.assign({}, defaultOption, option);
|
|
192
|
+
destroyWatermark(options);
|
|
193
|
+
_createWatermark(options);
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 暴露接口
|
|
197
|
+
export default {
|
|
198
|
+
createWatermark, destroyWatermark
|
|
199
|
+
}
|
package/package.json
CHANGED
package/panel.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
panels: [
|
|
3
|
-
{
|
|
4
|
-
index: 0,
|
|
5
|
-
height: 296.6,
|
|
6
|
-
width: 210,
|
|
7
|
-
paperHeader: 49.5,
|
|
8
|
-
paperFooter: 780,
|
|
9
|
-
watermarkOptions: {
|
|
10
|
-
content: "hiPrint",
|
|
11
|
-
rotate: 45,
|
|
12
|
-
},
|
|
13
|
-
printElements: [],
|
|
14
|
-
paperNumberLeft: 565.5,
|
|
15
|
-
paperNumberTop: 819,
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
};
|
|
1
|
+
export default {
|
|
2
|
+
panels: [
|
|
3
|
+
{
|
|
4
|
+
index: 0,
|
|
5
|
+
height: 296.6,
|
|
6
|
+
width: 210,
|
|
7
|
+
paperHeader: 49.5,
|
|
8
|
+
paperFooter: 780,
|
|
9
|
+
watermarkOptions: {
|
|
10
|
+
content: "hiPrint",
|
|
11
|
+
rotate: 45,
|
|
12
|
+
},
|
|
13
|
+
printElements: [],
|
|
14
|
+
paperNumberLeft: 565.5,
|
|
15
|
+
paperNumberTop: 819,
|
|
16
|
+
},
|
|
17
|
+
],
|
|
18
|
+
};
|
package/scale.js
CHANGED
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import $ from "jquery";
|
|
2
|
-
export default (function () {
|
|
3
|
-
function t() {
|
|
4
|
-
// json模板 options 对应键值 key
|
|
5
|
-
this.name = "scale";
|
|
6
|
-
}
|
|
7
|
-
// 涉及修改元素样式, 添加一个 css 方法
|
|
8
|
-
// t: 元素对象, e 参数值
|
|
9
|
-
return (
|
|
10
|
-
(t.prototype.css = function (t, e) {
|
|
11
|
-
if (t && t.length) {
|
|
12
|
-
if (e) return t.css("transform", "scale(" + e + ")");
|
|
13
|
-
}
|
|
14
|
-
return null;
|
|
15
|
-
}),
|
|
16
|
-
// 创建 DOM
|
|
17
|
-
(t.prototype.createTarget = function (t, i, e) {
|
|
18
|
-
// t: 元素对象,i: 元素options, e: 元素printElementType
|
|
19
|
-
return (
|
|
20
|
-
(this.target = $(
|
|
21
|
-
'<div class="hiprint-option-item">\n <div class="hiprint-option-item-label">\n 缩放\n </div>\n <div class="hiprint-option-item-field">\n <input type="number" value="1" step="0.1" min="0.1" max="3" class="auto-submit"/>\n </div>\n </div>'
|
|
22
|
-
)),
|
|
23
|
-
this.target
|
|
24
|
-
);
|
|
25
|
-
}),
|
|
26
|
-
// 获取值
|
|
27
|
-
(t.prototype.getValue = function () {
|
|
28
|
-
var t = this.target.find("input").val();
|
|
29
|
-
if (t) return parseFloat(t.toString());
|
|
30
|
-
}),
|
|
31
|
-
// 设置值
|
|
32
|
-
(t.prototype.setValue = function (t) {
|
|
33
|
-
// t: options 对应键的值
|
|
34
|
-
this.target.find("input").val(t);
|
|
35
|
-
}),
|
|
36
|
-
// 销毁 DOM
|
|
37
|
-
(t.prototype.destroy = function () {
|
|
38
|
-
this.target.remove();
|
|
39
|
-
}),
|
|
40
|
-
t
|
|
41
|
-
);
|
|
42
|
-
})();
|
|
1
|
+
import $ from "jquery";
|
|
2
|
+
export default (function () {
|
|
3
|
+
function t() {
|
|
4
|
+
// json模板 options 对应键值 key
|
|
5
|
+
this.name = "scale";
|
|
6
|
+
}
|
|
7
|
+
// 涉及修改元素样式, 添加一个 css 方法
|
|
8
|
+
// t: 元素对象, e 参数值
|
|
9
|
+
return (
|
|
10
|
+
(t.prototype.css = function (t, e) {
|
|
11
|
+
if (t && t.length) {
|
|
12
|
+
if (e) return t.css("transform", "scale(" + e + ")");
|
|
13
|
+
}
|
|
14
|
+
return null;
|
|
15
|
+
}),
|
|
16
|
+
// 创建 DOM
|
|
17
|
+
(t.prototype.createTarget = function (t, i, e) {
|
|
18
|
+
// t: 元素对象,i: 元素options, e: 元素printElementType
|
|
19
|
+
return (
|
|
20
|
+
(this.target = $(
|
|
21
|
+
'<div class="hiprint-option-item">\n <div class="hiprint-option-item-label">\n 缩放\n </div>\n <div class="hiprint-option-item-field">\n <input type="number" value="1" step="0.1" min="0.1" max="3" class="auto-submit"/>\n </div>\n </div>'
|
|
22
|
+
)),
|
|
23
|
+
this.target
|
|
24
|
+
);
|
|
25
|
+
}),
|
|
26
|
+
// 获取值
|
|
27
|
+
(t.prototype.getValue = function () {
|
|
28
|
+
var t = this.target.find("input").val();
|
|
29
|
+
if (t) return parseFloat(t.toString());
|
|
30
|
+
}),
|
|
31
|
+
// 设置值
|
|
32
|
+
(t.prototype.setValue = function (t) {
|
|
33
|
+
// t: options 对应键的值
|
|
34
|
+
this.target.find("input").val(t);
|
|
35
|
+
}),
|
|
36
|
+
// 销毁 DOM
|
|
37
|
+
(t.prototype.destroy = function () {
|
|
38
|
+
this.target.remove();
|
|
39
|
+
}),
|
|
40
|
+
t
|
|
41
|
+
);
|
|
42
|
+
})();
|
package/z-index.js
CHANGED
|
File without changes
|