Video autoplay with cookie

This commit is contained in:
Nicolas VARROT 2016-03-21 18:41:25 +01:00
parent bed539c0cf
commit e173d7ced7
3 changed files with 37 additions and 4 deletions

View File

@ -22,11 +22,17 @@ class Public::CustomersAuthsController < ApplicationController
end
if cookies[:video_read] == "true"
@video_must_read = false
else
cookies.permanent[:video_read] = "true"
@video_must_read = true
end
end
def create
@video_must_read = false
@biglogo = true
@customer = Customer.new()
if cookies[:mlm_token] and @parent = Customer.find_parrain(cookies[:mlm_token])

View File

@ -57,10 +57,36 @@
#flashs= bootstrap_flash
-if @video_must_read
:javascript
$(document).ready(function() {
$('#negos-video').magnificPopup({
$.magnificPopup.open({
items: {
src: 'http://www.youtube.com/watch?v=0uf7X-fcu1o'
},
type:'iframe',
iframe: {
markup: '<div class="mfp-iframe-scaler">'+'<div class="mfp-close"></div>'+'<iframe class="mfp-iframe" frameborder="0" allowfullscreen></iframe>'+'</div>',
patterns: {
youtube: {
index: 'youtube.com/',
id: 'v=',
src: '//www.youtube.com/embed/%id%?autoplay=1'
}
},
srcAction: 'iframe_src',
}
});
});
:javascript
$(document).ready(function() {
$('.negos-video').magnificPopup({
items: {
src: 'http://www.youtube.com/watch?v=0uf7X-fcu1o'
},

View File

@ -3,8 +3,8 @@
-if current_customer
%ul
-if current_customer.account_validated?
%li=link_to ic(:"youtube-play")+" Négos, comment ça marche ?","", :class => "btn", id:"negos-video"
%li=link_to ic(:"youtube-play")+" Négos, comment ça marche ?","", :class => "btn negos-video"
-if current_customer.account_validated?
%li=link_to ic(:star)+" Besoins", public_needs_path, :class => "btn"
- unread_message = ContactMessage.where(contact_id: current_customer.id, read_by_customer: false).count
@ -15,5 +15,6 @@
-else
%ul
%li=link_to ic(:"youtube-play")+" Négos, comment ça marche ?","", :class => "btn negos-video"
%li=link_to "S'inscrire", new_public_customer_path(:p => params[:p]), :class => "btn"
%li=link_to "Se connecter", new_public_customers_auth_path(:p => params[:p]), :class => "btn"