|
54 | 54 | window_w = $(window).width(); |
55 | 55 | if ( window_w < 992 ) { |
56 | 56 | cl_nav.removeClass('fixed scrolled outOfSight'); |
57 | | - } else{ |
| 57 | + } else { |
58 | 58 | window.addEventListener("scroll", updateNav, false); |
59 | 59 | updateNav(); |
60 | 60 | } |
|
160 | 160 | $(this).attr('data-lightbox', galleryTitle); |
161 | 161 | }); |
162 | 162 |
|
| 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 | + } |
163 | 235 | }); |
164 | 236 |
|
165 | 237 | jQuery(window).load(function ($) { |
@@ -253,3 +325,4 @@ function testimonialHeight() { |
253 | 325 | jQuery('.testimonial-section .parallax-window').css('height', jQuery('.testimonial-section .parallax-window .container').outerHeight() + 150); |
254 | 326 | jQuery(window).trigger('resize').trigger('scroll'); |
255 | 327 | } |
| 328 | + |
0 commit comments