Skip to content

Commit 65b14e4

Browse files
author
Cosmin
authored
Merge pull request #9 from c0sm1n87/master
video widget
2 parents 94487d8 + 89a5dd0 commit 65b14e4

File tree

4 files changed

+111
-15
lines changed

4 files changed

+111
-15
lines changed

inc/extras.php

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -608,18 +608,4 @@ class="mb0 btn btn-lg btn-filled cfa-button">
608608
<!--end of container-->
609609
</section><?php
610610
}
611-
}
612-
613-
add_action( 'wp_ajax_shapely_get_attachment_image', 'shapely_get_attachment_image' );
614-
add_action( 'wp_ajax_nopriv_shapely_get_attachment_image', 'shapely_get_attachment_image' );
615-
616-
function shapely_get_attachment_image() {
617-
$id = intval( $_POST['attachment_id'] );
618-
$src = wp_get_attachment_image_src( $id, 'full', false );
619-
620-
if ( ! empty( $src[0] ) ) {
621-
echo esc_url( $src[0] );
622-
}
623-
624-
die();
625611
}

js/shapely-scripts.js

Lines changed: 74 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
window_w = $(window).width();
5555
if ( window_w < 992 ) {
5656
cl_nav.removeClass('fixed scrolled outOfSight');
57-
} else{
57+
} else {
5858
window.addEventListener("scroll", updateNav, false);
5959
updateNav();
6060
}
@@ -160,6 +160,78 @@
160160
$(this).attr('data-lightbox', galleryTitle);
161161
});
162162

163+
164+
var videos = $('.video-widget');
165+
if ( videos.length ) {
166+
$.each(videos, function () {
167+
var play = $(this).find('.play-button'),
168+
pause = $(this).find('.pause-button'),
169+
isYoutube = $(this).hasClass('youtube');
170+
171+
if ( isYoutube ) {
172+
var videoId = $(this).attr('data-video-id'),
173+
autoplay = parseInt($(this).attr('data-autoplay')),
174+
instance = $(this).YTPlayer({
175+
fitToBackground: true,
176+
videoId : videoId,
177+
playerVars : {
178+
modestbranding: 0,
179+
autoplay : autoplay,
180+
controls : 0,
181+
showinfo : 0,
182+
branding : 0,
183+
rel : 0,
184+
autohide : 0
185+
}
186+
}),
187+
self = $(this);
188+
189+
190+
$(document).on('YTBGREADY', function () {
191+
var iframe = self.find('iframe'),
192+
height = iframe.height();
193+
194+
if ( self.height() == 0 ) {
195+
self.height(height);
196+
}
197+
});
198+
199+
200+
$(play).on('click', function (e) {
201+
e.preventDefault();
202+
var parent = $(this).parents('.video-widget'),
203+
instance = $(parent).data('ytPlayer').player;
204+
instance.playVideo();
205+
});
206+
207+
$(pause).on('click', function (e) {
208+
e.preventDefault();
209+
var parent = $(this).parents('.video-widget'),
210+
instance = $(parent).data('ytPlayer').player;
211+
instance.pauseVideo();
212+
});
213+
214+
} else {
215+
$(play).on('click', function (e) {
216+
e.preventDefault();
217+
var parent = $(this).parents('.video-widget'),
218+
instance = $(parent).data('vide'),
219+
video = instance.getVideoObject();
220+
221+
video.play();
222+
});
223+
224+
$(pause).on('click', function (e) {
225+
e.preventDefault();
226+
var parent = $(this).parents('.video-widget'),
227+
instance = $(parent).data('vide'),
228+
video = instance.getVideoObject();
229+
230+
video.pause();
231+
});
232+
}
233+
});
234+
}
163235
});
164236

165237
jQuery(window).load(function ($) {
@@ -253,3 +325,4 @@ function testimonialHeight() {
253325
jQuery('.testimonial-section .parallax-window').css('height', jQuery('.testimonial-section .parallax-window .container').outerHeight() + 150);
254326
jQuery(window).trigger('resize').trigger('scroll');
255327
}
328+

single.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@
3232
</div><!-- #primary -->
3333

3434
<?php
35+
3536
get_sidebar();
3637
get_footer();

style.css

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3184,4 +3184,40 @@ footer.bg-dark a {
31843184

31853185
#colophon .customize-partial-edit-shortcut button, #colophon .widget .customize-partial-edit-shortcut button, #secondary .customize-partial-edit-shortcut button, #secondary .widget .customize-partial-edit-shortcut button {
31863186
left: -30px !important;
3187+
}
3188+
3189+
.video-widget {
3190+
position: relative;
3191+
overflow: hidden;
3192+
}
3193+
3194+
.video-widget .video-controls {
3195+
position: absolute;
3196+
bottom: 20px;
3197+
left: 20px;
3198+
}
3199+
3200+
.video-widget .video-controls button {
3201+
background: #745cf9;
3202+
color: #fff;
3203+
border: none;
3204+
outline: none;
3205+
padding: 5px 10px;
3206+
text-align: center;
3207+
}
3208+
3209+
.video-widget.youtube {
3210+
position: relative;
3211+
background: transparent;
3212+
}
3213+
3214+
.ytplayer-container {
3215+
position: absolute;
3216+
top: 0;
3217+
z-index: -1;
3218+
}
3219+
3220+
.shapely_home_parallax {
3221+
width: 100%;
3222+
display: inline-block;
31873223
}

0 commit comments

Comments
 (0)