Geoposicionador de cosas
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
/**
|
||||
* Scripts del admin - FP Geo Content
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
'use strict';
|
||||
|
||||
$(document).ready(function() {
|
||||
// Copiar shortcode al portapapeles
|
||||
$('.fp-geo-shortcode').on('click', function() {
|
||||
const text = $(this).text();
|
||||
navigator.clipboard.writeText(text).then(function() {
|
||||
alert('Shortcode copiado al portapapeles');
|
||||
});
|
||||
}).css('cursor', 'pointer').attr('title', 'Clic para copiar');
|
||||
|
||||
// Media uploader para icono personalizado
|
||||
let mediaUploader;
|
||||
|
||||
$('.fp-geo-upload-btn').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const targetId = $(this).data('target');
|
||||
const $input = $('#' + targetId);
|
||||
const $preview = $('#' + targetId + '_preview');
|
||||
const $removeBtn = $('.fp-geo-remove-btn[data-target="' + targetId + '"]');
|
||||
|
||||
// Si el uploader ya existe, abrirlo
|
||||
if (mediaUploader) {
|
||||
mediaUploader.open();
|
||||
return;
|
||||
}
|
||||
|
||||
// Crear el media uploader
|
||||
mediaUploader = wp.media({
|
||||
title: 'Seleccionar icono de marcador',
|
||||
button: {
|
||||
text: 'Usar este icono'
|
||||
},
|
||||
multiple: false,
|
||||
library: {
|
||||
type: 'image'
|
||||
}
|
||||
});
|
||||
|
||||
// Cuando se selecciona una imagen
|
||||
mediaUploader.on('select', function() {
|
||||
const attachment = mediaUploader.state().get('selection').first().toJSON();
|
||||
|
||||
// Actualizar input
|
||||
$input.val(attachment.id);
|
||||
|
||||
// Mostrar preview
|
||||
const imgUrl = attachment.sizes.thumbnail ? attachment.sizes.thumbnail.url : attachment.url;
|
||||
$preview.html('<img src="' + imgUrl + '" alt="" style="max-width: 60px; height: auto;">').show();
|
||||
|
||||
// Mostrar botón eliminar
|
||||
$removeBtn.show();
|
||||
});
|
||||
|
||||
mediaUploader.open();
|
||||
});
|
||||
|
||||
// Eliminar imagen
|
||||
$('.fp-geo-remove-btn').on('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
const targetId = $(this).data('target');
|
||||
const $input = $('#' + targetId);
|
||||
const $preview = $('#' + targetId + '_preview');
|
||||
|
||||
$input.val('');
|
||||
$preview.html('').hide();
|
||||
$(this).hide();
|
||||
});
|
||||
|
||||
// Toggle opciones de color por categoría
|
||||
$('input[name="fp_geo_content_options[use_category_colors]"]').on('change', function() {
|
||||
const $options = $('.fp-geo-category-color-options');
|
||||
if ($(this).is(':checked')) {
|
||||
$options.slideDown();
|
||||
} else {
|
||||
$options.slideUp();
|
||||
}
|
||||
}).trigger('change');
|
||||
});
|
||||
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user