From 811720e5fb2f12002204e784f356fe0abaaaaba0 Mon Sep 17 00:00:00 2001 From: Hans Christian Reinl Date: Sat, 1 Feb 2014 18:45:53 +0100 Subject: [PATCH] Add jQuery video --- plugins/modal.video.js | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 plugins/modal.video.js diff --git a/plugins/modal.video.js b/plugins/modal.video.js new file mode 100644 index 0000000..6649b0b --- /dev/null +++ b/plugins/modal.video.js @@ -0,0 +1,26 @@ +/* + * On closing the modal, stop video + */ +(function () { + 'use strict'; + + $(document) + .on('cssmodal:hide', function () { + var $video = $('.semantic-content iframe'); + var source; + + if ($video.length > 0) { + source = $video.attr('src'); + + $video.attr('src', '').attr('data-src', source); + } + }) + + .on('cssmodal:show', function () { + var $video = $('.semantic-content iframe'); + var dataSource = $video.attr('data-src'); + if ($video.length > 0 && dataSource !== '') { + $video.attr('src', dataSource).attr('data-src', ''); + } + }); +})