Last active
October 13, 2015 03:33
-
-
Save willsza/72ca580fc5eb43b1d2b2 to your computer and use it in GitHub Desktop.
Código não funciona...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
########################################################## | |
# Gerencia os campos selects do direcionamento das pages # | |
########################################################## | |
# Remove selects de direcionamento | |
$(document).on 'click', 'form .remove_fields', (event) -> | |
$(this).prev('input[type="hidden"]').val('1') | |
$(this).closest('.fields').hide() | |
event.preventDefault() | |
# Adiciona selects de direcionamento | |
$(document).on 'click', 'form .add_fields', (event) -> | |
time = new Date().getTime() | |
regexp = new RegExp($(this).data('id'), 'g') | |
$('.separator').before($(this).data('fields').replace(regexp, time)) | |
new_id = '_' + time | |
select_first = $('#select_first').attr('id', 'select_first' + new_id) | |
select_next = $('#select_next').attr('id', 'select_next' + new_id) | |
select_question_m = $('#select_question_m').attr('id', 'select_question_m' + new_id).hide() | |
select_answer_option_m = $('#select_answer_option_m').attr('id', 'select_answer_option_m' + new_id).hide() | |
select_question_b = $('#select_question_b').attr('id', 'select_question_b' + new_id).hide().hide() | |
select_answer_option_b = $('#select_answer_option_b').attr('id', 'select_answer_option_b' + new_id).hide() | |
select_goal = $('#select_goal').attr('id', 'select_goal' + new_id).hide() | |
select_post = $('#select_post').attr('id', 'select_post' + new_id).hide() | |
select_task = $('#select_task').attr('id', 'select_task' + new_id).hide() | |
select_tag = $('#select_tag').attr('id', 'select_tag' + new_id).hide() | |
# console.log select_first | |
# console.log($('[data-fields] #select_first')) | |
$(select_first).change -> | |
select_first_val = $(select_first).val() | |
console.log(select_first_val) | |
if select_first_val == "Pergunta M" | |
$(select_question_m).show() | |
$(select_answer_option_m).show() | |
else | |
$(select_question_m).hide() | |
$(select_answer_option_m).hide() | |
if select_first_val == "Pergunta B" | |
$(select_question_b).show() | |
$(select_answer_option_b).show() | |
else | |
$(select_question_b).hide() | |
$(select_answer_option_b).hide() | |
if select_first_val == "Objetivo" | |
$(select_goal).show() | |
else | |
$(select_goal).hide() | |
if select_first_val == "Post" | |
$(select_post).show() | |
else | |
$(select_post).hide() | |
if select_first_val == "Tarefa" | |
$(select_task).show() | |
else | |
$(select_task).hide() | |
if select_first_val == "Tag" | |
$(select_tag).show() | |
else | |
$(select_tag).hide() | |
event.preventDefault() | |
$(document).ready -> | |
$('#select_question_m').hide() | |
$('#select_answer_option_m').hide() | |
$('#select_question_b').hide() | |
$('#select_answer_option_b').hide() | |
$('#select_goal').hide() | |
$('#select_post').hide() | |
$('#select_task').hide() | |
$('#select_tag').hide() | |
select_first_active = $('#select_first option:selected').val() | |
if select_first_active == "Pergunta M" | |
$('#select_question_m').show() | |
$('#select_answer_option_m').show() | |
else | |
$('#select_question_m').hide() | |
$('#select_answer_option_m').hide() | |
if select_first_active == "Pergunta B" | |
$('#select_question_b').show() | |
$('#select_answer_option_b').show() | |
else | |
$('#select_question_b').hide() | |
$('#select_answer_option_b').hide() | |
if select_first_active == "Objetivo" | |
$('#select_goal').show() | |
else | |
$('#select_goal').hide() | |
if select_first_active == "Post" | |
$('#select_post').show() | |
else | |
$('#select_post').hide() | |
if select_first_active == "Tarefa" | |
$('#select_task').show() | |
else | |
$('#select_task').hide() | |
if select_first_active == "Tag" | |
$('#select_tag').show() | |
else | |
$('#select_tag').hide() | |
console.log select_first_active | |
$('#select_first').change -> | |
select_first_edit = $('#select_first').val() | |
console.log select_first_edit | |
if select_first_edit == "Pergunta M" | |
$('#select_question_m').show() | |
$('#select_answer_option_m').show() | |
else | |
$('#select_question_m').hide() | |
$('#select_answer_option_m').hide() | |
if select_first_edit == "Pergunta B" | |
$('#select_question_b').show() | |
$('#select_answer_option_b').show() | |
else | |
$('#select_question_m').hide() | |
$('#select_answer_option_m').hide() | |
if select_first_edit == "Objetivo" | |
$('#select_goal').show() | |
else | |
$('#select_goal').hide() | |
if select_first_edit == "Post" | |
$('#select_post').show() | |
else | |
$('#select_post').hide() | |
if select_first_edit == "Tarefa" | |
$('#select_task').show() | |
else | |
$('#select_task').hide() | |
if select_first_edit == "Tag" | |
$('#select_tag').show() | |
else | |
$('#select_tag').hide() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment