Upload folder via GUI - integrations
This commit is contained in:
63
integrations/assets/js/dashboard.js
Normal file
63
integrations/assets/js/dashboard.js
Normal file
@@ -0,0 +1,63 @@
|
||||
(function($){
|
||||
$(document).on('change','input[name*=services]',function(e){
|
||||
var $i=$(e.target),v=$i.val(),$w=$i.parents('.inside');
|
||||
if(v){var $s=$('#wmf-service-'+v,$w);if($s.length){$('.wmf-service-integration',$w).hide();$i.parents('[data-active-service]').attr('data-active-service',v);$s.show();}}
|
||||
else{$('.wmf-service-integration',$w).hide();}
|
||||
$i.parents('form').trigger('wmf.enable');
|
||||
});
|
||||
$(document).on('change','input[name*="[mode]"]',function(e){ $(e.target).parents('[data-active-mode]').attr('data-active-mode',$(e.target).val()); });
|
||||
$(document).on('submit','#wmf-integrations-screen form.hf-ajax-submit',function(e){
|
||||
e.preventDefault();
|
||||
var $f=$(e.target),$w=$f.parent(),$sp=$('.spinner',$w),$sb=$('input[type=submit]',$w);
|
||||
$sb.prop('disabled',true);$sp.css('visibility','visible');
|
||||
$.post(ajaxurl,$f.serialize(),function(r){$sb.prop('disabled',false);$sp.css('visibility','hidden');$f.replaceWith(r);});
|
||||
});
|
||||
function refresh(){
|
||||
var sg=$('#wmf-integration-filters').val(),st=$('#wmf-search-input').val().trim();
|
||||
var $rw=$('#wmf-integrations-results-wrap'),$rc=$('#wmf-integrations-results'),$dw=$('#dashboard-widgets');
|
||||
$('.wmf-integrations-widget',$rc).each(function(){$('.notice',$(this)).remove();$('#'+$(this).attr('id'),$dw).replaceWith($(this));});
|
||||
$('.wmf-integrations-widget',$rc).remove();$rc.hide();$rw.removeClass('no-results');
|
||||
if(!sg&&!st){$dw.show();return;}
|
||||
$dw.hide();
|
||||
var $r=$('.wmf-integrations-widget',$dw);
|
||||
if(sg)$r=$r.filter(function(){return $(this).hasClass('wmf-integrations-widget-group-'+sg);});
|
||||
if(st)$r=$r.filter(function(){return $('h2',$(this)).text().toLowerCase().indexOf(st.toLowerCase())>=0;});
|
||||
$r=$r.filter(function(){return'none'!==$(this).css('display');});
|
||||
$r=$r.clone(true,true).get();
|
||||
if(!$r.length)$rw.addClass('no-results');
|
||||
$rc.show();
|
||||
var $cols=$('.postbox-container:visible',$rc);
|
||||
while($r.length>0){$cols.each(function(){if($r.length>0)$(this).append($r.pop());});}
|
||||
}
|
||||
$(document).on('input','#wmf-integration-toolbar',refresh);
|
||||
$(window).on('resize',refresh);
|
||||
})(jQuery);
|
||||
|
||||
/* Widget-Formulare AJAX speichern */
|
||||
(function($){
|
||||
$(document).on('submit', '.wmf-int-form', function(e){
|
||||
e.preventDefault();
|
||||
var $form = $(this);
|
||||
var $btn = $form.find('button[type=submit]');
|
||||
var $wrap = $form.closest('.wmf-widget-body');
|
||||
$btn.prop('disabled', true).text('Speichere...');
|
||||
$.post(ajaxurl, $form.serialize(), function(response){
|
||||
$btn.prop('disabled', false).text('Speichern');
|
||||
var $notice = $('<div class="wmf-widget-notice">').text('Gespeichert!').css({
|
||||
background:'#f0fdf4',border:'1px solid #46b450',color:'#166534',
|
||||
padding:'6px 10px',borderRadius:'3px',marginBottom:'8px',fontSize:'13px'
|
||||
});
|
||||
$wrap.prepend($notice);
|
||||
setTimeout(function(){ $notice.fadeOut(300, function(){ $(this).remove(); }); }, 2500);
|
||||
// Badge aktualisieren
|
||||
if(response && response.indexOf('Verbunden') !== -1) {
|
||||
if(!$wrap.find('.wmf-connected-badge').length) {
|
||||
$wrap.prepend('<div class="wmf-connected-badge">✓ Verbunden</div>');
|
||||
}
|
||||
}
|
||||
}).fail(function(){
|
||||
$btn.prop('disabled', false).text('Speichern');
|
||||
alert('Fehler beim Speichern. Bitte Seite neu laden.');
|
||||
});
|
||||
});
|
||||
})(jQuery);
|
||||
Reference in New Issue
Block a user