1 2(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.ModalVideo = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ 3// Polyfill for creating CustomEvents on IE9/10/11 4 5// code pulled from: 6// https://github.com/d4tocchini/customevent-polyfill 7// https://developer.mozilla.org/en-US/docs/Web/API/CustomEvent#Polyfill 8 9try { 10 var ce = new window.CustomEvent('test'); 11 ce.preventDefault(); 12 if (ce.defaultPrevented !== true) { 13 // IE has problems with .preventDefault() on custom events 14 // http://stackoverflow.com/questions/23349191 15 throw new Error('Could not prevent default'); 16 } 17} catch(e) { 18 var CustomEvent = function(event, params) { 19 var evt, origPrevent; 20 params = params || { 21 bubbles: false, 22 cancelable: false, 23 detail: undefined 24 }; 25 26 evt = document.createEvent("CustomEvent"); 27 evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail); 28 origPrevent = evt.preventDefault; 29 evt.preventDefault = function () { 30 origPrevent.call(this); 31 try { 32 Object.defineProperty(this, 'defaultPrevented', { 33 get: function () { 34 return true; 35 } 36 }); 37 } catch(e) { 38 this.defaultPrevented = true; 39 } 40 }; 41 return evt; 42 }; 43 44 CustomEvent.prototype = window.Event.prototype; 45 window.CustomEvent = CustomEvent; // expose definition to window 46} 47 48},{}],2:[function(require,module,exports){ 49/** 50 * Code refactored from Mozilla Developer Network: 51 * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign 52 */ 53 54'use strict'; 55 56function assign(target, firstSource) { 57 if (target === undefined || target === null) { 58 throw new TypeError('Cannot convert first argument to object'); 59 } 60 61 var to = Object(target); 62 for (var i = 1; i < arguments.length; i++) { 63 var nextSource = arguments[i]; 64 if (nextSource === undefined || nextSource === null) { 65 continue; 66 } 67 68 var keysArray = Object.keys(Object(nextSource)); 69 for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) { 70 var nextKey = keysArray[nextIndex]; 71 var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey); 72 if (desc !== undefined && desc.enumerable) { 73 to[nextKey] = nextSource[nextKey]; 74 } 75 } 76 } 77 return to; 78} 79 80function polyfill() { 81 if (!Object.assign) { 82 Object.defineProperty(Object, 'assign', { 83 enumerable: false, 84 configurable: true, 85 writable: true, 86 value: assign 87 }); 88 } 89} 90 91module.exports = { 92 assign: assign, 93 polyfill: polyfill 94}; 95 96},{}],3:[function(require,module,exports){ 97'use strict'; 98 99Object.defineProperty(exports, "__esModule", { 100 value: true 101}); 102 103var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); 104 105require('custom-event-polyfill'); 106 107var _util = require('../lib/util'); 108 109function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } 110 111var assign = require('es6-object-assign').assign; 112 113var defaults = { 114 channel: 'youtube', 115 facebook: {}, 116 youtube: { 117 autoplay: 1, 118 cc_load_policy: 1, 119 color: null, 120 controls: 1, 121 disablekb: 0, 122 enablejsapi: 0, 123 end: null, 124 fs: 1, 125 h1: null, 126 iv_load_policy: 1, 127 list: null, 128 listType: null, 129 loop: 0, 130 modestbranding: null, 131 origin: null, 132 playlist: null, 133 playsinline: null, 134 rel: 0, 135 showinfo: 1, 136 start: 0, 137 wmode: 'transparent', 138 theme: 'dark', 139 nocookie: false 140 }, 141 ratio: '16:9', 142 vimeo: { 143 api: false, 144 autopause: true, 145 autoplay: true,
146 byline: true, 147 callback: null, 148 color: null, 149 height: null, 150 loop: false, 151 maxheight: null, 152 maxwidth: null, 153 player_id: null, 154 portrait: true, 155 title: true, 156 width: null, 157 xhtml: false 158 }, 159 allowFullScreen: true, 160 animationSpeed: 300, 161 classNames: { 162 modalVideo: 'modal-video', 163 modalVideoClose: 'modal-video-close', 164 modalVideoBody: 'modal-video-body', 165 modalVideoInner: 'modal-video-inner', 166 modalVideoIframeWrap: 'modal-video-movie-wrap', 167 modalVideoCloseBtn: 'modal-video-close-btn' 168 }, 169 aria: { 170 openMessage: 'You just openned the modal video', 171 dismissBtnMessage: 'Close the modal by clicking here' 172 } 173}; 174 175var ModalVideo = function () { 176 function ModalVideo(ele, option) { 177 var _this = this; 178 179 _classCallCheck(this, ModalVideo); 180 181 var opt = assign({}, defaults, option); 182 var selectors = typeof ele === 'string' ? document.querySelectorAll(ele) : ele; 183 var body = document.querySelector('body'); 184 var classNames = opt.classNames; 185 var speed = opt.animationSpeed; 186 [].forEach.call(selectors, function (selector) { 187 selector.addEventListener('click', function (event) { 188 if (selector.tagName === 'A') { 189 event.preventDefault(); 190 } 191 var videoId = selector.dataset.videoId; 192 var channel = selector.dataset.channel || opt.channel; 193 var id = (0, _util.getUniqId)(); 194 var videoUrl = selector.dataset.videoUrl || _this.getVideoUrl(opt, channel, videoId); 195 var html = _this.getHtml(opt, videoUrl, id); 196 (0, _util.append)(body, html); 197 var modal = document.getElementById(id); 198 var btn = modal.querySelector('.js-modal-video-dismiss-btn'); 199 modal.focus(); 200 modal.addEventListener('click', function () { 201 (0, _util.addClass)(modal, classNames.modalVideoClose); 202 setTimeout(function () { 203 (0, _util.remove)(modal); 204 selector.focus(); 205 }, speed); 206 }); 207 modal.addEventListener('keydown', function (e) { 208 if (e.which === 9) { 209 e.preventDefault(); 210 if (document.activeElement === modal) { 211 btn.focus(); 212 } else { 213 modal.setAttribute('aria-label', ''); 214 modal.focus(); 215 } 216 } 217 }); 218 btn.addEventListener('click', function () { 219 (0, _util.triggerEvent)(modal, 'click'); 220 }); 221 }); 222 }); 223 } 224 225 _createClass(ModalVideo, [{ 226 key: 'getPadding', 227 value: function getPadding(ratio) { 228 var arr = ratio.split(':'); 229 var width = Number(arr[0]); 230 var height = Number(arr[1]); 231 var padding = height * 100 / width; 232 return padding + '%'; 233 } 234 }, { 235 key: 'getQueryString', 236 value: function getQueryString(obj) { 237 var url = ''; 238 Object.keys(obj).forEach(function (key) { 239 url += key + '=' + obj[key] + '&'; 240 }); 241 return url.substr(0, url.length - 1); 242 } 243 }, { 244 key: 'getVideoUrl', 245 value: function getVideoUrl(opt, channel, videoId) { 246 if (channel === 'youtube') { 247 return this.getYoutubeUrl(opt.youtube, videoId); 248 } else if (channel === 'vimeo') { 249 return this.getVimeoUrl(opt.vimeo, videoId); 250 } else if (channel === 'facebook') { 251 return this.getFacebookUrl(opt.facebook, videoId); 252 } 253 return ''; 254 } 255 }, { 256 key: 'getVimeoUrl', 257 value: function getVimeoUrl(vimeo, videoId) { 258 var query = this.getQueryString(vimeo); 259 return '//player.vimeo.com/video/' + videoId + '?' + query; 260 } 261 }, { 262 key: 'getYoutubeUrl', 263 value: function getYoutubeUrl(youtube, videoId) { 264 var query = this.getQueryString(youtube); 265 if (youtube.nocookie === true) { 266 return '//www.youtube-nocookie.com/embed/' + videoId + '?' + query; 267 } 268 269 return '//www.youtube.com/embed/' + videoId + '?' + query; 270 } 271 }, { 272 key: 'getFacebookUrl', 273 value: function getFacebookUrl(facebook, videoId) { 274 return '//www.facebook.com/v2.10/plugins/video.php?href=https://www.facebook.com/facebook/videos/' + videoId + '&' + this.getQueryString(facebook); 275 } 276 }, { 277 key: 'getHtml', 278 value: function getHtml(opt, videoUrl, id) { 279 var padding = this.getPadding(opt.ratio); 280 var classNames = opt.classNames; 281 return '\n <div class="' + classNames.modalVideo + '" tabindex="-1" role="dialog" aria-label="' + opt.aria.openMessage + '" id="' + id + '">\n <div class="' + classNames.modalVideoBody + '">\n <div class="' + classNames.modalVideoInner + '">\n <div class="' + classNames.modalVideoIframeWrap + '" style="padding-bottom:' + padding + '">\n <button class="' + classNames.modalVideoCloseBtn + ' js-modal-video-dismiss-btn" aria-label="' + opt.aria.dismissBtnMessage + '"></button>\n <iframe width=\'460\' height=\'230\' src="' + videoUrl + '" frameborder=\'0\' allowfullscreen=' + opt.allowFullScreen + ' tabindex="-1"/>\n </div>\n </div>\n </div>\n </div>\n '; 282 } 283 }]); 284 285 return ModalVideo; 286}(); 287 288exports.default = ModalVideo; 289module.exports = exports['default']; 290 291},{"../lib/util":5,"custom-event-polyfill":1,"es6-object-assign":2}],4:[function(require,module,exports){ 292'use strict'; 293 294module.exports = require('./core/'); 295 296},{"./core/":3}],5:[function(require,module,exports){ 297'use strict'; 298 299Object.defineProperty(exports, "__esModule", { 300 value: true 301}); 302var append = exports.append = function append(element, string) { 303 var div = document.createElement('div'); 304 div.innerHTML = string; 305 while (div.children.length > 0) { 306 element.appendChild(div.children[0]); 307 } 308}; 309
310var getUniqId = exports.getUniqId = function getUniqId() { 311 return (Date.now().toString(36) + Math.random().toString(36).substr(2, 5)).toUpperCase(); 312}; 313 314var remove = exports.remove = function remove(element) { 315 if (element && element.parentNode) { 316 element.parentNode.removeChild(element); 317 } 318}; 319 320var addClass = exports.addClass = function addClass(element, className) { 321 if (element.classList) { 322 element.classList.add(className); 323 } else { 324 element.className += ' ' + className; 325 } 326}; 327 328var triggerEvent = exports.triggerEvent = function triggerEvent(el, eventName, options) { 329 var event = void 0; 330 if (window.CustomEvent) { 331 event = new CustomEvent(eventName, { cancelable: true }); 332 } else { 333 event = document.createEvent('CustomEvent'); 334 event.initCustomEvent(eventName, false, false, options); 335 } 336 el.dispatchEvent(event); 337}; 338 339},{}]},{},[4])(4) 340});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.