Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
<div id="gtm_videojs"  data-options='{"type":"channels","channel_id":"748260", "per_page":8, "gallery":true}'></div>
              
            
!

CSS

              
                #gtm_videojs{width:400px; height:100px;}
#gtm_videojs_gallery{width:400px; top:150px; height:400px; }
body{background-color:#000;}
              
            
!

JS

              
                gt = [];
/*
preroll:"http://videoads.theonion.com/vast/270.xml?url="+window.location+"&description_url="+document.title+"&correlator=" + new Date().getTime(),
postroll:"http://videoads.theonion.com/vast/268.xml?url="+window.location+"&description_url="+document.title+"&correlator=" + new Date().getTime(),
    
    
preroll: "{{DFP Preroll AD}}&url=" + window.location + "&description_url=" + document.title + "&correlator=" + new Date().getTime(),
postroll: "{{DFP Postroll AD}}&url=" + window.location + "&description_url=" + document.title + "&correlator=" + new Date().getTime(),
{{VideoJS Vimeo ID}}
{{DFP Preroll AD}}
{{DFP Postroll AD}}
*/

console.time('GTM Widget - VideoJS TTL: ');
(function() {
    if (typeof EPI !== "function") {
        EPI = function(options) {
            var self = this,
                f = {};
        };
        return EPI;
    }
})();
/*Run EPI Plugin*/
(function() {
    if (typeof epi) {
        var epi = new EPI(),
            state = {
              	vimeo:{cache:{}},
                videojs: {
                    videojs_js: {
                        ready: false,
                        settings: {
page: 1,
per_page: 8,
quality: 1,/* Video Quality: 0=mobile, 1=sd, 2=hd, 3=hls */
size: 3,/* Image Size: 0=75x100, 2=300x640, 3=720x1280 */
debug: window.location.href.indexOf("debug-videojs")>1,
techOrder: ['html5'],
controls: true,
autoplay: false,
autostart:false,                     
preload: "auto",
mute: true,
width: 640,
height: 256,
children: {
  controlBar: {
    children: {
      volumeControl: true,
      muteToggle: true,
      liveDisplay: true
}}},
plugins: {
  ads:{},
  vast: {
preroll:"http://videoads.theonion.com/vast/270.xml?url="+window.location+"&description_url="+document.title+"&correlator=" + new Date().getTime(),
postroll:"http://videoads.theonion.com/vast/268.xml?url="+window.location+"&description_url="+document.title+"&correlator=" + new Date().getTime(),
    url: ""
}},
state: {},
  element: {
    id: 'gtm_videojs'
}}},
   videojs_ads_js: {ready: false},
   vast_client_js: {ready: false},
   videojs_vast_js: {ready: false}
}};
        EPI.prototype.state = $.extend(true, EPI.prototype.state, state);
    }
})();
/*---------Extend Prototype------------*/
(function() {
    var EPI_prototype = {
        init: {
            videojs: function() {
                var epi = new EPI(),
                    state = epi.state.videojs.videojs_js.settings,
                    settings = $.extend(true, state, $('#' + state.element.id).data('options'));
                
                epi.get.vimeo_video(settings, function(response) {
                    if (typeof response.data === "undefined") {response.data = [response];}
                    var options = {
                        poster: response.data[0].pictures.sizes[2].link,
                        video: [{
                            type: response.data[0].files[0].type,
                            src: response.data[0].files[0].link
                        }]};
                    state = $.extend(true, options, settings);
                    epi.place.videojs_element(state, response.data[0]);
                    if (state.gallery){epi.place.videojs_gallery(state);}
                });}},
        get: {
            vimeo_video: function(options, callback) {
                var url, epi = new EPI(),
                    state = epi.state.videojs.videojs_js.settings,
                    settings = $.extend(true, state, options);
                    if (settings.debug) {console.info('get.vimeo_video');}
                switch (settings.type) {
                    case 'videos':url = '/me/videos/' + settings.video_id;break;
                    case 'channels':url = '/channels/' + settings.channel_id + "/videos";break;
                    case 'albums':url = '/albums/' + settings.album_id + "/videos";break;
                    default:url = '/me/videos';
                }
                $.ajax({
                    url: 'https://api.vimeo.com' + url,
                    type: 'get',
                    beforeSend: function(request) {
request.setRequestHeader("Content-Type", 'application/x-www-form-urlencoded');
request.setRequestHeader("Accept", 'application/vnd.vimeo.*+json;version=3.2');
request.setRequestHeader("Authorization", 'bearer 8f229a4865ac46b2389bfea62f5868bd');

                    },
                    data: {
                        per_page: settings.per_page,
                        page: settings.page
                    },
                    success: callback
                }).done(function(data){
                    if (settings.debug) {console.info('get.vimeo_video.done(cache)');
                    /*Catch Bang to enable gallery paging.*/                     
					EPI.prototype.state.vimeo = $.extend(true, EPI.prototype.state.vimeo,{cache:data});
                                        }});}
        },
        place: {videojs_gallery: function(options) {
                var defaults = {element: {class: 'vjs-playlist playlist'}},
                    settings = $.extend(true, defaults, options);
  					build=function(vimeo_data){
                      $.each(vimeo_data, function(key, data) {
                        if (data.status === 'available') {
                            a = $('<a/>', {"class": "vjs-track",
                                on: {
                                    click: function() {
                                        videojs(settings.element.id + '_player').dispose();
                                        $('#' + settings.element.id).empty();
                                        var epi = new EPI();
                                        epi.place.videojs_element({
                                            element: {
                                                id: settings.element.id
                                            },
                                            poster: data.pictures.sizes[settings.size].link,
                                            video: [{
                                                type: data.files[settings.quality].type,
                                                src: data.files[settings.quality].link
                                            }]
                                        }, data);
}}});
                            img = $('<img/>', {"class": "th","src": data.pictures.sizes[0].link});
                            h5 = $('<h5/>', {"text": data.name});
                            li = $('<li/>', {id: data.uri});
                            img.appendTo(a);
                            h5.appendTo(a);
                            a.appendTo(li);
                            li.appendTo('#' + settings.element.id + '_gallery ul');
}});}
                if (settings.debug) {console.info('place.video_gallery()');}
                $('<div/>', {
                    "id": settings.element.id + '_gallery',
                    "class": settings.element.class
                }).insertAfter('#' + settings.element.id);
                $('<ul/>', {
                    "class": "small-block-grid-2 medium-block-grid-3 large-block-grid-4"
                }).appendTo('#' + settings.element.id + '_gallery');
				
                var epi = new EPI();
  				if(epi.state.vimeo.cache.total>1){build(epi.state.vimeo.cache);}else{
                  
                epi.get.vimeo_video(settings, function(response) {
                    if (settings.debug) {console.info('place.video_gallery.build(get.vimeo_video)');}
                  	build(response.data);			
                });
                
                }
  
  },
            videojs_element: function(options, data) {
                var epi = new EPI(),
                    state = epi.state.videojs.videojs_js.settings,
                    defaults = $.extend(true, state, 
                       {element: {class: 'video-js vjs-default-skin vjs-big-play-centered'}
                    }),         
                    settings = $.extend(true, defaults, options),
                    dispose = function() {
                      if (settings.debug) {console.info('place.videojs_element.dispose()');}
                        var player = videojs(settings.element.id + '_player');
                        player.pause();
                        setTimeout(function() {
                            player.dispose();
                            var epi = new EPI();                   
                            epi.place.videojs_element(settings,data);
                        }, 600);
                        $('#' + settings.element.id).empty();
                    },
                    build = function() {
                        if (!settings.plugins.vast.url) {settings.plugins.vast.url = settings.plugins.vast.preroll;}
                        if (settings.debug) {console.info('place.videojs_element.build()');}
                        var container = $('<div/>', {class: "video-wrapper vimeo-embed-container"});
                        $('<video/>', {
                            "id": settings.element.id + '_player',
                            "class": settings.element.class
                        }).appendTo(container);
                        if(settings.plugins.vast.preroll==false){container.trigger('adscanceled');}else{container.trigger('adsready');}
                        container.prependTo('#' + settings.element.id);
                       
                        if ((settings.plugins.vast.url === settings.plugins.vast.postroll)&&(settings.plugins.vast.preroll!=false)) {
                            if (settings.debug) {console.info('videojs_element.build.postroll()');}
                            videojs(settings.element.id + '_player', settings, config).play();
                        } else {
                            if (settings.debug) {console.info('videojs_element.build.preroll()');}
                            videojs(settings.element.id + '_player', settings, config);
                        }
                    },
                    config = function() {if (settings.debug) {console.info('place.videojs_element.config()');}
                        var player = this;
                        player.src(settings.video);
                        settings.state.adPlaying=settings.state.adPlaying || true;
                        settings.state.paused = settings.state.paused || false;          
player.on('contentupdate', function() {if(settings.debug){console.info('player on contentupdate');}
                                      
});

player.on("adend", function() {if (settings.debug){console.info('player on adend');}
settings.state.adPlaying = false;
settings.plugins.vast.url = settings.plugins.vast.url || settings.plugins.vast.preroll;       
                               
if (settings.plugins.vast.url === settings.plugins.vast.preroll) {settings.plugins.vast.url = settings.plugins.vast.postroll;
} else {dispose();settings.plugins.vast.url = settings.plugins.vast.preroll;}
});
player.on("ended", function() {if(settings.debug){console.info('player on ended');}
if(settings.state.adPlaying === false && settings.state.play !== 'Stop') {
dispose();
gt.push({event: 'gtm_video',video: {category: 'Vimeo',action: 'Play Ended',label: data.name,value: data.link}});
}
settings.state.play = 'Stop';
});
player.on("error", function(e) {if (settings.debug) {console.info('player on error');}
var error = this.player().error();                                
gt.push({event: 'gtm_video',video: {category: 'Vimeo',action: 'Error',label: data.name + " | "+ error.message,value: error.code}});
});
player.on("fullscreenchange", function() {
if (settings.debug) {console.info('player on fullscreenschage');}
if (player.isFullscreen()) {settings.state.screen = 'Enter ';} else {settings.state.screen = 'Exit ';}
gt.push({event: 'gtm_video',video: {category: 'Vimeo',action: settings.state.screen + 'Full Screen Mode',label: data.name,value: data.link}});
});
player.on("play", function() {if (settings.debug){
 console.info('player on play');
 console.log("Is an Ad playing? "+settings.state.adPlaying);
 console.log("Was player paused? "+settings.state.paused);
 console.log("Should we update Google Analytics? " + (!settings.state.adPlaying  && !settings.state.paused));
 console.warn("data.name? " + data.name);

}
settings.state.play = 'Start';
if (!settings.state.adPlaying  && !settings.state.paused) {
gt.push({event: 'gtm_video',video: {category: 'Vimeo',action: 'Video Play',label: data.name,value: data.link}});
}
settings.state.paused = false;
});
player.on("volumechange", function() {if (settings.debug) {console.info('player on volumn change');}
gt.push({event: 'gtm_video',video: {category: 'Vimeo',action: 'Volume Change',label: data.name + " | " + data.link,value: player.volume()}});
});
player.on("pause", function() {if (settings.debug) {console.info('player on pause');}
if (settings.state.adPlaying === false) {settings.state.paused = true;}
});
player.on("adstart", function() {if (settings.debug) {console.info('player on adstart');}
settings.state.adPlaying = true;
gt.push({event: 'gtm_video',video: {category: 'Vimeo',action: 'Ad Play',label: 'DFP',value: settings.plugins.vast.url}});
});
                      
                      
player.on("adsready", function() {if (settings.debug) {console.info('player on adsready');}
});                      
player.on("adscanceled", function() {if (settings.debug) {console.info('player on adscanceled');settings.state.adPlaying = false;}
});
player.on("adserror", function() {if (settings.debug) {console.info('player on adserror');}
});
                      
player.on("adclick", function() {if (settings.debug) {console.info('player on adclick');}
gt.push({event: 'gtm_video',video: {category: 'Vimeo',action: 'Ad Click',label: 'DFP',value: settings.plugins.vast.url}});
});
player.on("adtimeout", function() {if (settings.debug) {console.info('player on adtimeout');}
settings.state.adPlaying = false;
});
};
  if(settings.debug){console.info('place.videojs_element');}
                build();
            }
  
  }};
    EPI.prototype = $.extend(true, EPI.prototype, EPI_prototype);
})();
/*Load Prerequisites*/
/*---------Loading videojs.css------------*/
$.each([{"url": "https://vjs.zencdn.net/4.12/video-js.css","type": "link"},
        {"url": "http://sites.eveningpostinteractive.com/js/carbon/vast/videojs.vast.css","type": "link"}, 
        {"url": "http://sites.eveningpostinteractive.com/carbon/stylesheets/vimeo-widget.css","type": "link"}],
       function(index, value){ $("<link/>",{"rel":"stylesheet","href":value.url}).appendTo("head");});
/*---------Loading video.js------------*/
$.getScript( "https://vjs.zencdn.net/4.12.12/video.js", function( data, textStatus, jqxhr ) {
EPI.prototype.state.videojs.videojs_js.ready = true;  
/*---------Video Ads JS------------*/
$.getScript( "http://www.postandcourier.com/js/vimeo/video.ads.js", function( data, textStatus, jqxhr ) {
EPI.prototype.state.videojs.videojs_ads_js.ready = true;
/*---------VideoJS VAST ------------*/  
$.getScript( "http://www.postandcourier.com/js/vimeo/vast-client.js", function( data, textStatus, jqxhr ) {
EPI.prototype.state.videojs.videojs_vast_js.ready = true;  
/*---------VideoJS VAST Client------------*/  
$.getScript( "http://www.postandcourier.com/js/vimeo/videojs.vast.js", function( data, textStatus, jqxhr ) {
EPI.prototype.state.videojs.vast_client_js.ready = true;  
var l = EPI.prototype.state.videojs.videojs_js.ready && EPI.prototype.state.videojs.videojs_ads_js.ready && EPI.prototype.state.videojs.vast_client_js.ready && EPI.prototype.state.videojs.videojs_vast_js.ready;
if(l){var e = new EPI();e.init.videojs();}
});});});});

console.timeEnd('GTM Widget - VideoJS TTL: ');
              
            
!
999px

Console