From 7a02f86a5bea00765f919a7191bb077eca655c24 Mon Sep 17 00:00:00 2001 From: Pablo Vazquez Date: Wed, 3 Apr 2019 23:39:53 +0200 Subject: [PATCH] UI Landing: open video_url in the page overlay. --- src/templates/projects/landing.pug | 46 +++++++++++++++++++++++------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/templates/projects/landing.pug b/src/templates/projects/landing.pug index 1000b85..fb37b4c 100644 --- a/src/templates/projects/landing.pug +++ b/src/templates/projects/landing.pug @@ -119,6 +119,7 @@ link(href="{{ url_for('static_cloud', filename='assets/css/project-main.css') }} .d-flex | {% if project.extension_props.cloud.video_url %} a.btn.btn-primary.px-5( + class="js-open-overlay-video", href="{{ project.extension_props.cloud.video_url }}", target="_blank") i.pi-play.pr-2 @@ -146,7 +147,7 @@ link(href="{{ url_for('static_cloud', filename='assets/css/project-main.css') }} | {% if n.node_type not in ['comment', 'post'] and n.picture %} .thumbnail.expand-image-links .img-container - a.js-open-overlay( + a.js-open-overlay-image( href="{{ n.picture.thumbnail('l', api=api) }}", title="{{ n.name }}") img(src="{{ n.picture.thumbnail('l', api=api) }}", alt="{{ n.name }}") @@ -191,7 +192,40 @@ script. .html(''); } - //- Click anywhere in the page to hide the overlay. + $("a.js-open-overlay-image").on( "click", function(e) { + e.preventDefault(); + e.stopPropagation(); + + var url = $(this).attr('href'); + showOverlay(''); + }); + + {% if project.extension_props.cloud.video_url %} + //- By isherwood - http://jsfiddle.net/isherwood/cH6e8/ + function getYoutubeId(url) { + var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]*).*/; + var match = url.match(regExp); + + if (match && match[2].length == 11) { + return match[2]; + } else { + return 'error'; + } + } + + var videoId = getYoutubeId('{{ project.extension_props.cloud.video_url }}'); + var iframeMarkup = ''; + + $("a.js-open-overlay-video").on( "click", function(e) { + e.preventDefault(); + e.stopPropagation(); + + showOverlay(iframeMarkup); + }); + {% endif %} + + //- Click anywhere on the page or hit Escape to hide the overlay. $(document).click(function () { hideOverlay(); }); @@ -201,12 +235,4 @@ script. hideOverlay(); } }); - - $("a.js-open-overlay").on( "click", function(e) { - e.preventDefault(); - e.stopPropagation(); - - var url = $(this).attr('href'); - showOverlay(''); - }); | {% endblock %}