update media field type

This commit is contained in:
vedatakd 2020-01-29 15:46:28 +03:00
parent 1357816544
commit 51c02ba8a6
4 changed files with 65 additions and 69 deletions

View File

@ -1,9 +1,11 @@
.ads-responsive-image {
width: 152px;
}
.ads-box-image {
padding: 5px;
}
.ads-responsive-image {
height: 100px!important;
}
.ads-box-image:hover {
padding: 5px;
transform: scale(1.1);
@ -15,7 +17,7 @@
.main-image {
background-color: #5cb85c;
height: 25px;
width: 25px;
width: 40px;
color: #fff;
position: absolute;
z-index: 15;
@ -23,16 +25,13 @@
top: 0px;
}
#setimage {
margin: -3px;
padding: 0px 10px;
padding: 9px 10px;
color: white;
border-radius: 0px;
font-weight: bold;
}
/*Mobil Modu*/
@media only screen and (max-width: 600px) {
.ads-responsive-image {
width: 80%;
height: 20vh;
}
.ads-box-image {
padding: 5px;
margin: 10px;
@ -44,10 +43,6 @@
/*Tablet Modu*/
@media only screen and (max-width: 767px) and (min-width: 601px) {
.ads-responsive-image {
width: 50%;
height: 20vh;
}
#setimage {
width: 17%;
}

View File

@ -2,9 +2,9 @@
Dropzone.autoDiscover = false;
$("div#myDrop").dropzone({url: "/file/post"});
var uploaded = $('input[name="files"]').val().split(',').map(Number);
$(function () {
var uploaded = [];
var uploader = $('#upload');
var element = $('.dropzone');
@ -78,6 +78,8 @@ $(function () {
file.previewElement.querySelector('[data-dz-uploadprogress]').setAttribute('class', 'progress progress-success');
setTimeout(function () {
addAppendByData(uploaded[0])
file.previewElement.remove();
}, 500);
});
@ -95,48 +97,40 @@ function addAppendByData(data_id) {
return $('a[data-id=' + data_id + ']').parent().parent().append('<div class="main-image image-eye-' + data_id + '"><i class="fa fa-eye "></i></div>');
}
$('.panel-table').on('click', '[data-dismiss="file"]', function (e) {
var arr = $('input[name="files"]').val().split(',');
arr.splice(arr.indexOf(String($(this).data('file'))), 1);
$('.panel-table').load(
REQUEST_ROOT_PATH + '/streams/media-field_type/selected?uploaded=' + arr.join(','),
function () {
$('input[name="files"]').val(arr.join(','))
}
);
});
function deleteImage(id) {
var key_item = $.inArray(id, uploaded);
uploaded.splice(key_item, 1);
$('input[name="files"]').val(uploaded.join(','))
$('.imageList').find('div[data-id="' + id + '"]').remove()
}
$('a[data-action="rotate-image"]').click(function () {
var event = $(this).parent('div').parent('div').find('img');
var img = event.attr('src');
function rotateImage(id) {
var img = $('.ads-box-image[data-id="' + id + '"]').find('img')
var img_url = img.attr('src');
$.ajax({
type: 'get',
dataType: "json",
data: {img_url: img},
data: {img_url: img_url},
url: '/image/rotate',
success: function (response) {
if (response.status == "success") {
hideLoader()
var newURL = updateQueryStringParameter(img, 't', Math.floor(Math.random() * 100000000));
event.attr('src', newURL);
var newURL = updateQueryStringParameter(img_url, 't', Math.floor(Math.random() * 100000000));
img.attr('src', newURL);
}
},
beforeSend: function () {
showLoader()
}
});
});
}
//Set Main İmage
function setMain(id) {
var imageList = $('[name="files"]').val().split(',');
$('.image-eye-' + imageList[0]).remove();
if (imageList.length != 1) {
imageList.splice($.inArray(id, imageList), 1);
$('[name="files"]').val(id + ',' + imageList.join(','));
}
$('.image-eye-' + uploaded[0]).remove();
var key_item = $.inArray(id, uploaded);
uploaded.splice(key_item, 1);
uploaded.unshift(id);
$('input[name="files"]').val(uploaded.join(','))
addAppendByData(id);
}

View File

@ -1,16 +1,17 @@
{{ asset_add("styles.css", "visiosoft.field_type.media::css/imgList.css") }}
{{ asset_add('scripts.js', 'visiosoft.field_type.media::js/input.js') }}
<div class="row">
{% for row in table.rows %}
<div class="col-xs-12 col-sm-3 ads-box-image">
<div class="card text-center">
<a class="img-card">
<img class="ads-responsive-image" height="114px" src="{{ url('files/' ~ row.columns.0.value) }}" alt="" />
</a>
<div class="card-read-more text-center">
{{ buttons(row.buttons)|raw }}
</div>
</div>
</div>
{% endfor %}
</div>
<div class="row imageList">
{% for row in table.rows %}
<div class="col-12 col-sm-3 ads-box-image" data-id="{{ row.key }}">
<div class="card text-center">
<a class="img-card">
<img class="ads-responsive-image img-thumbnail" src="{{ url('files/' ~ row.columns.0.value) }}"
alt=""/>
</a>
<div class="card-read-more text-center row">
{{ buttons(row.buttons)|raw }}
</div>
</div>
</div>
{% endfor %}
</div>

View File

@ -52,31 +52,37 @@ class ValueTableBuilder extends TableBuilder
* @var array
*/
protected $buttons = [
'window' => [
'window' => [
'text' => 'visiosoft.field_type.media::button.showOn',
'icon' => 'fa fa-eye',
'type' => 'success',
'data-id' => 'entry.id',
'class' => 'col-4',
'attributes' => [
'id' => 'setimage',
'onclick' => 'setMain({entry.id})'
],
],
'rotate' => [
'target' => '_blank',
'rotate' => [
'target' => '_blank',
'icon' => 'fas fa-redo',
'type' => 'info',
'text' => '',
'class' => 'col-4',
'attributes' => [
'id' => 'setimage',
'data-action' => 'rotate-image',
// 'data-action' => 'rotate-image',
'onclick' => 'rotateImage({entry.id})',
],
],
'remove' => [
'data-dismiss' => 'file',
'data-file' => 'entry.id',
'deleteImage' => [
'target' => '_blank',
'icon' => 'fas fa-trash',
'type' => 'danger',
'text' => '',
'class' => 'col-4 deleteImage',
'attributes' => [
'onclick' => 'deleteImage({entry.id})',
'id' => 'setimage',
],
],
@ -88,10 +94,10 @@ class ValueTableBuilder extends TableBuilder
* @var array
*/
protected $options = [
'limit' => 9999,
'show_headers' => false,
'sortable_headers' => false,
'table_view' => 'visiosoft.field_type.media::table/table',
'limit' => 9999,
'show_headers' => false,
'sortable_headers' => false,
'table_view' => 'visiosoft.field_type.media::table/table',
'no_results_message' => 'visiosoft.field_type.media::message.no_files_selected',
];
@ -156,7 +162,7 @@ class ValueTableBuilder extends TableBuilder
/**
* Set the field type.
*
* @param MediaFieldType $fieldType
* @param MediaFieldType $fieldType
* @return $this
*/
public function setFieldType(MediaFieldType $fieldType)
@ -192,7 +198,7 @@ class ValueTableBuilder extends TableBuilder
/**
* Set the table entries.
*
* @param \Illuminate\Support\Collection $entries
* @param \Illuminate\Support\Collection $entries
* @return $this
*/
public function setTableEntries(\Illuminate\Support\Collection $entries)