/** * DokuWiki Plugin farmer (JS for plugin management) * * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html * @author Michael Große * @author Andreas Gohr */ (function (exports) { 'use strict'; jQuery(document).ready(function () { // general animal select jQuery('select.farmer_choosen_animals').chosen({ width: '100%', search_contains: true, allow_single_deselect: true, "placeholder_text_single": LANG.plugins.farmer.animalSelect }); // Plugin Management for all Animals var bulkPluginSelector = jQuery('#farmer__bulkPluginSelect'); bulkPluginSelector.chosen({ width: '100%', search_contains: true, "placeholder_text_single": LANG.plugins.farmer.pluginSelect }); bulkPluginSelector.change(function () { jQuery(".bulkButton").prop('disabled', false); }); // Plugin Management of a single Animal var animalSelector = jQuery('#farmer__animalSelect'); animalSelector.chosen({ width: '100%', search_contains: true, "placeholder_text_single": LANG.plugins.farmer.animalSelect }); animalSelector.change(function () { var animal = animalSelector.val(); jQuery.post( DOKU_BASE + 'lib/exe/ajax.php', { call: 'plugin_farmer_getPlugins_' + animal }, function (data) { var submitButton = jQuery(''); var resetButton = jQuery(''); var pluginContainer = jQuery('#farmer__animalPlugins'); pluginContainer.html(''); pluginContainer.append(submitButton, resetButton); jQuery.each(data[0], function (index, value) { var checked = 'checked'; if (typeof data[1][value] !== 'undefined' && data[1][value] === 0) { checked = ''; } var pluginLabel = jQuery('') .append(jQuery('').text(value)) .append(jQuery('')) ; pluginContainer.append(pluginLabel); }); pluginContainer.append(submitButton.clone(), resetButton.clone()); // data is array you returned with action.php }, 'json' ); }); // make sure there's enough space for the dropdown jQuery('select').on('chosen:showing_dropdown', function (evt, params) { jQuery(evt.target).parent('fieldset').animate({ "padding-bottom": '20em' }, 400); }).on('chosen:hiding_dropdown', function (evt, params) { jQuery(evt.target).parent('fieldset').animate({ "padding-bottom": '7px' }, 400); }); jQuery("input[name=bulkSingleSwitch]:radio").change(function () { if (jQuery('#farmer__bulk').prop("checked")) { jQuery('#farmer__bulkForm').css('display', 'initial'); } else { jQuery('#farmer__bulkForm').css('display', 'none'); } if (jQuery('#farmer__single').prop("checked")) { jQuery('#farmer__singlePluginForm').css('display', 'initial'); } else { jQuery('#farmer__singlePluginForm').css('display', 'none'); } }); jQuery('#farmer__bulk').click(); }); })(this.farmer__plugin = {});