1jQuery(function() { 2 'use strict'; 3 4 jQuery('select[name="farmsync[source]"]').change(function (event) { 5 var $this = jQuery(this); 6 jQuery.get({ 7 'url': DOKU_BASE + 'lib/exe/ajax.php', 8 'data': { 9 'call': 'plugin_farmsync', 10 'farmsync-source': $this.val(), 11 'sectok': $this.closest('form').find('input[name=sectok]').val(), 12 'farmsync-getstruct': true 13 } 14 }).done(function (data) { 15 jQuery('div.structsync').html(data); 16 var checked = jQuery('input[name="farmsync[struct]"]').prop('checked'); 17 jQuery('div.structsync input[type=checkbox]').prop('checked', checked); 18 }).fail(function (jqXHR, textStatus, errorThrown) { 19 jQuery('div.structsync').html('<span>Failure! ' + textStatus + ' ' + errorThrown + '</span><div>' + jqXHR.responseText + '</div>'); 20 console.dir(jqXHR); 21 }); 22 }); 23 24 jQuery('input[name="farmsync[struct]"]').change(function (event) { 25 var $this = jQuery(this); 26 if ($this.prop('checked')) { 27 jQuery('div.structsync').show(); 28 jQuery('div.structsync input[type=checkbox]').prop('checked', 'checked'); 29 } else { 30 jQuery('div.structsync').hide(); 31 jQuery('div.structsync input[type=checkbox]').prop('checked', ''); 32 } 33 34 }); 35}); 36