WPR FM
uid=9814(b13i2mwmyrdbxio) php=8.4.28
info
cwd /data/sites/web/b13i2mwmyrdbxio/www |
naik
Buka
-
admin.css
4342
x
-
admin.js
5002
x
D
baeume/
-
pmtf-finder.js
26119
x
-
pmtf-flaeche.js
3641
x
-
pmtf-geo.js
74872
x
-
pmtf.css
31646
x
Upload
Simpan
/* PLANT-MY-TREE Flächen: Eingabemaske im Backend */ (function ($) { 'use strict'; /* Bilder wählen (einzeln oder mehrere) */ $(document).on('click', '.pmtf-img-pick', function (e) { e.preventDefault(); var $w = $(this).closest('.pmtf-img'), multi = String($w.data('multiple')) === '1', $in = $w.children('input[type=hidden]').first(); var frame = wp.media({ title: multi ? 'Fotos wählen' : 'Bild wählen', button: { text: 'Übernehmen' }, multiple: multi ? 'add' : false, library: { type: 'image' } }); frame.on('select', function () { var ids = multi && $in.val() ? $in.val().split(',') : []; var $prev = $w.children('.pmtf-img-prev'); if (!multi) { $prev.empty(); } frame.state().get('selection').toJSON().forEach(function (a) { if (ids.indexOf(String(a.id)) > -1) { return; } ids.push(String(a.id)); var url = a.sizes && a.sizes.thumbnail ? a.sizes.thumbnail.url : a.url; var $t = $('<span class="pmtf-thumb">').attr('data-id', a.id).append($('<img alt="">').attr('src', url)).append('<button type="button" class="pmtf-thumb-x" aria-label="Bild entfernen">×</button>'); $prev.append($t); }); $in.val(ids.join(',')); }); frame.open(); }); $(document).on('click', '.pmtf-thumb-x', function (e) { e.preventDefault(); var $t = $(this).closest('.pmtf-thumb'), $in = $t.closest('.pmtf-img').children('input[type=hidden]').first(), id = String($t.data('id')); $in.val($in.val().split(',').filter(function (x) { return x && x !== id; }).join(',')); $t.remove(); }); /* Neuigkeiten */ $(document).on('click', '.pmtf-news-add', function (e) { e.preventDefault(); var html = $('.pmtf-news-tpl').first().html().replace(/__i__/g, 'n' + Date.now()); var $row = $(html); $row.find('input[type=date]').val(PMTF_ADMIN.today); $('.pmtf-news-list').first().prepend($row); $row.find('textarea').trigger('focus'); }); $(document).on('click', '.pmtf-news-del', function (e) { e.preventDefault(); if (window.confirm('Diese Neuigkeit entfernen? Sie verschwindet nach dem Aktualisieren.')) { $(this).closest('.pmtf-news-row').remove(); } }); /* Partner suchen und zuordnen */ var timer = 0; $(document).on('input', '.pmtf-partner-q', function () { var q = this.value.trim(), $res = $(this).siblings('.pmtf-partner-res'); clearTimeout(timer); if (q.length < 2) { $res.empty(); return; } timer = setTimeout(function () { $.get(PMTF_ADMIN.ajax, { action: 'pmtf_partner_search', nonce: PMTF_ADMIN.nonce, q: q }, function (r) { $res.empty(); if (!r || !r.success || !r.data.length) { $res.append('<p class="pmtf-hint">Kein Partner gefunden.</p>'); return; } r.data.forEach(function (p) { $('<button type="button" class="button pmtf-partner-pick">').text(p.title).attr('data-id', p.id).appendTo($res); }); }); }, 250); }); $(document).on('keydown', '.pmtf-partner-q', function (e) { if (e.key === 'Enter') { e.preventDefault(); } }); $(document).on('click', '.pmtf-partner-pick', function () { var id = String($(this).data('id')), $box = $(this).closest('.pmtf-box'), $chips = $box.find('.pmtf-partner-chips'); if (!$chips.find('input').filter(function () { return this.value === id; }).length) { $('<span class="pmtf-chip">').append($('<input type="hidden" name="pmtf_partner[]">').val(id)).append(document.createTextNode($(this).text())) .append('<button type="button" class="pmtf-chip-x" aria-label="Entfernen">×</button>').appendTo($chips); } $box.find('.pmtf-partner-res').empty(); $box.find('.pmtf-partner-q').val('').trigger('focus'); }); $(document).on('click', '.pmtf-chip-x', function () { $(this).closest('.pmtf-chip').remove(); }); /* Baum-Icons: eigenes Bild wählen oder zurück zum mitgelieferten Icon */ $(document).on('click', '.pmtf-ic-pick', function (e) { e.preventDefault(); var $c = $(this).closest('.pmtf-ic'); var frame = wp.media({ title: 'Icon für „' + $.trim($c.find('.pmtf-ic-body strong').contents().first().text()) + '“ wählen', button: { text: 'Übernehmen' }, multiple: false, library: { type: 'image' } }); frame.on('select', function () { var a = frame.state().get('selection').first().toJSON(); var url = a.sizes && a.sizes.medium ? a.sizes.medium.url : a.url; $c.find('input[type=hidden]').val(a.id); $c.find('.pmtf-ic-own').attr('src', url).prop('hidden', false); $c.addClass('has-own').find('.pmtf-ic-reset').prop('hidden', false); $c.find('.pmtf-ic-pick').text('Anderes Bild wählen'); }); frame.open(); }); $(document).on('click', '.pmtf-ic-reset', function (e) { e.preventDefault(); var $c = $(this).closest('.pmtf-ic'); $c.find('input[type=hidden]').val(''); $c.find('.pmtf-ic-own').removeAttr('src').prop('hidden', true); $c.removeClass('has-own'); $(this).prop('hidden', true); $c.find('.pmtf-ic-pick').text('Eigenes Bild wählen'); }); $(document).on('change', '.pmtf-icons-kreis input', function () { $('.pmtf-ic-grid').toggleClass('has-kreis', this.checked); }); })(jQuery);
Exec