dpzvc-ui 1.0.0
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/LICENSE +21 -0
- package/README.md +46 -0
- package/build-style.js +42 -0
- package/dist/dpzvc.js +17605 -0
- package/dist/styles/dpzvc.css +1 -0
- package/dist-prod/index.html +26 -0
- package/dist-prod/main.js +1 -0
- package/dist-prod/vendor.bundle.js +1 -0
- package/package.json +88 -0
- package/src/components/Indicator/Indicator.vue +77 -0
- package/src/components/Indicator/index.js +153 -0
- package/src/components/Text/Number.vue +201 -0
- package/src/components/Text/index.js +7 -0
- package/src/components/Text/textBar.vue +142 -0
- package/src/components/action-sheet/actionSheet.vue +91 -0
- package/src/components/action-sheet/index.js +5 -0
- package/src/components/app.vue +66 -0
- package/src/components/badge/badge.vue +77 -0
- package/src/components/badge/index.js +5 -0
- package/src/components/button/button.vue +122 -0
- package/src/components/button/index.js +5 -0
- package/src/components/card/card.vue +59 -0
- package/src/components/card/index.js +5 -0
- package/src/components/cell/cell.vue +103 -0
- package/src/components/cell/index.js +5 -0
- package/src/components/cell-swipe/cell-swipe.vue +148 -0
- package/src/components/cell-swipe/index.js +5 -0
- package/src/components/checkBox/checkbox-group.vue +76 -0
- package/src/components/checkBox/checkbox.vue +107 -0
- package/src/components/checkBox/index.js +8 -0
- package/src/components/header/header.vue +82 -0
- package/src/components/header/index.js +5 -0
- package/src/components/loadMore/index.js +5 -0
- package/src/components/loadMore/loadmore.vue +293 -0
- package/src/components/message/confirm.js +52 -0
- package/src/components/message/index.js +132 -0
- package/src/components/message/message.vue +135 -0
- package/src/components/message/messageGroup.vue +74 -0
- package/src/components/modal/confirm.js +161 -0
- package/src/components/modal/index.js +63 -0
- package/src/components/modal/modal.vue +144 -0
- package/src/components/picker/area-picker/area-picker.vue +223 -0
- package/src/components/picker/area-picker/props.js +17 -0
- package/src/components/picker/date-picker/date-picker.vue +291 -0
- package/src/components/picker/date-picker/props.js +24 -0
- package/src/components/picker/index.js +5 -0
- package/src/components/picker/normal-picker/normal-picker.vue +107 -0
- package/src/components/picker/normal-picker/props.js +20 -0
- package/src/components/picker/picker-slot.vue +206 -0
- package/src/components/picker/picker.vue +111 -0
- package/src/components/popup/index.js +5 -0
- package/src/components/popup/popup.vue +117 -0
- package/src/components/progress/index.js +5 -0
- package/src/components/progress/progress.vue +77 -0
- package/src/components/prompt/confirm.js +174 -0
- package/src/components/prompt/index.js +50 -0
- package/src/components/prompt/prompt.vue +166 -0
- package/src/components/radioBox/index.js +8 -0
- package/src/components/radioBox/radiobox-group.vue +74 -0
- package/src/components/radioBox/radiobox.vue +117 -0
- package/src/components/rater/index.js +5 -0
- package/src/components/rater/rater.vue +164 -0
- package/src/components/slideBar/index.js +6 -0
- package/src/components/slideBar/slideBar.vue +269 -0
- package/src/components/spinner/behavior/blade.vue +22 -0
- package/src/components/spinner/behavior/double-bounce.vue +22 -0
- package/src/components/spinner/behavior/fading-circle.vue +37 -0
- package/src/components/spinner/behavior/snake.vue +32 -0
- package/src/components/spinner/behavior/triple-bounce.vue +41 -0
- package/src/components/spinner/index.js +5 -0
- package/src/components/spinner/props.js +25 -0
- package/src/components/spinner/spinner.vue +74 -0
- package/src/components/swipe/index.js +5 -0
- package/src/components/swipe/swipe.vue +399 -0
- package/src/components/switchbar/index.js +5 -0
- package/src/components/switchbar/switchbar.vue +83 -0
- package/src/components/tab/index.js +6 -0
- package/src/components/tab/tab.vue +95 -0
- package/src/components/toTop/index.js +5 -0
- package/src/components/toTop/topTop.vue +76 -0
- package/src/components/upload/index.js +5 -0
- package/src/components/upload/upload.vue +200 -0
- package/src/config/config.js +17 -0
- package/src/directives/clickoutside.js +32 -0
- package/src/directives/tranferDom.js +65 -0
- package/src/index.js +83 -0
- package/src/lib/MegaPixImage.js +253 -0
- package/src/lib/exif.js +808 -0
- package/src/main.js +76 -0
- package/src/mixin/emitter.js +41 -0
- package/src/mixin/input.js +41 -0
- package/src/router.js +229 -0
- package/src/styles/base/font.less +99 -0
- package/src/styles/base/reset.less +69 -0
- package/src/styles/base/variable.less +108 -0
- package/src/styles/components/actionSheet.less +43 -0
- package/src/styles/components/badge.less +79 -0
- package/src/styles/components/button.less +123 -0
- package/src/styles/components/card.less +31 -0
- package/src/styles/components/cell-swipe.less +20 -0
- package/src/styles/components/cell.less +71 -0
- package/src/styles/components/checkBox.less +111 -0
- package/src/styles/components/editor.less +3 -0
- package/src/styles/components/header.less +70 -0
- package/src/styles/components/indicator.less +37 -0
- package/src/styles/components/loadmore.less +48 -0
- package/src/styles/components/message.less +57 -0
- package/src/styles/components/modal.less +82 -0
- package/src/styles/components/number.less +58 -0
- package/src/styles/components/picker.less +150 -0
- package/src/styles/components/popup.less +46 -0
- package/src/styles/components/progress.less +50 -0
- package/src/styles/components/prompt.less +37 -0
- package/src/styles/components/radioBox.less +136 -0
- package/src/styles/components/slide-Bar.less +147 -0
- package/src/styles/components/spinner.less +328 -0
- package/src/styles/components/swipe.less +125 -0
- package/src/styles/components/switchBar.less +88 -0
- package/src/styles/components/tab.less +69 -0
- package/src/styles/components/text.less +80 -0
- package/src/styles/components/toTop.less +26 -0
- package/src/styles/components/upload.less +23 -0
- package/src/styles/index.less +38 -0
- package/src/styles/utils/1px.less +204 -0
- package/src/styles/utils/animation.less +131 -0
- package/src/styles/utils/nowrap.less +19 -0
- package/src/template/index.ejs +26 -0
- package/src/utils/util.js +203 -0
- package/src/vconsole-resources.min.js +6 -0
- package/src/vconsole-sources.min.js +6 -0
- package/src/vconsole.min.js +7 -0
- package/src/views/ActionSheet.vue +33 -0
- package/src/views/Badge.vue +40 -0
- package/src/views/Button.vue +40 -0
- package/src/views/Card.vue +52 -0
- package/src/views/Cell.vue +21 -0
- package/src/views/CellSwipe.vue +85 -0
- package/src/views/CheckBox.vue +53 -0
- package/src/views/Header.vue +47 -0
- package/src/views/Indicator.vue +69 -0
- package/src/views/LoadMore.vue +54 -0
- package/src/views/Message.vue +42 -0
- package/src/views/Modal.vue +32 -0
- package/src/views/Picker.vue +50 -0
- package/src/views/Popup.vue +87 -0
- package/src/views/Progress.vue +32 -0
- package/src/views/Prompt.vue +31 -0
- package/src/views/RadioBox.vue +55 -0
- package/src/views/Rater.vue +39 -0
- package/src/views/SlideBar.vue +47 -0
- package/src/views/Spinner.vue +15 -0
- package/src/views/Swipe.vue +34 -0
- package/src/views/SwitchBar.vue +36 -0
- package/src/views/Tab.vue +41 -0
- package/src/views/Text.vue +64 -0
- package/src/views/ToTop.vue +17 -0
- package/src/views/Upload.vue +44 -0
- package/src/views/guide.vue +159 -0
- package/src/views/index.vue +435 -0
- package/webpack.base.config.js +74 -0
- package/webpack.dev.config.js +67 -0
- package/webpack.dist.dev.config.js +44 -0
- package/webpack.dist.prod.config.js +50 -0
- package/webpack.prod.config.js +72 -0
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div :class="classes" :style="styles">
|
|
3
|
+
<slot>
|
|
4
|
+
<div :class="wrapperClasses">图片上传</div>
|
|
5
|
+
</slot>
|
|
6
|
+
<input type="file" ref="upload" :accept="accept" :multiple="multiple" @change="showPhoto"/>
|
|
7
|
+
</div>
|
|
8
|
+
</template>
|
|
9
|
+
|
|
10
|
+
<script>
|
|
11
|
+
|
|
12
|
+
import EXIF from 'exif-js'
|
|
13
|
+
import MegaPixImage from '../../lib/MegaPixImage'
|
|
14
|
+
import { JPEG } from '../../utils/util'
|
|
15
|
+
const prefixCls = 'dpzvc-upload';
|
|
16
|
+
export default {
|
|
17
|
+
props: {
|
|
18
|
+
multiple: {
|
|
19
|
+
|
|
20
|
+
type: Boolean,
|
|
21
|
+
default: false
|
|
22
|
+
},
|
|
23
|
+
accept: {
|
|
24
|
+
type: String,
|
|
25
|
+
default: 'image/*'
|
|
26
|
+
},
|
|
27
|
+
// capture: {
|
|
28
|
+
// type: String,
|
|
29
|
+
// default: ''
|
|
30
|
+
// },
|
|
31
|
+
styles: {
|
|
32
|
+
type: Object,
|
|
33
|
+
default(){
|
|
34
|
+
return {}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
data(){
|
|
39
|
+
return {
|
|
40
|
+
files: [],
|
|
41
|
+
fileLength:0
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
computed:{
|
|
45
|
+
classes(){
|
|
46
|
+
return [
|
|
47
|
+
`${prefixCls}`
|
|
48
|
+
]
|
|
49
|
+
},
|
|
50
|
+
wrapperClasses(){
|
|
51
|
+
return [
|
|
52
|
+
`${prefixCls}-wrapper`
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
methods: {
|
|
58
|
+
|
|
59
|
+
showPhoto(e){
|
|
60
|
+
this.$Indicator.snake({text:'上传中'});
|
|
61
|
+
this.files = [];
|
|
62
|
+
let file = e.target.files;
|
|
63
|
+
this.fileLength = file.length;
|
|
64
|
+
let that = this;
|
|
65
|
+
let Orientation = null;
|
|
66
|
+
|
|
67
|
+
for (let i = 0; i < file.length; i++) {
|
|
68
|
+
|
|
69
|
+
EXIF.getData(file[i], function () {
|
|
70
|
+
EXIF.getAllTags(this);
|
|
71
|
+
Orientation = EXIF.getTag(this, 'Orientation');
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
let reader = new FileReader();
|
|
76
|
+
reader.readAsDataURL(file[i]);
|
|
77
|
+
|
|
78
|
+
reader.onload = function (e) {
|
|
79
|
+
let img = new Image();
|
|
80
|
+
img.src = e.target.result;
|
|
81
|
+
|
|
82
|
+
img.onload = function (e) {
|
|
83
|
+
|
|
84
|
+
that.create(img, Orientation);
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
e.target.value = '';
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
},
|
|
94
|
+
create(file, Orientation){
|
|
95
|
+
|
|
96
|
+
let _this = this;
|
|
97
|
+
let data = null;
|
|
98
|
+
let img = new Image();
|
|
99
|
+
let mpImg = new MegaPixImage(file);
|
|
100
|
+
|
|
101
|
+
mpImg.render(img, {maxWidth: 600, quality: 0.8});
|
|
102
|
+
img.onload = function () {
|
|
103
|
+
|
|
104
|
+
let canvas = document.createElement('canvas');
|
|
105
|
+
let ctx = canvas.getContext('2d');
|
|
106
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
107
|
+
canvas.width = img.width;
|
|
108
|
+
canvas.height = img.height;
|
|
109
|
+
ctx.drawImage(this, 0, 0, canvas.width, canvas.height);
|
|
110
|
+
data = canvas.toDataURL("image/jpeg", 0.8);
|
|
111
|
+
|
|
112
|
+
if (navigator.userAgent.match(/iphone/i)) {
|
|
113
|
+
if (Orientation != "" && Orientation != 1) {
|
|
114
|
+
switch (Orientation) {
|
|
115
|
+
case 6:
|
|
116
|
+
_this.rotateImg(this, 'left', canvas);
|
|
117
|
+
break;
|
|
118
|
+
case 8:
|
|
119
|
+
_this.rotateImg(this, 'right', canvas);
|
|
120
|
+
break;
|
|
121
|
+
case 3:
|
|
122
|
+
_this.rotateImg(this, 'right', canvas);
|
|
123
|
+
_this.rotateImg(this, 'right', canvas);
|
|
124
|
+
break;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
data = canvas.toDataURL("image/jpeg", 0.8);
|
|
128
|
+
}
|
|
129
|
+
if (navigator.userAgent.match(/Android/i)) {
|
|
130
|
+
let JPEGEncoder = JPEG.JPEGEncoder;
|
|
131
|
+
let encoder = new JPEGEncoder();
|
|
132
|
+
data = encoder.encode(ctx.getImageData(0, 0, canvas.width, canvas.height), 80);
|
|
133
|
+
}
|
|
134
|
+
let result = {
|
|
135
|
+
base64: data,
|
|
136
|
+
clearBase64: data.substr(data.indexOf(',') + 1)
|
|
137
|
+
};
|
|
138
|
+
|
|
139
|
+
_this.files.push(result)
|
|
140
|
+
|
|
141
|
+
if (_this.files.length === _this.fileLength) _this.$Indicator.remove()
|
|
142
|
+
|
|
143
|
+
};
|
|
144
|
+
},
|
|
145
|
+
rotateImg(img, direction, canvas) {
|
|
146
|
+
let min_step = 0;
|
|
147
|
+
let max_step = 3;
|
|
148
|
+
if (img == null)return;
|
|
149
|
+
let height = img.height;
|
|
150
|
+
let width = img.width;
|
|
151
|
+
let step = 2;
|
|
152
|
+
if (step == null) {
|
|
153
|
+
step = min_step;
|
|
154
|
+
}
|
|
155
|
+
if (direction == 'right') {
|
|
156
|
+
step++;
|
|
157
|
+
step > max_step && (step = min_step);
|
|
158
|
+
} else {
|
|
159
|
+
step--;
|
|
160
|
+
step < min_step && (step = max_step);
|
|
161
|
+
}
|
|
162
|
+
let degree = step * 90 * Math.PI / 180;
|
|
163
|
+
let ctx = canvas.getContext('2d');
|
|
164
|
+
switch (step) {
|
|
165
|
+
case 0:
|
|
166
|
+
canvas.width = width;
|
|
167
|
+
canvas.height = height;
|
|
168
|
+
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
|
169
|
+
break;
|
|
170
|
+
case 1:
|
|
171
|
+
canvas.width = height;
|
|
172
|
+
canvas.height = width;
|
|
173
|
+
ctx.rotate(degree);
|
|
174
|
+
ctx.drawImage(img, 0, -height, canvas.height, canvas.width);
|
|
175
|
+
break;
|
|
176
|
+
case 2:
|
|
177
|
+
canvas.width = width;
|
|
178
|
+
canvas.height = height;
|
|
179
|
+
ctx.rotate(degree);
|
|
180
|
+
ctx.drawImage(img, -width, -height, canvas.width, canvas.height);
|
|
181
|
+
break;
|
|
182
|
+
case 3:
|
|
183
|
+
canvas.width = height;
|
|
184
|
+
canvas.height = width;
|
|
185
|
+
ctx.rotate(degree);
|
|
186
|
+
ctx.drawImage(img, -width, 0, canvas.height, canvas.width);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
watch: {
|
|
192
|
+
|
|
193
|
+
files(val){
|
|
194
|
+
this.$emit('on-change-file', val)
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
</script>
|
|
200
|
+
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by lcfevr on 16/7/18.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
let config = {
|
|
7
|
+
env: process.env.NODE_ENV,
|
|
8
|
+
PROJECT:'dpzvc',
|
|
9
|
+
VERSION:'1.0',
|
|
10
|
+
doc_title:'',
|
|
11
|
+
baseUrl:'',
|
|
12
|
+
isIPad: /ipad/i.test(window.navigator.userAgent),
|
|
13
|
+
isIphone: /iphone|ipad|ipod/i.test(window.navigator.userAgent),
|
|
14
|
+
isWechat: /MicroMessenger/i.test(window.navigator.userAgent),
|
|
15
|
+
isUCBrowser: /UCWEB|UCBrowser/i.test(window.navigator.userAgent)
|
|
16
|
+
};
|
|
17
|
+
export default config;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2017/7/4.
|
|
3
|
+
*/
|
|
4
|
+
//from mint-ui
|
|
5
|
+
const clickoutsideContext = '@@clickoutsideContext';
|
|
6
|
+
|
|
7
|
+
export default {
|
|
8
|
+
bind(el, binding, vnode) {
|
|
9
|
+
const documentHandler = function(e) {
|
|
10
|
+
if (vnode.context && !el.contains(e.target)) {
|
|
11
|
+
vnode.context[el[clickoutsideContext].methodName]();
|
|
12
|
+
}
|
|
13
|
+
};
|
|
14
|
+
el[clickoutsideContext] = {
|
|
15
|
+
documentHandler,
|
|
16
|
+
methodName: binding.expression,
|
|
17
|
+
arg: binding.arg || 'click'
|
|
18
|
+
};
|
|
19
|
+
document.addEventListener(el[clickoutsideContext].arg, documentHandler);
|
|
20
|
+
},
|
|
21
|
+
|
|
22
|
+
update(el, binding) {
|
|
23
|
+
el[clickoutsideContext].methodName = binding.expression;
|
|
24
|
+
},
|
|
25
|
+
|
|
26
|
+
unbind(el) {
|
|
27
|
+
document.removeEventListener(
|
|
28
|
+
el[clickoutsideContext].arg,
|
|
29
|
+
el[clickoutsideContext].documentHandler);
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2017/5/5.
|
|
3
|
+
*/
|
|
4
|
+
function getTarget (node) {
|
|
5
|
+
if (node === void 0) {
|
|
6
|
+
node = document.body
|
|
7
|
+
}
|
|
8
|
+
if (node === true) { return document.body }
|
|
9
|
+
return node instanceof window.Node ? node : document.querySelector(node)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const directive = {
|
|
13
|
+
inserted (el, { value }, vnode) {
|
|
14
|
+
el.className = el.className ? el.className + ' v-transfer-dom' : 'v-transfer-dom';
|
|
15
|
+
const parentNode = el.parentNode;
|
|
16
|
+
const home = document.createComment('');
|
|
17
|
+
let hasMovedOut = false;
|
|
18
|
+
|
|
19
|
+
if (value !== false) {
|
|
20
|
+
parentNode.replaceChild(home, el); // moving out, el is no longer in the document
|
|
21
|
+
getTarget(value).appendChild(el); // moving into new place
|
|
22
|
+
hasMovedOut = true
|
|
23
|
+
}
|
|
24
|
+
if (!el.__transferDomData) {
|
|
25
|
+
el.__transferDomData = {
|
|
26
|
+
parentNode: parentNode,
|
|
27
|
+
home: home,
|
|
28
|
+
target: getTarget(value),
|
|
29
|
+
hasMovedOut: hasMovedOut
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
componentUpdated (el, { value }) {
|
|
34
|
+
// need to make sure children are done updating (vs. `update`)
|
|
35
|
+
const ref$1 = el.__transferDomData;
|
|
36
|
+
// homes.get(el)
|
|
37
|
+
const parentNode = ref$1.parentNode;
|
|
38
|
+
const home = ref$1.home;
|
|
39
|
+
const hasMovedOut = ref$1.hasMovedOut; // recall where home is
|
|
40
|
+
|
|
41
|
+
if (!hasMovedOut && value) {
|
|
42
|
+
// remove from document and leave placeholder
|
|
43
|
+
parentNode.replaceChild(home, el);
|
|
44
|
+
// append to target
|
|
45
|
+
getTarget(value).appendChild(el);
|
|
46
|
+
el.__transferDomData = Object.assign({}, el.__transferDomData, { hasMovedOut: true, target: getTarget(value) });
|
|
47
|
+
} else if (hasMovedOut && value === false) {
|
|
48
|
+
// previously moved, coming back home
|
|
49
|
+
parentNode.replaceChild(el, home);
|
|
50
|
+
el.__transferDomData = Object.assign({}, el.__transferDomData, { hasMovedOut: false, target: getTarget(value) });
|
|
51
|
+
} else if (value) {
|
|
52
|
+
// already moved, going somewhere else
|
|
53
|
+
getTarget(value).appendChild(el);
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
unbind: function unbind (el, binding) {
|
|
57
|
+
el.className = el.className.replace('v-transfer-dom', '')
|
|
58
|
+
if (el.__transferDomData.hasMovedOut === true) {
|
|
59
|
+
el.__transferDomData.parentNode && el.__transferDomData.parentNode.appendChild(el)
|
|
60
|
+
}
|
|
61
|
+
el.__transferDomData = null
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export default directive;
|
package/src/index.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Created by admin on 2017/5/15.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import VButton from '@/button'
|
|
6
|
+
import CheckBox from './components/checkBox'
|
|
7
|
+
import Header from './components/Header'
|
|
8
|
+
import Message from './components/message'
|
|
9
|
+
import Modal from './components/modal'
|
|
10
|
+
import Picker from './components/picker'
|
|
11
|
+
import Radio from './components/radioBox'
|
|
12
|
+
import Swipe from './components/swipe'
|
|
13
|
+
import Tab from './components/tab'
|
|
14
|
+
import Prompt from './components/prompt'
|
|
15
|
+
import SlideBar from './components/slideBar'
|
|
16
|
+
import TextBar from './components/Text'
|
|
17
|
+
import Upload from './components/upload'
|
|
18
|
+
import ActionSheet from '@/action-sheet'
|
|
19
|
+
import SwitchBar from './components/switchbar'
|
|
20
|
+
import Rater from './components/rater'
|
|
21
|
+
import Spinner from './components/spinner'
|
|
22
|
+
import LoadMore from './components/loadMore'
|
|
23
|
+
import Popup from './components/popup'
|
|
24
|
+
import Indicator from './components/Indicator'
|
|
25
|
+
import Progress from './components/progress'
|
|
26
|
+
import ToTop from './components/toTop'
|
|
27
|
+
import Cell from './components/cell'
|
|
28
|
+
import CellSwipe from './components/cell-swipe'
|
|
29
|
+
import Badge from './components/badge'
|
|
30
|
+
import Card from './components/card'
|
|
31
|
+
|
|
32
|
+
const dpzvc = {
|
|
33
|
+
|
|
34
|
+
VButton,
|
|
35
|
+
CheckBox,
|
|
36
|
+
CheckBoxGroup:CheckBox.group,
|
|
37
|
+
Radio,
|
|
38
|
+
RadioGroup:Radio.group,
|
|
39
|
+
Header,
|
|
40
|
+
Message,
|
|
41
|
+
Modal,
|
|
42
|
+
Prompt,
|
|
43
|
+
Picker,
|
|
44
|
+
Swipe,
|
|
45
|
+
Tab,
|
|
46
|
+
SlideBar,
|
|
47
|
+
TextBar,
|
|
48
|
+
Number:TextBar.Number,
|
|
49
|
+
Upload,
|
|
50
|
+
ActionSheet,
|
|
51
|
+
SwitchBar,
|
|
52
|
+
Rater,
|
|
53
|
+
Spinner,
|
|
54
|
+
LoadMore,
|
|
55
|
+
Popup,
|
|
56
|
+
Indicator,
|
|
57
|
+
Progress,
|
|
58
|
+
ToTop,
|
|
59
|
+
Cell,
|
|
60
|
+
CellSwipe,
|
|
61
|
+
Badge,
|
|
62
|
+
Card
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const install = (Vue,options)=>{
|
|
66
|
+
|
|
67
|
+
Object.keys(dpzvc).forEach((key)=>{
|
|
68
|
+
Vue.component(key,dpzvc[key])
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
Vue.prototype.$Message = Message;
|
|
73
|
+
Vue.prototype.$Modal = Modal;
|
|
74
|
+
Vue.prototype.$Prompt = Prompt;
|
|
75
|
+
Vue.prototype.$Indicator = Indicator
|
|
76
|
+
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
if (typeof window !== 'undefined' && window.Vue) {
|
|
80
|
+
install(window.Vue);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
module.exports = Object.assign(dpzvc, {install});
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Detect subsampling in loaded image.
|
|
5
|
+
* In iOS, larger images than 2M pixels may be subsampled in rendering.
|
|
6
|
+
*/
|
|
7
|
+
function detectSubsampling(img) {
|
|
8
|
+
var iw = img.naturalWidth, ih = img.naturalHeight;
|
|
9
|
+
if (iw * ih > 1024 * 1024) { // subsampling may happen over megapixel image
|
|
10
|
+
var canvas = document.createElement('canvas');
|
|
11
|
+
canvas.width = canvas.height = 1;
|
|
12
|
+
var ctx = canvas.getContext('2d');
|
|
13
|
+
ctx.drawImage(img, -iw + 1, 0);
|
|
14
|
+
// subsampled image becomes half smaller in rendering size.
|
|
15
|
+
// check alpha channel value to confirm image is covering edge pixel or not.
|
|
16
|
+
// if alpha value is 0 image is not covering, hence subsampled.
|
|
17
|
+
return ctx.getImageData(0, 0, 1, 1).data[3] === 0;
|
|
18
|
+
} else {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Detecting vertical squash in loaded image.
|
|
25
|
+
* Fixes a bug which squash image vertically while drawing into canvas for some images.
|
|
26
|
+
*/
|
|
27
|
+
function detectVerticalSquash(img, iw, ih) {
|
|
28
|
+
var canvas = document.createElement('canvas');
|
|
29
|
+
canvas.width = 1;
|
|
30
|
+
canvas.height = ih;
|
|
31
|
+
var ctx = canvas.getContext('2d');
|
|
32
|
+
ctx.drawImage(img, 0, 0);
|
|
33
|
+
var data = ctx.getImageData(0, 0, 1, ih).data;
|
|
34
|
+
// search image edge pixel position in case it is squashed vertically.
|
|
35
|
+
var sy = 0;
|
|
36
|
+
var ey = ih;
|
|
37
|
+
var py = ih;
|
|
38
|
+
while (py > sy) {
|
|
39
|
+
var alpha = data[(py - 1) * 4 + 3];
|
|
40
|
+
if (alpha === 0) {
|
|
41
|
+
ey = py;
|
|
42
|
+
} else {
|
|
43
|
+
sy = py;
|
|
44
|
+
}
|
|
45
|
+
py = (ey + sy) >> 1;
|
|
46
|
+
}
|
|
47
|
+
var ratio = (py / ih);
|
|
48
|
+
return (ratio===0)?1:ratio;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Rendering image element (with resizing) and get its data URL
|
|
53
|
+
*/
|
|
54
|
+
function renderImageToDataURL(img, options, doSquash) {
|
|
55
|
+
var canvas = document.createElement('canvas');
|
|
56
|
+
renderImageToCanvas(img, canvas, options, doSquash);
|
|
57
|
+
return canvas.toDataURL("image/jpeg", options.quality || 0.8);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Rendering image element (with resizing) into the canvas element
|
|
62
|
+
*/
|
|
63
|
+
function renderImageToCanvas(img, canvas, options, doSquash) {
|
|
64
|
+
var iw = img.naturalWidth, ih = img.naturalHeight;
|
|
65
|
+
if (!(iw+ih)) return;
|
|
66
|
+
var width = options.width, height = options.height;
|
|
67
|
+
var ctx = canvas.getContext('2d');
|
|
68
|
+
ctx.save();
|
|
69
|
+
transformCoordinate(canvas, ctx, width, height, options.orientation);
|
|
70
|
+
var subsampled = detectSubsampling(img);
|
|
71
|
+
if (subsampled) {
|
|
72
|
+
iw /= 2;
|
|
73
|
+
ih /= 2;
|
|
74
|
+
}
|
|
75
|
+
var d = 1024; // size of tiling canvas
|
|
76
|
+
var tmpCanvas = document.createElement('canvas');
|
|
77
|
+
tmpCanvas.width = tmpCanvas.height = d;
|
|
78
|
+
var tmpCtx = tmpCanvas.getContext('2d');
|
|
79
|
+
var vertSquashRatio = doSquash ? detectVerticalSquash(img, iw, ih) : 1;
|
|
80
|
+
var dw = Math.ceil(d * width / iw);
|
|
81
|
+
var dh = Math.ceil(d * height / ih / vertSquashRatio);
|
|
82
|
+
var sy = 0;
|
|
83
|
+
var dy = 0;
|
|
84
|
+
while (sy < ih) {
|
|
85
|
+
var sx = 0;
|
|
86
|
+
var dx = 0;
|
|
87
|
+
while (sx < iw) {
|
|
88
|
+
tmpCtx.clearRect(0, 0, d, d);
|
|
89
|
+
tmpCtx.drawImage(img, -sx, -sy);
|
|
90
|
+
ctx.drawImage(tmpCanvas, 0, 0, d, d, dx, dy, dw, dh);
|
|
91
|
+
sx += d;
|
|
92
|
+
dx += dw;
|
|
93
|
+
}
|
|
94
|
+
sy += d;
|
|
95
|
+
dy += dh;
|
|
96
|
+
}
|
|
97
|
+
ctx.restore();
|
|
98
|
+
tmpCanvas = tmpCtx = null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Transform canvas coordination according to specified frame size and orientation
|
|
103
|
+
* Orientation value is from EXIF tag
|
|
104
|
+
*/
|
|
105
|
+
function transformCoordinate(canvas, ctx, width, height, orientation) {
|
|
106
|
+
switch (orientation) {
|
|
107
|
+
case 5:
|
|
108
|
+
case 6:
|
|
109
|
+
case 7:
|
|
110
|
+
case 8:
|
|
111
|
+
canvas.width = height;
|
|
112
|
+
canvas.height = width;
|
|
113
|
+
break;
|
|
114
|
+
default:
|
|
115
|
+
canvas.width = width;
|
|
116
|
+
canvas.height = height;
|
|
117
|
+
}
|
|
118
|
+
switch (orientation) {
|
|
119
|
+
case 2:
|
|
120
|
+
// horizontal flip
|
|
121
|
+
ctx.translate(width, 0);
|
|
122
|
+
ctx.scale(-1, 1);
|
|
123
|
+
break;
|
|
124
|
+
case 3:
|
|
125
|
+
// 180 rotate left
|
|
126
|
+
ctx.translate(width, height);
|
|
127
|
+
ctx.rotate(Math.PI);
|
|
128
|
+
break;
|
|
129
|
+
case 4:
|
|
130
|
+
// vertical flip
|
|
131
|
+
ctx.translate(0, height);
|
|
132
|
+
ctx.scale(1, -1);
|
|
133
|
+
break;
|
|
134
|
+
case 5:
|
|
135
|
+
// vertical flip + 90 rotate right
|
|
136
|
+
ctx.rotate(0.5 * Math.PI);
|
|
137
|
+
ctx.scale(1, -1);
|
|
138
|
+
break;
|
|
139
|
+
case 6:
|
|
140
|
+
// 90 rotate right
|
|
141
|
+
ctx.rotate(0.5 * Math.PI);
|
|
142
|
+
ctx.translate(0, -height);
|
|
143
|
+
break;
|
|
144
|
+
case 7:
|
|
145
|
+
// horizontal flip + 90 rotate right
|
|
146
|
+
ctx.rotate(0.5 * Math.PI);
|
|
147
|
+
ctx.translate(width, -height);
|
|
148
|
+
ctx.scale(-1, 1);
|
|
149
|
+
break;
|
|
150
|
+
case 8:
|
|
151
|
+
// 90 rotate left
|
|
152
|
+
ctx.rotate(-0.5 * Math.PI);
|
|
153
|
+
ctx.translate(-width, 0);
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
var URL = window.URL && window.URL.createObjectURL ? window.URL :
|
|
161
|
+
window.webkitURL && window.webkitURL.createObjectURL ? window.webkitURL :
|
|
162
|
+
null;
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* MegaPixImage class
|
|
166
|
+
*/
|
|
167
|
+
function MegaPixImage(srcImage) {
|
|
168
|
+
if (window.Blob && srcImage instanceof Blob) {
|
|
169
|
+
if (!URL) { throw Error("No createObjectURL function found to create blob url"); }
|
|
170
|
+
var img = new Image();
|
|
171
|
+
img.src = URL.createObjectURL(srcImage);
|
|
172
|
+
this.blob = srcImage;
|
|
173
|
+
srcImage = img;
|
|
174
|
+
}
|
|
175
|
+
if (!srcImage.naturalWidth && !srcImage.naturalHeight) {
|
|
176
|
+
var _this = this;
|
|
177
|
+
srcImage.onload = srcImage.onerror = function() {
|
|
178
|
+
var listeners = _this.imageLoadListeners;
|
|
179
|
+
if (listeners) {
|
|
180
|
+
_this.imageLoadListeners = null;
|
|
181
|
+
for (var i=0, len=listeners.length; i<len; i++) {
|
|
182
|
+
listeners[i]();
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
};
|
|
186
|
+
this.imageLoadListeners = [];
|
|
187
|
+
}
|
|
188
|
+
this.srcImage = srcImage;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* Rendering megapix image into specified target element
|
|
193
|
+
*/
|
|
194
|
+
MegaPixImage.prototype.render = function(target, options, callback) {
|
|
195
|
+
if (this.imageLoadListeners) {
|
|
196
|
+
var _this = this;
|
|
197
|
+
this.imageLoadListeners.push(function() { _this.render(target, options, callback); });
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
options = options || {};
|
|
201
|
+
var imgWidth = this.srcImage.naturalWidth, imgHeight = this.srcImage.naturalHeight,
|
|
202
|
+
width = options.width, height = options.height,
|
|
203
|
+
maxWidth = options.maxWidth, maxHeight = options.maxHeight,
|
|
204
|
+
doSquash = !this.blob || this.blob.type === 'image/jpeg';
|
|
205
|
+
if (width && !height) {
|
|
206
|
+
height = (imgHeight * width / imgWidth) << 0;
|
|
207
|
+
} else if (height && !width) {
|
|
208
|
+
width = (imgWidth * height / imgHeight) << 0;
|
|
209
|
+
} else {
|
|
210
|
+
width = imgWidth;
|
|
211
|
+
height = imgHeight;
|
|
212
|
+
}
|
|
213
|
+
if (maxWidth && width > maxWidth) {
|
|
214
|
+
width = maxWidth;
|
|
215
|
+
height = (imgHeight * width / imgWidth) << 0;
|
|
216
|
+
}
|
|
217
|
+
if (maxHeight && height > maxHeight) {
|
|
218
|
+
height = maxHeight;
|
|
219
|
+
width = (imgWidth * height / imgHeight) << 0;
|
|
220
|
+
}
|
|
221
|
+
var opt = { width : width, height : height };
|
|
222
|
+
for (var k in options) opt[k] = options[k];
|
|
223
|
+
|
|
224
|
+
var tagName = target.tagName.toLowerCase();
|
|
225
|
+
if (tagName === 'img') {
|
|
226
|
+
target.src = renderImageToDataURL(this.srcImage, opt, doSquash);
|
|
227
|
+
} else if (tagName === 'canvas') {
|
|
228
|
+
renderImageToCanvas(this.srcImage, target, opt, doSquash);
|
|
229
|
+
}
|
|
230
|
+
if (typeof this.onrender === 'function') {
|
|
231
|
+
this.onrender(target);
|
|
232
|
+
}
|
|
233
|
+
if (callback) {
|
|
234
|
+
callback();
|
|
235
|
+
}
|
|
236
|
+
if (this.blob) {
|
|
237
|
+
this.blob = null;
|
|
238
|
+
URL.revokeObjectURL(this.srcImage.src);
|
|
239
|
+
}
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
/**
|
|
243
|
+
* Export class to global
|
|
244
|
+
*/
|
|
245
|
+
if (typeof define === 'function' && define.amd) {
|
|
246
|
+
define([], function() { return MegaPixImage; }); // for AMD loader
|
|
247
|
+
} else if (typeof exports === 'object') {
|
|
248
|
+
module.exports = MegaPixImage; // for CommonJS
|
|
249
|
+
} else {
|
|
250
|
+
this.MegaPixImage = MegaPixImage;
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
})();
|