mirror of
https://github.com/openclassify/openclassify.git
synced 2026-02-09 23:06:08 -06:00
#3033 Change order of ad images
This commit is contained in:
parent
29a37d5da7
commit
62d7e8ba6e
@ -63,4 +63,8 @@
|
||||
.input-group-addon input[type=radio],
|
||||
.input-group-addon input[type=checkbox] {
|
||||
margin-top: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.ads-box-image:hover {
|
||||
cursor: move;
|
||||
}
|
||||
|
||||
@ -267,20 +267,22 @@ $(document).ready(function () {
|
||||
$('#configurationForm').submit(function (e) {
|
||||
e.preventDefault();
|
||||
crudAjax($(this).serialize(), '/advs/configuration/ajax/create', 'POST', function (callback) {
|
||||
$('.configuration-table').append(`<tr id="configuration-${callback.id}">
|
||||
<td>${callback.option_name}</td>
|
||||
<td>${callback.stock}</td>
|
||||
<td>${callback.currency_price}</td>
|
||||
<td class="text-right">
|
||||
<a href="javascript:void(0)" class="btn btn-sm remove-conf" data-id="${callback.id}"><svg id="Group_42321" data-name="Group 42321" xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30">
|
||||
<g id="Group_15874" data-name="Group 15874">
|
||||
<path id="Path_10381" data-name="Path 10381" d="M15,0A15,15,0,1,1,0,15,15,15,0,0,1,15,0Z" fill="#f8f8f8"></path>
|
||||
<path id="close" d="M10.557.6l-.6-.6L5.278,4.675.6,0,0,.6,4.675,5.278,0,9.953l.6.6L5.278,5.882l4.675,4.675.6-.6L5.882,5.278Z" transform="translate(9.5 9.5)" fill="#c7c7c7" stroke="#c7c7c7" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.7"></path>
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
</td>
|
||||
</tr>`);
|
||||
$('.configuration-table').append(`
|
||||
<tr id="configuration-${callback.id}">
|
||||
<td>${callback.option_name}</td>
|
||||
<td>${callback.stock}</td>
|
||||
<td>${callback.currency_price}</td>
|
||||
<td class="text-right">
|
||||
<a href="javascript:void(0)" class="btn btn-sm remove-conf" data-id="${callback.id}"><svg id="Group_42321" data-name="Group 42321" xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30">
|
||||
<g id="Group_15874" data-name="Group 15874">
|
||||
<path id="Path_10381" data-name="Path 10381" d="M15,0A15,15,0,1,1,0,15,15,15,0,0,1,15,0Z" fill="#f8f8f8"></path>
|
||||
<path id="close" d="M10.557.6l-.6-.6L5.278,4.675.6,0,0,.6,4.675,5.278,0,9.953l.6.6L5.278,5.882l4.675,4.675.6-.6L5.882,5.278Z" transform="translate(9.5 9.5)" fill="#c7c7c7" stroke="#c7c7c7" stroke-linecap="round" stroke-linejoin="round" stroke-width="0.7"></path>
|
||||
</g>
|
||||
</svg>
|
||||
</a>
|
||||
</td>
|
||||
</tr>
|
||||
`);
|
||||
$('#configurationForm').trigger("reset");
|
||||
})
|
||||
});
|
||||
@ -293,4 +295,33 @@ $(document).ready(function () {
|
||||
})
|
||||
});
|
||||
|
||||
// Add classified image sorting
|
||||
function getIdsOfImages() {
|
||||
var values = [];
|
||||
$('.imageList .ads-box-image').each(function (index) {
|
||||
values.push($(this).attr("data-id"));
|
||||
});
|
||||
|
||||
$('[name=files]').val(values.join(','));
|
||||
}
|
||||
|
||||
// Listen for the event.
|
||||
document.querySelector('#mediaSelectedWrapper').addEventListener('dropzone.changed', function (e) {
|
||||
setTimeout(function () {
|
||||
const imageList = $('.imageList');
|
||||
imageList.unbind();
|
||||
|
||||
imageList.sortable({
|
||||
update: function(event, ui) {
|
||||
getIdsOfImages();
|
||||
}
|
||||
});
|
||||
}, 500)
|
||||
}, false);
|
||||
|
||||
$( ".imageList" ).sortable({
|
||||
update: function(event, ui) {
|
||||
getIdsOfImages();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
<style>
|
||||
{{ asset_inline("visiosoft.module.advs::css/new-create.css") }}
|
||||
{{ asset_inline("visiosoft.module.advs::css/new-create-new.scss") }}
|
||||
{{ asset_inline("visiosoft.theme.base::css/jquery-ui.min.css") }}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
@ -344,5 +345,6 @@
|
||||
{{ asset_add("scripts.js", "visiosoft.module.advs::js/new-create.js") }}
|
||||
{{ asset_add("scripts.js", "streams::js/form/form.js") }}
|
||||
{{ asset_add("scripts.js", "streams::js/form/translations.js") }}
|
||||
{{ asset_add("scripts.js", "visiosoft.theme.base::js/vendor/jquery-ui.min.js") }}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
7
addons/default/visiosoft/base-theme/resources/css/jquery-ui.min.css
vendored
Normal file
7
addons/default/visiosoft/base-theme/resources/css/jquery-ui.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
addons/default/visiosoft/base-theme/resources/js/vendor/jquery-ui.min.js
vendored
Normal file
6
addons/default/visiosoft/base-theme/resources/js/vendor/jquery-ui.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -1,11 +1,13 @@
|
||||
// Add dropzone change event
|
||||
const event = new Event('dropzone.changed');
|
||||
|
||||
// Disabling autoDiscover, otherwise Dropzone will try to attach twice.
|
||||
Dropzone.autoDiscover = false;
|
||||
$("div#myDrop").dropzone({url: "/file/post"});
|
||||
|
||||
var doc_input = $('input[name="doc_files"]');
|
||||
|
||||
|
||||
var uploaded = $('input[name="files"]').val().split(',').map(Number);
|
||||
const getUploaded = () => $('input[name="files"]').val().split(',').map(Number);
|
||||
|
||||
if (doc_input.length) {
|
||||
var docsUploaded = doc_input.val().split(',').map(Number);
|
||||
@ -72,6 +74,7 @@ $(function () {
|
||||
var response = JSON.parse(file.xhr.response);
|
||||
var mimeType = response.mime_type.split('/')
|
||||
if (mimeType[0] === 'image') {
|
||||
let uploaded = getUploaded();
|
||||
uploaded.push(response.id);
|
||||
|
||||
$('.media-selected-wrapper').load(
|
||||
@ -84,9 +87,11 @@ $(function () {
|
||||
file.previewElement.querySelector('[data-dz-uploadprogress]').setAttribute('class', 'progress progress-success');
|
||||
|
||||
setTimeout(function () {
|
||||
|
||||
addAppendByData(uploaded[0])
|
||||
file.previewElement.remove();
|
||||
|
||||
// Dispatch the event.
|
||||
document.querySelector('#mediaSelectedWrapper').dispatchEvent(event);
|
||||
}, 500);
|
||||
} else {
|
||||
if (doc_input.length) {
|
||||
@ -126,6 +131,7 @@ function addAppendByData(data_id) {
|
||||
function deleteImage(e, id) {
|
||||
e.preventDefault()
|
||||
|
||||
let uploaded = getUploaded();
|
||||
var key_item = $.inArray(id, uploaded);
|
||||
uploaded.splice(key_item, 1);
|
||||
$('input[name="files"]').val(uploaded.join(','))
|
||||
@ -163,6 +169,8 @@ function rotateImage(e, id) {
|
||||
function setMain(e, id) {
|
||||
e.preventDefault()
|
||||
|
||||
let uploaded = getUploaded();
|
||||
|
||||
$('.main-image').remove();
|
||||
var key_item = $.inArray(id, uploaded);
|
||||
uploaded.splice(key_item, 1);
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
<input type="hidden" name="{{ field_type.input_name }}"
|
||||
value="{{ field_type.ids|join(',') }}" {{ html_attributes(field_type.attributes) }} {{ field_type.disabled ? 'disabled' }} {{ field_type.readonly ? 'readonly' }}>
|
||||
|
||||
<div class="selected media-selected-wrapper">
|
||||
<div class="selected media-selected-wrapper" id="mediaSelectedWrapper">
|
||||
{{ field_type.value_table|raw }}
|
||||
</div>
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user