From 27dbfb92e039cc20dcff5c773341aa34442a9ce0 Mon Sep 17 00:00:00 2001 From: Tessier Date: Tue, 22 Sep 2020 18:51:33 +0200 Subject: [PATCH] first push prod --- web/app/themes/la_mine/functions.php | 5 + .../themes/la_mine/src/assets/js/scripts.js | 119 ++++-------------- .../la_mine/src/assets/js/simplePlayer.js | 82 ++++++++++++ web/app/themes/la_mine/templates/accueil.twig | 7 +- .../components/thumbnails/thumbnails.twig | 3 - 5 files changed, 118 insertions(+), 98 deletions(-) create mode 100644 web/app/themes/la_mine/src/assets/js/simplePlayer.js diff --git a/web/app/themes/la_mine/functions.php b/web/app/themes/la_mine/functions.php index 7bc5739f..7b55f1a4 100644 --- a/web/app/themes/la_mine/functions.php +++ b/web/app/themes/la_mine/functions.php @@ -40,6 +40,11 @@ } add_action( 'wp_footer', 'rellax' ); + function simplePlayer(){ + wp_enqueue_script( 'script', + get_template_directory_uri() . '/src/assets/js/simplePlayer.js', array() ); + } + add_action( 'wp_footer', 'simplePlayer' ); function customJs(){ wp_enqueue_script( 'script', diff --git a/web/app/themes/la_mine/src/assets/js/scripts.js b/web/app/themes/la_mine/src/assets/js/scripts.js index 6c03e185..a7ac0b59 100644 --- a/web/app/themes/la_mine/src/assets/js/scripts.js +++ b/web/app/themes/la_mine/src/assets/js/scripts.js @@ -125,104 +125,39 @@ function scrollto(){ }); } -function callPlayer(frame_id, func, args) { - - if (window.jQuery && frame_id instanceof jQuery) frame_id = frame_id.get(0).id; - var iframe = document.getElementById(frame_id); - if (iframe && iframe.tagName.toUpperCase() != 'IFRAME') { - iframe = iframe.getElementsByTagName('iframe')[0]; - } - // When the player is not ready yet, add the event to a queue - // Each frame_id is associated with an own queue. - // Each queue has three possible states: - // undefined = uninitialised / array = queue / .ready=true = ready - - console.log('domReady',iframe); - - if (!callPlayer.queue) callPlayer.queue = {}; - var queue = callPlayer.queue[frame_id], - domReady = document.readyState == 'complete'; - if (domReady && !iframe) { - // DOM is ready and iframe does not exist. Log a message - window.console && console.log('callPlayer: Frame not found; id=' + frame_id); - if (queue) clearInterval(queue.poller); - } else if (func === 'listening') { - // Sending the "listener" message to the frame, to request status updates - if (iframe && iframe.contentWindow) { - func = '{"event":"listening","id":' + JSON.stringify(''+frame_id) + '}'; - iframe.contentWindow.postMessage(func, '*'); - } - } else if ((!queue || !queue.ready) && ( - !domReady || - iframe && !iframe.contentWindow || - typeof func === 'function')) { - if (!queue) queue = callPlayer.queue[frame_id] = []; - queue.push([func, args]); - if (!('poller' in queue)) { - // keep polling until the document and frame is ready - queue.poller = setInterval(function() { - callPlayer(frame_id, 'listening'); - }, 250); - // Add a global "message" event listener, to catch status updates: - messageEvent(1, function runOnceReady(e) { - if (!iframe) { - iframe = document.getElementById(frame_id); - if (!iframe) return; - if (iframe.tagName.toUpperCase() != 'IFRAME') { - iframe = iframe.getElementsByTagName('iframe')[0]; - if (!iframe) return; - } - } - if (e.source === iframe.contentWindow) { - // Assume that the player is ready if we receive a - // message from the iframe - clearInterval(queue.poller); - queue.ready = true; - messageEvent(0, runOnceReady); - // .. and release the queue: - while (tmp = queue.shift()) { - callPlayer(frame_id, tmp[0], tmp[1]); - } - } - }, false); - } - } else if (iframe && iframe.contentWindow) { - // When a function is supplied, just call it (like "onYouTubePlayerReady") - if (func.call) return func(); - // Frame exists, send message - iframe.contentWindow.postMessage(JSON.stringify({ - "event": "command", - "func": func, - "args": args || [], - "id": frame_id - }), "*"); - } - function messageEvent(add, listener) { - var w3 = add ? window.addEventListener : window.removeEventListener; - w3 ? - w3('message', listener, !1) - : - (add ? window.attachEvent : window.detachEvent)('onmessage', listener); - } -} - - -function setupPlayers() { - $('#section_MineVideo .cover').click(function(){ - $(this).fadeOut(); - var id = $(this).parent().find('iframe').attr('id'); - callPlayer(id, function() { - callPlayer(id, "playVideo"); - }); - }); -} +// function setupPlayers() { +// // $('#section_MineVideo .cover').click(function(){ +// // $(this).fadeOut(); +// // var id = $(this).parent().find('iframe').attr('id'); +// // callPlayer(id, function() { +// // callPlayer(id, "playVideo"); +// // }); +// // }); +// // Load the IFrame Player API code asynchronously. +// var tag = document.createElement('script'); +// tag.src = "https://www.youtube.com/player_api"; +// var firstScriptTag = document.getElementsByTagName('script')[0]; +// firstScriptTag.parentNode.insertBefore(tag, firstScriptTag); +// +// // Replace the 'ytplayer' element with an + #} +
+ {# #} {% endif %} diff --git a/web/app/themes/la_mine/templates/components/thumbnails/thumbnails.twig b/web/app/themes/la_mine/templates/components/thumbnails/thumbnails.twig index fc6d8951..3db90aba 100644 --- a/web/app/themes/la_mine/templates/components/thumbnails/thumbnails.twig +++ b/web/app/themes/la_mine/templates/components/thumbnails/thumbnails.twig @@ -47,9 +47,6 @@
{{item.informations_lieu}}
- - -