1(function(exports) { 2 'use strict'; 3 4 jQuery(document).ready(function () { 5 var bulkPluginSelector = jQuery('#farmer__bulkPluginSelect'); 6 if (jQuery().chosen) { 7 bulkPluginSelector.chosen({ 8 width: '100%', 9 search_contains: true, 10 "placeholder_text_single": LANG.plugins.farmer.pluginSelect 11 }); 12 } 13 14 bulkPluginSelector.change(function () { 15 jQuery(".bulkButton").prop('disabled',false); 16 }); 17 18 var animalSelector = jQuery('#farmer__animalSelect'); 19 if (jQuery().chosen) { 20 animalSelector.chosen({ 21 width: '100%', 22 search_contains: true, 23 "placeholder_text_single": LANG.plugins.farmer.animalSelect 24 }); 25 } 26 animalSelector.change(function () { 27 var animal = animalSelector.val(); 28 jQuery.post( 29 DOKU_BASE + 'lib/exe/ajax.php', 30 { 31 call: 'plugin_farmer_getPlugins_' + animal 32 }, 33 function(data) { 34 var submitButton = jQuery('<button type="submit" value="updateSingleAnimal" name="plugin_farmer[submit_type]">'+LANG.plugins.farmer.submit+'</button>'); 35 var resetButton = jQuery('<button type="reset">'+LANG.plugins.farmer.reset+'</button>'); 36 var pluginContainer = jQuery('#farmer__animalPlugins'); 37 pluginContainer.html(''); 38 pluginContainer.append(submitButton, resetButton); 39 jQuery.each(data[0], function(index, value) { 40 var checked = 'checked'; 41 var pluginCheckbox; 42 if (typeof data[1][value] !== 'undefined' && data[1][value] === 0) { 43 checked = ''; 44 } 45 pluginCheckbox = jQuery('<input class="edit" type="checkbox" id="farmer__plugin_' + value + '" name="plugin_farmer_plugins[' + value + ']" ' + checked + '>'); 46 pluginContainer.append(pluginCheckbox); 47 jQuery('#farmer__plugin_' + value).wrap('<label class="block"></label>').parent().prepend(value); 48 }); 49 pluginContainer.append(submitButton.clone(), resetButton.clone()); 50 51 // data is array you returned with action.php 52 }, 53 'json' 54 ); 55 }); 56 57 jQuery('select').on('chosen:showing_dropdown', function(evt, params) { 58 jQuery(evt.target).parent('fieldset').animate({ 59 "padding-bottom": '20em' 60 }, 400); 61 }); 62 jQuery('select').on('chosen:hiding_dropdown', function(evt, params) { 63 jQuery(evt.target).parent('fieldset').animate({ 64 "padding-bottom": '7px' 65 }, 400); 66 }); 67 68 jQuery("input[name=serversetup]:radio").change(function () { 69 if (jQuery('#htaccess__setup').prop("checked")) { 70 jQuery('label.htaccess').css('display','block'); 71 } else { 72 jQuery('label.htaccess').css('display','none'); 73 } 74 }); 75 76 jQuery("input[name=bulkSingleSwitch]:radio").change(function () { 77 if (jQuery('#farmer__bulk').prop("checked")) { 78 jQuery('#farmer__bulkForm').css('display','initial'); 79 } else { 80 jQuery('#farmer__bulkForm').css('display','none'); 81 } 82 if (jQuery('#farmer__single').prop("checked")) { 83 jQuery('#farmer__singlePluginForm').css('display','initial'); 84 } else { 85 jQuery('#farmer__singlePluginForm').css('display','none'); 86 } 87 }); 88 89 90 jQuery.fn.exists = function(){return this.length>0;}; 91 if(jQuery('#farmer__create_animal_form').exists()) { 92 var get_address; 93 if (typeof JSINFO['FARMRELDIR'] === 'undefined') { 94 JSINFO['FARMRELDIR'] = ''; 95 } 96 if(jQuery('#plugin__farmer_animalCreation_success_msg').exists()) { 97 98 var animalname = jQuery('div.success #animal__name').html(); 99 get_address = JSINFO['FARMRELDIR'] + animalname + '/lib/plugins/farmer/plugin.info.txt'; 100 jQuery.get( 101 get_address 102 ) 103 .done(function() { 104 jQuery('#plugin__farmer_animalCreation_success_msg').append(jQuery('<span> '+ LANG.plugins.farmer['animal ajax success'] +'</span>')); 105 }) 106 .fail(function () { 107 alert(LANG.plugins.farmer['animal ajax failure']); 108 }); 109 } 110 if(jQuery('#plugin__farmer_preload_success_msg').exists() && JSINFO['FARMRELDIR'] !== '') { 111 get_address = JSINFO['FARMRELDIR'] + 'invalid_name' + '/lib/exe/ajax.php'; 112 jQuery.get( 113 get_address, 114 { 115 call: 'plugin_farmer_checkSetup' 116 }, 117 null, 118 'json' 119 ) 120 .done(function() { 121 jQuery('#plugin__farmer_preload_success_msg').append(jQuery('<span> '+ LANG.plugins.farmer['preload ajax success'] +'</span>')); 122 }) 123 .fail(function () { 124 alert(LANG.plugins.farmer['preload ajax failure']); 125 }); 126 } 127 } 128 129 }); 130 131})(this.farmer__plugin = {}); 132