From 1b51e7287cabea3e047efdb7e771edfdbf7fe05d Mon Sep 17 00:00:00 2001 From: Nicolas Bally Date: Sun, 13 Apr 2014 12:26:48 +0200 Subject: [PATCH] plaquettes & js --- Gemfile.lock | 13 - .../javascripts/admin/articles_actions.coffee | 41 --- .../javascripts/note_files/note_files.js | 4 +- app/assets/javascripts/plaquettes.coffee | 258 ++++++++++-------- app/assets/stylesheets/plaquettes.css.less | 51 +++- app/views/layouts/plaquettes.html.haml | 8 +- app/views/plaquettes/jardins.html.haml | 2 +- app/views/plaquettes/remerciements.html.haml | 6 +- public/manifest.appcache | 6 +- 9 files changed, 196 insertions(+), 193 deletions(-) delete mode 100644 app/assets/javascripts/admin/articles_actions.coffee diff --git a/Gemfile.lock b/Gemfile.lock index 2c8495c..a398b8e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,12 +40,6 @@ GEM bcrypt-ruby (3.0.1) builder (3.1.4) cancan (1.6.10) - capistrano (2.15.5) - highline - net-scp (>= 1.0.0) - net-sftp (>= 2.0.0) - net-ssh (>= 2.0.14) - net-ssh-gateway (>= 1.1.0) carrierwave (0.9.0) activemodel (>= 3.2.0) activesupport (>= 3.2.0) @@ -115,13 +109,6 @@ GEM minitest (4.7.5) multi_json (1.9.2) mysql2 (0.3.15) - net-scp (1.1.2) - net-ssh (>= 2.6.5) - net-sftp (2.1.2) - net-ssh (>= 2.6.5) - net-ssh (2.8.0) - net-ssh-gateway (1.2.0) - net-ssh (>= 2.6.5) nokogiri (1.6.1) mini_portile (~> 0.5.0) non-stupid-digest-assets (1.0.4) diff --git a/app/assets/javascripts/admin/articles_actions.coffee b/app/assets/javascripts/admin/articles_actions.coffee deleted file mode 100644 index f3fcf9a..0000000 --- a/app/assets/javascripts/admin/articles_actions.coffee +++ /dev/null @@ -1,41 +0,0 @@ - - -$('.article_row .show_details').live "click", -> - url = $(this).attr("href")+".html" - - $(this).closest(".article_row").addClass('active') - $('#article_detail').load url, -> - - $("#article_detail").show().delay(1).css - "-webkit-transition-duration": "0.8s" - "-moz-transition-duration": "0.8s" - "margin-right": "0px" - - - $("#article_index_slide").show().delay(1).css - "-webkit-transition-duration": "0.8s" - "-moz-transition-duration": "0.8s" - "margin-left": "-110%" - "margin-right": "110%" - false - -$('#article_detail .hide').live "click", -> - $("#article_detail #content_types_draggables").hide(); - - $("#article_index_slide").show().delay(1).css - "-webkit-transition-duration": "0.8s" - "-moz-transition-duration": "0.8s" - "margin-left": "0%" - "margin-right": "0%" - - - $("#article_detail").css( - "-webkit-transition-duration": "0.8s" - "-moz-transition-duration": "0.8s" - "margin-right": "-110%").delay(800).queue -> - $("#article_detail").html("").clearQueue() - false - - - false - diff --git a/app/assets/javascripts/note_files/note_files.js b/app/assets/javascripts/note_files/note_files.js index 7ae5c37..f4113fd 100644 --- a/app/assets/javascripts/note_files/note_files.js +++ b/app/assets/javascripts/note_files/note_files.js @@ -44,8 +44,8 @@ function init_note_upload_fields(note_id){ $(document).ready(function () { - $(".note .add_files").live("click",function(){ - alert('test'); + $("body").on("click", ".note .add_files",function(){ + $(this).next('input').click(); return false; }); diff --git a/app/assets/javascripts/plaquettes.coffee b/app/assets/javascripts/plaquettes.coffee index 52b3e2c..c0c165a 100644 --- a/app/assets/javascripts/plaquettes.coffee +++ b/app/assets/javascripts/plaquettes.coffee @@ -34,11 +34,29 @@ test_question = (question) -> return rep - +(($) -> + $.fn.nodoubletapzoom = -> + $(this).bind "touchstart", preventZoom = (e) -> + t2 = e.timeStamp + t1 = $(this).data("lastTouch") or t2 + dt = t2 - t1 + fingers = e.originalEvent.touches.length + $(this).data "lastTouch", t2 + return if not dt or dt > 500 or fingers > 1 # not double-tap + e.preventDefault() # double tap - prevent the zoom + # also synthesize click events we just swallowed up + $(this).trigger("click").trigger "click" + return + + return + + return +) jQuery $ -> - $(".quizz_img").hide() - $("a.def").click -> + $("body").nodoubletapzoom() + + $("body").on "click","a.def", -> r = "

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

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

" @@ -64,7 +82,7 @@ $ -> $(this).remove(); - $("a.img").click -> + $("body").on "click", "a.img",-> r = "
" @@ -79,19 +97,19 @@ $ -> $("body").append(r) - $(".pane_hover").click -> + $(".pane_hover").on "click", -> $(this).remove(); $(".page").hide() $(".page:first").show() - $(".prev_slide").click -> + $("body").on "click",".prev_slide", -> $(this).closest(".page").hide() $(this).closest(".page").prev(".page").show() - $(".next_slide").click -> + $("body").on "click",".next_slide", -> $(this).closest(".page").hide() $(this).closest(".page").next(".page").show() @@ -109,32 +127,7 @@ $ -> - $(".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")) - + @@ -261,93 +254,28 @@ initialize_vie_sol = () -> $(".t_sortable").closest(".animaux_sol").html archive initialize_vie_sol() +initialize_jeu_1 = -> + + $(".sortable_quizz").each -> - + element = $(this) -$(document).ready -> - - - intialize_arbre() - - initialize_vie_sol() - - - - - intialize_places_jeu2() - intialize_places_jeu() - - - - 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(".sortable").sortable + stop: () -> + win = true + i = 0 + element.find("img").each -> + i = i + 1 + win = false unless i is $(this).data("order") - 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() + 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 @@ -355,5 +283,99 @@ $(document).ready -> element.find(".win").hide() element.find(".loose").hide() - initialize_jeu_1() - initialize_jeu_2() +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() + + + + + +$(document).ready -> + + + initialize_plaquette = -> + intialize_arbre() + initialize_vie_sol() + intialize_places_jeu2() + intialize_places_jeu() + intialize_puzzle() + initialize_jeu_1() + initialize_jeu_2() + + $(".quizz_img").hide() + + $(".quizz").each -> + $(this).find(".prev").click -> + test_question($(this).closest(".question")) + $(this).closest(".question").hide() + $(this).closest(".question").prev(".question").show() + + $(this).find(".next").on "click", -> + if test_question($(this).closest(".question")) == true + + $(this).closest(".question").fadeOut(0) + $(this).closest(".question").next(".question").fadeIn(0) + + $(this).find("input").change -> + test_question($(this).closest(".question")) + + $(this).find(".fail, .success").hide() + + $(this).find(".question").hide() + $(this).find(".question:first").show() + + + + + + archive_plaquette = $("body").html() + + + initialize_plaquette() + + $("body").on "click",".restart_plaquette", -> + $("body").html(archive_plaquette) + + initialize_plaquette() + + + + diff --git a/app/assets/stylesheets/plaquettes.css.less b/app/assets/stylesheets/plaquettes.css.less index 31522d2..f52aeaa 100644 --- a/app/assets/stylesheets/plaquettes.css.less +++ b/app/assets/stylesheets/plaquettes.css.less @@ -60,8 +60,8 @@ text-align:center !important; color:white; font-size:30px; -padding:10px 20px; -background:rgba(0,0,0,0.9); +padding:20px 30px; +background:rgba(0,0,0,0.2); position:absolute; bottom:10px; cursor:pointer; @@ -71,15 +71,16 @@ text-align:right; } .next_slide{ - -border-radius:30px 0px 0px 0px; +padding-right:23px; +border-radius:50px 0px 0px 0px; bottom:0px; right:0px; } .prev_slide{ -border-radius:0px 30px 0px 0px; +padding-left:23px; +border-radius:0px 50px 0px 0px; text-align:left; bottom:0px; left:0px; @@ -172,7 +173,8 @@ padding:1em; .quizz{ .quizz_answer{ -margin:1em 0; +margin:1.8em 0; + } label{ @@ -189,8 +191,8 @@ input[type="radio"] { input[type="radio"] + label { position:relative; padding: 0 0 0 25px; - font-size: 20px; - line-height: 20px; + font-size: 25px; + line-height: 25px; } input[type="radio"] + label:before { content:""; @@ -218,9 +220,17 @@ p{ text-align:left; } *{ -font-size:1.2em !important; +font-size:25px !important; } +.quizz_img p, .quizz_ill p{ + +font-size:20px !important; + +} + + + h3{ font-size:1.7em !important; line-height:1.3em; @@ -564,4 +574,25 @@ height:100% !important; } } - +ul{ + +li{ +padding:0.3em; + +} + +} + + +.page_jardins{ +li{ +padding:0.1em; + +} + +} + + + + + diff --git a/app/views/layouts/plaquettes.html.haml b/app/views/layouts/plaquettes.html.haml index bf63a0c..d1aaf05 100644 --- a/app/views/layouts/plaquettes.html.haml +++ b/app/views/layouts/plaquettes.html.haml @@ -10,11 +10,11 @@ - + - - - + + + %body diff --git a/app/views/plaquettes/jardins.html.haml b/app/views/plaquettes/jardins.html.haml index 9a9621d..c895280 100644 --- a/app/views/plaquettes/jardins.html.haml +++ b/app/views/plaquettes/jardins.html.haml @@ -1,5 +1,5 @@ -.page +.page.page_jardins .content{:style => "width:500px;box-sizing:border-box;padding:1em;font-size:0.99em;"} %div{:style => "font-size:1.30em;"} %h1 Un jardin et son compost diff --git a/app/views/plaquettes/remerciements.html.haml b/app/views/plaquettes/remerciements.html.haml index d8e6d93..8dcbad0 100644 --- a/app/views/plaquettes/remerciements.html.haml +++ b/app/views/plaquettes/remerciements.html.haml @@ -16,7 +16,7 @@ %p Nous remercions également l'entreprise Nicolas Bally pour la confection de toute l’application. - + @@ -26,4 +26,8 @@ =image_tag "plaquettes/logos/logo_leader.jpg" =image_tag "plaquettes/logos/logo_CAPV.jpg" =image_tag "plaquettes/logos/logo_nb.png" + + %center + .restart_plaquette.btn + Remettre à zero diff --git a/public/manifest.appcache b/public/manifest.appcache index 0e86e76..145b3ab 100644 --- a/public/manifest.appcache +++ b/public/manifest.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version6 +#version10 CACHE: /plaquettes/index.html @@ -113,8 +113,8 @@ CACHE: /assets/plaquettes/jardin/piege.jpg /assets/plaquettes/jardin/tas.jpg /assets/plaquettes/jardin/campagnol.jpg -/apple-icon.png -/favicon.ico +/apple-iconp.png +/faviconp.ico FALLBACK: