Commit a565819f5c0e68223c1641a462394beea3eb7a5e

Authored by Karpikau Andrei
1 parent 751c77d3

check choose image from modal, not popup, check image lis

@@ -1324,6 +1324,44 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat @@ -1324,6 +1324,44 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat
1324 var csrf_token = $('meta[name=csrf-token]').attr('content'), 1324 var csrf_token = $('meta[name=csrf-token]').attr('content'),
1325 csrf_param = $('meta[name=csrf-param]').attr('content'); 1325 csrf_param = $('meta[name=csrf-param]').attr('content');
1326 1326
  1327 +$('body').on('click', '.delete-image-from-list', function(){
  1328 + var $this = $(this),
  1329 + url = $this.attr('href'),
  1330 + title = "Are you sure?";
  1331 +
  1332 + bootbox.confirm(title, function(result) {
  1333 + if(result){
  1334 + jQuery.ajax({
  1335 + type: 'GET',
  1336 + url: url,
  1337 + dataType: 'json',
  1338 + success: function(data){
  1339 + if(data.status == 'ok'){
  1340 + $('#gallery_image_' + data.id).remove();
  1341 + }
  1342 + }
  1343 +
  1344 + });
  1345 + }
  1346 + });
  1347 +
  1348 + return false;
  1349 +});
  1350 +
  1351 +$('body').on('click', '.copy-to-memory', function(){
  1352 + var str = $(this).data('str');
  1353 + var el = document.createElement('textarea');
  1354 + el.value = str;
  1355 + document.body.appendChild(el);
  1356 + el.select();
  1357 + document.execCommand('copy');
  1358 + document.body.removeChild(el);
  1359 +
  1360 + bootbox.alert('URL copied to memory');
  1361 +
  1362 + return false;
  1363 +});
  1364 +
1327 1365
1328 1366
1329 $('.delete-row-item').click(function(){ 1367 $('.delete-row-item').click(function(){
@@ -1589,49 +1627,18 @@ jQuery(document).ready(function(){ @@ -1589,49 +1627,18 @@ jQuery(document).ready(function(){
1589 type: 'POST', 1627 type: 'POST',
1590 url: galleryUrl, 1628 url: galleryUrl,
1591 success: function (data) { 1629 success: function (data) {
1592 - var $popover = $this.$original_element.closest('form').find('*[data-cmd="cms-image"]'),  
1593 - $data = $(data),  
1594 - layer_position = 'left'; 1630 + var $modal = $(data).modal({show:false, keyboard: false, backdrop: 'static'}).on('shown.bs.modal', function () {
  1631 + $modal.find('.gallery-item').click(function(){
  1632 + var img_link = $(this).attr('href');
1595 1633
1596 - if($this.$original_element.froalaEditor('fullscreen.isActive')){  
1597 - layer_position = 'bottom';  
1598 - $popover = $('.fr-fullscreen').find('*[data-cmd="cms-image"]');  
1599 - } 1634 + $this.$original_element.froalaEditor('image.insert', img_link, true, {});
1600 1635
1601 - $popover.popover({  
1602 - content: $data,  
1603 - html: true,  
1604 - trigger: 'manual',  
1605 - placement: layer_position  
1606 - }).on('shown.bs.popover', function () {  
1607 - var $obj = $($(this).data("bs.popover").getTipElement());  
1608 - $obj.addClass('rte-popover');  
1609 - if(!$this.$original_element.froalaEditor('fullscreen.isActive')){  
1610 - $obj.css('left', '-490px');  
1611 - }  
1612 - }).on('hidden.bs.popover', function () {  
1613 - $popover.popover('dispose');  
1614 - }).popover('show');  
1615 -  
1616 - $('body').on( 'click', function(e) {  
1617 - if($popover.next('.popover')){  
1618 - if ( !$popover.next('.popover').has(e.target).length ) {$popover.popover('dispose'); }  
1619 - } 1636 + return false;
  1637 + });
  1638 + }).on('hidden.bs.modal', function () {
  1639 + $modal.remove();
1620 }); 1640 });
1621 -  
1622 -  
1623 -  
1624 - $data.find('.gallery-item').click(function(){  
1625 - var img_link = $(this).attr('href');  
1626 -  
1627 - $this.$original_element.froalaEditor('image.insert', img_link, true, {});  
1628 - $popover.popover('dispose');  
1629 -  
1630 - return false;  
1631 - });  
1632 -  
1633 -  
1634 - 1641 + $modal.modal('show');
1635 } 1642 }
1636 }); 1643 });
1637 1644
@@ -5391,4 +5391,8 @@ body .jvectormap-zoomout { @@ -5391,4 +5391,8 @@ body .jvectormap-zoomout {
5391 .arrow:after{ 5391 .arrow:after{
5392 border-left-color:#f5f7fa; 5392 border-left-color:#f5f7fa;
5393 } 5393 }
  5394 +}
  5395 +
  5396 +.image-preview-in-list{
  5397 + margin:20px;
5394 } 5398 }
@@ -50,8 +50,8 @@ module Kanjai @@ -50,8 +50,8 @@ module Kanjai
50 50
51 def delete_gallery_image 51 def delete_gallery_image
52 @image = Image.find(params[:id]) 52 @image = Image.find(params[:id])
53 -  
54 @image.destroy 53 @image.destroy
  54 + render json: {status: 'ok', id: @image.id}
55 end 55 end
56 56
57 def get_gallery 57 def get_gallery
@@ -5,6 +5,7 @@ module Kanjai @@ -5,6 +5,7 @@ module Kanjai
5 belongs_to :object, polymorphic: true, optional: true 5 belongs_to :object, polymorphic: true, optional: true
6 6
7 IMAGE_MIME_TYPE = ['image/bmp', 'image/gif', 'image/jpeg', 'image/pipeg', 'image/svg+xml', 'image/png'] 7 IMAGE_MIME_TYPE = ['image/bmp', 'image/gif', 'image/jpeg', 'image/pipeg', 'image/svg+xml', 'image/png']
  8 + PDF_MIME_TYPE = ['application/pdf']
8 9
9 # has_attached_file :image, 10 # has_attached_file :image,
10 # :styles => {:mini => '200x200>'}, 11 # :styles => {:mini => '200x200>'},
1 <div class="card-columns"> 1 <div class="card-columns">
2 <% collection.each do |item| %> 2 <% collection.each do |item| %>
3 <div class="card mb-4" id="gallery_image_<%= item.id %>" > 3 <div class="card mb-4" id="gallery_image_<%= item.id %>" >
4 - <%= image_tag item.image_link, class: 'card-img-top img-fluid', alt: '' %> 4 + <% if Kanjai::Image::IMAGE_MIME_TYPE.include?(item.file_type) %>
  5 + <%= image_tag item.image_link, class: 'card-img-top img-fluid', alt: '' %>
  6 + <% else %>
  7 + <div class="text-center image-preview-in-list">
  8 + <% if Kanjai::Image::PDF_MIME_TYPE.include?(item.file_type) %>
  9 + <em class="fa-5x far fa-file-pdf text-primary"></em>
  10 + <% else %>
  11 + <em class="fa-5x far fa-file text-primary"></em>
  12 + <% end %>
  13 + </div>
  14 + <% end %>
5 <div class="card-body"> 15 <div class="card-body">
6 <div class="content"> 16 <div class="content">
7 <h4 class="card-title"><%= item.title %></h4> 17 <h4 class="card-title"><%= item.title %></h4>
8 <p class="card-text"><%= Kanjai::Image.human_attribute_name(:size) %>: <%= number_to_human_size(item.file_size) %></p> 18 <p class="card-text"><%= Kanjai::Image.human_attribute_name(:size) %>: <%= number_to_human_size(item.file_size) %></p>
9 <p class="card-text"><%= Kanjai::Image.human_attribute_name(:format) %>: <%= item.file_type %></p> 19 <p class="card-text"><%= Kanjai::Image.human_attribute_name(:format) %>: <%= item.file_type %></p>
  20 + <p class="card-text"><%= Kanjai::Image.human_attribute_name(:created_at) %>: <%= l(item.created_at, format: :short) %></p>
  21 + <p class="card-text"><%= Kanjai::Image.human_attribute_name(:public_url) %>: <%= item.image_link %> <%= link_to '<i class="fa fa-copy"></i>'.html_safe, '#', class: 'copy-to-memory', data: {str: item.image_link} %></p>
10 </div> 22 </div>
11 <div class="action"> 23 <div class="action">
12 <div class="dropdown dropleft without-icon"> 24 <div class="dropdown dropleft without-icon">
@@ -15,7 +27,7 @@ @@ -15,7 +27,7 @@
15 </button> 27 </button>
16 <ul class="dropdown-menu" style="padding-left:0;"> 28 <ul class="dropdown-menu" style="padding-left:0;">
17 <li class="dropdown-item"><%= link_to t('actions.edit'), edit_admin_image_url(item), class: 'dropdown-item show-in-layer', remote: true %></li> 29 <li class="dropdown-item"><%= link_to t('actions.edit'), edit_admin_image_url(item), class: 'dropdown-item show-in-layer', remote: true %></li>
18 - <li class="dropdown-item"><%= link_to t('actions.delete'), delete_gallery_image_admin_image_path(item), remote: true, :class => 'dropdown-item' %></li> 30 + <li class="dropdown-item"><%= link_to t('actions.delete'), delete_gallery_image_admin_image_path(item), :class => 'delete-image-from-list dropdown-item' %></li>
19 </ul> 31 </ul>
20 </div> 32 </div>
21 </div> 33 </div>
1 -$('#gallery_image_<%= @image.id %>').remove();  
1 -<div class="card-columns">  
2 - <% @collection.each do |item| %>  
3 - <a href="<%= item.image_link %>" class="gallery-item">  
4 - <div class="card mb-4" >  
5 - <%= image_tag item.image_link, class: 'card-img-top img-fluid', alt: '' %> 1 +<div class="modal" id="myModal">
  2 + <div class="modal-dialog modal-lg">
  3 + <div class="modal-content">
  4 +
  5 + <!-- Modal Header -->
  6 + <div class="modal-header">
  7 + <h4 class="modal-title"><%= t('rte_choose_image') %></h4>
  8 + <button type="button" class="close" data-dismiss="modal">&times;</button>
6 </div> 9 </div>
7 - </a>  
8 - <% end %> 10 +
  11 + <!-- Modal body -->
  12 + <div class="modal-body">
  13 + <div class="card-columns">
  14 + <% @collection.each do |item| %>
  15 + <a href="<%= item.image_link %>" class="gallery-item">
  16 + <div class="card mb-4" >
  17 + <%= image_tag item.image_link, class: 'card-img-top img-fluid', alt: '' %>
  18 + </div>
  19 + </a>
  20 + <% end %>
  21 + </div>
  22 + </div>
  23 +
  24 + </div>
  25 + </div>
9 </div> 26 </div>
@@ -42,6 +42,7 @@ en: @@ -42,6 +42,7 @@ en:
42 password_reset_text: "Fill with your mail to receive instructions on how to reset your password." 42 password_reset_text: "Fill with your mail to receive instructions on how to reset your password."
43 password_reset_email: "Email address" 43 password_reset_email: "Email address"
44 password_reset_error: "Can not send instrution, please check email" 44 password_reset_error: "Can not send instrution, please check email"
  45 + rte_choose_image: "Choose Image"
45 46
46 47
47 date: 48 date:
@@ -51,6 +52,7 @@ en: @@ -51,6 +52,7 @@ en:
51 formats: 52 formats:
52 default: "%d.%m.%Y %H:%M" 53 default: "%d.%m.%Y %H:%M"
53 full: "%d.%m.%Y %H:%M:%S" 54 full: "%d.%m.%Y %H:%M:%S"
  55 + short: "%d.%m.%Y"
54 time_zone: 56 time_zone:
55 formats: 57 formats:
56 default: "%d.%m.%Y %H:%M" 58 default: "%d.%m.%Y %H:%M"
@@ -91,6 +93,8 @@ en: @@ -91,6 +93,8 @@ en:
91 tags: "Tags" 93 tags: "Tags"
92 size: "Size" 94 size: "Size"
93 format: "Format" 95 format: "Format"
  96 + created_at: "Upload Date"
  97 + public_url: "URL"
94 kanjai/page_datum: 98 kanjai/page_datum:
95 meta_title: Meta Title 99 meta_title: Meta Title
96 meta_description: Meta Description 100 meta_description: Meta Description
@@ -111,6 +115,7 @@ en: @@ -111,6 +115,7 @@ en:
111 enable: "Enable" 115 enable: "Enable"
112 edit_with_lang: "Edit %{lang}" 116 edit_with_lang: "Edit %{lang}"
113 duplicate: "Duplicate" 117 duplicate: "Duplicate"
  118 + copy: "Copy"
114 119
115 admin: 120 admin:
116 page_structure: 121 page_structure:
1 module Kanjai 1 module Kanjai
2 - VERSION = "0.0.151" 2 + VERSION = "0.0.152"
3 end 3 end