#= require jquery #= require jquery_ujs #= require jquery-ui #= require ./shared/jquery.ui.touch-punch #= require ./shared/jquery-jPuzzle test_question = (question) -> $(".info").hide() $(".quizz_img").hide() rep = question.find("input[type='radio']:checked").closest("div") rep.find(".info").show() if rep.find(".quizz_img").size() > 0 rep.find(".quizz_img").show() rep.closest(".question").find(".quizz_ill").hide() else rep.closest(".question").find(".quizz_ill").show() if question.find(".response input:checked")[0] question.find(".success").show(); question.find(".fail").hide(); rep = true else question.find(".fail").show(); question.find(".success").hide(); rep =false return rep $ -> $(".quizz_img").hide() $("a.def").click -> r = "

"+$(this).html()+"

"+$(this).data("def")+"

" $("body").append(r) $(".pane_hover").click -> $(this).remove(); $(document).on "click", ".receptable img", -> r = "

"+$(this).data("legend")+"

" $("body").append(r) $(".pane_hover").click -> $(this).remove(); $("a.img").click -> r = "
" if ($(this).data("legend")) r+= "

"+$(this).data("legend")+"

" if ($(this).data("desc")) r+= "

"+$(this).data("desc")+"

" r += "
" $("body").append(r) $(".pane_hover").click -> $(this).remove(); $(".page").hide() $(".page:first").show() $(".prev_slide").click -> $(this).closest(".page").hide() $(this).closest(".page").prev(".page").show() $(".next_slide").click -> $(this).closest(".page").hide() $(this).closest(".page").next(".page").show() $(".places_jeu2").each -> $(this).find(".receptable").droppable tolerance: "touch" accept: (e) -> if e.hasClass("intru") == false and $(this).find("img").size() == 0 true drop: ( event, ui ) -> $( this ).append(ui.draggable) ui.draggable.attr("style", "") if $(this).closest(".places_jeu2").find(".vignettes img").size() == 2 $(this).closest(".places_jeu2").find(".success").show() $(this).find(".vignettes img").draggable #connectWith: ".receptable" tolerance: "pointer" revert: "invalid" $(".places_jeu").each -> $(this).find(".receptable").droppable tolerance: "touch" accept: (e) -> if e.data("rep") == $(this).data("rep") true drop: ( event, ui ) -> $( this ).append(ui.draggable) ui.draggable.attr("style", "") if $(this).closest(".places_jeu").find(".vignettes img").size() == 0 $(this).closest(".places_jeu").find(".success").show() $(this).find(".vignettes img").draggable #connectWith: ".receptable" tolerance: "pointer" revert: "invalid" $(".quizz").each -> $(this).find("input").change -> test_question($(this).closest(".question")) $(this).find(".fail, .success").hide() $(this).find(".question").hide() $(this).find(".question:first").show() $(this).find(".prev").click -> test_question($(this).closest(".question")) $(this).closest(".question").hide() $(this).closest(".question").prev(".question").show() $(this).find(".next").click -> if test_question($(this).closest(".question")) == true $(this).closest(".question").fadeOut(0) $(this).closest(".question").next(".question").fadeIn(0) $(this).find(".check").click -> test_question($(this).closest(".question")) intialize_puzzle = () -> $(".puzzle").each -> archive = $(this).html() $(this).find(".piece_place").droppable tolerance: "touch" accept: (e) -> if e.data("rep") == $(this).data("rep") true drop: ( event, ui ) -> $( this ).append(ui.draggable) ui.draggable.attr("style", "") if $(this).closest(".puzzle").find(".pieces .piece").size() == 0 $(this).closest(".puzzle").find(".success").show() $(this).draggable( 'disable' ); $(this).find(".piece").draggable tolerance: "pointer" revert: "invalid" $(this).find(".reset").click -> $(this).closest(".puzzle").html archive $(this).closest(".puzzle").find(".success").hide() intialize_puzzle() intialize_arbre = () -> archive = $(".vie-arbre.story").closest(".sortable_quizz").html() $(".vie-arbre.story").sortable items: 'td' stop:() -> win = true i = 0 $(this).find("td").each -> i = i + 1 win = false unless i is $(this).data("order") if win is true $(".success").show() $(".vie-arbre.story").closest(".sortable_quizz").find(".reset").click -> $(".vie-arbre.story").closest(".sortable_quizz").html archive intialize_arbre() initialize_vie_sol = () -> archive = $(".t_sortable").closest(".animaux_sol").html() $(".t_sortable").sortable items: 'tr' stop:() -> win = true i = 0 $(this).find("tr").each -> i = i + 1 win = false unless i is $(this).data("order") if win is true $(".success").show() $(".t_sortable").closest(".animaux_sol").find(".reset").click -> $(".t_sortable").closest(".animaux_sol").html archive initialize_vie_sol() $(document).ready -> intialize_arbre() initialize_vie_sol() intialize_puzzle() #$.backstretch(["/assets/plaquettes/fond.jpg"]); initialize_jeu_1 = -> $(".sortable_quizz").each -> element = $(this) html = element.find(".sortable").html() element.find(".sortable").sortable stop: () -> win = true i = 0 element.find("img").each -> i = i + 1 win = false unless i is $(this).data("order") if win is true element.find(".win").show() element.find(".loose").hide() element.find(".sortable").disableSelection() element.find(".reset").click -> element.find(".sortable").html html element.find(".sortable").sortable "refresh" element.find(".win").hide() element.find(".loose").hide() initialize_jeu_2 = -> element = $("#insectes_jeu_2") html = element.find(".sortable").html() element.find(".receptable").sortable connectWith: ".labels,.receptable" items: ".label" tolerance: "pointer" receive: (event, ui) -> if $(this).children().length > 1 child = $(this).children().not(ui.item)[0] element.find(".labels").append child element.find(".receptable ul").disableSelection() element.find(".labels").sortable connectWith: ".receptable" tolerance: "pointer" items: ".label" receive: (event, ui) -> ui.item.attr "style", "" element.find(".labels").disableSelection() element.find(".verif").bind "click", -> win = true i = 0 element.find("img").each -> i = i + 1 win = false unless i is $(this).data("order") if win is true element.find(".win").show() element.find(".loose").hide() else element.find(".win").hide() element.find(".loose").show() element.find(".reset").click -> element.find(".sortable").html html element.find(".sortable").sortable "refresh" element.find(".win").hide() element.find(".loose").hide() initialize_jeu_1() initialize_jeu_2()