Commit a565819f5c0e68223c1641a462394beea3eb7a5e
1 parent
751c77d3
check choose image from modal, not popup, check image lis
Showing
9 changed files
with
97 additions
and
52 deletions
| ... | ... | @@ -1324,6 +1324,44 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterat |
| 1324 | 1324 | var csrf_token = $('meta[name=csrf-token]').attr('content'), |
| 1325 | 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 | 1367 | $('.delete-row-item').click(function(){ |
| ... | ... | @@ -1589,49 +1627,18 @@ jQuery(document).ready(function(){ |
| 1589 | 1627 | type: 'POST', |
| 1590 | 1628 | url: galleryUrl, |
| 1591 | 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 | ... | ... |
| ... | ... | @@ -5,6 +5,7 @@ module Kanjai |
| 5 | 5 | belongs_to :object, polymorphic: true, optional: true |
| 6 | 6 | |
| 7 | 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 | 10 | # has_attached_file :image, |
| 10 | 11 | # :styles => {:mini => '200x200>'}, | ... | ... |
| 1 | 1 | <div class="card-columns"> |
| 2 | 2 | <% collection.each do |item| %> |
| 3 | 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 | 15 | <div class="card-body"> |
| 6 | 16 | <div class="content"> |
| 7 | 17 | <h4 class="card-title"><%= item.title %></h4> |
| 8 | 18 | <p class="card-text"><%= Kanjai::Image.human_attribute_name(:size) %>: <%= number_to_human_size(item.file_size) %></p> |
| 9 | 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 | 22 | </div> |
| 11 | 23 | <div class="action"> |
| 12 | 24 | <div class="dropdown dropleft without-icon"> |
| ... | ... | @@ -15,7 +27,7 @@ |
| 15 | 27 | </button> |
| 16 | 28 | <ul class="dropdown-menu" style="padding-left:0;"> |
| 17 | 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 | 31 | </ul> |
| 20 | 32 | </div> |
| 21 | 33 | </div> | ... | ... |
app/views/kanjai/admin/images/delete_gallery_image.js.erb
deleted
100644 → 0
| 1 | -$('#gallery_image_<%= @image.id %>').remove(); | |
| \ No newline at end of file |
| 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">×</button> | |
| 6 | 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 | 26 | </div> |
| \ No newline at end of file | ... | ... |
| ... | ... | @@ -42,6 +42,7 @@ en: |
| 42 | 42 | password_reset_text: "Fill with your mail to receive instructions on how to reset your password." |
| 43 | 43 | password_reset_email: "Email address" |
| 44 | 44 | password_reset_error: "Can not send instrution, please check email" |
| 45 | + rte_choose_image: "Choose Image" | |
| 45 | 46 | |
| 46 | 47 | |
| 47 | 48 | date: |
| ... | ... | @@ -51,6 +52,7 @@ en: |
| 51 | 52 | formats: |
| 52 | 53 | default: "%d.%m.%Y %H:%M" |
| 53 | 54 | full: "%d.%m.%Y %H:%M:%S" |
| 55 | + short: "%d.%m.%Y" | |
| 54 | 56 | time_zone: |
| 55 | 57 | formats: |
| 56 | 58 | default: "%d.%m.%Y %H:%M" |
| ... | ... | @@ -91,6 +93,8 @@ en: |
| 91 | 93 | tags: "Tags" |
| 92 | 94 | size: "Size" |
| 93 | 95 | format: "Format" |
| 96 | + created_at: "Upload Date" | |
| 97 | + public_url: "URL" | |
| 94 | 98 | kanjai/page_datum: |
| 95 | 99 | meta_title: Meta Title |
| 96 | 100 | meta_description: Meta Description |
| ... | ... | @@ -111,6 +115,7 @@ en: |
| 111 | 115 | enable: "Enable" |
| 112 | 116 | edit_with_lang: "Edit %{lang}" |
| 113 | 117 | duplicate: "Duplicate" |
| 118 | + copy: "Copy" | |
| 114 | 119 | |
| 115 | 120 | admin: |
| 116 | 121 | page_structure: | ... | ... |