(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 = $('