Show More
@@ -0,0 +1,9 b'' | |||
|
1 | <%namespace name="sourceblock" file="/codeblocks/source.mako"/> | |
|
2 | ||
|
3 | <%def name="render_lines(lines)"> | |
|
4 | <table class="cb codehilite"> | |
|
5 | %for line_num, tokens in enumerate(lines, 1): | |
|
6 | ${sourceblock.render_line(line_num, tokens)} | |
|
7 | %endfor | |
|
8 | </table> | |
|
9 | </%def> |
@@ -1,110 +1,114 b'' | |||
|
1 | 1 | <%inherit file="/base/base.mako"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('{} Files Add').format(c.repo_name)} |
|
5 | 5 | %if c.rhodecode_name: |
|
6 | 6 | · ${h.branding(c.rhodecode_name)} |
|
7 | 7 | %endif |
|
8 | 8 | </%def> |
|
9 | 9 | |
|
10 | 10 | <%def name="menu_bar_nav()"> |
|
11 | 11 | ${self.menu_items(active='repositories')} |
|
12 | 12 | </%def> |
|
13 | 13 | |
|
14 | 14 | <%def name="breadcrumbs_links()"></%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="menu_bar_subnav()"> |
|
17 | 17 | ${self.repo_menu(active='files')} |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | <%def name="main()"> |
|
21 | 21 | |
|
22 | 22 | <div class="box"> |
|
23 | 23 | |
|
24 | 24 | <div class="edit-file-title"> |
|
25 | 25 | <span class="title-heading">${_('Add new file')} @ <code>${h.show_id(c.commit)}</code></span> |
|
26 | <span class="tag branchtag"><i class="icon-branch"></i> ${c.commit.branch}</span> | |
|
26 | % if c.commit.branch: | |
|
27 | <span class="tag branchtag"> | |
|
28 | <i class="icon-branch"></i> ${c.commit.branch} | |
|
29 | </span> | |
|
30 | % endif | |
|
27 | 31 | </div> |
|
28 | 32 | |
|
29 | 33 | ${h.secure_form(h.route_path('repo_files_create_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path), id='eform', request=request)} |
|
30 | 34 | <div class="edit-file-fieldset"> |
|
31 | 35 | <div class="path-items"> |
|
32 | 36 | <ul> |
|
33 | 37 | <li class="breadcrumb-path"> |
|
34 | 38 | <div> |
|
35 | 39 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}"><i class="icon-home"></i></a> / |
|
36 | 40 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path)}">${c.f_path}</a> ${('/' if c.f_path else '')} |
|
37 | 41 | </div> |
|
38 | 42 | </li> |
|
39 | 43 | <li class="location-path"> |
|
40 | 44 | <input class="file-name-input input-small" type="text" value="" name="filename" id="filename" placeholder="${_('Filename e.g example.py, or docs/readme.md')}"> |
|
41 | 45 | </li> |
|
42 | 46 | </ul> |
|
43 | 47 | </div> |
|
44 | 48 | |
|
45 | 49 | </div> |
|
46 | 50 | |
|
47 | 51 | <div class="table"> |
|
48 | 52 | <div id="files_data"> |
|
49 | 53 | |
|
50 | 54 | <div id="codeblock" class="codeblock"> |
|
51 | 55 | <div class="editor-items"> |
|
52 | 56 | <div class="editor-action active show-editor pull-left" onclick="fileEditor.showEditor(); return false"> |
|
53 | 57 | ${_('Edit')} |
|
54 | 58 | </div> |
|
55 | 59 | |
|
56 | 60 | <div class="editor-action show-preview pull-left" onclick="fileEditor.showPreview(); return false"> |
|
57 | 61 | ${_('Preview')} |
|
58 | 62 | </div> |
|
59 | 63 | |
|
60 | 64 | <div class="pull-right"> |
|
61 | 65 | ${h.dropdownmenu('line_wrap', 'off', [('on', _('Line wraps on')), ('off', _('line wraps off'))], extra_classes=['last-item'])} |
|
62 | 66 | </div> |
|
63 | 67 | <div class="pull-right"> |
|
64 | 68 | ${h.dropdownmenu('set_mode','plain',[('plain', _('plain'))], enable_filter=True)} |
|
65 | 69 | </div> |
|
66 | 70 | </div> |
|
67 | 71 | |
|
68 | 72 | <div id="editor_container"> |
|
69 | 73 | <pre id="editor_pre"></pre> |
|
70 | 74 | <textarea id="editor" name="content" ></textarea> |
|
71 | 75 | <div id="editor_preview"></div> |
|
72 | 76 | </div> |
|
73 | 77 | </div> |
|
74 | 78 | </div> |
|
75 | 79 | </div> |
|
76 | 80 | |
|
77 | 81 | <div class="edit-file-fieldset"> |
|
78 | 82 | <div class="fieldset"> |
|
79 | 83 | <div class="message"> |
|
80 | 84 | <textarea id="commit" name="message" placeholder="${c.default_message}"></textarea> |
|
81 | 85 | </div> |
|
82 | 86 | </div> |
|
83 | 87 | <div class="pull-left"> |
|
84 | 88 | ${h.submit('commit_btn',_('Commit changes'), class_="btn btn-small btn-success")} |
|
85 | 89 | </div> |
|
86 | 90 | </div> |
|
87 | 91 | ${h.end_form()} |
|
88 | 92 | </div> |
|
89 | 93 | |
|
90 | 94 | <script type="text/javascript"> |
|
91 | 95 | |
|
92 | 96 | $(document).ready(function () { |
|
93 | 97 | var modes_select = $('#set_mode'); |
|
94 | 98 | var filename_selector = '#filename'; |
|
95 | 99 | fillCodeMirrorOptions(modes_select); |
|
96 | 100 | |
|
97 | 101 | fileEditor = new FileEditor('#editor'); |
|
98 | 102 | |
|
99 | 103 | // on change of select field set mode |
|
100 | 104 | setCodeMirrorModeFromSelect(modes_select, filename_selector, fileEditor.cm, null); |
|
101 | 105 | |
|
102 | 106 | // on entering the new filename set mode, from given extension |
|
103 | 107 | setCodeMirrorModeFromInput(modes_select, filename_selector, fileEditor.cm, null); |
|
104 | 108 | |
|
105 | 109 | $('#filename').focus(); |
|
106 | 110 | |
|
107 | 111 | }); |
|
108 | 112 | |
|
109 | 113 | </script> |
|
110 | 114 | </%def> |
@@ -1,85 +1,89 b'' | |||
|
1 | 1 | <%inherit file="/base/base.mako"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('{} Files Delete').format(c.repo_name)} |
|
5 | 5 | %if c.rhodecode_name: |
|
6 | 6 | · ${h.branding(c.rhodecode_name)} |
|
7 | 7 | %endif |
|
8 | 8 | </%def> |
|
9 | 9 | |
|
10 | 10 | <%def name="menu_bar_nav()"> |
|
11 | 11 | ${self.menu_items(active='repositories')} |
|
12 | 12 | </%def> |
|
13 | 13 | |
|
14 | 14 | <%def name="breadcrumbs_links()"></%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="menu_bar_subnav()"> |
|
17 | 17 | ${self.repo_menu(active='files')} |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | <%def name="main()"> |
|
21 | 21 | |
|
22 | 22 | <div class="box"> |
|
23 | 23 | |
|
24 | 24 | <div class="edit-file-title"> |
|
25 | 25 | <span class="title-heading">${_('Delete file')} @ <code>${h.show_id(c.commit)}</code></span> |
|
26 | <span class="tag branchtag"><i class="icon-branch"></i> ${c.commit.branch}</span> | |
|
26 | % if c.commit.branch: | |
|
27 | <span class="tag branchtag"> | |
|
28 | <i class="icon-branch"></i> ${c.commit.branch} | |
|
29 | </span> | |
|
30 | % endif | |
|
27 | 31 | </div> |
|
28 | 32 | |
|
29 | 33 | ${h.secure_form(h.route_path('repo_files_delete_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path), id='eform', request=request)} |
|
30 | 34 | <div class="edit-file-fieldset"> |
|
31 | 35 | <div class="path-items"> |
|
32 | 36 | <li class="breadcrumb-path"> |
|
33 | 37 | <div> |
|
34 | 38 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}"><i class="icon-home"></i></a> / |
|
35 | 39 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.file.dir_path)}">${c.file.dir_path}</a> ${('/' if c.file.dir_path else '')} |
|
36 | 40 | </div> |
|
37 | 41 | </li> |
|
38 | 42 | <li class="location-path"> |
|
39 | 43 | <input type="hidden" value="${c.f_path}" name="root_path"> |
|
40 | 44 | <input class="file-name-input input-small" type="text" value="${c.file.name}" name="filename" id="filename" disabled="disabled"> |
|
41 | 45 | </li> |
|
42 | 46 | </div> |
|
43 | 47 | |
|
44 | 48 | </div> |
|
45 | 49 | |
|
46 | 50 | <div id="codeblock" class="codeblock delete-file-preview"> |
|
47 | 51 | <div class="code-body"> |
|
48 | 52 | %if c.file.is_binary: |
|
49 | 53 | ${_('Binary file (%s)') % c.file.mimetype} |
|
50 | 54 | %else: |
|
51 | 55 | %if c.file.size < c.visual.cut_off_limit_file: |
|
52 | 56 | ${h.pygmentize(c.file,linenos=True,anchorlinenos=False,cssclass="code-highlight")} |
|
53 | 57 | %else: |
|
54 | 58 | ${_('File size {} is bigger then allowed limit {}. ').format(h.format_byte_size_binary(c.file.size), h.format_byte_size_binary(c.visual.cut_off_limit_file))} ${h.link_to(_('Show as raw'), |
|
55 | 59 | h.route_path('repo_file_raw',repo_name=c.repo_name,commit_id=c.commit.raw_id,f_path=c.f_path))} |
|
56 | 60 | %endif |
|
57 | 61 | %endif |
|
58 | 62 | </div> |
|
59 | 63 | </div> |
|
60 | 64 | |
|
61 | 65 | <div class="edit-file-fieldset"> |
|
62 | 66 | <div class="fieldset"> |
|
63 | 67 | <div class="message"> |
|
64 | 68 | <textarea id="commit" name="message" placeholder="${c.default_message}"></textarea> |
|
65 | 69 | </div> |
|
66 | 70 | </div> |
|
67 | 71 | <div class="pull-left"> |
|
68 | 72 | ${h.submit('commit',_('Commit changes'),class_="btn btn-small btn-danger-action")} |
|
69 | 73 | </div> |
|
70 | 74 | </div> |
|
71 | 75 | ${h.end_form()} |
|
72 | 76 | </div> |
|
73 | 77 | |
|
74 | 78 | |
|
75 | 79 | <script type="text/javascript"> |
|
76 | 80 | |
|
77 | 81 | $(document).ready(function () { |
|
78 | 82 | |
|
79 | 83 | fileEditor = new FileEditor('#editor'); |
|
80 | 84 | |
|
81 | 85 | }); |
|
82 | 86 | |
|
83 | 87 | </script> |
|
84 | 88 | |
|
85 | 89 | </%def> |
@@ -1,120 +1,124 b'' | |||
|
1 | 1 | <%inherit file="/base/base.mako"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('{} Files Edit').format(c.repo_name)} |
|
5 | 5 | %if c.rhodecode_name: |
|
6 | 6 | · ${h.branding(c.rhodecode_name)} |
|
7 | 7 | %endif |
|
8 | 8 | </%def> |
|
9 | 9 | |
|
10 | 10 | <%def name="menu_bar_nav()"> |
|
11 | 11 | ${self.menu_items(active='repositories')} |
|
12 | 12 | </%def> |
|
13 | 13 | |
|
14 | 14 | <%def name="breadcrumbs_links()"></%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="menu_bar_subnav()"> |
|
17 | 17 | ${self.repo_menu(active='files')} |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | <%def name="main()"> |
|
21 | 21 | |
|
22 | 22 | <div class="box"> |
|
23 | 23 | |
|
24 | 24 | <div class="edit-file-title"> |
|
25 | 25 | <span class="title-heading">${_('Edit file')} @ <code>${h.show_id(c.commit)}</code></span> |
|
26 | <span class="tag branchtag"><i class="icon-branch"></i> ${c.commit.branch}</span> | |
|
26 | % if c.commit.branch: | |
|
27 | <span class="tag branchtag"> | |
|
28 | <i class="icon-branch"></i> ${c.commit.branch} | |
|
29 | </span> | |
|
30 | % endif | |
|
27 | 31 | </div> |
|
28 | 32 | |
|
29 | 33 | ${h.secure_form(h.route_path('repo_files_update_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path), id='eform', request=request)} |
|
30 | 34 | <div class="edit-file-fieldset"> |
|
31 | 35 | <div class="path-items"> |
|
32 | 36 | <ul> |
|
33 | 37 | <li class="breadcrumb-path"> |
|
34 | 38 | <div> |
|
35 | 39 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}"><i class="icon-home"></i></a> / |
|
36 | 40 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.file.dir_path)}">${c.file.dir_path}</a> ${('/' if c.file.dir_path else '')} |
|
37 | 41 | </div> |
|
38 | 42 | </li> |
|
39 | 43 | <li class="location-path"> |
|
40 | 44 | <input type="hidden" value="${c.f_path}" name="root_path"> |
|
41 | 45 | <input class="file-name-input input-small" type="text" value="${c.file.name}" name="filename" id="filename" placeholder="${_('Filename e.g example.py, or docs/readme.md')}"> |
|
42 | 46 | </li> |
|
43 | 47 | </ul> |
|
44 | 48 | </div> |
|
45 | 49 | |
|
46 | 50 | </div> |
|
47 | 51 | |
|
48 | 52 | <div class="table"> |
|
49 | 53 | <div id="files_data"> |
|
50 | 54 | |
|
51 | 55 | <div id="codeblock" class="codeblock"> |
|
52 | 56 | <div class="editor-items"> |
|
53 | 57 | <div class="editor-action active show-editor pull-left" onclick="fileEditor.showEditor(); return false"> |
|
54 | 58 | ${_('Edit')} |
|
55 | 59 | </div> |
|
56 | 60 | |
|
57 | 61 | <div class="editor-action show-preview pull-left" onclick="fileEditor.showPreview(); return false"> |
|
58 | 62 | ${_('Preview')} |
|
59 | 63 | </div> |
|
60 | 64 | |
|
61 | 65 | <div class="pull-right"> |
|
62 | 66 | ${h.dropdownmenu('line_wrap', 'off', [('on', _('Line wraps on')), ('off', _('line wraps off')),])} |
|
63 | 67 | </div> |
|
64 | 68 | <div class="pull-right"> |
|
65 | 69 | ${h.dropdownmenu('set_mode','plain',[('plain', _('plain'))],enable_filter=True)} |
|
66 | 70 | </div> |
|
67 | 71 | </div> |
|
68 | 72 | |
|
69 | 73 | <div id="editor_container"> |
|
70 | 74 | <pre id="editor_pre"></pre> |
|
71 | 75 | <textarea id="editor" name="content" >${h.escape(c.file.content)|n}</textarea> |
|
72 | 76 | <div id="editor_preview" ></div> |
|
73 | 77 | </div> |
|
74 | 78 | </div> |
|
75 | 79 | </div> |
|
76 | 80 | </div> |
|
77 | 81 | |
|
78 | 82 | <div class="edit-file-fieldset"> |
|
79 | 83 | <div class="fieldset"> |
|
80 | 84 | <div class="message"> |
|
81 | 85 | <textarea id="commit" name="message" placeholder="${c.default_message}"></textarea> |
|
82 | 86 | </div> |
|
83 | 87 | </div> |
|
84 | 88 | <div class="pull-left"> |
|
85 | 89 | ${h.submit('commit_btn',_('Commit changes'), class_="btn btn-small btn-success")} |
|
86 | 90 | </div> |
|
87 | 91 | </div> |
|
88 | 92 | ${h.end_form()} |
|
89 | 93 | </div> |
|
90 | 94 | |
|
91 | 95 | <script type="text/javascript"> |
|
92 | 96 | |
|
93 | 97 | $(document).ready(function() { |
|
94 | 98 | var modes_select = $('#set_mode'); |
|
95 | 99 | var filename_selector = '#filename'; |
|
96 | 100 | fillCodeMirrorOptions(modes_select); |
|
97 | 101 | |
|
98 | 102 | fileEditor = new FileEditor('#editor'); |
|
99 | 103 | |
|
100 | 104 | // try to detect the mode based on the file we edit |
|
101 | 105 | var detected_mode = detectCodeMirrorMode("${c.file.name}", "${c.file.mimetype}"); |
|
102 | 106 | |
|
103 | 107 | if (detected_mode) { |
|
104 | 108 | setCodeMirrorMode(fileEditor.cm, detected_mode); |
|
105 | 109 | |
|
106 | 110 | var mimetype = $(modes_select).find("option[mode={0}]".format(detected_mode)).val(); |
|
107 | 111 | $(modes_select).select2("val", mimetype).trigger('change'); |
|
108 | 112 | } |
|
109 | 113 | |
|
110 | 114 | // on change of select field set mode |
|
111 | 115 | setCodeMirrorModeFromSelect(modes_select, filename_selector, fileEditor.cm, null); |
|
112 | 116 | |
|
113 | 117 | // on entering the new filename set mode, from given extension |
|
114 | 118 | setCodeMirrorModeFromInput(modes_select, filename_selector, fileEditor.cm, null); |
|
115 | 119 | |
|
116 | 120 | }); |
|
117 | 121 | |
|
118 | 122 | |
|
119 | 123 | </script> |
|
120 | 124 | </%def> |
@@ -1,207 +1,211 b'' | |||
|
1 | 1 | <%inherit file="/base/base.mako"/> |
|
2 | 2 | |
|
3 | 3 | <%def name="title()"> |
|
4 | 4 | ${_('{} Files Upload').format(c.repo_name)} |
|
5 | 5 | %if c.rhodecode_name: |
|
6 | 6 | · ${h.branding(c.rhodecode_name)} |
|
7 | 7 | %endif |
|
8 | 8 | </%def> |
|
9 | 9 | |
|
10 | 10 | <%def name="menu_bar_nav()"> |
|
11 | 11 | ${self.menu_items(active='repositories')} |
|
12 | 12 | </%def> |
|
13 | 13 | |
|
14 | 14 | <%def name="breadcrumbs_links()"></%def> |
|
15 | 15 | |
|
16 | 16 | <%def name="menu_bar_subnav()"> |
|
17 | 17 | ${self.repo_menu(active='files')} |
|
18 | 18 | </%def> |
|
19 | 19 | |
|
20 | 20 | <%def name="main()"> |
|
21 | 21 | |
|
22 | 22 | <div class="box"> |
|
23 | 23 | ## Template for uploads |
|
24 | 24 | <div style="display: none" id="tpl-dropzone"> |
|
25 | 25 | <div class="dz-preview dz-file-preview"> |
|
26 | 26 | <div class="dz-details"> |
|
27 | 27 | |
|
28 | 28 | <div class="dz-filename"> |
|
29 | 29 | <span data-dz-name></span> |
|
30 | 30 | </div> |
|
31 | 31 | <div class="dz-filename-size"> |
|
32 | 32 | <span class="dz-size" data-dz-size></span> |
|
33 | 33 | |
|
34 | 34 | </div> |
|
35 | 35 | |
|
36 | 36 | <div class="dz-sending" style="display: none">${_('Uploading...')}</div> |
|
37 | 37 | <div class="dz-response" style="display: none"> |
|
38 | 38 | ${_('Uploaded')} 100% |
|
39 | 39 | </div> |
|
40 | 40 | |
|
41 | 41 | </div> |
|
42 | 42 | <div class="dz-progress"> |
|
43 | 43 | <span class="dz-upload" data-dz-uploadprogress></span> |
|
44 | 44 | </div> |
|
45 | 45 | |
|
46 | 46 | <div class="dz-error-message"> |
|
47 | 47 | </div> |
|
48 | 48 | </div> |
|
49 | 49 | </div> |
|
50 | 50 | |
|
51 | 51 | <div class="edit-file-title"> |
|
52 | 52 | <span class="title-heading">${_('Upload new file')} @ <code>${h.show_id(c.commit)}</code></span> |
|
53 | <span class="tag branchtag"><i class="icon-branch"></i> ${c.commit.branch}</span> | |
|
53 | % if c.commit.branch: | |
|
54 | <span class="tag branchtag"> | |
|
55 | <i class="icon-branch"></i> ${c.commit.branch} | |
|
56 | </span> | |
|
57 | % endif | |
|
54 | 58 | </div> |
|
55 | 59 | |
|
56 | 60 | <% form_url = h.route_path('repo_files_upload_file', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path) %> |
|
57 | 61 | ##${h.secure_form(form_url, id='eform', enctype="multipart/form-data", request=request)} |
|
58 | 62 | <div class="edit-file-fieldset"> |
|
59 | 63 | <div class="path-items"> |
|
60 | 64 | <ul> |
|
61 | 65 | <li class="breadcrumb-path"> |
|
62 | 66 | <div> |
|
63 | 67 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path='')}"><i class="icon-home"></i></a> / |
|
64 | 68 | <a href="${h.route_path('repo_files', repo_name=c.repo_name, commit_id=c.commit.raw_id, f_path=c.f_path)}">${c.f_path}</a> ${('/' if c.f_path else '')} |
|
65 | 69 | </div> |
|
66 | 70 | </li> |
|
67 | 71 | <li class="location-path"> |
|
68 | 72 | |
|
69 | 73 | </li> |
|
70 | 74 | </ul> |
|
71 | 75 | </div> |
|
72 | 76 | |
|
73 | 77 | </div> |
|
74 | 78 | |
|
75 | 79 | <div class="upload-form table"> |
|
76 | 80 | <div id="files_data"> |
|
77 | 81 | |
|
78 | 82 | <div class="dropzone-wrapper" id="file-uploader"> |
|
79 | 83 | <div class="dropzone-pure"> |
|
80 | 84 | <div class="dz-message"> |
|
81 | 85 | <i class="icon-upload" style="font-size:36px"></i></br> |
|
82 | 86 | ${_("Drag'n Drop files here or")} <span class="link">${_('Choose your files')}</span>.<br> |
|
83 | 87 | </div> |
|
84 | 88 | </div> |
|
85 | 89 | |
|
86 | 90 | </div> |
|
87 | 91 | </div> |
|
88 | 92 | |
|
89 | 93 | </div> |
|
90 | 94 | |
|
91 | 95 | <div class="upload-form edit-file-fieldset"> |
|
92 | 96 | <div class="fieldset"> |
|
93 | 97 | <div class="message"> |
|
94 | 98 | <textarea id="commit" name="message" placeholder="${c.default_message}"></textarea> |
|
95 | 99 | </div> |
|
96 | 100 | </div> |
|
97 | 101 | <div class="pull-left"> |
|
98 | 102 | ${h.submit('commit_btn',_('Commit changes'), class_="btn btn-small btn-success")} |
|
99 | 103 | </div> |
|
100 | 104 | </div> |
|
101 | 105 | ##${h.end_form()} |
|
102 | 106 | |
|
103 | 107 | <div class="file-upload-transaction-wrapper" style="display: none"> |
|
104 | 108 | <div class="file-upload-transaction"> |
|
105 | 109 | <h3>${_('Commiting...')}</h3> |
|
106 | 110 | <p>${_('Please wait while the files are being uploaded')}</p> |
|
107 | 111 | <p class="error" style="display: none"> |
|
108 | 112 | |
|
109 | 113 | </p> |
|
110 | 114 | <i class="icon-spin animate-spin"></i> |
|
111 | 115 | <p></p> |
|
112 | 116 | </div> |
|
113 | 117 | </div> |
|
114 | 118 | |
|
115 | 119 | </div> |
|
116 | 120 | |
|
117 | 121 | <script type="text/javascript"> |
|
118 | 122 | |
|
119 | 123 | $(document).ready(function () { |
|
120 | 124 | |
|
121 | 125 | //see: https://www.dropzonejs.com/#configuration |
|
122 | 126 | myDropzone = new Dropzone("div#file-uploader", { |
|
123 | 127 | url: "${form_url}", |
|
124 | 128 | headers: {"X-CSRF-Token": CSRF_TOKEN}, |
|
125 | 129 | paramName: function () { |
|
126 | 130 | return "files_upload" |
|
127 | 131 | }, // The name that will be used to transfer the file |
|
128 | 132 | parallelUploads: 20, |
|
129 | 133 | maxFiles: 20, |
|
130 | 134 | uploadMultiple: true, |
|
131 | 135 | //chunking: true, // use chunking transfer, not supported at the moment |
|
132 | 136 | //maxFilesize: 2, // in MBs |
|
133 | 137 | autoProcessQueue: false, // if false queue will not be processed automatically. |
|
134 | 138 | createImageThumbnails: false, |
|
135 | 139 | previewTemplate: document.querySelector('#tpl-dropzone').innerHTML, |
|
136 | 140 | accept: function (file, done) { |
|
137 | 141 | done(); |
|
138 | 142 | }, |
|
139 | 143 | init: function () { |
|
140 | 144 | this.on("addedfile", function (file) { |
|
141 | 145 | |
|
142 | 146 | }); |
|
143 | 147 | |
|
144 | 148 | this.on("sending", function (file, xhr, formData) { |
|
145 | 149 | formData.append("message", $('#commit').val()); |
|
146 | 150 | $(file.previewElement).find('.dz-sending').show(); |
|
147 | 151 | }); |
|
148 | 152 | |
|
149 | 153 | this.on("success", function (file, response) { |
|
150 | 154 | $(file.previewElement).find('.dz-sending').hide(); |
|
151 | 155 | $(file.previewElement).find('.dz-response').show(); |
|
152 | 156 | |
|
153 | 157 | if (response.error !== null) { |
|
154 | 158 | $('.file-upload-transaction-wrapper .error').html('ERROR: {0}'.format(response.error)); |
|
155 | 159 | $('.file-upload-transaction-wrapper .error').show(); |
|
156 | 160 | $('.file-upload-transaction-wrapper i').hide() |
|
157 | 161 | } |
|
158 | 162 | |
|
159 | 163 | var redirect_url = response.redirect_url || '/'; |
|
160 | 164 | window.location = redirect_url |
|
161 | 165 | |
|
162 | 166 | }); |
|
163 | 167 | |
|
164 | 168 | this.on("error", function (file, errorMessage, xhr) { |
|
165 | 169 | var error = null; |
|
166 | 170 | |
|
167 | 171 | if (xhr !== undefined){ |
|
168 | 172 | var httpStatus = xhr.status + " " + xhr.statusText; |
|
169 | 173 | if (xhr.status >= 500) { |
|
170 | 174 | error = httpStatus; |
|
171 | 175 | } |
|
172 | 176 | } |
|
173 | 177 | |
|
174 | 178 | if (error === null) { |
|
175 | 179 | error = errorMessage.error || errorMessage || httpStatus; |
|
176 | 180 | } |
|
177 | 181 | |
|
178 | 182 | $(file.previewElement).find('.dz-error-message').html('ERROR: {0}'.format(error)); |
|
179 | 183 | }); |
|
180 | 184 | } |
|
181 | 185 | }); |
|
182 | 186 | |
|
183 | 187 | $('#commit_btn').on('click', function(e) { |
|
184 | 188 | e.preventDefault(); |
|
185 | 189 | var button = $(this); |
|
186 | 190 | if (button.hasClass('clicked')) { |
|
187 | 191 | button.attr('disabled', true); |
|
188 | 192 | } else { |
|
189 | 193 | button.addClass('clicked'); |
|
190 | 194 | } |
|
191 | 195 | |
|
192 | 196 | var files = myDropzone.getQueuedFiles(); |
|
193 | 197 | if (files.length === 0) { |
|
194 | 198 | alert("Missing files"); |
|
195 | 199 | e.preventDefault(); |
|
196 | 200 | } |
|
197 | 201 | |
|
198 | 202 | $('.upload-form').hide(); |
|
199 | 203 | $('.file-upload-transaction-wrapper').show(); |
|
200 | 204 | myDropzone.processQueue(); |
|
201 | 205 | |
|
202 | 206 | }); |
|
203 | 207 | |
|
204 | 208 | }); |
|
205 | 209 | |
|
206 | 210 | </script> |
|
207 | 211 | </%def> |
General Comments 0
You need to be logged in to leave comments.
Login now