Skip to content

Commit

Permalink
Merge pull request #2351 from pascalbetz/add-playsinline
Browse files Browse the repository at this point in the history
add playsinline attribute to ingredient and essence
  • Loading branch information
tvdeyen authored Jul 25, 2022
2 parents 7262c05 + d90be6f commit db975f9
Show file tree
Hide file tree
Showing 9 changed files with 23 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/controllers/alchemy/admin/essence_videos_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def essence_video_params
:controls,
:loop,
:muted,
:playsinline,
:preload,
:attachment_id
)
Expand Down
1 change: 1 addition & 0 deletions app/models/alchemy/ingredients/video.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Video < Alchemy::Ingredient
:height,
:loop,
:muted,
:playsinline,
:preload,
:width

Expand Down
1 change: 1 addition & 0 deletions app/views/alchemy/admin/essence_videos/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<%= f.input :controls %>
<%= f.input :loop %>
<%= f.input :muted %>
<%= f.input :playsinline %>
<%= f.input :preload, collection: %w(auto none metadata),
include_blank: false, input_html: {class: 'alchemy_selectbox'} %>
<%= f.submit Alchemy.t(:save) %>
Expand Down
1 change: 1 addition & 0 deletions app/views/alchemy/admin/ingredients/_video_fields.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<%= f.input :controls, as: :boolean %>
<%= f.input :loop, as: :boolean %>
<%= f.input :muted, as: :boolean %>
<%= f.input :playsinline, as: :boolean %>
<%= f.input :preload, collection: %w(auto none metadata),
include_blank: false, input_html: {class: 'alchemy_selectbox'} %>
1 change: 1 addition & 0 deletions app/views/alchemy/essences/_essence_video_view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
autoplay: content.essence.autoplay,
loop: content.essence.loop,
muted: content.essence.muted,
playsinline: content.essence.playsinline,
preload: content.essence.preload.presence,
width: content.essence.width.presence,
height: content.essence.height.presence do %>
Expand Down
1 change: 1 addition & 0 deletions app/views/alchemy/ingredients/_video_view.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
autoplay: video_view.autoplay,
loop: video_view.loop,
muted: video_view.muted,
playsinline: video_view.playsinline,
preload: video_view.preload.presence,
width: video_view.width.presence,
height: video_view.height.presence do %>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class AddPlaysinlineToAlchemyEssenceVideos < ActiveRecord::Migration[6.0]
def change
return if column_exists?(:alchemy_essence_videos, :playsinline)

add_column :alchemy_essence_videos, :playsinline, :boolean, default: false, null: false
end
end
6 changes: 6 additions & 0 deletions spec/models/alchemy/ingredients/video_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@
it { is_expected.to eq(true) }
end

describe "#playsinline" do
subject { video_ingredient.playsinline }
before { video_ingredient.playsinline = true }
it { is_expected.to eq(true) }
end

describe "#preload" do
subject { video_ingredient.preload }
before { video_ingredient.preload = "auto" }
Expand Down
3 changes: 2 additions & 1 deletion spec/views/alchemy/ingredients/video_view_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
height: 720,
loop: true,
muted: true,
playsinline: true,
preload: "auto",
width: 1280,
)
Expand All @@ -39,7 +40,7 @@
it "renders a video tag with source" do
render ingredient
expect(rendered).to have_selector(
"video[controls][muted][loop][autoplay][preload='auto'][width='1280'][height='720'] source[src]"
"video[controls][muted][playsinline][loop][autoplay][preload='auto'][width='1280'][height='720'] source[src]"
)
end
end
Expand Down

0 comments on commit db975f9

Please sign in to comment.