safecheck-client 3.0.35-52 → 3.0.35-53

Sign up to get free protection for your applications and to get access to all the features.
Files changed (247) hide show
  1. package/.babelrc +5 -5
  2. package/.editorconfig +9 -9
  3. package/android.html +18 -18
  4. package/config/dev.env.js +6 -6
  5. package/config/index.js +38 -38
  6. package/config/prod.env.js +3 -3
  7. package/config/test.env.js +6 -6
  8. package/docs/AppBase.md +22 -22
  9. package/docs/Busy.md +14 -14
  10. package/docs/CriteriaPaged.md +47 -47
  11. package/docs/DataGrid.md +54 -54
  12. package/docs/DataModel.md +22 -22
  13. package/docs/Dynamic.md +42 -42
  14. package/docs/GetParams.md +11 -11
  15. package/docs/HttpBusy.md +13 -13
  16. package/docs/HttpStore.md +29 -29
  17. package/docs/MessageBox.md +28 -28
  18. package/docs/PagedList.md +29 -29
  19. package/docs/Pager.md +21 -21
  20. package/docs/Project.md +23 -23
  21. package/docs/Route.md +105 -105
  22. package/docs/SafetyCheck/AdjustPlan.md +13 -13
  23. package/docs/SafetyCheck/CheckerPlan.md +12 -12
  24. package/docs/Task.md +46 -46
  25. package/docs/TreeList.md +28 -28
  26. package/docs/TreeMixin.md +18 -18
  27. package/docs/all.md +10 -10
  28. package/docs/list.md +42 -42
  29. package/docs/partial.md +75 -75
  30. package/docs/selector.md +82 -82
  31. package/docs//345/274/200/345/217/221/346/226/207/346/241/243/Snippets.md +28 -28
  32. package/docs//345/274/200/345/217/221/346/226/207/346/241/243/vue-strap/345/217/230/346/233/264/350/256/260/345/275/225.md +7 -7
  33. package/docs//345/274/200/345/217/221/346/226/207/346/241/243/vue/345/217/230/346/233/264/350/256/260/345/275/225.md +13 -13
  34. package/docs//345/274/200/345/217/221/346/226/207/346/241/243//345/274/200/345/217/221/347/216/257/345/242/203/350/256/276/347/275/256.md +77 -77
  35. package/docs//347/225/214/351/235/242/345/210/266/344/275/234/350/247/204/350/214/203.md +54 -54
  36. package/examples/AddressList/App.vue +13 -13
  37. package/examples/AddressList/index.html +11 -11
  38. package/examples/DispatchList/App.vue +10 -10
  39. package/examples/DispatchList/BaseTree.vue +13 -13
  40. package/examples/DispatchList/Init.vue +22 -22
  41. package/examples/DispatchList/Test.vue +20 -20
  42. package/examples/DispatchList/index.html +11 -11
  43. package/examples/DispatchList/main.js +18 -18
  44. package/home.html +16 -16
  45. package/package.json +1 -1
  46. package/publish.bat +7 -7
  47. package/release.bat +5 -5
  48. package/src/App.vue +31 -31
  49. package/src/Widget.vue +13 -13
  50. package/src/android-bootstrap/fonts/glyphicons-halflings-regular.svg +287 -287
  51. package/src/android-bootstrap/less/.csscomb.json +304 -304
  52. package/src/android-bootstrap/less/.csslintrc +19 -19
  53. package/src/android-bootstrap/less/alerts.less +73 -73
  54. package/src/android-bootstrap/less/badges.less +66 -66
  55. package/src/android-bootstrap/less/bootstrap.less +56 -56
  56. package/src/android-bootstrap/less/breadcrumbs.less +26 -26
  57. package/src/android-bootstrap/less/button-groups.less +247 -247
  58. package/src/android-bootstrap/less/buttons.less +173 -173
  59. package/src/android-bootstrap/less/carousel.less +269 -269
  60. package/src/android-bootstrap/less/close.less +34 -34
  61. package/src/android-bootstrap/less/code.less +69 -69
  62. package/src/android-bootstrap/less/component-animations.less +33 -33
  63. package/src/android-bootstrap/less/grid.less +84 -84
  64. package/src/android-bootstrap/less/input-groups.less +167 -167
  65. package/src/android-bootstrap/less/jumbotron.less +52 -52
  66. package/src/android-bootstrap/less/labels.less +64 -64
  67. package/src/android-bootstrap/less/list-group.less +141 -141
  68. package/src/android-bootstrap/less/media.less +66 -66
  69. package/src/android-bootstrap/less/mixins/alerts.less +14 -14
  70. package/src/android-bootstrap/less/mixins/background-variant.less +9 -9
  71. package/src/android-bootstrap/less/mixins/border-radius.less +18 -18
  72. package/src/android-bootstrap/less/mixins/buttons.less +69 -69
  73. package/src/android-bootstrap/less/mixins/center-block.less +7 -7
  74. package/src/android-bootstrap/less/mixins/clearfix.less +22 -22
  75. package/src/android-bootstrap/less/mixins/forms.less +90 -90
  76. package/src/android-bootstrap/less/mixins/gradients.less +59 -59
  77. package/src/android-bootstrap/less/mixins/grid-framework.less +92 -92
  78. package/src/android-bootstrap/less/mixins/grid.less +122 -122
  79. package/src/android-bootstrap/less/mixins/hide-text.less +21 -21
  80. package/src/android-bootstrap/less/mixins/image.less +33 -33
  81. package/src/android-bootstrap/less/mixins/labels.less +12 -12
  82. package/src/android-bootstrap/less/mixins/list-group.less +30 -30
  83. package/src/android-bootstrap/less/mixins/nav-divider.less +10 -10
  84. package/src/android-bootstrap/less/mixins/nav-vertical-align.less +9 -9
  85. package/src/android-bootstrap/less/mixins/opacity.less +8 -8
  86. package/src/android-bootstrap/less/mixins/pagination.less +24 -24
  87. package/src/android-bootstrap/less/mixins/panels.less +24 -24
  88. package/src/android-bootstrap/less/mixins/progress-bar.less +10 -10
  89. package/src/android-bootstrap/less/mixins/reset-filter.less +8 -8
  90. package/src/android-bootstrap/less/mixins/reset-text.less +18 -18
  91. package/src/android-bootstrap/less/mixins/resize.less +6 -6
  92. package/src/android-bootstrap/less/mixins/responsive-visibility.less +15 -15
  93. package/src/android-bootstrap/less/mixins/size.less +10 -10
  94. package/src/android-bootstrap/less/mixins/tab-focus.less +9 -9
  95. package/src/android-bootstrap/less/mixins/table-row.less +44 -44
  96. package/src/android-bootstrap/less/mixins/text-emphasis.less +9 -9
  97. package/src/android-bootstrap/less/mixins/text-overflow.less +8 -8
  98. package/src/android-bootstrap/less/mixins/vendor-prefixes.less +227 -227
  99. package/src/android-bootstrap/less/mixins.less +40 -40
  100. package/src/android-bootstrap/less/modals.less +151 -151
  101. package/src/android-bootstrap/less/navbar.less +660 -660
  102. package/src/android-bootstrap/less/navs.less +290 -290
  103. package/src/android-bootstrap/less/normalize.less +424 -424
  104. package/src/android-bootstrap/less/pager.less +76 -76
  105. package/src/android-bootstrap/less/pagination.less +89 -89
  106. package/src/android-bootstrap/less/panels.less +274 -274
  107. package/src/android-bootstrap/less/popovers.less +131 -131
  108. package/src/android-bootstrap/less/print.less +101 -101
  109. package/src/android-bootstrap/less/progress-bars.less +87 -87
  110. package/src/android-bootstrap/less/responsive-embed.less +35 -35
  111. package/src/android-bootstrap/less/responsive-utilities.less +194 -194
  112. package/src/android-bootstrap/less/scaffolding.less +161 -161
  113. package/src/android-bootstrap/less/tables.less +262 -262
  114. package/src/android-bootstrap/less/theme.less +291 -291
  115. package/src/android-bootstrap/less/thumbnails.less +36 -36
  116. package/src/android-bootstrap/less/tooltip.less +102 -102
  117. package/src/android-bootstrap/less/type.less +303 -303
  118. package/src/android-bootstrap/less/utilities.less +55 -55
  119. package/src/android-bootstrap/less/variables.less +896 -896
  120. package/src/android-bootstrap/less/wells.less +29 -29
  121. package/src/androidTest.js +20 -20
  122. package/src/bootstrap/less/.csscomb.json +304 -304
  123. package/src/bootstrap/less/.csslintrc +19 -19
  124. package/src/bootstrap/less/alerts.less +73 -73
  125. package/src/bootstrap/less/badges.less +66 -66
  126. package/src/bootstrap/less/breadcrumbs.less +26 -26
  127. package/src/bootstrap/less/button-groups.less +247 -247
  128. package/src/bootstrap/less/buttons.less +172 -172
  129. package/src/bootstrap/less/carousel.less +269 -269
  130. package/src/bootstrap/less/close.less +34 -34
  131. package/src/bootstrap/less/code.less +69 -69
  132. package/src/bootstrap/less/component-animations.less +33 -33
  133. package/src/bootstrap/less/dropdowns.less +216 -216
  134. package/src/bootstrap/less/forms.less +626 -626
  135. package/src/bootstrap/less/grid.less +84 -84
  136. package/src/bootstrap/less/input-groups.less +167 -167
  137. package/src/bootstrap/less/jumbotron.less +52 -52
  138. package/src/bootstrap/less/labels.less +64 -64
  139. package/src/bootstrap/less/list-group.less +141 -141
  140. package/src/bootstrap/less/media.less +66 -66
  141. package/src/bootstrap/less/mixins/alerts.less +14 -14
  142. package/src/bootstrap/less/mixins/background-variant.less +9 -9
  143. package/src/bootstrap/less/mixins/border-radius.less +18 -18
  144. package/src/bootstrap/less/mixins/buttons.less +69 -69
  145. package/src/bootstrap/less/mixins/center-block.less +7 -7
  146. package/src/bootstrap/less/mixins/clearfix.less +22 -22
  147. package/src/bootstrap/less/mixins/forms.less +90 -90
  148. package/src/bootstrap/less/mixins/gradients.less +59 -59
  149. package/src/bootstrap/less/mixins/grid-framework.less +92 -92
  150. package/src/bootstrap/less/mixins/grid.less +122 -122
  151. package/src/bootstrap/less/mixins/hide-text.less +21 -21
  152. package/src/bootstrap/less/mixins/image.less +33 -33
  153. package/src/bootstrap/less/mixins/labels.less +12 -12
  154. package/src/bootstrap/less/mixins/list-group.less +30 -30
  155. package/src/bootstrap/less/mixins/nav-divider.less +10 -10
  156. package/src/bootstrap/less/mixins/nav-vertical-align.less +9 -9
  157. package/src/bootstrap/less/mixins/opacity.less +8 -8
  158. package/src/bootstrap/less/mixins/pagination.less +24 -24
  159. package/src/bootstrap/less/mixins/panels.less +24 -24
  160. package/src/bootstrap/less/mixins/progress-bar.less +10 -10
  161. package/src/bootstrap/less/mixins/reset-filter.less +8 -8
  162. package/src/bootstrap/less/mixins/reset-text.less +18 -18
  163. package/src/bootstrap/less/mixins/resize.less +6 -6
  164. package/src/bootstrap/less/mixins/responsive-visibility.less +15 -15
  165. package/src/bootstrap/less/mixins/size.less +10 -10
  166. package/src/bootstrap/less/mixins/tab-focus.less +9 -9
  167. package/src/bootstrap/less/mixins/table-row.less +44 -44
  168. package/src/bootstrap/less/mixins/text-emphasis.less +9 -9
  169. package/src/bootstrap/less/mixins/text-overflow.less +8 -8
  170. package/src/bootstrap/less/mixins/vendor-prefixes.less +227 -227
  171. package/src/bootstrap/less/mixins.less +40 -40
  172. package/src/bootstrap/less/modals.less +151 -151
  173. package/src/bootstrap/less/navbar.less +660 -660
  174. package/src/bootstrap/less/normalize.less +424 -424
  175. package/src/bootstrap/less/pagination.less +89 -89
  176. package/src/bootstrap/less/panels.less +275 -275
  177. package/src/bootstrap/less/popovers.less +131 -131
  178. package/src/bootstrap/less/print.less +101 -101
  179. package/src/bootstrap/less/progress-bars.less +87 -87
  180. package/src/bootstrap/less/responsive-embed.less +35 -35
  181. package/src/bootstrap/less/responsive-utilities.less +194 -194
  182. package/src/bootstrap/less/scaffolding.less +161 -161
  183. package/src/bootstrap/less/theme.less +291 -291
  184. package/src/bootstrap/less/thumbnails.less +36 -36
  185. package/src/bootstrap/less/tooltip.less +102 -102
  186. package/src/bootstrap/less/type.less +303 -303
  187. package/src/bootstrap/less/utilities.less +55 -55
  188. package/src/bootstrap/less/wells.less +29 -29
  189. package/src/components/FileUpload.vue +696 -696
  190. package/src/components/Hello.vue +39 -39
  191. package/src/components/LeftTree.vue +27 -27
  192. package/src/components/android/AddressList.vue +61 -61
  193. package/src/components/android/AttendanceTally.vue +116 -116
  194. package/src/components/android/Blank.vue +10 -10
  195. package/src/components/android/CheckUnplanPage.vue +56 -56
  196. package/src/components/android/Checker.vue +12 -12
  197. package/src/components/android/CheckerAnnual.vue +81 -81
  198. package/src/components/android/CheckerAvarta.vue +82 -82
  199. package/src/components/android/EquipmentInspection.vue +348 -348
  200. package/src/components/android/FootprintMap.vue +120 -120
  201. package/src/components/android/HiddentroubleInvestigation.vue +192 -192
  202. package/src/components/android/MasterMain.vue +77 -77
  203. package/src/components/android/Menu.vue +132 -132
  204. package/src/components/android/NavBottom.vue +157 -157
  205. package/src/components/android/PaperAlarm.vue +85 -85
  206. package/src/components/android/PaperDeviceNoncivil.vue +214 -214
  207. package/src/components/android/PlumberAnnual.vue +83 -83
  208. package/src/components/android/PlumberAnnualDetail.vue +65 -65
  209. package/src/components/android/PlumberMonthly.vue +84 -84
  210. package/src/components/android/PostMap.vue +83 -83
  211. package/src/components/android/QueryCheckHistory.vue +122 -122
  212. package/src/components/android/QueryCheckHistoryItem.vue +62 -62
  213. package/src/components/android/RepairMain.vue +60 -60
  214. package/src/components/android/Repairman.vue +12 -12
  215. package/src/components/android/StationMaster.vue +12 -12
  216. package/src/components/defects/DefectModal.vue +101 -101
  217. package/src/components/defects/DevicesAndItem.vue +39 -39
  218. package/src/components/issueplan/IssuePlanMain.vue +23 -23
  219. package/src/components/notice/NoticeForm.vue +100 -100
  220. package/src/components/notice/NoticeIssue.vue +20 -20
  221. package/src/components/paper/PicViewer.vue +18 -18
  222. package/src/components/phonestate/MonthlyTraffic.vue +66 -66
  223. package/src/components/phonestate/MonthlyTrafficRouter.vue +15 -15
  224. package/src/components/phonestate/PostMap.vue +82 -82
  225. package/src/components/querycheckpaper/PaperItem.vue +59 -59
  226. package/src/components/userfile/MeterFile.vue +145 -145
  227. package/src/components/userfile/MeterModify.vue +46 -46
  228. package/src/components/userfileaudit/MeterAuditFile.vue +129 -129
  229. package/src/filiale/bayan/pc.js +22 -24
  230. package/src/filiale/weinan/android/SafecheckOrderV.vue +3343 -3340
  231. package/src/filiale/weinan/android/SafecheckUserInfo.vue +791 -778
  232. package/src/filiale/weinan/pc/PaperList.vue +687 -674
  233. package/src/main.js +33 -33
  234. package/src/plugins/LoadData.js +10 -10
  235. package/src/plugins/LoadParams.js +24 -24
  236. package/src/stores/wxconfig.js +10 -10
  237. package/src/utils/getNowDate.js +33 -33
  238. package/test/e2e/custom-assertions/elementCount.js +26 -26
  239. package/test/e2e/nightwatch.conf.js +40 -40
  240. package/test/e2e/runner.js +30 -30
  241. package/test/e2e/specs/test.js +13 -13
  242. package/test/unit/.eslintrc +5 -5
  243. package/test/unit/TestUtil.js +62 -62
  244. package/test/unit/context.html +20 -20
  245. package/test/unit/index.js +13 -13
  246. package/src/filiale/bayan/pc/usergashistory.vue +0 -149
  247. package/src/filiale/bayan/pc/usergashistorynian.vue +0 -149
@@ -1,696 +1,696 @@
1
- <template>
2
- <label :class="{'file-uploads': true, 'file-uploads-html5': $mode == 'html5', 'file-uploads-html4': $mode == 'html4'}">
3
- <span>{{{title}}}</span>
4
- <input-file></input-file>
5
- </label>
6
- </template>
7
-
8
- <style>
9
- .file-uploads {
10
- overflow: hidden;
11
- position: relative;
12
- text-align: center;
13
- }
14
- .file-uploads span{
15
- -webkit-user-select: none;
16
- -moz-user-select: none;
17
- -ms-user-select: none;
18
- -o-user-select: none;
19
- user-select: none;
20
- }
21
- .file-uploads input{
22
- z-index: 1;
23
- opacity: 0;
24
- font-size: 20em;
25
- top: 0;
26
- left: 0;
27
- right: 0;
28
- bottom: 0;
29
- position: absolute;
30
- width: 100%;
31
- height: 100%;
32
- }
33
- .file-uploads.file-uploads-html5 input{
34
- float: left;
35
- width: 1px !important;
36
- height: 1px !important;
37
- top:-1px !important;
38
- left:-1px !important;
39
- right:auto !important;
40
- bottom:auto !important;
41
- }
42
- </style>
43
-
44
- <script>
45
- export default {
46
- props: {
47
- title: {
48
- type: String,
49
- default: 'Upload file',
50
- },
51
- name: {
52
- type: String,
53
- default: 'file',
54
- },
55
- drop: {
56
- default: false,
57
- },
58
- extensions: {
59
- default: () => [],
60
- },
61
- postAction: {
62
- type: String,
63
- },
64
- putAction: {
65
- type: String,
66
- },
67
- accept: {
68
- type:String,
69
- },
70
- multiple: {
71
- type: Boolean,
72
- },
73
- timeout: {
74
- type: Number,
75
- default:0,
76
- },
77
- size: {
78
- type: Number,
79
- },
80
- events: {
81
- type: Object,
82
- default: () => {},
83
- },
84
- },
85
-
86
- components: {
87
- inputFile : {
88
- template: '<input type="file" :name="$parent.name" :id="$parent.id||$parent.name" :accept="$parent.accept" @change="change" :multiple="$parent.multiple && $parent.$mode == \'html5\'">',
89
- methods: {
90
- change(e) {
91
- this.$parent._addFileUploads(e.target);
92
- this.$destroy();
93
- },
94
- },
95
- },
96
- },
97
-
98
- data() {
99
- return {
100
- files: [],
101
- active: false,
102
- uploaded: true,
103
- dropActive: false,
104
- dropElement: false,
105
- request: {
106
- data: {},
107
- headers: {},
108
- },
109
- }
110
- },
111
-
112
- ready() {
113
- this._drop(this.drop);
114
- },
115
-
116
-
117
- init() {
118
- var input = document.createElement('input');
119
- input.type = 'file';
120
- if (window.FormData && input.files) {
121
- this.$mode = 'html5';
122
- } else {
123
- this.$mode = 'html4';
124
- }
125
- this._index = 0;
126
- this._dropActive = 0;
127
- this._files = {};
128
- },
129
-
130
-
131
- beforeDestroy() {
132
- this.active = false;
133
- this.files = [];
134
- },
135
-
136
- watch: {
137
- drop(value) {
138
- this._drop(value);
139
- },
140
- files(files) {
141
- var ids = [];
142
- for (var i = 0; i < files.length; i++) {
143
- var file = files[i];
144
- if (!file.errno && !file.success) {
145
- this.uploaded = false;
146
- }
147
- ids.push(file.id);
148
- }
149
- for (var id in this._files) {
150
- if (ids.indexOf(id) != -1) {
151
- continue;
152
- }
153
-
154
-
155
- var file = this._files[id]._file;
156
-
157
- file.removed = true;
158
- var xhr = this._files[id].xhr;
159
- if (xhr) {
160
- try {
161
- xhr.abort();
162
- xhr.timeout = 1;
163
- } catch (e) {
164
-
165
- }
166
- }
167
- var iframe = this._files[id].iframe;
168
- if (iframe) {
169
- iframe.onabort({type:'abort'});
170
- }
171
- delete this._files[id];
172
- this._uploadEvents('removeFileUpload', file);
173
- }
174
- this._index = 0;
175
- },
176
-
177
- active(newValue, oldValue) {
178
- if (newValue && !oldValue) {
179
- this._fileUploads();
180
- }
181
- },
182
-
183
- uploaded(uploaded) {
184
- if (uploaded) {
185
- this.active = false;
186
- }
187
- },
188
- },
189
-
190
- methods: {
191
- clear() {
192
- if (this.files.length) {
193
- this.files.splice(0, this.files.length);
194
- }
195
- },
196
-
197
- _uploadEvents(name, file) {
198
- this.$dispatch && this.$dispatch(name, file, this);
199
- this[name] && this[name](file);
200
- this.events && this.events[name] && this.events[name](file, this);
201
- },
202
-
203
- _drop(value) {
204
- if (this.dropElement && this.$mode === 'html5') {
205
- try {
206
- window.document.removeEventListener('dragenter', this._onDragenter, false);
207
- window.document.removeEventListener('dragleave', this._onDragleave, false);
208
- this.dropElement.removeEventListener('dragover', this._onDragover, false);
209
- this.dropElement.removeEventListener('drop', this._onDrop, false);
210
- } catch (e) {
211
- }
212
- }
213
-
214
- if (!value) {
215
- this.dropElement = false;
216
- return;
217
- }
218
-
219
- if (typeof value == 'string') {
220
- this.dropElement = document.querySelector(value) || this.$root.$el.querySelector(value);
221
- } else if (typeof value == 'boolean') {
222
- this.dropElement = this.$parent.$el;
223
- } else {
224
- this.dropElement = this.drop;
225
- }
226
- if (this.dropElement && this.$mode === 'html5') {
227
- window.document.addEventListener('dragenter', this._onDragenter, false);
228
- window.document.addEventListener('dragleave', this._onDragleave, false);
229
- this.dropElement.addEventListener('dragover', this._onDragover, false);
230
- this.dropElement.addEventListener('drop', this._onDrop, false);
231
- }
232
- },
233
- _onDragenter(e) {
234
- this._dropActive++;
235
- this.dropActive = !!this._dropActive;
236
- e.preventDefault();
237
- },
238
- _onDragleave(e) {
239
- e.preventDefault();
240
- this._dropActive--;
241
- if (e.target.nodeName == 'HTML' || (e.screenX == 0 && e.screenY == 0)) {
242
- this.dropActive = !!this._dropActive;
243
- }
244
- },
245
- _onDragover(e) {
246
- e.preventDefault();
247
- },
248
-
249
- _addFileUpload(hiddenData, file) {
250
- var defaultFile = {
251
- size:-1,
252
- name: 'Filename',
253
- progress: '0.00',
254
- speed: 0,
255
- active: false,
256
- error: '',
257
- errno: '',
258
- success: false,
259
- data: {},
260
- request: {
261
- headers:{},
262
- data:{}
263
- }
264
- };
265
- for (let key in defaultFile) {
266
- if (typeof file[key] == 'undefined') {
267
- file[key] = defaultFile[key];
268
- }
269
- }
270
- if (!file.id) {
271
- file.id = Math.random().toString(36).substr(2);
272
- }
273
-
274
- if (!this.multiple) {
275
- this.clear();
276
- }
277
-
278
- this._files[file.id] = hiddenData;
279
- file = this.files[this.files.push(file) - 1];
280
- this._files[file.id]._file = file;
281
- this._uploadEvents('addFileUpload', file);
282
- },
283
- _onDrop(e) {
284
- this._dropActive = 0;
285
- this.dropActive = false;
286
- e.preventDefault();
287
- if (e.dataTransfer.files.length) {
288
- for (let i = 0; i < e.dataTransfer.files.length; i++) {
289
- let file = e.dataTransfer.files[i];
290
- this._addFileUpload({file:file}, {size:file.size, name: file.name});
291
- if (!this.multiple) {
292
- break;
293
- }
294
- }
295
- }
296
- },
297
-
298
- _addFileUploads(el) {
299
- var Component = this.$options.components.inputFile;
300
- new Component({
301
- parent: this,
302
- el: el,
303
- });
304
- this.uploaded = false;
305
-
306
-
307
- if (el.files) {
308
- for (let i = 0; i < el.files.length; i++) {
309
- let file = el.files[i];
310
- this._addFileUpload({file:file, el:el}, {size:file.size, name: file.name});
311
- }
312
- } else {
313
- this._addFileUpload({el:el}, {size: -1, name: el.value.replace(/^.*?([^\/\\\r\n]+)$/, '$1')});
314
- }
315
- },
316
-
317
- _fileUploads() {
318
- if (!this.active) {
319
- return;
320
- }
321
- for (; this._index < this.files.length; this._index++) {
322
- var file = this.files[this._index];
323
- if (file.active || file.success || file.errno) {
324
- continue;
325
- }
326
- if (this.size && this.size > 0 && file.size >= 0 && file.size > this.size) {
327
- file.error = 'Size';
328
- file.errno = 'size';
329
- continue;
330
- }
331
-
332
- if (this.extensions && (this.extensions.length || typeof this.extensions.length == 'undefined')) {
333
- var extensions = this.extensions;
334
- if (typeof extensions == 'object' && extensions instanceof RegExp) {
335
-
336
- } else {
337
- if (typeof extensions == 'string') {
338
- extensions = extensions.split(',').map(function(value) {
339
- return value.trim();
340
- }).filter(function(value) {
341
- return value;
342
- });
343
- }
344
- extensions = new RegExp('\\.('+ extensions.join('|').replace(/\./g, '\\.') +')$', 'i');
345
- }
346
-
347
- if (file.name.search(extensions) == -1) {
348
- file.error = 'Extension';
349
- file.errno = 'extension';
350
- continue;
351
- }
352
- }
353
-
354
- if (this.$mode == 'html5') {
355
- if (this.putAction || file.putAction) {
356
- this._fileUploadPut(file);
357
- } else if (this.postAction || file.postAction) {
358
- this._fileUploadHtml5(file);
359
- } else {
360
- file.error = 'Not Support';
361
- file.errno = 'not_support';
362
- continue;
363
- }
364
- } else {
365
- if (this.postAction || file.postAction) {
366
- this._fileUploadHtml4(file);
367
- } else {
368
- file.error = 'Not Support';
369
- file.errno = 'not_support';
370
- continue;
371
- }
372
- }
373
- return;
374
- }
375
- this.active = false;
376
- this.uploaded = true;
377
- },
378
-
379
- _fileUploadXhr(xhr, file, data) {
380
- var _self = this;
381
- var hiddenData = this._files[file.id];
382
- var fileUploads = false;
383
- var speedTime = 0;
384
- var speedLoaded = 0;
385
- xhr.upload.onprogress = function(e) {
386
- if (file.removed) {
387
- xhr.abort();
388
- return;
389
- }
390
- if (!_self.active || !file.active) {
391
- xhr.abort();
392
- return;
393
- }
394
- if (e.lengthComputable) {
395
- file.progress = (e.loaded / e.total * 100).toFixed(2);
396
- var speedTime2 = Math.round(Date.now() / 1000);
397
- if (speedTime2 != speedTime) {
398
- file.speed = e.loaded - speedLoaded;
399
- speedLoaded = e.loaded;
400
- speedTime = speedTime2;
401
- }
402
- }
403
- _self._uploadEvents('fileUploadProgress', file);
404
- };
405
-
406
-
407
- var callback = function(e) {
408
- switch (e.type) {
409
- case 'timeout':
410
- file.errno = 'timeout';
411
- file.error = 'Timeout';
412
- break;
413
- case 'abort':
414
- file.errno = 'abort';
415
- file.error = 'Abort';
416
- break;
417
- case 'error':
418
- if (!xhr.status) {
419
- file.errno = 'network';
420
- file.error = 'Network';
421
- } else if(xhr.status >= 500) {
422
- file.errno = 'server';
423
- file.error = 'Server';
424
- } else if (xhr.status >= 400) {
425
- file.errno = 'denied';
426
- file.error = 'Denied';
427
- }
428
- break;
429
- default:
430
- if(xhr.status >= 500) {
431
- file.errno = 'server';
432
- file.error = 'Server';
433
- } else if (xhr.status >= 400) {
434
- file.errno = 'denied';
435
- file.error = 'Denied';
436
- } else {
437
- file.progress = '100.00';
438
- file.success = true;
439
- }
440
- }
441
- file.active = false;
442
- if (xhr.responseText) {
443
- var contentType = xhr.getResponseHeader('Content-Type');
444
- if (contentType && contentType.indexOf('/json') != -1) {
445
- file.data = JSON.parse(xhr.responseText);
446
- } else {
447
- file.data = xhr.responseText;
448
- }
449
- }
450
- if (!fileUploads) {
451
- fileUploads = true;
452
- if (!file.removed) {
453
- _self._uploadEvents('afterFileUpload', file);
454
- }
455
- setTimeout(function() {
456
- _self._fileUploads();
457
- }, 50);
458
- }
459
- };
460
-
461
- xhr.onload = callback;
462
- xhr.onerror = callback;
463
- xhr.onabort = callback;
464
- xhr.ontimeout = callback;
465
-
466
-
467
- if (this.timeout) {
468
- xhr.timeout = this.timeout;
469
- }
470
-
471
-
472
- xhr.onload = callback;
473
- xhr.onerror = callback;
474
- xhr.onabort = callback;
475
- xhr.ontimeout = callback;
476
-
477
- if (this.timeout) {
478
- xhr.timeout = this.timeout;
479
- }
480
-
481
- // xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
482
- for (var key in this.request.headers) {
483
- xhr.setRequestHeader(key, this.request.headers[key]);
484
- }
485
- for (var key in file.request.headers) {
486
- xhr.setRequestHeader(key, file.request.headers[key]);
487
- }
488
-
489
-
490
- xhr.send(data);
491
- file.active = true;
492
- hiddenData.xhr = xhr;
493
- var interval = setInterval(function() {
494
- if (!_self.active || !file.active || file.success || file.errno) {
495
- clearInterval(interval);
496
- if (!file.success && !file.errno) {
497
- xhr.abort();
498
- }
499
- }
500
- }, 100);
501
- this._uploadEvents('beforeFileUpload', file);
502
- },
503
- _fileUploadPut(file) {
504
- var _self = this;
505
-
506
- var querys = {};
507
- for (let key in this.request.data) {
508
- querys[key] = this.request.data[key];
509
- }
510
- for (let key in file.request.data) {
511
- querys[key] = file.request.data[key];
512
- }
513
- var queryArray = [];
514
- for (let key in querys) {
515
- if (querys[key] !== null && typeof querys[key] !== 'undefined') {
516
- queryArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(querys[key]));
517
- }
518
- }
519
- var queryString = queryArray.length ? '?' + queryArray.join('&') : '';
520
-
521
- var xhr = new XMLHttpRequest();
522
- xhr.open('PUT', (file.putAction || this.putAction) + queryString);
523
- this._fileUploadXhr(xhr, file, this._files[file.id].file);
524
- },
525
-
526
-
527
-
528
- _fileUploadHtml5(file) {
529
- var form = new window.FormData();
530
- form.append(this.name, this._files[file.id].file);
531
- for (var key in this.request.data) {
532
- form.append(key, this.request.data[key]);
533
- }
534
-
535
- for (var key in file.request.data) {
536
- form.append(key, file.request.data[key]);
537
- }
538
-
539
- var xhr = new XMLHttpRequest();
540
- xhr.open('POST', file.postAction || this.postAction);
541
- this._fileUploadXhr(xhr, file, form);
542
- },
543
-
544
- _fileUploadHtml4(file) {
545
- var _self = this;
546
- var hiddenData = this._files[file.id];
547
-
548
- var fileUploads = false;
549
-
550
-
551
-
552
- var keydown = function(e) {
553
- if (e.keyCode == 27) {
554
- e.preventDefault();
555
- }
556
- };
557
-
558
- var iframe = document.createElement('iframe');
559
- iframe.id = 'upload-iframe-' + file.id;
560
- iframe.name = 'upload-iframe-' + file.id;
561
- iframe.src = 'about:blank';
562
- iframe.style.width = '1px';
563
- iframe.style.height = '1px';
564
- iframe.style.top = '-9999px';
565
- iframe.style.left = '-9999px';
566
- iframe.style.position = 'absolute';
567
- iframe.style.marginTop = '-9999em';
568
-
569
-
570
- var form = document.createElement('form');
571
- form.action = file.postAction || this.postAction;
572
- form.name = 'upload-form-' + file.id;
573
- form.setAttribute('method', 'POST');
574
- form.setAttribute('target', 'upload-iframe-' + file.id);
575
- form.setAttribute('enctype', 'multipart/form-data');
576
- form.appendChild(hiddenData.el);
577
- for (var key in this.request.data) {
578
- var input = document.createElement('input');
579
- input.type = 'hidden';
580
- input.name = key;
581
- input.value = this.request.data[key];
582
- form.appendChild(input);
583
- }
584
-
585
- for (var key in file.request.data) {
586
- var input = document.createElement('input');
587
- input.type = 'hidden';
588
- input.name = key;
589
- input.value = file.request.data[key];
590
- form.appendChild(input);
591
- }
592
-
593
- var getDocumentData = function() {
594
- var doc;
595
- try {
596
- if (iframe.contentWindow) {
597
- doc = iframe.contentWindow.document;
598
- }
599
- } catch(err) {
600
- }
601
- if (!doc) {
602
- try {
603
- doc = iframe.contentDocument ? iframe.contentDocument : iframe.document;
604
- } catch(err) {
605
- doc = iframe.document;
606
- }
607
- }
608
- if (doc && doc.body) {
609
- return doc.body.innerHTML;
610
- }
611
- return null;
612
- }
613
-
614
-
615
-
616
- var callback = function(e) {
617
- switch (e.type) {
618
- case 'abort':
619
- file.errno = 'abort';
620
- file.error = 'Abort';
621
- break;
622
- case 'error':
623
- var data = getDocumentData();
624
- if (file.errno) {
625
-
626
- } else if (data === null) {
627
- file.errno = 'network';
628
- file.error = 'Network';
629
- } else {
630
- file.errno = 'denied';
631
- file.error = 'Denied';
632
- }
633
- break;
634
- default:
635
- var data = getDocumentData();
636
- if (file.errno) {
637
-
638
- } else if (data === null) {
639
- file.errno = 'network';
640
- file.error = 'Network';
641
- } else {
642
- file.progress = '100.00';
643
- file.success = true;
644
- }
645
- }
646
-
647
- file.active = false;
648
- if (typeof data != "undefined") {
649
- if (data && data.substr(0, 1) == '{' && data.substr(data.length - 1, 1) == '}') {
650
- try {
651
- data = JSON.parse(data);
652
- } catch (err) {
653
- }
654
- }
655
- file.data = data;
656
- }
657
- if (!fileUploads) {
658
- document.body.removeEventListener('keydown', keydown);
659
- document.body.removeEventListener('keydown', keydown);
660
- fileUploads = true;
661
- iframe.parentNode && iframe.parentNode.removeChild(iframe);
662
- if (!file.removed) {
663
- _self._uploadEvents('afterFileUpload', file);
664
- }
665
- setTimeout(function() {
666
- _self._fileUploads();
667
- }, 50);
668
- }
669
- };
670
-
671
-
672
- setTimeout(function() {
673
- document.body.appendChild(iframe).appendChild(form).submit();
674
- iframe.onload = callback;
675
- iframe.onerror = callback;
676
- iframe.onabort = callback;
677
-
678
- file.active = true;
679
-
680
- hiddenData.iframe = iframe;
681
-
682
- document.body.addEventListener('keydown', keydown);
683
- var interval = setInterval(function() {
684
- if (!_self.active || !file.active || file.success || file.errno) {
685
- clearInterval(interval);
686
- if (!file.success && !file.errno) {
687
- iframe.onabort({type:'abort'});
688
- }
689
- }
690
- }, 50);
691
- _self._uploadEvents('beforeFileUpload', file);
692
- }, 10);
693
- },
694
- }
695
- }
696
- </script>
1
+ <template>
2
+ <label :class="{'file-uploads': true, 'file-uploads-html5': $mode == 'html5', 'file-uploads-html4': $mode == 'html4'}">
3
+ <span>{{{title}}}</span>
4
+ <input-file></input-file>
5
+ </label>
6
+ </template>
7
+
8
+ <style>
9
+ .file-uploads {
10
+ overflow: hidden;
11
+ position: relative;
12
+ text-align: center;
13
+ }
14
+ .file-uploads span{
15
+ -webkit-user-select: none;
16
+ -moz-user-select: none;
17
+ -ms-user-select: none;
18
+ -o-user-select: none;
19
+ user-select: none;
20
+ }
21
+ .file-uploads input{
22
+ z-index: 1;
23
+ opacity: 0;
24
+ font-size: 20em;
25
+ top: 0;
26
+ left: 0;
27
+ right: 0;
28
+ bottom: 0;
29
+ position: absolute;
30
+ width: 100%;
31
+ height: 100%;
32
+ }
33
+ .file-uploads.file-uploads-html5 input{
34
+ float: left;
35
+ width: 1px !important;
36
+ height: 1px !important;
37
+ top:-1px !important;
38
+ left:-1px !important;
39
+ right:auto !important;
40
+ bottom:auto !important;
41
+ }
42
+ </style>
43
+
44
+ <script>
45
+ export default {
46
+ props: {
47
+ title: {
48
+ type: String,
49
+ default: 'Upload file',
50
+ },
51
+ name: {
52
+ type: String,
53
+ default: 'file',
54
+ },
55
+ drop: {
56
+ default: false,
57
+ },
58
+ extensions: {
59
+ default: () => [],
60
+ },
61
+ postAction: {
62
+ type: String,
63
+ },
64
+ putAction: {
65
+ type: String,
66
+ },
67
+ accept: {
68
+ type:String,
69
+ },
70
+ multiple: {
71
+ type: Boolean,
72
+ },
73
+ timeout: {
74
+ type: Number,
75
+ default:0,
76
+ },
77
+ size: {
78
+ type: Number,
79
+ },
80
+ events: {
81
+ type: Object,
82
+ default: () => {},
83
+ },
84
+ },
85
+
86
+ components: {
87
+ inputFile : {
88
+ template: '<input type="file" :name="$parent.name" :id="$parent.id||$parent.name" :accept="$parent.accept" @change="change" :multiple="$parent.multiple && $parent.$mode == \'html5\'">',
89
+ methods: {
90
+ change(e) {
91
+ this.$parent._addFileUploads(e.target);
92
+ this.$destroy();
93
+ },
94
+ },
95
+ },
96
+ },
97
+
98
+ data() {
99
+ return {
100
+ files: [],
101
+ active: false,
102
+ uploaded: true,
103
+ dropActive: false,
104
+ dropElement: false,
105
+ request: {
106
+ data: {},
107
+ headers: {},
108
+ },
109
+ }
110
+ },
111
+
112
+ ready() {
113
+ this._drop(this.drop);
114
+ },
115
+
116
+
117
+ init() {
118
+ var input = document.createElement('input');
119
+ input.type = 'file';
120
+ if (window.FormData && input.files) {
121
+ this.$mode = 'html5';
122
+ } else {
123
+ this.$mode = 'html4';
124
+ }
125
+ this._index = 0;
126
+ this._dropActive = 0;
127
+ this._files = {};
128
+ },
129
+
130
+
131
+ beforeDestroy() {
132
+ this.active = false;
133
+ this.files = [];
134
+ },
135
+
136
+ watch: {
137
+ drop(value) {
138
+ this._drop(value);
139
+ },
140
+ files(files) {
141
+ var ids = [];
142
+ for (var i = 0; i < files.length; i++) {
143
+ var file = files[i];
144
+ if (!file.errno && !file.success) {
145
+ this.uploaded = false;
146
+ }
147
+ ids.push(file.id);
148
+ }
149
+ for (var id in this._files) {
150
+ if (ids.indexOf(id) != -1) {
151
+ continue;
152
+ }
153
+
154
+
155
+ var file = this._files[id]._file;
156
+
157
+ file.removed = true;
158
+ var xhr = this._files[id].xhr;
159
+ if (xhr) {
160
+ try {
161
+ xhr.abort();
162
+ xhr.timeout = 1;
163
+ } catch (e) {
164
+
165
+ }
166
+ }
167
+ var iframe = this._files[id].iframe;
168
+ if (iframe) {
169
+ iframe.onabort({type:'abort'});
170
+ }
171
+ delete this._files[id];
172
+ this._uploadEvents('removeFileUpload', file);
173
+ }
174
+ this._index = 0;
175
+ },
176
+
177
+ active(newValue, oldValue) {
178
+ if (newValue && !oldValue) {
179
+ this._fileUploads();
180
+ }
181
+ },
182
+
183
+ uploaded(uploaded) {
184
+ if (uploaded) {
185
+ this.active = false;
186
+ }
187
+ },
188
+ },
189
+
190
+ methods: {
191
+ clear() {
192
+ if (this.files.length) {
193
+ this.files.splice(0, this.files.length);
194
+ }
195
+ },
196
+
197
+ _uploadEvents(name, file) {
198
+ this.$dispatch && this.$dispatch(name, file, this);
199
+ this[name] && this[name](file);
200
+ this.events && this.events[name] && this.events[name](file, this);
201
+ },
202
+
203
+ _drop(value) {
204
+ if (this.dropElement && this.$mode === 'html5') {
205
+ try {
206
+ window.document.removeEventListener('dragenter', this._onDragenter, false);
207
+ window.document.removeEventListener('dragleave', this._onDragleave, false);
208
+ this.dropElement.removeEventListener('dragover', this._onDragover, false);
209
+ this.dropElement.removeEventListener('drop', this._onDrop, false);
210
+ } catch (e) {
211
+ }
212
+ }
213
+
214
+ if (!value) {
215
+ this.dropElement = false;
216
+ return;
217
+ }
218
+
219
+ if (typeof value == 'string') {
220
+ this.dropElement = document.querySelector(value) || this.$root.$el.querySelector(value);
221
+ } else if (typeof value == 'boolean') {
222
+ this.dropElement = this.$parent.$el;
223
+ } else {
224
+ this.dropElement = this.drop;
225
+ }
226
+ if (this.dropElement && this.$mode === 'html5') {
227
+ window.document.addEventListener('dragenter', this._onDragenter, false);
228
+ window.document.addEventListener('dragleave', this._onDragleave, false);
229
+ this.dropElement.addEventListener('dragover', this._onDragover, false);
230
+ this.dropElement.addEventListener('drop', this._onDrop, false);
231
+ }
232
+ },
233
+ _onDragenter(e) {
234
+ this._dropActive++;
235
+ this.dropActive = !!this._dropActive;
236
+ e.preventDefault();
237
+ },
238
+ _onDragleave(e) {
239
+ e.preventDefault();
240
+ this._dropActive--;
241
+ if (e.target.nodeName == 'HTML' || (e.screenX == 0 && e.screenY == 0)) {
242
+ this.dropActive = !!this._dropActive;
243
+ }
244
+ },
245
+ _onDragover(e) {
246
+ e.preventDefault();
247
+ },
248
+
249
+ _addFileUpload(hiddenData, file) {
250
+ var defaultFile = {
251
+ size:-1,
252
+ name: 'Filename',
253
+ progress: '0.00',
254
+ speed: 0,
255
+ active: false,
256
+ error: '',
257
+ errno: '',
258
+ success: false,
259
+ data: {},
260
+ request: {
261
+ headers:{},
262
+ data:{}
263
+ }
264
+ };
265
+ for (let key in defaultFile) {
266
+ if (typeof file[key] == 'undefined') {
267
+ file[key] = defaultFile[key];
268
+ }
269
+ }
270
+ if (!file.id) {
271
+ file.id = Math.random().toString(36).substr(2);
272
+ }
273
+
274
+ if (!this.multiple) {
275
+ this.clear();
276
+ }
277
+
278
+ this._files[file.id] = hiddenData;
279
+ file = this.files[this.files.push(file) - 1];
280
+ this._files[file.id]._file = file;
281
+ this._uploadEvents('addFileUpload', file);
282
+ },
283
+ _onDrop(e) {
284
+ this._dropActive = 0;
285
+ this.dropActive = false;
286
+ e.preventDefault();
287
+ if (e.dataTransfer.files.length) {
288
+ for (let i = 0; i < e.dataTransfer.files.length; i++) {
289
+ let file = e.dataTransfer.files[i];
290
+ this._addFileUpload({file:file}, {size:file.size, name: file.name});
291
+ if (!this.multiple) {
292
+ break;
293
+ }
294
+ }
295
+ }
296
+ },
297
+
298
+ _addFileUploads(el) {
299
+ var Component = this.$options.components.inputFile;
300
+ new Component({
301
+ parent: this,
302
+ el: el,
303
+ });
304
+ this.uploaded = false;
305
+
306
+
307
+ if (el.files) {
308
+ for (let i = 0; i < el.files.length; i++) {
309
+ let file = el.files[i];
310
+ this._addFileUpload({file:file, el:el}, {size:file.size, name: file.name});
311
+ }
312
+ } else {
313
+ this._addFileUpload({el:el}, {size: -1, name: el.value.replace(/^.*?([^\/\\\r\n]+)$/, '$1')});
314
+ }
315
+ },
316
+
317
+ _fileUploads() {
318
+ if (!this.active) {
319
+ return;
320
+ }
321
+ for (; this._index < this.files.length; this._index++) {
322
+ var file = this.files[this._index];
323
+ if (file.active || file.success || file.errno) {
324
+ continue;
325
+ }
326
+ if (this.size && this.size > 0 && file.size >= 0 && file.size > this.size) {
327
+ file.error = 'Size';
328
+ file.errno = 'size';
329
+ continue;
330
+ }
331
+
332
+ if (this.extensions && (this.extensions.length || typeof this.extensions.length == 'undefined')) {
333
+ var extensions = this.extensions;
334
+ if (typeof extensions == 'object' && extensions instanceof RegExp) {
335
+
336
+ } else {
337
+ if (typeof extensions == 'string') {
338
+ extensions = extensions.split(',').map(function(value) {
339
+ return value.trim();
340
+ }).filter(function(value) {
341
+ return value;
342
+ });
343
+ }
344
+ extensions = new RegExp('\\.('+ extensions.join('|').replace(/\./g, '\\.') +')$', 'i');
345
+ }
346
+
347
+ if (file.name.search(extensions) == -1) {
348
+ file.error = 'Extension';
349
+ file.errno = 'extension';
350
+ continue;
351
+ }
352
+ }
353
+
354
+ if (this.$mode == 'html5') {
355
+ if (this.putAction || file.putAction) {
356
+ this._fileUploadPut(file);
357
+ } else if (this.postAction || file.postAction) {
358
+ this._fileUploadHtml5(file);
359
+ } else {
360
+ file.error = 'Not Support';
361
+ file.errno = 'not_support';
362
+ continue;
363
+ }
364
+ } else {
365
+ if (this.postAction || file.postAction) {
366
+ this._fileUploadHtml4(file);
367
+ } else {
368
+ file.error = 'Not Support';
369
+ file.errno = 'not_support';
370
+ continue;
371
+ }
372
+ }
373
+ return;
374
+ }
375
+ this.active = false;
376
+ this.uploaded = true;
377
+ },
378
+
379
+ _fileUploadXhr(xhr, file, data) {
380
+ var _self = this;
381
+ var hiddenData = this._files[file.id];
382
+ var fileUploads = false;
383
+ var speedTime = 0;
384
+ var speedLoaded = 0;
385
+ xhr.upload.onprogress = function(e) {
386
+ if (file.removed) {
387
+ xhr.abort();
388
+ return;
389
+ }
390
+ if (!_self.active || !file.active) {
391
+ xhr.abort();
392
+ return;
393
+ }
394
+ if (e.lengthComputable) {
395
+ file.progress = (e.loaded / e.total * 100).toFixed(2);
396
+ var speedTime2 = Math.round(Date.now() / 1000);
397
+ if (speedTime2 != speedTime) {
398
+ file.speed = e.loaded - speedLoaded;
399
+ speedLoaded = e.loaded;
400
+ speedTime = speedTime2;
401
+ }
402
+ }
403
+ _self._uploadEvents('fileUploadProgress', file);
404
+ };
405
+
406
+
407
+ var callback = function(e) {
408
+ switch (e.type) {
409
+ case 'timeout':
410
+ file.errno = 'timeout';
411
+ file.error = 'Timeout';
412
+ break;
413
+ case 'abort':
414
+ file.errno = 'abort';
415
+ file.error = 'Abort';
416
+ break;
417
+ case 'error':
418
+ if (!xhr.status) {
419
+ file.errno = 'network';
420
+ file.error = 'Network';
421
+ } else if(xhr.status >= 500) {
422
+ file.errno = 'server';
423
+ file.error = 'Server';
424
+ } else if (xhr.status >= 400) {
425
+ file.errno = 'denied';
426
+ file.error = 'Denied';
427
+ }
428
+ break;
429
+ default:
430
+ if(xhr.status >= 500) {
431
+ file.errno = 'server';
432
+ file.error = 'Server';
433
+ } else if (xhr.status >= 400) {
434
+ file.errno = 'denied';
435
+ file.error = 'Denied';
436
+ } else {
437
+ file.progress = '100.00';
438
+ file.success = true;
439
+ }
440
+ }
441
+ file.active = false;
442
+ if (xhr.responseText) {
443
+ var contentType = xhr.getResponseHeader('Content-Type');
444
+ if (contentType && contentType.indexOf('/json') != -1) {
445
+ file.data = JSON.parse(xhr.responseText);
446
+ } else {
447
+ file.data = xhr.responseText;
448
+ }
449
+ }
450
+ if (!fileUploads) {
451
+ fileUploads = true;
452
+ if (!file.removed) {
453
+ _self._uploadEvents('afterFileUpload', file);
454
+ }
455
+ setTimeout(function() {
456
+ _self._fileUploads();
457
+ }, 50);
458
+ }
459
+ };
460
+
461
+ xhr.onload = callback;
462
+ xhr.onerror = callback;
463
+ xhr.onabort = callback;
464
+ xhr.ontimeout = callback;
465
+
466
+
467
+ if (this.timeout) {
468
+ xhr.timeout = this.timeout;
469
+ }
470
+
471
+
472
+ xhr.onload = callback;
473
+ xhr.onerror = callback;
474
+ xhr.onabort = callback;
475
+ xhr.ontimeout = callback;
476
+
477
+ if (this.timeout) {
478
+ xhr.timeout = this.timeout;
479
+ }
480
+
481
+ // xhr.setRequestHeader('X-Requested-With', 'XMLHttpRequest');
482
+ for (var key in this.request.headers) {
483
+ xhr.setRequestHeader(key, this.request.headers[key]);
484
+ }
485
+ for (var key in file.request.headers) {
486
+ xhr.setRequestHeader(key, file.request.headers[key]);
487
+ }
488
+
489
+
490
+ xhr.send(data);
491
+ file.active = true;
492
+ hiddenData.xhr = xhr;
493
+ var interval = setInterval(function() {
494
+ if (!_self.active || !file.active || file.success || file.errno) {
495
+ clearInterval(interval);
496
+ if (!file.success && !file.errno) {
497
+ xhr.abort();
498
+ }
499
+ }
500
+ }, 100);
501
+ this._uploadEvents('beforeFileUpload', file);
502
+ },
503
+ _fileUploadPut(file) {
504
+ var _self = this;
505
+
506
+ var querys = {};
507
+ for (let key in this.request.data) {
508
+ querys[key] = this.request.data[key];
509
+ }
510
+ for (let key in file.request.data) {
511
+ querys[key] = file.request.data[key];
512
+ }
513
+ var queryArray = [];
514
+ for (let key in querys) {
515
+ if (querys[key] !== null && typeof querys[key] !== 'undefined') {
516
+ queryArray.push(encodeURIComponent(key) + '=' + encodeURIComponent(querys[key]));
517
+ }
518
+ }
519
+ var queryString = queryArray.length ? '?' + queryArray.join('&') : '';
520
+
521
+ var xhr = new XMLHttpRequest();
522
+ xhr.open('PUT', (file.putAction || this.putAction) + queryString);
523
+ this._fileUploadXhr(xhr, file, this._files[file.id].file);
524
+ },
525
+
526
+
527
+
528
+ _fileUploadHtml5(file) {
529
+ var form = new window.FormData();
530
+ form.append(this.name, this._files[file.id].file);
531
+ for (var key in this.request.data) {
532
+ form.append(key, this.request.data[key]);
533
+ }
534
+
535
+ for (var key in file.request.data) {
536
+ form.append(key, file.request.data[key]);
537
+ }
538
+
539
+ var xhr = new XMLHttpRequest();
540
+ xhr.open('POST', file.postAction || this.postAction);
541
+ this._fileUploadXhr(xhr, file, form);
542
+ },
543
+
544
+ _fileUploadHtml4(file) {
545
+ var _self = this;
546
+ var hiddenData = this._files[file.id];
547
+
548
+ var fileUploads = false;
549
+
550
+
551
+
552
+ var keydown = function(e) {
553
+ if (e.keyCode == 27) {
554
+ e.preventDefault();
555
+ }
556
+ };
557
+
558
+ var iframe = document.createElement('iframe');
559
+ iframe.id = 'upload-iframe-' + file.id;
560
+ iframe.name = 'upload-iframe-' + file.id;
561
+ iframe.src = 'about:blank';
562
+ iframe.style.width = '1px';
563
+ iframe.style.height = '1px';
564
+ iframe.style.top = '-9999px';
565
+ iframe.style.left = '-9999px';
566
+ iframe.style.position = 'absolute';
567
+ iframe.style.marginTop = '-9999em';
568
+
569
+
570
+ var form = document.createElement('form');
571
+ form.action = file.postAction || this.postAction;
572
+ form.name = 'upload-form-' + file.id;
573
+ form.setAttribute('method', 'POST');
574
+ form.setAttribute('target', 'upload-iframe-' + file.id);
575
+ form.setAttribute('enctype', 'multipart/form-data');
576
+ form.appendChild(hiddenData.el);
577
+ for (var key in this.request.data) {
578
+ var input = document.createElement('input');
579
+ input.type = 'hidden';
580
+ input.name = key;
581
+ input.value = this.request.data[key];
582
+ form.appendChild(input);
583
+ }
584
+
585
+ for (var key in file.request.data) {
586
+ var input = document.createElement('input');
587
+ input.type = 'hidden';
588
+ input.name = key;
589
+ input.value = file.request.data[key];
590
+ form.appendChild(input);
591
+ }
592
+
593
+ var getDocumentData = function() {
594
+ var doc;
595
+ try {
596
+ if (iframe.contentWindow) {
597
+ doc = iframe.contentWindow.document;
598
+ }
599
+ } catch(err) {
600
+ }
601
+ if (!doc) {
602
+ try {
603
+ doc = iframe.contentDocument ? iframe.contentDocument : iframe.document;
604
+ } catch(err) {
605
+ doc = iframe.document;
606
+ }
607
+ }
608
+ if (doc && doc.body) {
609
+ return doc.body.innerHTML;
610
+ }
611
+ return null;
612
+ }
613
+
614
+
615
+
616
+ var callback = function(e) {
617
+ switch (e.type) {
618
+ case 'abort':
619
+ file.errno = 'abort';
620
+ file.error = 'Abort';
621
+ break;
622
+ case 'error':
623
+ var data = getDocumentData();
624
+ if (file.errno) {
625
+
626
+ } else if (data === null) {
627
+ file.errno = 'network';
628
+ file.error = 'Network';
629
+ } else {
630
+ file.errno = 'denied';
631
+ file.error = 'Denied';
632
+ }
633
+ break;
634
+ default:
635
+ var data = getDocumentData();
636
+ if (file.errno) {
637
+
638
+ } else if (data === null) {
639
+ file.errno = 'network';
640
+ file.error = 'Network';
641
+ } else {
642
+ file.progress = '100.00';
643
+ file.success = true;
644
+ }
645
+ }
646
+
647
+ file.active = false;
648
+ if (typeof data != "undefined") {
649
+ if (data && data.substr(0, 1) == '{' && data.substr(data.length - 1, 1) == '}') {
650
+ try {
651
+ data = JSON.parse(data);
652
+ } catch (err) {
653
+ }
654
+ }
655
+ file.data = data;
656
+ }
657
+ if (!fileUploads) {
658
+ document.body.removeEventListener('keydown', keydown);
659
+ document.body.removeEventListener('keydown', keydown);
660
+ fileUploads = true;
661
+ iframe.parentNode && iframe.parentNode.removeChild(iframe);
662
+ if (!file.removed) {
663
+ _self._uploadEvents('afterFileUpload', file);
664
+ }
665
+ setTimeout(function() {
666
+ _self._fileUploads();
667
+ }, 50);
668
+ }
669
+ };
670
+
671
+
672
+ setTimeout(function() {
673
+ document.body.appendChild(iframe).appendChild(form).submit();
674
+ iframe.onload = callback;
675
+ iframe.onerror = callback;
676
+ iframe.onabort = callback;
677
+
678
+ file.active = true;
679
+
680
+ hiddenData.iframe = iframe;
681
+
682
+ document.body.addEventListener('keydown', keydown);
683
+ var interval = setInterval(function() {
684
+ if (!_self.active || !file.active || file.success || file.errno) {
685
+ clearInterval(interval);
686
+ if (!file.success && !file.errno) {
687
+ iframe.onabort({type:'abort'});
688
+ }
689
+ }
690
+ }, 50);
691
+ _self._uploadEvents('beforeFileUpload', file);
692
+ }, 10);
693
+ },
694
+ }
695
+ }
696
+ </script>