Commit 9b4c827a711057a15977b72c5708f55e8fabb6bf

Authored by Karpikau Andrei
1 parent 3b923200

add choose and remove file buttons for content type

... ... @@ -1670,9 +1670,9 @@ jQuery(document).ready(function(){
1670 1670
1671 1671 $(document).on('click', '.content-choose-image', function(){
1672 1672 var $this = $(this),
1673   - $previewWrapper = $this.closest('.btn-group').next();
  1673 + $previewWrapper = $this.closest('.btn-group').prev();
1674 1674 chooseImageLayer($this.attr('href'), function(img_link, file_type){
1675   - $this.closest('.btn-group').prev().val(img_link);
  1675 + $this.closest('.btn-group').prev().prev().val(img_link);
1676 1676 if(file_type == 'image'){
1677 1677 var $preview = $('<div class="image-preview-block without-border">' +
1678 1678 '<div class="image-preview">' +
... ... @@ -1691,9 +1691,9 @@ jQuery(document).ready(function(){
1691 1691
1692 1692 $(document).on('click', '.content-remove-image', function(){
1693 1693 var $this = $(this),
1694   - $previewWrapper = $this.closest('.btn-group').next();
  1694 + $previewWrapper = $this.closest('.btn-group').prev();
1695 1695
1696   - $this.closest('.btn-group').prev().val('');
  1696 + $this.closest('.btn-group').prev().prev().val('');
1697 1697 $previewWrapper.html('');
1698 1698
1699 1699 $(this).addClass('not-visible');
... ...
... ... @@ -10,10 +10,6 @@
10 10 <% end %>
11 11 <% if form2.object.get_marker_type(@type_content) == 'file' %>
12 12 <%= form2.hidden_field :text_value %>
13   - <div class="btn-group">
14   - <%= link_to 'Choose Image', get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>
15   - <%= link_to 'Remove Image', get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %>
16   - </div>
17 13 <div class="preview">
18 14 <% if form2.object.text_value.present? %>
19 15 <% if Kanjai::PageContentMarker.image?(form2.object.text_value) %>
... ... @@ -27,6 +23,10 @@
27 23 <% end %>
28 24 <% end %>
29 25 </div>
  26 + <div class="btn-group">
  27 + <%= link_to 'Choose Image', get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>
  28 + <%= link_to 'Remove Image', get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %>
  29 + </div>
30 30 <% end %>
31 31 <% if form2.object.get_marker_type(@type_content) == 'form' %>
32 32 <div>
... ... @@ -107,10 +107,6 @@
107 107 <% end %>
108 108 <% if form2.object.get_marker_type(@type_content) == 'file' %>
109 109 <%= form2.hidden_field :text_value %>
110   - <div class="btn-group">
111   - <%= link_to 'Choose Image', get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>
112   - <%= link_to 'Remove Image', get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %>
113   - </div>
114 110 <div class="preview">
115 111 <% if form2.object.text_value.present? %>
116 112 <% if Kanjai::PageContentMarker.image?(form2.object.text_value) %>
... ... @@ -124,6 +120,10 @@
124 120 <% end %>
125 121 <% end %>
126 122 </div>
  123 + <div class="btn-group">
  124 + <%= link_to 'Choose Image', get_files_admin_images_url, class: 'btn btn-primary content-choose-image' %>
  125 + <%= link_to 'Remove Image', get_files_admin_images_url, class: "btn btn-danger content-remove-image #{form2.object.text_value.present? ? '' : 'not-visible'}" %>
  126 + </div>
127 127 <% end %>
128 128
129 129 </div>
... ...