imagine_cms 5.2.0 → 5.2.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile +16 -42
  3. data/README.md +28 -11
  4. data/app/assets/javascripts/dojo/dojo.js +1 -1
  5. data/app/assets/javascripts/dojo/src/widget/templates/richtextframe.html +3 -0
  6. data/app/assets/javascripts/imagine_cms/core.js +31 -40
  7. data/app/assets/stylesheets/imagine_cms.css.scss +15 -7
  8. data/app/assets/stylesheets/imagine_controls.css.scss +45 -2
  9. data/app/controllers/cms/content_controller.rb +2 -2
  10. data/app/controllers/manage/cms_pages_controller.rb +34 -25
  11. data/app/helpers/cms_application_helper.rb +27 -27
  12. data/app/helpers/cms_custom_helper.rb +13 -0
  13. data/app/mailers/imagine_cms_mailer.rb +1 -1
  14. data/app/views/imagine_cms/_dialogs.html.erb +3 -3
  15. data/app/views/imagine_cms/_header.html.erb +8 -8
  16. data/app/views/imagine_cms_mailer/request_review.text.erb +0 -2
  17. data/app/views/layouts/management.html.erb +5 -4
  18. data/app/views/manage/cms_pages/_create_file_link.html.erb +16 -3
  19. data/app/views/manage/cms_pages/_crop_feature_image.html.erb +1 -1
  20. data/app/views/manage/cms_pages/_crop_image.html.erb +31 -29
  21. data/app/views/manage/cms_pages/_crop_thumb.html.erb +1 -1
  22. data/app/views/manage/cms_pages/_edit_page.html.erb +18 -4
  23. data/app/views/manage/cms_pages/_list_page.html.erb +28 -7
  24. data/app/views/manage/cms_pages/_list_page_select.html.erb +17 -7
  25. data/app/views/manage/cms_pages/_list_pages.html.erb +1 -1
  26. data/app/views/manage/cms_pages/_list_pages_select.html.erb +1 -1
  27. data/app/views/manage/cms_pages/_page_list.html.erb +5 -5
  28. data/app/views/manage/cms_pages/_page_list_source_tag.html.erb +6 -2
  29. data/app/views/manage/cms_pages/_upload_feature_image.html.erb +51 -11
  30. data/app/views/manage/cms_pages/_upload_file.html.erb +2 -2
  31. data/app/views/manage/cms_pages/_upload_image.html.erb +95 -23
  32. data/app/views/manage/cms_pages/_upload_thumb.html.erb +51 -11
  33. data/app/views/manage/cms_pages/gallery_management.html.erb +1 -1
  34. data/app/views/manage/cms_pages/index.html.erb +36 -35
  35. data/app/views/manage/cms_pages/select_page.html.erb +39 -39
  36. data/app/views/manage/cms_pages/toolbar_preview.html.erb +1 -1
  37. data/app/views/management/users/index.html.erb +1 -1
  38. data/docker-compose.override.yml.example +6 -19
  39. data/docker-compose.yml +5 -7
  40. data/docker/conf/{nginx-vhost.conf → nginx-vhost.conf.template} +3 -3
  41. data/docker/services/{memcached.sh → memcached} +0 -0
  42. data/docker/services/{sidekiq.sh → sidekiq} +0 -0
  43. data/docker/services/{webpack.sh → webpack} +0 -0
  44. data/lib/extensions/action_controller_extensions.rb +18 -17
  45. data/lib/imagine_cms/engine.rb +1 -0
  46. data/lib/imagine_cms/version.rb +1 -1
  47. data/lib/upload_progress/lib/multipart_progress.rb +1 -1
  48. metadata +11 -11
@@ -197,7 +197,7 @@ Pressing "Save Thumbnail" will crop the thumbnail and set it as the new thumbnai
197
197
  </tr>
198
198
  </table>
199
199
 
200
- <%= submit_tag 'Save Thumbnail', :class => 'form_button', :onclick => 'cropper.remove(); this.disabled = true; this.value = "Saving...";' %>
200
+ <%= submit_tag 'Save Thumbnail', class: 'form_button', data: { disable_with: 'Saving...' } %>
201
201
  <%= link_to_function "Cancel", "cancelSelectThumbnail()" %>
202
202
  <%- end -%>
203
203
  </center>
@@ -21,7 +21,7 @@
21
21
  <table id="dlg-page-properties">
22
22
  <col width="120"><col width="*"><col width="5">
23
23
  <%- if @pg.id != 1 -%>
24
- <tr>
24
+ <tr id="cms_page-form-name-row">
25
25
  <td>Name (for URL):</td>
26
26
  <td>
27
27
  <%= text_field :pg, :name, class: 'form', style: 'margin-bottom: 0; width: 150px', onchange: (@pg.new_record? ? '' : "if (!confirm('Are you sure you want to change the name of this page? Any bookmarks or links to this page will no longer work if you proceed with this change.')) { this.value = $('original_name').value; };") %><br/>
@@ -30,6 +30,15 @@
30
30
  </td>
31
31
  </tr>
32
32
  <%- end -%>
33
+ <tr id="cms_page-form-parent_id-row" style="display: none;">
34
+ <td>Parent Page ID:</td>
35
+ <td><%= text_field :pg, :parent_id, class: 'form', style: 'width: 100%;' %></td>
36
+ </tr>
37
+ <script>
38
+ let nameRow = document.getElementById("cms_page-form-name-row");
39
+ let parentIdRow = document.getElementById("cms_page-form-parent_id-row");
40
+ if (nameRow && parentIdRow) nameRow.addEventListener("click", (e) => { if (e.altKey) { parentIdRow.style.display = "table-row"; } });
41
+ </script>
33
42
  <tr>
34
43
  <td>Page Title:</td>
35
44
  <td><%= text_field :pg, :title, class: 'form', style: 'width: 100%;' %></td>
@@ -172,8 +181,13 @@
172
181
  <div style="position: relative;">
173
182
  <%= text_field_tag :custom_attribute_name, '', class: 'form', style: 'margin-bottom: 4px;', placeholder: '[ attribute name ]' %>
174
183
  <div id="custom_attribute_name_auto_complete" class="auto_complete" style="display: none;"></div>
175
- <%= javascript_tag "$('custom_attribute_name').onkeydown = disableEnterKey; new Autocompleter.Local('custom_attribute_name', 'custom_attribute_name_auto_complete', attrlist, { frequency: 0.1, minChars: 1 });" %>
176
-
184
+ <script type="text/javascript">
185
+ window.addEventListener('DOMContentLoaded', (event) => {
186
+ $('custom_attribute_name').onkeydown = disableEnterKey;
187
+ new Autocompleter.Local('custom_attribute_name', 'custom_attribute_name_auto_complete', attrlist, { frequency: 0.1, minChars: 1 });
188
+ });
189
+ </script>
190
+
177
191
  <%= button_to_function 'Add', "new Ajax.Updater('custom_attributes', '#{url_for(controller: '/manage/cms_pages', action: 'page_attribute')}?name=' + $('custom_attribute_name').value, {asynchronous:true, method:'get', evalScripts:true, insertion:Insertion.Bottom}); $('custom_attribute_name').value = ''; return false;", class: 'form_button', style: 'margin-bottom: 5px;' %>
178
192
  </div>
179
193
  </td>
@@ -196,7 +210,7 @@
196
210
  </tr>
197
211
  </table>
198
212
  <% end -%>
199
- <<script type="text/javascript">
213
+ <script type="text/javascript">
200
214
  jQuery('#pg_cms_template_id').change(function () {
201
215
  jQuery.get('<%= url_for(action: 'show_template_options', id: @pg) %>?template_id=' + jQuery(this).val(), null, function (data) {
202
216
  jQuery('#edit_page_template_options').html(data);
@@ -1,8 +1,29 @@
1
- <div id="<%= "cb_item_#{list_page.id}" %>" class="cb_item" style="width: 148px; overflow: hidden; margin: 2px; float: left; cursor: pointer" onclick="$('view_link').href = '<%= list_page.path.blank? ? '' : '/' + list_page.path %>/version/<%= list_page.published_version > 0 ? list_page.published_version : list_page.version %>'; $('new_link').onclick = function () { editProperties('<%=raw url_for action: 'new', mode: 'ajax_new', parent_id: list_page %>', 'Create New Page under /<%= list_page.path %>'); return false; }; $('edit_link').onclick = function () { editProperties('<%=raw url_for action: 'edit_page', id: list_page, mode: 'ajax_edit' %>', 'Page Properties: <%= list_page.name %>'); return false; }; $('edit_content_link').href = '<%=raw url_for action: 'edit_page_content', id: list_page %>'; $('delete_link').href = '<%=raw url_for action: 'delete_page', id: list_page.id %>'; setTimeout('cbSelectItem(\'' + this.id + '\', <%= @page_level %>, \'<%=raw url_for action: 'list_pages', level: @page_level + 1, parent_id: list_page.id %>\');', 200);" ondblclick="$('edit_content_link').click();">
2
- <table cellpadding="0" cellspacing="0" border="0">
3
- <tr>
4
- <td valign="top"><%= image_tag 'management/icon_page.gif', style: 'margin: 2px 5px 0 0;' %></td>
5
- <td<%= list_page.published_version >= 0 ? '' : ' style="color: gray"'.html_safe %>><%= list_page.name %></td>
6
- </tr>
7
- </table>
1
+ <div id="cb_item_<%= list_page.id %>" class="cb_item<%= ' cb_item_offline' unless list_page.published_version >= 0 %>">
2
+ <%= image_tag 'management/icon_page.gif' %></td>
3
+ <span><%= list_page.name %></span>
8
4
  </div>
5
+
6
+ <script type="text/javascript">
7
+ jQuery('#cb_item_<%= list_page.id %>').on('click', () => {
8
+ jQuery('#view_link').prop('href', '<%= list_page.path.blank? ? '' : '/' + list_page.path %>/version/<%= list_page.published_version > 0 ? list_page.published_version : list_page.version %>');
9
+ jQuery('#new_link').off('click');
10
+ jQuery('#new_link').on('click', () => {
11
+ editProperties('<%=raw url_for action: 'new', mode: 'ajax_new', parent_id: list_page %>', 'Create New Page under /<%= list_page.path %>');
12
+ return false;
13
+ });
14
+ jQuery('#edit_link').off('click');
15
+ jQuery('#edit_link').on('click', () => {
16
+ editProperties('<%=raw url_for action: 'edit_page', id: list_page, mode: 'ajax_edit' %>', 'Page Properties: <%= list_page.name %>');
17
+ return false;
18
+ });
19
+ jQuery('#edit_content_link').prop('href', '<%=raw url_for action: 'edit_page_content', id: list_page %>');
20
+ jQuery('#delete_link').prop('href', '<%=raw url_for action: 'delete_page', id: list_page.id %>');
21
+ setTimeout(() => {
22
+ cbSelectItem('#cb_item_<%= list_page.id %>', <%= @page_level %>, '<%=raw url_for action: 'list_pages', level: @page_level + 1, parent_id: list_page.id %>');
23
+ }, 200);
24
+ });
25
+ jQuery('#cb_item_<%= list_page.id %>').on('dblclick', (event) => {
26
+ location.href = jQuery('#edit_content_link')[0].href;
27
+ return false;
28
+ });
29
+ </script>
@@ -1,8 +1,18 @@
1
- <div id="<%= "cb_item_#{list_page_select.id}" %>" class="cb_item" style="width: 148px; overflow: hidden; margin: 2px; float: left; cursor: pointer" onclick="$('page_browser_selection').value = '/<%= list_page_select.path %>'; setTimeout('cbSelectItem(\'' + this.id + '\', <%= @page_level %>, \'<%=raw url_for :action => 'list_pages_select', :level => @page_level + 1, :parent_id => list_page_select.id %>\');', 200);" ondblclick="return false;">
2
- <table cellpadding="0" cellspacing="0" border="0">
3
- <tr>
4
- <td valign="top"><%= image_tag 'management/icon_page.gif', style: 'margin: 2px 5px 0 0;' %></td>
5
- <td<%= list_page_select.published_version >= 0 ? '' : ' style="color: gray"'.html_safe %>><%= list_page_select.name %></td>
6
- </tr>
7
- </table>
1
+ <%- list_page = list_page_select -%>
2
+
3
+ <div id="cb_item_<%= list_page.id %>" class="cb_item<%= ' cb_item_offline' unless list_page.published_version >= 0 %>">
4
+ <%= image_tag 'management/icon_page.gif' %></td>
5
+ <span><%= list_page.name %></span>
8
6
  </div>
7
+
8
+ <script type="text/javascript">
9
+ jQuery('#cb_item_<%= list_page.id %>').on('click', () => {
10
+ jQuery('#page_browser_selection').val('/<%= list_page.path %>');
11
+ setTimeout(() => {
12
+ cbSelectItem('#cb_item_<%= list_page.id %>', <%= @page_level %>, '<%=raw url_for action: 'list_pages_select', level: @page_level + 1, parent_id: list_page.id %>');
13
+ }, 200);
14
+ });
15
+ jQuery('#cb_item_<%= list_page.id %>').on('dblclick', (event) => {
16
+ return false;
17
+ });
18
+ </script>
@@ -1 +1 @@
1
- <%= render :partial => 'list_page', :collection => @pages %>
1
+ <%= render partial: 'list_page', collection: @pages %>
@@ -1 +1 @@
1
- <%= render :partial => 'list_page_select', :collection => @pages %>
1
+ <%= render partial: 'list_page_select', collection: @pages %>
@@ -177,12 +177,12 @@
177
177
  </div>
178
178
 
179
179
  <script type="text/javascript">
180
- var displayAsList = jQuery('#page_objects_<%= key %>-style-display-as_list').checked;
181
- jQuery('.page_list_<%= key %>_list_option').toggle(displayAsList);
182
- jQuery('.page_list_<%= key %>_calendar_option').toggle(!displayAsList);
183
-
184
180
  // reattach to a safe place in the DOM (away from styled regions)
185
- jQuery(document).ready(function () {
181
+ window.addEventListener('DOMContentLoaded', (event) => {
182
+ var displayAsList = jQuery('#page_objects_<%= key %>-style-display-as_list').checked;
183
+ jQuery('.page_list_<%= key %>_list_option').toggle(displayAsList);
184
+ jQuery('.page_list_<%= key %>_calendar_option').toggle(!displayAsList);
185
+
186
186
  jQuery('#page_list_<%= key %>').appendTo(jQuery('#page_content_form')[0]);
187
187
  jQuery('#page_objects_<%= key %>-style-display-as_list').click(function () {
188
188
  jQuery('.page_list_<%= key %>_list_option').show();
@@ -8,11 +8,15 @@
8
8
  <%= text_field(:page_objects, "#{key}-sources-tag#{i}", :class => 'form', :style => 'margin: 0; padding: 2px; border: 1px solid gray; width: 98%;') %>
9
9
 
10
10
  <div id="page_objects_<%= key %>-sources-tag<%= i %>_auto_complete" class="auto_complete" style="display: none;"></div>
11
- <%= javascript_tag "new Autocompleter.Local('page_objects_#{key}-sources-tag#{i}', 'page_objects_#{key}-sources-tag#{i}_auto_complete', taglist, { frequency: 0.1, minChars: 1 })" %>
11
+ <script type="text/javascript">
12
+ window.addEventListener('DOMContentLoaded', (event) => {
13
+ new Autocompleter.Local('page_objects_<%= key %>-sources-tag<%= i %>', 'page_objects_<%= key %>-sources-tag<%= i %>_auto_complete', taglist, { frequency: 0.1, minChars: 1 });
14
+ });
15
+ </script>
12
16
  </td>
13
17
  <td>
14
18
  <%= select(:page_objects, "#{key}-sources-tag#{i}-behavior", [ 'include', 'exclude', 'require' ], {}, :class => 'form', :style => 'margin: 0; padding: 1px; border: 1px solid gray; width: 100%;') %>
15
19
  </td>
16
20
  </tr>
17
21
  </table>
18
- </div>
22
+ </div>
@@ -5,31 +5,71 @@
5
5
  certain your image is already web-ready. Otherwise, click "Next" to crop and
6
6
  resize your image before using it.</p>
7
7
 
8
- <%= form_tag_with_upload_progress({ :action => 'receive_image', :id => @pg, :overwrite => 1 },
9
- { :finish => "if (arguments[0]) { $('filename').value = arguments[0]; $('mainform').onsubmit(); }" }) do -%>
8
+ <%= form_tag({ action: 'receive_image', id: @pg, overwrite: 1 }, { id: 'upload-image-form', multipart: true }) do %>
10
9
  <table>
11
10
  <tr>
12
11
  <td>File:</td>
13
12
  <td>
14
- <%= file_field 'file', 'data', :class => 'form', :style => 'margin-bottom: 0; width: 150px' %><br/>
13
+ <%= file_field 'file', 'data', :class => 'form', :style => 'margin-bottom: 0; min-width: 150px' %><br/>
15
14
  <span style="color: #888888">Valid image types: jpeg, png, gif</span>
16
15
  </td>
17
16
  </tr>
18
17
  <tr>
19
18
  <td></td>
20
19
  <td>
21
- <div id="upload_status_div" class="error"><%= upload_status_tag %></div>
22
- <%= submit_tag 'Next', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('file_data').value == '') return false; $('next_clicked_upload').value = '1'; $('next_clicked').value = '1'; this.disabled = true; this.value = 'Uploading...';" %>
23
- <%= submit_tag 'Finish', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('file_data').value == '') return false; this.disabled = true; this.value = 'Uploading...';" %>
24
- <%= link_to_function "Cancel", "cancelSelectThumbnail()" %>
20
+ <%= submit_tag 'Next', id: 'upload-image-next-button', class: 'form_button', style: 'min-width: 70px' %>
21
+ <%= submit_tag 'Finish', id: 'upload-image-finish-button', class: 'form_button', style: 'min-width: 70px' %>
25
22
  <%= text_field_tag 'next_clicked_upload', '0', :style => 'display: none' %>
26
23
  </td>
27
24
  </tr>
28
25
  </table>
29
26
  <%- end -%>
30
27
 
31
- <%= form_remote_tag(:update => 'select_thumbnail_dialog_content', :html => { :id => 'mainform' },
32
- :url => { :action => 'crop_feature_image', :id => @pg }) do -%>
33
- <%= text_field_tag 'next_clicked', '0', :style => 'display: none' %>
34
- <%= text_field_tag 'filename', '', :style => 'display: none' %>
28
+ <%= form_remote_tag(update: 'select_thumbnail_dialog_content', html: { id: 'mainform' },
29
+ url: { action: 'crop_feature_image', id: @pg }) do %>
30
+ <%= text_field_tag 'next_clicked', '0', style: 'display: none' %>
31
+ <%= text_field_tag 'filename', '', style: 'display: none' %>
35
32
  <%- end -%>
33
+
34
+ <script>
35
+ const uploadImageForm = document.getElementById("upload-image-form");
36
+ const nextButton = document.getElementById("upload-image-next-button");
37
+ const finishButton = document.getElementById("upload-image-finish-button");
38
+ const uploadFileField = document.getElementById("file_data");
39
+
40
+ nextButton.addEventListener("click", (e) => {
41
+ e.target.dataset.disableWith = "Uploading...";
42
+ document.getElementById("next_clicked").value = "1";
43
+ });
44
+ finishButton.addEventListener("click", (e) => {
45
+ e.target.dataset.disableWith = "Uploading...";
46
+ });
47
+
48
+ uploadImageForm.addEventListener("submit", async (e) => {
49
+ e.preventDefault();
50
+
51
+ if (uploadFileField.value == "") {
52
+ setTimeout(() => {
53
+ nextButton.value = "Next";
54
+ finishButton.value = "Finish";
55
+ nextButton.dataset.disableWith = null;
56
+ finishButton.dataset.disableWith = null;
57
+ nextButton.disabled = false;
58
+ finishButton.disabled = false;
59
+ });
60
+ return;
61
+ }
62
+
63
+ let file = uploadFileField.files[0];
64
+ let formData = new FormData(uploadImageForm);
65
+
66
+ let resp = await fetch(uploadImageForm.action, {
67
+ method: 'POST',
68
+ body: formData
69
+ });
70
+ let data = await resp.json();
71
+
72
+ document.getElementById("filename").value = data.filename;
73
+ document.getElementById("mainform").onsubmit();
74
+ });
75
+ </script>
@@ -11,14 +11,14 @@
11
11
  <tr>
12
12
  <td>File:</td>
13
13
  <td>
14
- <%= file_field 'file', 'data', :class => 'form', :style => 'margin-bottom: 0; width: 150px' %>
14
+ <%= file_field 'file', 'data', class: 'form', style: 'margin-bottom: 0; min-width: 150px' %>
15
15
  </td>
16
16
  </tr>
17
17
  <tr>
18
18
  <td></td>
19
19
  <td>
20
20
  <div id="upload_status_div" class="error"><%= upload_status_tag %></div>
21
- <%= submit_tag 'Finish', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('file_data').value == '') return false; this.disabled = true; this.value = 'Uploading...';" %>
21
+ <%= submit_tag 'Finish', class: 'form_button', style: 'width: 70px;', data: { disable_with: 'Uploading...' } %>
22
22
  <%= link_to_function "Cancel", "cancelInsertFile()" %>
23
23
  </td>
24
24
  </tr>
@@ -1,4 +1,8 @@
1
- <%= javascript_tag "try { $('insert_file_dialog_content').innerHTML = ''; } catch (e) {}" %>
1
+ <script>
2
+ try {
3
+ document.getElementById("insert_file_dialog_content").innerHTML = "";
4
+ } catch (e) { }
5
+ </script>
2
6
 
3
7
  <div id="save_errors" class="error"></div>
4
8
  <h3 style="margin-bottom: 10px;">Insert Image</h3>
@@ -10,12 +14,11 @@
10
14
  certain your image is already web-ready. Otherwise, click "Next" to crop and
11
15
  resize your image before using it.</p>
12
16
 
13
- <%= form_tag_with_upload_progress({ :action => 'receive_image', :id => @pg },
14
- { :finish => "if (arguments[0]) { $('filename').value = arguments[0]; $('mainform').onsubmit(); }" }) do -%>
17
+ <%= form_tag({ action: 'receive_image', id: @pg }, { id: 'upload-image-form', multipart: true }) do %>
15
18
  <table>
16
19
  <tr>
17
20
  <td width="70">Image file:</td>
18
- <td><%= file_field 'file', 'data', :class => 'form', :style => 'margin-bottom: 0; width: 150px' %></td>
21
+ <td><%= file_field 'file', 'data', class: 'form', style: 'margin-bottom: 0; min-width: 250px' %></td>
19
22
  </tr>
20
23
  <tr>
21
24
  <td></td>
@@ -24,50 +27,119 @@
24
27
  <tr>
25
28
  <td></td>
26
29
  <td>
27
- <div id="upload_status_div" class="error"><%= upload_status_tag %></div>
28
- <%= submit_tag 'Next', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('file_data').value == '') return false; $('next_clicked_upload').value = '1'; $('next_clicked').value = '1'; this.disabled = true; this.value = 'Uploading...';" %>
29
- <%= submit_tag 'Finish', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('file_data').value == '') return false; this.disabled = true; this.value = 'Uploading...';" %>
30
+ <%= submit_tag 'Next', id: 'upload-image-next-button', class: 'form_button', style: 'min-width: 70px' %>
31
+ <%= submit_tag 'Finish', id: 'upload-image-finish-button', class: 'form_button', style: 'min-width: 70px' %>
30
32
  <%= link_to_function "Cancel", "cancelInsertImage()" %>
31
- <%= text_field_tag 'next_clicked_upload', '0', :style => 'display: none' %>
32
33
  </td>
33
34
  </tr>
34
35
  </table>
35
- <%- end -%>
36
- </fieldset><br/>
36
+ <% end %>
37
+ </fieldset><br>
37
38
 
38
39
  <fieldset>
39
40
  <legend>New Photo Gallery</legend>
40
41
 
41
42
  <p>Upload a zip file of images to create a photo gallery.</p>
42
43
 
43
- <%= form_tag_with_upload_progress({ :action => 'receive_gallery', :id => @pg },
44
- { :finish => "if (arguments[0]) { $('dirname').value = arguments[0]; $('mainform_gallery').onsubmit(); }" }) do -%>
44
+ <%= form_tag({ action: 'receive_gallery', id: @pg }, { id: 'upload-gallery-form', multipart: true }) do %>
45
45
  <table>
46
46
  <tr>
47
47
  <td width="70">Zip file:</td>
48
48
  <td>
49
- <%= file_field 'gallery_file', 'data', :class => 'form', :style => 'margin-bottom: 0; width: 150px' %><br/>
49
+ <%= file_field 'gallery_file', 'data', class: 'form', style: 'margin-bottom: 0; min-width: 250px' %><br/>
50
50
  </td>
51
51
  </tr>
52
52
  <tr>
53
53
  <td></td>
54
54
  <td>
55
- <div id="upload_status_div" class="error"><%= upload_status_tag %></div>
56
- <%= submit_tag 'Next', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('gallery_file_data').value == '') return false; this.disabled = true; this.value = 'Uploading...';" %>
55
+ <%= submit_tag 'Next', id: 'upload-gallery-next-button', class: 'form_button', style: 'min-width: 70px' %>
57
56
  <%= link_to_function "Cancel", "cancelInsertImage()" %>
58
57
  </td>
59
58
  </tr>
60
59
  </table>
61
- <%- end -%>
60
+ <% end %>
62
61
  </fieldset><br>
63
62
 
64
- <%= form_remote_tag(:update => 'insert_image_dialog_content', :html => { :id => 'mainform' },
65
- :url => { :action => 'crop_image', :id => @pg }) do -%>
66
- <%= text_field_tag 'next_clicked', '0', :style => 'display: none' %>
67
- <%= text_field_tag 'filename', '', :style => 'display: none' %>
63
+ <%= form_remote_tag(update: 'insert_image_dialog_content', html: { id: 'mainform' },
64
+ url: { action: 'crop_image', id: @pg }) do %>
65
+ <%= text_field_tag 'next_clicked', '0', style: 'display: none' %>
66
+ <%= text_field_tag 'filename', '', style: 'display: none' %>
68
67
  <%- end -%>
69
68
 
70
- <%= form_remote_tag(:update => 'insert_image_dialog_content', :html => { :id => 'mainform_gallery' },
71
- :url => { :action => 'gallery_setup', :id => @pg }) do -%>
72
- <%= text_field_tag :dirname, '', :style => 'display: none' %>
69
+ <%= form_remote_tag(update: 'insert_image_dialog_content', html: { id: 'mainform_gallery' },
70
+ url: { action: 'gallery_setup', id: @pg }) do %>
71
+ <%= text_field_tag :dirname, '', style: 'display: none' %>
73
72
  <%- end -%>
73
+
74
+ <script>
75
+ const uploadImageForm = document.getElementById("upload-image-form");
76
+ const uploadGalleryForm = document.getElementById("upload-gallery-form");
77
+ const nextButton = document.getElementById("upload-image-next-button");
78
+ const finishButton = document.getElementById("upload-image-finish-button");
79
+ const uploadFileField = document.getElementById("file_data");
80
+ const galleryNextButton = document.getElementById("upload-gallery-next-button");
81
+
82
+ nextButton.addEventListener("click", (e) => {
83
+ e.target.dataset.disableWith = "Uploading...";
84
+ document.getElementById("next_clicked").value = "1";
85
+ });
86
+ finishButton.addEventListener("click", (e) => {
87
+ e.target.dataset.disableWith = "Uploading...";
88
+ });
89
+ galleryNextButton.addEventListener("click", (e) => {
90
+ e.target.dataset.disableWith = "Uploading...";
91
+ });
92
+
93
+ uploadImageForm.addEventListener("submit", async (e) => {
94
+ e.preventDefault();
95
+
96
+ if (uploadFileField.value == "") {
97
+ setTimeout(() => {
98
+ nextButton.value = "Next";
99
+ finishButton.value = "Finish";
100
+ nextButton.dataset.disableWith = null;
101
+ finishButton.dataset.disableWith = null;
102
+ nextButton.disabled = false;
103
+ finishButton.disabled = false;
104
+ });
105
+ return;
106
+ }
107
+
108
+ let file = uploadFileField.files[0];
109
+ let formData = new FormData(uploadImageForm);
110
+
111
+ let resp = await fetch(uploadImageForm.action, {
112
+ method: 'POST',
113
+ body: formData
114
+ });
115
+ let data = await resp.json();
116
+
117
+ document.getElementById("filename").value = data.filename;
118
+ document.getElementById("mainform").onsubmit();
119
+ });
120
+
121
+ uploadGalleryForm.addEventListener("submit", async (e) => {
122
+ e.preventDefault();
123
+
124
+ if (uploadFileField.value == "") {
125
+ setTimeout(() => {
126
+ galleryNextButton.value = "Next";
127
+ galleryNextButton.dataset.disableWith = null;
128
+ galleryNextButton.disabled = false;
129
+ });
130
+ return;
131
+ }
132
+
133
+ let file = uploadFileField.files[0];
134
+ let formData = new FormData(uploadImageForm);
135
+
136
+ let resp = await fetch(uploadImageForm.action, {
137
+ method: 'POST',
138
+ body: formData
139
+ });
140
+ let data = await resp.json();
141
+
142
+ document.getElementById("dirname").value = data.filename;
143
+ document.getElementById("mainform_gallery").onsubmit();
144
+ });
145
+ </script>
@@ -5,31 +5,71 @@
5
5
  certain your image is already web-ready. Otherwise, click "Next" to crop and
6
6
  resize your image before using it.</p>
7
7
 
8
- <%= form_tag_with_upload_progress({ :action => 'receive_image', :id => @pg, :overwrite => 1 },
9
- { :finish => "if (arguments[0]) { $('filename').value = arguments[0]; $('mainform').onsubmit(); }" }) do -%>
8
+ <%= form_tag({ action: 'receive_image', id: @pg, overwrite: 1 }, { id: 'upload-image-form', multipart: true }) do %>
10
9
  <table>
11
10
  <tr>
12
11
  <td>File:</td>
13
12
  <td>
14
- <%= file_field 'file', 'data', :class => 'form', :style => 'margin-bottom: 0; width: 150px' %><br/>
13
+ <%= file_field 'file', 'data', :class => 'form', :style => 'margin-bottom: 0; min-width: 150px' %><br>
15
14
  <span style="color: #888888">Valid image types: jpeg, png, gif</span>
16
15
  </td>
17
16
  </tr>
18
17
  <tr>
19
18
  <td></td>
20
19
  <td>
21
- <div id="upload_status_div" class="error"><%= upload_status_tag %></div>
22
- <%= submit_tag 'Next', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('file_data').value == '') return false; $('next_clicked_upload').value = '1'; $('next_clicked').value = '1'; this.disabled = true; this.value = 'Uploading...';" %>
23
- <%= submit_tag 'Finish', :class => 'form_button', :style => 'width: 70px;', :onclick => "if ($('file_data').value == '') return false; this.disabled = true; this.value = 'Uploading...';" %>
20
+ <%= submit_tag 'Next', id: 'upload-image-next-button', class: 'form_button', style: 'min-width: 70px' %>
21
+ <%= submit_tag 'Finish', id: 'upload-image-finish-button', class: 'form_button', style: 'min-width: 70px' %>
24
22
  <%= link_to_function "Cancel", "cancelSelectThumbnail()" %>
25
- <%= text_field_tag 'next_clicked_upload', '0', :style => 'display: none' %>
26
23
  </td>
27
24
  </tr>
28
25
  </table>
29
26
  <%- end -%>
30
27
 
31
- <%= form_remote_tag(:update => 'select_thumbnail_dialog_content', :html => { :id => 'mainform' },
32
- :url => { :action => 'crop_thumb', :id => @pg }) do -%>
33
- <%= text_field_tag 'next_clicked', '0', :style => 'display: none' %>
34
- <%= text_field_tag 'filename', '', :style => 'display: none' %>
28
+ <%= form_remote_tag(update: 'select_thumbnail_dialog_content', html: { id: 'mainform' },
29
+ url: { action: 'crop_thumb', id: @pg }) do %>
30
+ <%= text_field_tag 'next_clicked', '0', style: 'display: none' %>
31
+ <%= text_field_tag 'filename', '', style: 'display: none' %>
35
32
  <%- end -%>
33
+
34
+ <script>
35
+ const uploadImageForm = document.getElementById("upload-image-form");
36
+ const nextButton = document.getElementById("upload-image-next-button");
37
+ const finishButton = document.getElementById("upload-image-finish-button");
38
+ const uploadFileField = document.getElementById("file_data");
39
+
40
+ nextButton.addEventListener("click", (e) => {
41
+ e.target.dataset.disableWith = "Uploading...";
42
+ document.getElementById("next_clicked").value = "1";
43
+ });
44
+ finishButton.addEventListener("click", (e) => {
45
+ e.target.dataset.disableWith = "Uploading...";
46
+ });
47
+
48
+ uploadImageForm.addEventListener("submit", async (e) => {
49
+ e.preventDefault();
50
+
51
+ if (uploadFileField.value == "") {
52
+ setTimeout(() => {
53
+ nextButton.value = "Next";
54
+ finishButton.value = "Finish";
55
+ nextButton.dataset.disableWith = null;
56
+ finishButton.dataset.disableWith = null;
57
+ nextButton.disabled = false;
58
+ finishButton.disabled = false;
59
+ });
60
+ return;
61
+ }
62
+
63
+ let file = uploadFileField.files[0];
64
+ let formData = new FormData(uploadImageForm);
65
+
66
+ let resp = await fetch(uploadImageForm.action, {
67
+ method: 'POST',
68
+ body: formData
69
+ });
70
+ let data = await resp.json();
71
+
72
+ document.getElementById("filename").value = data.filename;
73
+ document.getElementById("mainform").onsubmit();
74
+ });
75
+ </script>