Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to embed Vimeo video #45 #197

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions app/assets/javascripts/admin.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,12 @@ Crowdhoster.admin =
$('.include_comments_input').slideToggle()

$('input[name="campaign[media_type]"]').on "change", ->
$('#video-options').slideToggle()
$('#image-options').slideToggle()
if $('input[name="campaign[media_type]"]:checked').val() == "image"
$('#video-options').slideUp()
$('#image-options').slideDown()
else
$('#video-options').slideDown()
$('#image-options').slideUp()

$('input#campaign_payment_type_any').on "change", ->
$('#preset-amount').slideUp()
Expand Down
1 change: 0 additions & 1 deletion app/assets/javascripts/validate.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@ $( document ).ready(function() {
"reward[][delivery_date]": { required: true },
"reward[][number]": { number: true },
"campaign[contributor_reference]": { required: true },
"campaign[video_embed_id]": { minlength: 11 , maxlength: 11},
"campaign[primary_call_to_action_button]": { required: true },
"campaign[secondary_call_to_action_button]": { required: true },
"campaign[comments_shortname]": { required: true },
Expand Down
8 changes: 5 additions & 3 deletions app/views/admin/campaigns/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -172,12 +172,14 @@
<div class="field clearfix">
<p class="explanation">We STRONGLY recommend including a video with your project. Just paste the youtube video id (it's the 11 character code that comes at the very end of the youtube url). You can also specify a placeholder image to show over top of the video in case you don't like your video's thumbnail. Alternatively, you can choose to simply upload an image to show instead of a video.</p>

<label class="inline"><input id="campaign_media_type_video" name="campaign[media_type]" value="video" type="radio" <%= @campaign.media_type == 'video' ? "checked" : "" %>>Use Video</label>

<label class="inline"><input id="campaign_media_type_video" name="campaign[media_type]" value="video" type="radio" <%= @campaign.media_type == 'video' ? "checked" : "" %>>Use Youtube</label>
<label class="inline ml-20"><input id="campaign_media_type_vimeo" name="campaign[media_type]" value="vimeo" type="radio" <%= @campaign.media_type == 'vimeo' ? "checked" : "" %>>Use Vimeo</label>
<label class="inline ml-20"><input id="campaign_media_type_image" name="campaign[media_type]" value="image" type="radio" <%= @campaign.media_type == 'image' ? "checked" : "" %>>Use Image</label>



<div id="video-options" style="<%= @campaign.media_type == 'video' ? "" : "display:none" %>">
<label>Youtube Video ID</label>
<label>Video ID</label>
<%= f.text_field :video_embed_id %>
<label>Video Placeholder</label>
<% if @campaign.video_placeholder.file? %>
Expand Down
26 changes: 21 additions & 5 deletions app/views/theme/views/campaign.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,27 @@
</div>

<% else %>

<div id="image">
<%= image_tag @campaign.main_image.url(:main), alt: "project_image" %>
</div>

<% if @campaign.media_type == 'vimeo' %>

<div id="video">
<% if @campaign.video_placeholder.file? %>
<div id="video_image">
<%= image_tag @campaign.video_placeholder.url(:main), alt: "video_place_holder" %>
</div>
<% if [email protected]_embed_id.blank? %>
<iframe src="//player.vimeo.com/video/<%= @campaign.video_embed_id %>?title=0&amp;byline=0&amp;portrait=0&amp;badge=0&amp;color=05597a&amp;autoplay=0" width="512" height="385" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<% end %>
<% else %>
<% if [email protected]_embed_id.blank? %>
<iframe src="//player.vimeo.com/video/<%= @campaign.video_embed_id %>?title=0&amp;byline=0&amp;portrait=0&amp;badge=0&amp;color=05597a&amp;autoplay=0" width="512" height="385" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
<% end %>
<% end %>
</div>
<% else %>
<div id="image">
<%= image_tag @campaign.main_image.url(:main), alt: "project_image" %>
</div>
<% end %>
<% end %>

<div id="backing">
Expand Down