rich_table_component 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +156 -139
- data/app/helpers/component_helper.rb +176 -0
- data/app/helpers/documents_helper.rb +22 -0
- data/app/helpers/menus_helper.rb +182 -0
- data/app/helpers/paragraph_helper.rb +57 -0
- data/app/helpers/translations_helper.rb +9 -0
- data/app/views/application/_document_fields.html.haml +20 -0
- data/app/views/application/_edit.html.haml +11 -0
- data/app/views/application/_new.html.haml +11 -0
- data/app/views/application/access_denied.js.erb +5 -0
- data/app/views/application/create.js.erb +19 -0
- data/app/views/application/destroy.js.erb +9 -0
- data/app/views/application/destroy_fail.js.erb +2 -0
- data/app/views/application/edit.html.haml +8 -0
- data/app/views/application/edit.js.erb +28 -0
- data/app/views/application/index.js.erb +7 -0
- data/app/views/application/index.pdf.haml +87 -0
- data/app/views/application/index.xls.haml +64 -0
- data/app/views/application/new.html.haml +7 -0
- data/app/views/application/new.js.erb +23 -0
- data/app/views/application/recapitulation.js.erb +12 -0
- data/app/views/application/recapitulation.pdf.haml +68 -0
- data/app/views/application/recapitulation.xls.haml +41 -0
- data/app/views/application/session_expired.js.erb +5 -0
- data/app/views/application/show.js.erb +29 -0
- data/app/views/application/update.js.erb +15 -0
- data/app/views/layouts/print/pdf.html.haml +8 -0
- data/app/views/layouts/print/recapitulation.html.haml +8 -0
- data/app/views/rich_table_component/_notification.html.haml +9 -0
- data/app/views/rich_table_component/_pagination.html.haml +11 -0
- data/app/views/rich_table_component/_recapitulation_matrix_groups.html.haml +42 -0
- data/app/views/rich_table_component/component/_ajax_upload.html.haml +6 -0
- data/app/views/rich_table_component/component/_ajax_upload_result.html.haml +2 -0
- data/app/views/rich_table_component/component/_breadcrumbs.html.haml +25 -0
- data/app/views/rich_table_component/component/_breadcrumbs_dropdown.html.haml +18 -0
- data/app/views/rich_table_component/component/_tabbed.html.haml +5 -0
- data/app/views/rich_table_component/rtc/_advanced_search.html.haml +95 -0
- data/app/views/rich_table_component/rtc/_advanced_search_recapitulation.html.haml +90 -0
- data/app/views/rich_table_component/rtc/_component.html.haml +62 -0
- data/app/views/rich_table_component/rtc/_component_actions.html.haml +69 -0
- data/app/views/rich_table_component/rtc/_component_content.html.haml +37 -0
- data/app/views/rich_table_component/rtc/_component_title.html.haml +37 -0
- data/app/views/rich_table_component/rtc/_content.html.haml +22 -0
- data/app/views/rich_table_component/rtc/_footer.html.haml +4 -0
- data/app/views/rich_table_component/rtc/_header.html.haml +56 -0
- data/app/views/rich_table_component/rtc/_recapitulation_matrix.html.haml +25 -0
- data/app/views/rich_table_component/rtc/_recapitulation_matrix_form.html.haml +47 -0
- data/app/views/rich_table_component/rtc/_table.html.haml +22 -0
- data/lib/pagination_list_link_renderer.rb +51 -0
- data/lib/rich_table_component/version.rb +1 -1
- data/lib/rich_table_component.rb +0 -8
- data/rich_table_component.gemspec +0 -1
- data/vendor/assets/images/icons/file_extension/file_extension_.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_3gp.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_7z.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ace.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ai.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_aif.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_aiff.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_amr.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_asf.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_asx.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_bat.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_bin.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_bmp.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_bup.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_cab.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_cbr.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_cda.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_cdl.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_cdr.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_chm.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_dat.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_divx.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_dll.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_dmg.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_doc.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_dss.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_dvf.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_dwg.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_eml.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_eps.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_exe.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_fla.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_flv.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_gif.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_gz.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_hqx.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_htm.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_html.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ifo.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_indd.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_iso.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_jar.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_jpeg.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_jpg.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_lnk.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_log.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_m4a.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_m4b.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_m4p.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_m4v.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mcd.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mdb.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mid.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mov.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mp2.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mp4.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mpeg.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mpg.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_msi.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_mswmm.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ogg.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_pdf.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_png.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_pps.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ppt.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ps.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_psd.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_pst.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ptb.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_pub.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_qbb.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_qbw.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_qxd.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ram.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_rar.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_rm.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_rmvb.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_rtf.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_sea.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ses.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_sit.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_sitx.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ss.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_swf.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_tgz.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_thm.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_tif.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_tmp.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_torrent.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_ttf.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_txt.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_vcd.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_vob.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_wav.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_wma.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_wmv.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_wps.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_xls.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_xpi.png +0 -0
- data/vendor/assets/images/icons/file_extension/file_extension_zip.png +0 -0
- data/vendor/assets/images/loading_image.gif +0 -0
- data/vendor/assets/images/pbar-ani.gif +0 -0
- data/vendor/assets/javascripts/admin/starqle.grid.js +708 -0
- data/vendor/assets/javascripts/admin/starqle.ui.jquery.js +927 -0
- data/vendor/assets/javascripts/ckeditor/config.js +112 -0
- data/vendor/assets/javascripts/jquery-ui-1.8.13.custom.min.js +445 -0
- data/vendor/assets/javascripts/jquery.fileupload-ui.js +533 -0
- data/vendor/assets/javascripts/jquery.fileupload.js +975 -0
- data/vendor/assets/javascripts/jquery.tmpl.min.js +1 -0
- data/vendor/assets/javascripts/jquery.tokeninput.js +860 -0
- data/vendor/assets/javascripts/nested_attribute_action.js +19 -0
- data/vendor/assets/javascripts/rich_table_component.js +51 -0
- data/vendor/assets/stylesheets/fontfaces/england_hand_db/Freeware License.txt +5 -0
- data/vendor/assets/stylesheets/fontfaces/england_hand_db/england-webfont.eot +0 -0
- data/vendor/assets/stylesheets/fontfaces/england_hand_db/england-webfont.svg +146 -0
- data/vendor/assets/stylesheets/fontfaces/england_hand_db/england-webfont.ttf +0 -0
- data/vendor/assets/stylesheets/fontfaces/england_hand_db/england-webfont.woff +0 -0
- data/vendor/assets/stylesheets/fontfaces/england_hand_db/stylesheet.css +16 -0
- data/vendor/assets/stylesheets/fontfaces/museo300-regular-webfont.eot +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo300-regular-webfont.svg +249 -0
- data/vendor/assets/stylesheets/fontfaces/museo300-regular-webfont.ttf +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo300-regular-webfont.woff +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo500-regular-webfont.eot +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo500-regular-webfont.svg +249 -0
- data/vendor/assets/stylesheets/fontfaces/museo500-regular-webfont.ttf +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo500-regular-webfont.woff +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo700-regular-webfont.eot +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo700-regular-webfont.svg +249 -0
- data/vendor/assets/stylesheets/fontfaces/museo700-regular-webfont.ttf +0 -0
- data/vendor/assets/stylesheets/fontfaces/museo700-regular-webfont.woff +0 -0
- data/vendor/assets/stylesheets/partial/_base_functions.sass +101 -0
- data/vendor/assets/stylesheets/partial/_base_variables.sass +76 -0
- data/vendor/assets/stylesheets/partial/_form.sass +57 -0
- data/vendor/assets/stylesheets/partial/_grid.css +374 -0
- data/vendor/assets/stylesheets/partial/_notification.sass +33 -0
- data/vendor/assets/stylesheets/partial/_position.sass +122 -0
- data/vendor/assets/stylesheets/partial/_starqle.ui.grid.sass +495 -0
- data/vendor/assets/stylesheets/partial/_style.sass +674 -0
- data/vendor/assets/stylesheets/partial/_tabbed.sass +33 -0
- data/vendor/assets/stylesheets/partial/_user_component.sass +2 -0
- data/vendor/assets/stylesheets/rich_table_component/_custom.sass +0 -0
- data/vendor/assets/stylesheets/rich_table_component.css +18 -0
- data/vendor/assets/stylesheets/rtc_bootstrap_and_overrides.css.less +315 -0
- data/vendor/assets/stylesheets/rtc_config.sass +31 -0
- data/vendor/assets/stylesheets/rtc_jquery.fileupload-ui.css +155 -0
- data/vendor/assets/stylesheets/smoothness/images/Thumbs.db +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/vendor/assets/stylesheets/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/vendor/assets/stylesheets/smoothness/jquery-ui-1.8.11.custom.css +573 -0
- metadata +209 -17
@@ -0,0 +1,533 @@
|
|
1
|
+
/*
|
2
|
+
* jQuery File Upload User Interface Plugin 4.4.1
|
3
|
+
* https://github.com/blueimp/jQuery-File-Upload
|
4
|
+
*
|
5
|
+
* Copyright 2010, Sebastian Tschan
|
6
|
+
* https://blueimp.net
|
7
|
+
*
|
8
|
+
* Licensed under the MIT license:
|
9
|
+
* http://creativecommons.org/licenses/MIT/
|
10
|
+
*/
|
11
|
+
|
12
|
+
/*jslint browser: true, unparam: true */
|
13
|
+
/*global jQuery, FileReader, URL, webkitURL */
|
14
|
+
|
15
|
+
(function ($) {
|
16
|
+
'use strict';
|
17
|
+
|
18
|
+
var undef = 'undefined',
|
19
|
+
func = 'function',
|
20
|
+
UploadHandler,
|
21
|
+
methods,
|
22
|
+
|
23
|
+
MultiLoader = function (callBack) {
|
24
|
+
var loaded = 0,
|
25
|
+
list = [];
|
26
|
+
this.complete = function () {
|
27
|
+
loaded += 1;
|
28
|
+
if (loaded === list.length + 1) {
|
29
|
+
// list.length * onComplete + 1 * onLoadAll
|
30
|
+
callBack(list);
|
31
|
+
loaded = 0;
|
32
|
+
list = [];
|
33
|
+
}
|
34
|
+
};
|
35
|
+
this.push = function (item) {
|
36
|
+
list.push(item);
|
37
|
+
};
|
38
|
+
this.getList = function () {
|
39
|
+
return list;
|
40
|
+
};
|
41
|
+
};
|
42
|
+
|
43
|
+
UploadHandler = function (container, options) {
|
44
|
+
var uploadHandler = this,
|
45
|
+
dragOverTimeout,
|
46
|
+
isDropZoneEnlarged,
|
47
|
+
multiLoader = new MultiLoader(function (list) {
|
48
|
+
uploadHandler.hideProgressBarAll(function () {
|
49
|
+
uploadHandler.resetProgressBarAll();
|
50
|
+
if (typeof uploadHandler.onCompleteAll === func) {
|
51
|
+
uploadHandler.onCompleteAll(list);
|
52
|
+
}
|
53
|
+
});
|
54
|
+
}),
|
55
|
+
getUploadTable = function (handler) {
|
56
|
+
return typeof handler.uploadTable === func ?
|
57
|
+
handler.uploadTable(handler) : handler.uploadTable;
|
58
|
+
},
|
59
|
+
getDownloadTable = function (handler) {
|
60
|
+
return typeof handler.downloadTable === func ?
|
61
|
+
handler.downloadTable(handler) : handler.downloadTable;
|
62
|
+
};
|
63
|
+
|
64
|
+
this.requestHeaders = {'Accept': 'application/json, text/javascript, */*; q=0.01'};
|
65
|
+
this.dropZone = container;
|
66
|
+
this.imageTypes = /^image\/(gif|jpeg|png)$/;
|
67
|
+
this.previewMaxWidth = this.previewMaxHeight = 80;
|
68
|
+
this.previewLoadDelay = 100;
|
69
|
+
this.previewAsCanvas = true;
|
70
|
+
this.previewSelector = '.file_upload_preview';
|
71
|
+
this.progressSelector = '.file_upload_progress div';
|
72
|
+
this.cancelSelector = '.file_upload_cancel button';
|
73
|
+
this.cssClassSmall = 'file_upload_small';
|
74
|
+
this.cssClassLarge = 'file_upload_large';
|
75
|
+
this.cssClassHighlight = 'file_upload_highlight';
|
76
|
+
this.dropEffect = 'highlight';
|
77
|
+
this.uploadTable = this.downloadTable = null;
|
78
|
+
this.buildUploadRow = this.buildDownloadRow = null;
|
79
|
+
this.progressAllNode = null;
|
80
|
+
|
81
|
+
this.loadImage = function (file, callBack, maxWidth, maxHeight, imageTypes, noCanvas) {
|
82
|
+
var img,
|
83
|
+
scaleImage,
|
84
|
+
urlAPI,
|
85
|
+
fileReader;
|
86
|
+
if (imageTypes && !imageTypes.test(file.type)) {
|
87
|
+
return null;
|
88
|
+
}
|
89
|
+
scaleImage = function (img) {
|
90
|
+
var canvas = document.createElement('canvas'),
|
91
|
+
scale = Math.min(
|
92
|
+
(maxWidth || img.width) / img.width,
|
93
|
+
(maxHeight || img.height) / img.height
|
94
|
+
);
|
95
|
+
if (scale > 1) {
|
96
|
+
scale = 1;
|
97
|
+
}
|
98
|
+
img.width = parseInt(img.width * scale, 10);
|
99
|
+
img.height = parseInt(img.height * scale, 10);
|
100
|
+
if (noCanvas || typeof canvas.getContext !== func) {
|
101
|
+
return img;
|
102
|
+
}
|
103
|
+
canvas.width = img.width;
|
104
|
+
canvas.height = img.height;
|
105
|
+
canvas.getContext('2d').drawImage(img, 0, 0, img.width, img.height);
|
106
|
+
return canvas;
|
107
|
+
};
|
108
|
+
img = document.createElement('img');
|
109
|
+
urlAPI = typeof URL !== undef ? URL : typeof webkitURL !== undef ? webkitURL : null;
|
110
|
+
if (urlAPI && typeof urlAPI.createObjectURL === func) {
|
111
|
+
img.onload = function () {
|
112
|
+
urlAPI.revokeObjectURL(this.src);
|
113
|
+
callBack(scaleImage(img));
|
114
|
+
};
|
115
|
+
img.src = urlAPI.createObjectURL(file);
|
116
|
+
} else if (typeof FileReader !== undef &&
|
117
|
+
typeof FileReader.prototype.readAsDataURL === func) {
|
118
|
+
img.onload = function () {
|
119
|
+
callBack(scaleImage(img));
|
120
|
+
};
|
121
|
+
fileReader = new FileReader();
|
122
|
+
fileReader.onload = function (e) {
|
123
|
+
img.src = e.target.result;
|
124
|
+
};
|
125
|
+
fileReader.readAsDataURL(file);
|
126
|
+
} else {
|
127
|
+
callBack(null);
|
128
|
+
}
|
129
|
+
};
|
130
|
+
|
131
|
+
this.addNode = function (parentNode, node, callBack) {
|
132
|
+
if (parentNode && parentNode.length && node && node.length) {
|
133
|
+
node.css('display', 'none').appendTo(parentNode).fadeIn(function () {
|
134
|
+
if (typeof callBack === func) {
|
135
|
+
try {
|
136
|
+
callBack();
|
137
|
+
} catch (e) {
|
138
|
+
// Fix endless exception loop:
|
139
|
+
node.stop();
|
140
|
+
throw e;
|
141
|
+
}
|
142
|
+
}
|
143
|
+
});
|
144
|
+
} else if (typeof callBack === func) {
|
145
|
+
callBack();
|
146
|
+
}
|
147
|
+
};
|
148
|
+
|
149
|
+
this.removeNode = function (node, callBack) {
|
150
|
+
if (node && node.length) {
|
151
|
+
node.fadeOut(function () {
|
152
|
+
node.remove();
|
153
|
+
if (typeof callBack === func) {
|
154
|
+
try {
|
155
|
+
callBack();
|
156
|
+
} catch (e) {
|
157
|
+
// Fix endless exception loop:
|
158
|
+
node.stop();
|
159
|
+
throw e;
|
160
|
+
}
|
161
|
+
}
|
162
|
+
});
|
163
|
+
} else if (typeof callBack === func) {
|
164
|
+
callBack();
|
165
|
+
}
|
166
|
+
};
|
167
|
+
|
168
|
+
this.replaceNode = function (oldNode, newNode, callBack) {
|
169
|
+
if (!(newNode && newNode.length)) {
|
170
|
+
return uploadHandler.removeNode(oldNode, callBack);
|
171
|
+
}
|
172
|
+
if (oldNode && oldNode.length) {
|
173
|
+
oldNode.fadeOut(function () {
|
174
|
+
newNode.css('display', 'none');
|
175
|
+
oldNode.replaceWith(newNode);
|
176
|
+
newNode.fadeIn(function () {
|
177
|
+
if (typeof callBack === func) {
|
178
|
+
try {
|
179
|
+
callBack();
|
180
|
+
} catch (e) {
|
181
|
+
// Fix endless exception loop:
|
182
|
+
oldNode.stop();
|
183
|
+
newNode.stop();
|
184
|
+
throw e;
|
185
|
+
}
|
186
|
+
}
|
187
|
+
});
|
188
|
+
});
|
189
|
+
} else if (typeof callBack === func) {
|
190
|
+
callBack();
|
191
|
+
}
|
192
|
+
};
|
193
|
+
|
194
|
+
this.resetProgressBarAll = function () {
|
195
|
+
if (uploadHandler.progressbarAll) {
|
196
|
+
uploadHandler.progressbarAll.progressbar(
|
197
|
+
'value',
|
198
|
+
0
|
199
|
+
);
|
200
|
+
}
|
201
|
+
};
|
202
|
+
|
203
|
+
this.hideProgressBarAll = function (callBack) {
|
204
|
+
if (uploadHandler.progressbarAll && !$(getUploadTable(uploadHandler))
|
205
|
+
.find(uploadHandler.progressSelector + ':visible:first').length) {
|
206
|
+
uploadHandler.progressbarAll.fadeOut(callBack);
|
207
|
+
} else if (typeof callBack === func) {
|
208
|
+
callBack();
|
209
|
+
}
|
210
|
+
};
|
211
|
+
|
212
|
+
this.onAbort = function (event, files, index, xhr, handler) {
|
213
|
+
handler.removeNode(handler.uploadRow, handler.hideProgressBarAll);
|
214
|
+
};
|
215
|
+
|
216
|
+
this.cancelUpload = function (event, files, index, xhr, handler) {
|
217
|
+
var readyState = xhr.readyState;
|
218
|
+
xhr.abort();
|
219
|
+
// If readyState is below 2, abort() has no effect:
|
220
|
+
if (typeof readyState !== 'number' || readyState < 2) {
|
221
|
+
handler.onAbort(event, files, index, xhr, handler);
|
222
|
+
}
|
223
|
+
};
|
224
|
+
|
225
|
+
this.initProgressBar = function (node, value) {
|
226
|
+
if (!node || !node.length) {
|
227
|
+
return null;
|
228
|
+
}
|
229
|
+
if (typeof node.progressbar === func) {
|
230
|
+
return node.progressbar({
|
231
|
+
value: value
|
232
|
+
});
|
233
|
+
} else {
|
234
|
+
node.addClass('progressbar')
|
235
|
+
.append($('<div/>').css('width', value + '%'))
|
236
|
+
.progressbar = function (key, value) {
|
237
|
+
return this.each(function () {
|
238
|
+
if (key === 'destroy') {
|
239
|
+
$(this).removeClass('progressbar').empty();
|
240
|
+
} else {
|
241
|
+
$(this).children().css('width', value + '%');
|
242
|
+
}
|
243
|
+
});
|
244
|
+
};
|
245
|
+
return node;
|
246
|
+
}
|
247
|
+
};
|
248
|
+
|
249
|
+
this.destroyProgressBar = function (node) {
|
250
|
+
if (!node || !node.length) {
|
251
|
+
return null;
|
252
|
+
}
|
253
|
+
return node.progressbar('destroy');
|
254
|
+
};
|
255
|
+
|
256
|
+
this.initUploadProgress = function (xhr, handler) {
|
257
|
+
if (!xhr.upload && handler.progressbar) {
|
258
|
+
handler.progressbar.progressbar(
|
259
|
+
'value',
|
260
|
+
100 // indeterminate progress displayed by a full animated progress bar
|
261
|
+
);
|
262
|
+
}
|
263
|
+
};
|
264
|
+
|
265
|
+
this.initUploadProgressAll = function () {
|
266
|
+
if (uploadHandler.progressbarAll && uploadHandler.progressbarAll.is(':hidden')) {
|
267
|
+
uploadHandler.progressbarAll.fadeIn();
|
268
|
+
}
|
269
|
+
};
|
270
|
+
|
271
|
+
this.onSend = function (event, files, index, xhr, handler) {
|
272
|
+
handler.initUploadProgress(xhr, handler);
|
273
|
+
};
|
274
|
+
|
275
|
+
this.onProgress = function (event, files, index, xhr, handler) {
|
276
|
+
if (handler.progressbar && event.lengthComputable) {
|
277
|
+
handler.progressbar.progressbar(
|
278
|
+
'value',
|
279
|
+
parseInt(event.loaded / event.total * 100, 10)
|
280
|
+
);
|
281
|
+
}
|
282
|
+
};
|
283
|
+
|
284
|
+
this.onProgressAll = function (event, list) {
|
285
|
+
if (uploadHandler.progressbarAll && event.lengthComputable) {
|
286
|
+
uploadHandler.progressbarAll.progressbar(
|
287
|
+
'value',
|
288
|
+
parseInt(event.loaded / event.total * 100, 10)
|
289
|
+
);
|
290
|
+
}
|
291
|
+
};
|
292
|
+
|
293
|
+
this.onLoadAll = function (list) {
|
294
|
+
multiLoader.complete();
|
295
|
+
};
|
296
|
+
|
297
|
+
this.initProgressBarAll = function () {
|
298
|
+
if (!uploadHandler.progressbarAll) {
|
299
|
+
uploadHandler.progressbarAll = uploadHandler.initProgressBar(
|
300
|
+
(typeof uploadHandler.progressAllNode === func ?
|
301
|
+
uploadHandler.progressAllNode(uploadHandler) : uploadHandler.progressAllNode),
|
302
|
+
0
|
303
|
+
);
|
304
|
+
}
|
305
|
+
};
|
306
|
+
|
307
|
+
this.destroyProgressBarAll = function () {
|
308
|
+
uploadHandler.destroyProgressBar(uploadHandler.progressbarAll);
|
309
|
+
};
|
310
|
+
|
311
|
+
this.loadPreviewImage = function (files, index, handler) {
|
312
|
+
index = index || 0;
|
313
|
+
handler.uploadRow.find(handler.previewSelector).each(function () {
|
314
|
+
var previewNode = $(this),
|
315
|
+
file = files[index];
|
316
|
+
setTimeout(function () {
|
317
|
+
handler.loadImage(
|
318
|
+
file,
|
319
|
+
function (img) {
|
320
|
+
handler.addNode(
|
321
|
+
previewNode,
|
322
|
+
$(img)
|
323
|
+
);
|
324
|
+
},
|
325
|
+
handler.previewMaxWidth,
|
326
|
+
handler.previewMaxHeight,
|
327
|
+
handler.imageTypes,
|
328
|
+
!handler.previewAsCanvas
|
329
|
+
);
|
330
|
+
}, handler.previewLoadDelay);
|
331
|
+
index += 1;
|
332
|
+
});
|
333
|
+
};
|
334
|
+
|
335
|
+
this.initUploadRow = function (event, files, index, xhr, handler) {
|
336
|
+
var uploadRow = handler.uploadRow = (typeof handler.buildUploadRow === func ?
|
337
|
+
handler.buildUploadRow(files, index, handler) : null);
|
338
|
+
if (uploadRow) {
|
339
|
+
handler.progressbar = handler.initProgressBar(
|
340
|
+
uploadRow.find(handler.progressSelector),
|
341
|
+
0
|
342
|
+
);
|
343
|
+
uploadRow.find(handler.cancelSelector).click(function (e) {
|
344
|
+
handler.cancelUpload(e, files, index, xhr, handler);
|
345
|
+
e.preventDefault();
|
346
|
+
});
|
347
|
+
handler.loadPreviewImage(files, index, handler);
|
348
|
+
}
|
349
|
+
};
|
350
|
+
|
351
|
+
this.initUpload = function (event, files, index, xhr, handler, callBack) {
|
352
|
+
handler.initUploadRow(event, files, index, xhr, handler);
|
353
|
+
handler.addNode(
|
354
|
+
getUploadTable(handler),
|
355
|
+
handler.uploadRow,
|
356
|
+
function () {
|
357
|
+
if (typeof handler.beforeSend === func) {
|
358
|
+
handler.beforeSend(event, files, index, xhr, handler, callBack);
|
359
|
+
} else {
|
360
|
+
callBack();
|
361
|
+
}
|
362
|
+
}
|
363
|
+
);
|
364
|
+
handler.initUploadProgressAll();
|
365
|
+
};
|
366
|
+
|
367
|
+
this.parseResponse = function (xhr, handler) {
|
368
|
+
if (typeof xhr.responseText !== undef) {
|
369
|
+
return $.parseJSON(xhr.responseText);
|
370
|
+
} else {
|
371
|
+
// Instead of an XHR object, an iframe is used for legacy browsers:
|
372
|
+
return $.parseJSON(xhr.contents().text());
|
373
|
+
}
|
374
|
+
};
|
375
|
+
|
376
|
+
this.initDownloadRow = function (event, files, index, xhr, handler) {
|
377
|
+
var json, downloadRow;
|
378
|
+
try {
|
379
|
+
json = handler.response = handler.parseResponse(xhr, handler);
|
380
|
+
} catch (e) {
|
381
|
+
if (typeof handler.onError === func) {
|
382
|
+
handler.originalEvent = event;
|
383
|
+
handler.onError(e, files, index, xhr, handler);
|
384
|
+
} else {
|
385
|
+
throw e;
|
386
|
+
}
|
387
|
+
}
|
388
|
+
downloadRow = handler.downloadRow = (typeof handler.buildDownloadRow === func ?
|
389
|
+
handler.buildDownloadRow(json, handler) : null);
|
390
|
+
};
|
391
|
+
|
392
|
+
this.onLoad = function (event, files, index, xhr, handler) {
|
393
|
+
var uploadTable = getUploadTable(handler),
|
394
|
+
downloadTable = getDownloadTable(handler),
|
395
|
+
callBack = function () {
|
396
|
+
if (typeof handler.onComplete === func) {
|
397
|
+
handler.onComplete(event, files, index, xhr, handler);
|
398
|
+
}
|
399
|
+
multiLoader.complete();
|
400
|
+
};
|
401
|
+
multiLoader.push(Array.prototype.slice.call(arguments, 1));
|
402
|
+
handler.initDownloadRow(event, files, index, xhr, handler);
|
403
|
+
if (uploadTable && handler.uploadRow && handler.uploadRow.length &&
|
404
|
+
(!downloadTable || uploadTable.get(0) === downloadTable.get(0))) {
|
405
|
+
handler.replaceNode(handler.uploadRow, handler.downloadRow, callBack);
|
406
|
+
} else {
|
407
|
+
handler.removeNode(handler.uploadRow, function () {
|
408
|
+
handler.addNode(
|
409
|
+
downloadTable,
|
410
|
+
handler.downloadRow,
|
411
|
+
callBack
|
412
|
+
);
|
413
|
+
});
|
414
|
+
}
|
415
|
+
};
|
416
|
+
|
417
|
+
this.dropZoneEnlarge = function () {
|
418
|
+
if (!isDropZoneEnlarged) {
|
419
|
+
if (typeof uploadHandler.dropZone.switchClass === func) {
|
420
|
+
uploadHandler.dropZone.switchClass(
|
421
|
+
uploadHandler.cssClassSmall,
|
422
|
+
uploadHandler.cssClassLarge
|
423
|
+
);
|
424
|
+
} else {
|
425
|
+
uploadHandler.dropZone.addClass(uploadHandler.cssClassLarge);
|
426
|
+
uploadHandler.dropZone.removeClass(uploadHandler.cssClassSmall);
|
427
|
+
}
|
428
|
+
isDropZoneEnlarged = true;
|
429
|
+
}
|
430
|
+
};
|
431
|
+
|
432
|
+
this.dropZoneReduce = function () {
|
433
|
+
if (typeof uploadHandler.dropZone.switchClass === func) {
|
434
|
+
uploadHandler.dropZone.switchClass(
|
435
|
+
uploadHandler.cssClassLarge,
|
436
|
+
uploadHandler.cssClassSmall
|
437
|
+
);
|
438
|
+
} else {
|
439
|
+
uploadHandler.dropZone.addClass(uploadHandler.cssClassSmall);
|
440
|
+
uploadHandler.dropZone.removeClass(uploadHandler.cssClassLarge);
|
441
|
+
}
|
442
|
+
isDropZoneEnlarged = false;
|
443
|
+
};
|
444
|
+
|
445
|
+
this.onDocumentDragEnter = function (event) {
|
446
|
+
uploadHandler.dropZoneEnlarge();
|
447
|
+
};
|
448
|
+
|
449
|
+
this.onDocumentDragOver = function (event) {
|
450
|
+
if (dragOverTimeout) {
|
451
|
+
clearTimeout(dragOverTimeout);
|
452
|
+
}
|
453
|
+
dragOverTimeout = setTimeout(function () {
|
454
|
+
uploadHandler.dropZoneReduce();
|
455
|
+
}, 200);
|
456
|
+
};
|
457
|
+
|
458
|
+
this.onDragEnter = this.onDragLeave = function (event) {
|
459
|
+
uploadHandler.dropZone.toggleClass(uploadHandler.cssClassHighlight);
|
460
|
+
};
|
461
|
+
|
462
|
+
this.onDrop = function (event) {
|
463
|
+
if (dragOverTimeout) {
|
464
|
+
clearTimeout(dragOverTimeout);
|
465
|
+
}
|
466
|
+
if (uploadHandler.dropEffect && typeof uploadHandler.dropZone.effect === func) {
|
467
|
+
uploadHandler.dropZone.effect(uploadHandler.dropEffect, function () {
|
468
|
+
uploadHandler.dropZone.removeClass(uploadHandler.cssClassHighlight);
|
469
|
+
uploadHandler.dropZoneReduce();
|
470
|
+
});
|
471
|
+
} else {
|
472
|
+
uploadHandler.dropZone.removeClass(uploadHandler.cssClassHighlight);
|
473
|
+
uploadHandler.dropZoneReduce();
|
474
|
+
}
|
475
|
+
};
|
476
|
+
|
477
|
+
this.init = function () {
|
478
|
+
uploadHandler.initProgressBarAll();
|
479
|
+
if (typeof uploadHandler.initExtended === func) {
|
480
|
+
uploadHandler.initExtended();
|
481
|
+
}
|
482
|
+
};
|
483
|
+
|
484
|
+
this.destroy = function () {
|
485
|
+
if (typeof uploadHandler.destroyExtended === func) {
|
486
|
+
uploadHandler.destroyExtended();
|
487
|
+
}
|
488
|
+
uploadHandler.destroyProgressBarAll();
|
489
|
+
};
|
490
|
+
|
491
|
+
$.extend(this, options);
|
492
|
+
};
|
493
|
+
|
494
|
+
methods = {
|
495
|
+
init : function (options) {
|
496
|
+
return this.each(function () {
|
497
|
+
$(this).fileUpload(new UploadHandler($(this), options));
|
498
|
+
});
|
499
|
+
},
|
500
|
+
|
501
|
+
option: function (option, value, namespace) {
|
502
|
+
if (!option || (typeof option === 'string' && typeof value === undef)) {
|
503
|
+
return $(this).fileUpload('option', option, value, namespace);
|
504
|
+
}
|
505
|
+
return this.each(function () {
|
506
|
+
$(this).fileUpload('option', option, value, namespace);
|
507
|
+
});
|
508
|
+
},
|
509
|
+
|
510
|
+
destroy : function (namespace) {
|
511
|
+
return this.each(function () {
|
512
|
+
$(this).fileUpload('destroy', namespace);
|
513
|
+
});
|
514
|
+
},
|
515
|
+
|
516
|
+
upload: function (files, namespace) {
|
517
|
+
return this.each(function () {
|
518
|
+
$(this).fileUpload('upload', files, namespace);
|
519
|
+
});
|
520
|
+
}
|
521
|
+
};
|
522
|
+
|
523
|
+
$.fn.fileUploadUI = function (method) {
|
524
|
+
if (methods[method]) {
|
525
|
+
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
|
526
|
+
} else if (typeof method === 'object' || !method) {
|
527
|
+
return methods.init.apply(this, arguments);
|
528
|
+
} else {
|
529
|
+
$.error('Method "' + method + '" does not exist on jQuery.fileUploadUI');
|
530
|
+
}
|
531
|
+
};
|
532
|
+
|
533
|
+
}(jQuery));
|