1jQuery(document).ready(function($){ 2 var pollmessage = $('.poll-message'); 3 message = { 4 main: '.poll-message', 5 set: function(text, success){ 6 var message = this; 7 $(message.main).text(text).stop(true,true).show(); 8 $(message.main).removeClass("error success"); 9 if( success != "" && success != null && success != "null"){ 10 $(message.main).addClass(success); 11 } 12 setTimeout( function(){ 13 $(message.main).text('').stop(true,true).hide(); 14 },5000 ) 15 } 16 } 17 $('.datepicker').datepicker({ dateFormat: 'yy-mm-dd' }); 18 $('a.poll-question-add').click(function(e){ 19 20 }); 21 $('#fields button').on("click",function(){ 22 var id_field = $(this).data('field'); 23 var type = $(this).data('type'); 24 var groupInput = $('#group-input'); 25 groupInput.empty(); 26 groupInput.hide(); 27 $(this).closest('ul').find('button').removeClass('active'); 28 $(this).addClass('active'); 29 $('input[name=id_field]').val(id_field); 30 "radio" == type ? (groupInput.show(), groupInput.append($("<div/>", { 31 class: "input-field large-12" 32 }).append($("<input/>", { 33 type: "radio", 34 disabled: "disabled" 35 })).append($("<input/>", { 36 type: "text", 37 class:'width-large-9 input-choice', 38 name: 'choice[]' 39 })).append($("<button/>", { 40 type: "button", 41 class: "button button-primary delete-option", 42 text: "Eliminar" 43 }))).append($("<button/>", { 44 type: "button", 45 class: "button button-primary add-option", 46 text: "Agregar Campo" 47 }))) : "checkbox" == type ? (groupInput.show(), groupInput.append($("<div/>", { 48 class: "input-field large-12" 49 }).append($("<input/>", { 50 type: "checkbox", 51 disabled: "disabled" 52 })).append($("<input/>", { 53 type: "text", 54 class:'width-large-9 input-choice', 55 name: "choice[]" 56 })).append($("<button/>", { 57 type: "button", 58 class: "button button-primary delete-option", 59 text: "Eliminar" 60 }))).append($("<div/>",{ 61 class:'input-field large-12', 62 63 }).append($("<input/>",{ 64 type:"text", 65 name:"max", 66 class:"width-large-input-50" 67 })).append($('<div/>',{ 68 html:'<small>Numero de selecciones, dejar en blanco para no limitar.</small>' 69 }))).append($("<button/>", { 70 type: "button", 71 class: "button button-primary add-option", 72 text: "Agregar Campo" 73 }))) : "selected" == type && (groupInput.show(), groupInput.append($("<div/>", { 74 class: "input-field large-12" 75 }).append($("<input/>", { 76 type: "text", 77 class:'width-large-9 input-choice', 78 name: "choice[]" 79 })).append($("<button/>", { 80 type: "button", 81 class: "button button-primary delete-option", 82 text: "Eliminar" 83 }))).append($("<button/>", { 84 type: "button", 85 class: "button button-primary add-option", 86 text: "Agregar Campo" 87 }))); 88 89 }); 90 91 $(document).on("click",'.poll button.delete-option',function(){ 92 var inputs = $("#group-input").find('.input-field'); 93 var id_choice = $(this).attr('rel'); 94 if(inputs.size() > 1){ 95 $(this).closest('.input-field').remove(); 96 } 97 98 }); 99 $(document).on("click",'.poll button.add-option',function(){ 100 var clone = $(this).closest('.input-field').find('.input-field:first').clone(); 101 clone.find("input[name^='choice']").attr('name','choice[]'); 102 clone.find('input').val(''); 103 clone.insertBefore($(this).prev()); 104 }); 105 106 $(document).on("click",'.poll button.poll-question-list',function(){ 107 $(".panel-question-add").hide(); 108 $(".panel-question-list").show(); 109 }) 110 111 $(document).on("click", '.poll .poll-question-delete',function(e){ 112 var conf = confirm("Estas seguro que deseas eliminar esta pregunta"+ 113 " y las respuestas asociadas a los usuarios?"); 114 if(conf == true){ 115 return true; 116 } 117 e.preventDefault(); 118 }); 119 120 $(document).on("click", '.poll .poll-button-delete',function(e){ 121 var conf = confirm("Estas seguro que deseas eliminar esta encuesta y todas sus preguntas,"+ 122 " exporta un excel de las estadisticas, antes de eliminar?"); 123 if(conf == true){ 124 return true; 125 } 126 e.preventDefault(); 127 }); 128 129 130 $('.poll-checkbox :checkbox[required]').change(function(){ 131 var pollCheckboxes = $(this).closest('.poll-checkbox'); 132 var cacheCheckboxes = pollCheckboxes.find(':checkbox'); 133 var requiredCheckboxes = pollCheckboxes.find(':checkbox[required]'); 134 if($(this).is(':checked')) { 135 requiredCheckboxes.removeAttr('required'); 136 } else { 137 cacheCheckboxes.attr('required', 'required'); 138 } 139 });
140 141 $('.poll-checkbox :checkbox').click(function(e){ 142 var pollCheckboxes = $(this).closest('.poll-checkbox'); 143 var checked = pollCheckboxes.find(":checkbox:checked").length; 144 var max = pollCheckboxes.data('max'); 145 if(max < checked){ 146 message.set('El numero maximo de '+ 147 'alernativas para marcar es '+ max 148 ); 149 e.preventDefault(); 150 } 151 }); 152 153 $("form[name=poll-response] button[type=submit]").on("click",function(){ 154 var form = $(this).closest('form'); 155 var checkboxes = form.find('.poll-checkbox'); 156 var error = false; 157 $.each(checkboxes, function(i, val){ 158 var max = $(this).data('max'); 159 var checked = $(this).find(":checkbox:checked").length; 160 (max < checked || parseInt(checked) == 0)? error = true : null; 161 }); 162 163 $.each(form.find(':text[required]'),function(i, val){ 164 ($(this).val()=='')? error = true : null; 165 }); 166 167 if( error == true ){ 168 message.set('Debes completar todos los '+ 169 ' campos requeridos'); 170 } 171 172 }); 173 174 $("form[name=poll-response]").on("submit",function(e){ 175 var checkboxes = $(this).find('.poll-checkbox'); 176 var error = false; 177 $.each(checkboxes, function(i, val){ 178 var max = $(this).data('max'); 179 var checked = $(this).find(":checkbox:checked").length; 180 (max < checked || parseInt(checked) == 0)? error = true : null; 181 }); 182 $.each($(this).find(':text[required]'),function(i, val){ 183 ($(this).val()=='')? error = true : null; 184 }); 185 if( error == true ){ 186 e.preventDefault(); 187 return false; 188 } 189 190 return true; 191 }); 192 193 $("form[name=poll-front] button[type=submit]").on("click",function(){ 194 var form = $(this).closest('form'); 195 var checkboxes = form.find('.poll-checkbox'); 196 var error = false; 197 $.each(checkboxes, function(i, val){ 198 var max = $(this).data('max'); 199 var checked = $(this).find(":checkbox:checked").length; 200 (max < checked || parseInt(checked) == 0)? error = true : null; 201 }); 202 203 $.each(form.find(':text[required]'),function(i, val){ 204 ($(this).val()=='')? error = true : null; 205 }); 206 207 if( error == true ){ 208 message.set('Debes completar todos los '+ 209 ' campos requeridos'); 210 } 211 212 }); 213 214 $("form[name=poll-front]").on("submit",function(e){ 215 e.preventDefault(); 216 var form = $(this); 217 var fieldset = $(this).find('fieldset'); 218 var checkboxes = $(this).find('.poll-checkbox'); 219 var error = false; 220 $.each(checkboxes, function(i, val){ 221 var max = $(this).data('max'); 222 var checked = $(this).find(":checkbox:checked").length; 223 (max < checked || parseInt(checked) == 0)? error = true : null; 224 }); 225 $.each($(this).find(':text[required]'),function(i, val){ 226 ($(this).val()=='')? error = true : null; 227 }); 228 if( error == true ){ 229 return false; 230 } else if(error == false) { 231 var data = 'action=ajax_poll_answer&'+form.serialize(); 232 fieldset.attr('disabled','disabled'); 233 $.ajax({
234 method: "POST", 235 url: "/wp-admin/admin-ajax.php", 236 data: data 237 }).done(function( msg ) { 238 msg = jQuery.parseJSON(msg); 239 if(msg != 'null' && msg != null){ 240 if( msg.status == 'success'){ 241 form[0].reset(); 242 } 243 message.set(msg.message, msg.status); 244 } 245 fieldset.removeAttr('disabled'); 246 }).always(function() { 247 fieldset.removeAttr('disabled'); 248 }); 249 250 } 251 return true; 252 }); 253 254});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.