/* Detect-zoom
* -----------
* Cross Browser Zoom and Pixel Ratio Detector
* Version 1.0.4 | Apr 1 2013
* dual-licensed under the WTFPL and MIT license
* Maintained by https://github/tombigel
* Original developer https://github.com/yonran
*/
//AMD and CommonJS initialization copied from https://github.com/zohararad/audio5js
(function (root, ns, factory) {
"use strict";
if (typeof (module) !== 'undefined' && module.exports) { // CommonJS
module.exports = factory(ns, root);
} else if (typeof (define) === 'function' && define.amd) { // AMD
define("factory", function () {
return factory(ns, root);
});
} else {
root[ns] = factory(ns, root);
}
}(window, 'detectZoom', function () {
/**
* Use devicePixelRatio if supported by the browser
* @return {Number}
* @private
*/
var devicePixelRatio = function () {
return window.devicePixelRatio || 1;
};
/**
* Fallback function to set default values
* @return {Object}
* @private
*/
var fallback = function () {
return {
zoom: 1,
devicePxPerCssPx: 1
};
};
/**
* IE 8 and 9: no trick needed!
* TODO: Test on IE10 and Windows 8 RT
* @return {Object}
* @private
**/
var ie8 = function () {
var zoom = Math.round((screen.deviceXDPI / screen.logicalXDPI) * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* For IE10 we need to change our technique again...
* thanks https://github.com/stefanvanburen
* @return {Object}
* @private
*/
var ie10 = function () {
var zoom = Math.round((document.documentElement.offsetHeight / window.innerHeight) * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* Mobile WebKit
* the trick: window.innerWIdth is in CSS pixels, while
* screen.width and screen.height are in system pixels.
* And there are no scrollbars to mess up the measurement.
* @return {Object}
* @private
*/
var webkitMobile = function () {
var deviceWidth = (Math.abs(window.orientation) == 90) ? screen.height : screen.width;
var zoom = deviceWidth / window.innerWidth;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* Desktop Webkit
* the trick: an element's clientHeight is in CSS pixels, while you can
* set its line-height in system pixels using font-size and
* -webkit-text-size-adjust:none.
* device-pixel-ratio: http://www.webkit.org/blog/55/high-dpi-web-sites/
*
* Previous trick (used before http://trac.webkit.org/changeset/100847):
* documentElement.scrollWidth is in CSS pixels, while
* document.width was in system pixels. Note that this is the
* layout width of the document, which is slightly different from viewport
* because document width does not include scrollbars and might be wider
* due to big elements.
* @return {Object}
* @private
*/
var webkit = function () {
var important = function (str) {
return str.replace(/;/g, " !important;");
};
var div = document.createElement('div');
div.innerHTML = "1
2
3
4
5
6
7
8
9
0";
div.setAttribute('style', important('font: 100px/1em sans-serif; -webkit-text-size-adjust: none; text-size-adjust: none; height: auto; width: 1em; padding: 0; overflow: visible;'));
// The container exists so that the div will be laid out in its own flow
// while not impacting the layout, viewport size, or display of the
// webpage as a whole.
// Add !important and relevant CSS rule resets
// so that other rules cannot affect the results.
var container = document.createElement('div');
container.setAttribute('style', important('width:0; height:0; overflow:hidden; visibility:hidden; position: absolute;'));
container.appendChild(div);
document.body.appendChild(container);
var zoom = 1000 / div.clientHeight;
zoom = Math.round(zoom * 100) / 100;
document.body.removeChild(container);
return{
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* no real trick; device-pixel-ratio is the ratio of device dpi / css dpi.
* (Note that this is a different interpretation than Webkit's device
* pixel ratio, which is the ratio device dpi / system dpi).
*
* Also, for Mozilla, there is no difference between the zoom factor and the device ratio.
*
* @return {Object}
* @private
*/
var firefox4 = function () {
var zoom = mediaQueryBinarySearch('min--moz-device-pixel-ratio', '', 0, 10, 20, 0.0001);
zoom = Math.round(zoom * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom
};
};
/**
* Firefox 18.x
* Mozilla added support for devicePixelRatio to Firefox 18,
* but it is affected by the zoom level, so, like in older
* Firefox we can't tell if we are in zoom mode or in a device
* with a different pixel ratio
* @return {Object}
* @private
*/
var firefox18 = function () {
return {
zoom: firefox4().zoom,
devicePxPerCssPx: devicePixelRatio()
};
};
/**
* works starting Opera 11.11
* the trick: outerWidth is the viewport width including scrollbars in
* system px, while innerWidth is the viewport width including scrollbars
* in CSS px
* @return {Object}
* @private
*/
var opera11 = function () {
var zoom = window.top.outerWidth / window.top.innerWidth;
zoom = Math.round(zoom * 100) / 100;
return {
zoom: zoom,
devicePxPerCssPx: zoom * devicePixelRatio()
};
};
/**
* Use a binary search through media queries to find zoom level in Firefox
* @param property
* @param unit
* @param a
* @param b
* @param maxIter
* @param epsilon
* @return {Number}
*/
var mediaQueryBinarySearch = function (property, unit, a, b, maxIter, epsilon) {
var matchMedia;
var head, style, div;
if (window.matchMedia) {
matchMedia = window.matchMedia;
} else {
head = document.getElementsByTagName('head')[0];
style = document.createElement('style');
head.appendChild(style);
div = document.createElement('div');
div.className = 'mediaQueryBinarySearch';
div.style.display = 'none';
document.body.appendChild(div);
matchMedia = function (query) {
style.sheet.insertRule('@media ' + query + '{.mediaQueryBinarySearch ' + '{text-decoration: underline} }', 0);
var matched = getComputedStyle(div, null).textDecoration == 'underline';
style.sheet.deleteRule(0);
return {matches: matched};
};
}
var ratio = binarySearch(a, b, maxIter);
if (div) {
head.removeChild(style);
document.body.removeChild(div);
}
return ratio;
function binarySearch(a, b, maxIter) {
var mid = (a + b) / 2;
if (maxIter <= 0 || b - a < epsilon) {
return mid;
}
var query = "(" + property + ":" + mid + unit + ")";
if (matchMedia(query).matches) {
return binarySearch(mid, b, maxIter - 1);
} else {
return binarySearch(a, mid, maxIter - 1);
}
}
};
/**
* Generate detection function
* @private
*/
var detectFunction = (function () {
var func = fallback;
//IE8+
if (!isNaN(screen.logicalXDPI) && !isNaN(screen.systemXDPI)) {
func = ie8;
}
// IE10+ / Touch
else if (window.navigator.msMaxTouchPoints) {
func = ie10;
}
//Mobile Webkit
else if ('orientation' in window && typeof document.body.style.webkitMarquee === 'string') {
func = webkitMobile;
}
//WebKit
else if (typeof document.body.style.webkitMarquee === 'string') {
func = webkit;
}
//Opera
else if (navigator.userAgent.indexOf('Opera') >= 0) {
func = opera11;
}
//Last one is Firefox
//FF 18.x
else if (window.devicePixelRatio) {
func = firefox18;
}
//FF 4.0 - 17.x
else if (firefox4().zoom > 0.001) {
func = firefox4;
}
return func;
}());
return ({
/**
* Ratios.zoom shorthand
* @return {Number} Zoom level
*/
zoom: function () {
return detectFunction().zoom;
},
/**
* Ratios.devicePxPerCssPx shorthand
* @return {Number} devicePxPerCssPx level
*/
device: function () {
return detectFunction().devicePxPerCssPx;
}
});
}));
var wpcom_img_zoomer = {
zoomed: false,
timer: null,
interval: 1000, // zoom polling interval in millisecond
// Should we apply width/height attributes to control the image size?
imgNeedsSizeAtts: function( img ) {
// Do not overwrite existing width/height attributes.
if ( img.getAttribute('width') !== null || img.getAttribute('height') !== null )
return false;
// Do not apply the attributes if the image is already constrained by a parent element.
if ( img.width < img.naturalWidth || img.height < img.naturalHeight )
return false;
return true;
},
init: function() {
var t = this;
try{
t.zoomImages();
t.timer = setInterval( function() { t.zoomImages(); }, t.interval );
}
catch(e){
}
},
stop: function() {
if ( this.timer )
clearInterval( this.timer );
},
getScale: function() {
var scale = detectZoom.device();
// Round up to 1.5 or the next integer below the cap.
if ( scale <= 1.0 ) scale = 1.0;
else if ( scale <= 1.5 ) scale = 1.5;
else if ( scale <= 2.0 ) scale = 2.0;
else if ( scale <= 3.0 ) scale = 3.0;
else if ( scale <= 4.0 ) scale = 4.0;
else scale = 5.0;
return scale;
},
shouldZoom: function( scale ) {
var t = this;
// Do not operate on hidden frames.
if ( "innerWidth" in window && !window.innerWidth )
return false;
// Don't do anything until scale > 1
if ( scale == 1.0 && t.zoomed == false )
return false;
return true;
},
zoomImages: function() {
var t = this;
var scale = t.getScale();
if ( ! t.shouldZoom( scale ) ){
return;
}
t.zoomed = true;
// Loop through all the elements on the page.
var imgs = document.getElementsByTagName("img");
for ( var i = 0; i < imgs.length; i++ ) {
// Skip images that don't need processing.
var imgScale = imgs[i].getAttribute("scale");
if ( imgScale == scale || imgScale == "0" )
continue;
// Skip images that have already failed at this scale
var scaleFail = imgs[i].getAttribute("scale-fail");
if ( scaleFail && scaleFail <= scale )
continue;
// Skip images that have no dimensions yet.
if ( ! ( imgs[i].width && imgs[i].height ) )
continue;
if ( t.scaleImage( imgs[i], scale ) ) {
// Mark the img as having been processed at this scale.
imgs[i].setAttribute("scale", scale);
}
else {
// Set the flag to skip this image.
imgs[i].setAttribute("scale", "0");
}
}
},
scaleImage: function( img, scale ) {
var t = this;
var newSrc = img.src;
// Skip slideshow images
if ( img.parentNode.className.match(/slideshow-slide/) )
return false;
// Scale gravatars that have ?s= or ?size=
if ( img.src.match( /^https?:\/\/([^\/]*\.)?gravatar\.com\/.+[?&](s|size)=/ ) ) {
newSrc = img.src.replace( /([?&](s|size)=)(\d+)/, function( $0, $1, $2, $3 ) {
// Stash the original size
var originalAtt = "originals",
originalSize = img.getAttribute(originalAtt);
if ( originalSize === null ) {
originalSize = $3;
img.setAttribute(originalAtt, originalSize);
if ( t.imgNeedsSizeAtts( img ) ) {
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
}
}
// Get the width/height of the image in CSS pixels
var size = img.clientWidth;
// Convert CSS pixels to device pixels
var targetSize = Math.ceil(img.clientWidth * scale);
// Don't go smaller than the original size
targetSize = Math.max( targetSize, originalSize );
// Don't go larger than the service supports
targetSize = Math.min( targetSize, 512 );
return $1 + targetSize;
});
}
// Scale resize queries (*.files.wordpress.com) that have ?w= or ?h=
else if ( img.src.match( /^https?:\/\/([^\/]+)\.files\.wordpress\.com\/.+[?&][wh]=/ ) ) {
if ( img.src.match( /[?&]crop/ ) )
return false;
var changedAttrs = {};
var matches = img.src.match( /([?&]([wh])=)(\d+)/g );
for ( var i = 0; i < matches.length; i++ ) {
var lr = matches[i].split( '=' );
var thisAttr = lr[0].replace(/[?&]/g, '' );
var thisVal = lr[1];
// Stash the original size
var originalAtt = 'original' + thisAttr, originalSize = img.getAttribute( originalAtt );
if ( originalSize === null ) {
originalSize = thisVal;
img.setAttribute(originalAtt, originalSize);
if ( t.imgNeedsSizeAtts( img ) ) {
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
}
}
// Get the width/height of the image in CSS pixels
var size = thisAttr == 'w' ? img.clientWidth : img.clientHeight;
var naturalSize = ( thisAttr == 'w' ? img.naturalWidth : img.naturalHeight );
// Convert CSS pixels to device pixels
var targetSize = Math.ceil(size * scale);
// Don't go smaller than the original size
targetSize = Math.max( targetSize, originalSize );
// Don't go bigger unless the current one is actually lacking
if ( scale > img.getAttribute("scale") && targetSize <= naturalSize )
targetSize = thisVal;
// Don't try to go bigger if the image is already smaller than was requested
if ( naturalSize < thisVal )
targetSize = thisVal;
if ( targetSize != thisVal )
changedAttrs[ thisAttr ] = targetSize;
}
var w = changedAttrs.w || false;
var h = changedAttrs.h || false;
if ( w ) {
newSrc = img.src.replace(/([?&])w=\d+/g, function( $0, $1 ) {
return $1 + 'w=' + w;
});
}
if ( h ) {
newSrc = newSrc.replace(/([?&])h=\d+/g, function( $0, $1 ) {
return $1 + 'h=' + h;
});
}
}
// Scale mshots that have width
else if ( img.src.match(/^https?:\/\/([^\/]+\.)*(wordpress|wp)\.com\/mshots\/.+[?&]w=\d+/) ) {
newSrc = img.src.replace( /([?&]w=)(\d+)/, function($0, $1, $2) {
// Stash the original size
var originalAtt = 'originalw', originalSize = img.getAttribute(originalAtt);
if ( originalSize === null ) {
originalSize = $2;
img.setAttribute(originalAtt, originalSize);
if ( t.imgNeedsSizeAtts( img ) ) {
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
}
}
// Get the width of the image in CSS pixels
var size = img.clientWidth;
// Convert CSS pixels to device pixels
var targetSize = Math.ceil(size * scale);
// Don't go smaller than the original size
targetSize = Math.max( targetSize, originalSize );
// Don't go bigger unless the current one is actually lacking
if ( scale > img.getAttribute("scale") && targetSize <= img.naturalWidth )
targetSize = $2;
if ( $2 != targetSize )
return $1 + targetSize;
return $0;
});
}
// Scale simple imgpress queries (s0.wp.com) that only specify w/h/fit
else if ( img.src.match(/^https?:\/\/([^\/.]+\.)*(wp|wordpress)\.com\/imgpress\?(.+)/) ) {
var imgpressSafeFunctions = ["zoom", "url", "h", "w", "fit", "filter", "brightness", "contrast", "colorize", "smooth", "unsharpmask"];
// Search the query string for unsupported functions.
var qs = RegExp.$3.split('&');
for ( var q in qs ) {
q = qs[q].split('=')[0];
if ( imgpressSafeFunctions.indexOf(q) == -1 ) {
return false;
}
}
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
// Compute new src
if ( scale == 1 )
newSrc = img.src.replace(/\?(zoom=[^&]+&)?/, '?');
else
newSrc = img.src.replace(/\?(zoom=[^&]+&)?/, '?zoom=' + scale + '&');
}
// Scale LaTeX images or Photon queries (i#.wp.com)
else if (
img.src.match(/^https?:\/\/([^\/.]+\.)*(wp|wordpress)\.com\/latex\.php\?(latex|zoom)=(.+)/) ||
img.src.match(/^https?:\/\/i[\d]{1}\.wp\.com\/(.+)/)
) {
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
// Compute new src
if ( scale == 1 )
newSrc = img.src.replace(/\?(zoom=[^&]+&)?/, '?');
else
newSrc = img.src.replace(/\?(zoom=[^&]+&)?/, '?zoom=' + scale + '&');
}
// Scale static assets that have a name matching *-1x.png or *@1x.png
else if ( img.src.match(/^https?:\/\/[^\/]+\/.*[-@]([12])x\.(gif|jpeg|jpg|png)(\?|$)/) ) {
// Fix width and height attributes to rendered dimensions.
img.width = img.width;
img.height = img.height;
var currentSize = RegExp.$1, newSize = currentSize;
if ( scale <= 1 )
newSize = 1;
else
newSize = 2;
if ( currentSize != newSize )
newSrc = img.src.replace(/([-@])[12]x\.(gif|jpeg|jpg|png)(\?|$)/, '$1'+newSize+'x.$2$3');
}
else {
return false;
}
// Don't set img.src unless it has changed. This avoids unnecessary reloads.
if ( newSrc != img.src ) {
// Store the original img.src
var prevSrc, origSrc = img.getAttribute("src-orig");
if ( !origSrc ) {
origSrc = img.src;
img.setAttribute("src-orig", origSrc);
}
// In case of error, revert img.src
if ( img.complete )
prevSrc = img.src;
else
prevSrc = origSrc;
img.onerror = function(){
img.src = prevSrc;
if ( img.getAttribute("scale-fail") < scale )
img.setAttribute("scale-fail", scale);
img.onerror = null;
};
// Finally load the new image
img.src = newSrc;
}
return true;
}
};
wpcom_img_zoomer.init();
;
// WARNING: This file is distributed verbatim in Jetpack. There should be nothing WordPress.com specific in this file. @hide-in-jetpack
(function($){ // Open closure
// Local vars
var Scroller, ajaxurl, stats, type, text, totop, timer;
// IE requires special handling
var isIE = ( -1 != navigator.userAgent.search( 'MSIE' ) );
if ( isIE ) {
var IEVersion = navigator.userAgent.match(/MSIE\s?(\d+)\.?\d*;/);
var IEVersion = parseInt( IEVersion[1] );
}
/**
* Loads new posts when users scroll near the bottom of the page.
*/
Scroller = function( settings ) {
var self = this;
// Initialize our variables
this.id = settings.id;
this.body = $( document.body );
this.window = $( window );
this.element = $( '#' + settings.id );
this.wrapperClass = settings.wrapper_class;
this.ready = true;
this.disabled = false;
this.page = 1;
this.offset = settings.offset;
this.order = settings.order;
this.throttle = false;
this.handle = '
' + jQuery.VideoPress.error.messages.age + "
"); } else { jQuery.VideoPress.video.play(container_el); } }, allowedDomain: function (allowed_domains) { if ( jQuery.type(allowed_domains)==="array" ) { if ( jQuery.inArray( top.document.location.hostname, allowed_domains )===-1 ) { return false; } } return true; } }, video:{ flash:{ // Protocol and domain for player_uri and expressinstall set in video.play() player_uri: ( 'https:' == location.protocol ? 'https://v0.wordpress.com' : 'http://s0.videopress.com' ) + "/player.swf?v=1.03", min_version:"10.0.0", params:{wmode:"direct",quality:"autohigh",seamlesstabbing:"true",allowfullscreen:"true",allowscriptaccess:"always",overstretch:"true"}, expressinstall: ( 'https:' == location.protocol ? 'https://v0.wordpress.com' : 'http://s0.videopress.com' ) + "/playerProductInstall.swf", embedCallback: function(event) { if ( event.success===false ) { jQuery("#" + event.id).html("" + jQuery.VideoPress.error.messages.flash + "
"); } } }, types:{mp4:'video/mp4; codecs="avc1.64001E, mp4a.40.2"',ogv:'video/ogg; codecs="theora, vorbis"'}, canPlay:function () { if ( jQuery.VideoPress.support.flash() ) { jQuery.VideoPress.video.playerSupport = "flash"; } else if ( jQuery.VideoPress.support.html5Video() ) { if ( jQuery.VideoPress.support.html5Video( jQuery.VideoPress.video.types.mp4 ) ) { jQuery.VideoPress.video.playerSupport = "mp4"; } else if ( jQuery.VideoPress.support.html5Video( jQuery.VideoPress.video.types.ogv ) ) { jQuery.VideoPress.video.playerSupport = "ogv"; } else { jQuery.VideoPress.video.playerSupport = "html5"; } } else { jQuery.VideoPress.video.playerSupport = ""; } }, prepare: function ( guid, config, count ) { var video = jQuery.VideoPress.data[guid][count]; if ( config.container === undefined || jQuery.type(video)!=="object" ) { return; } var width = 0; if ( config.width !== undefined ) { width = config.width; } else { config.container.width(); } var height = 0; if ( config.height !== undefined ) { height = config.height; } else { config.container.height(); } var div_id = "#v-" + guid + '-' + count; var parent_width = jQuery( div_id ).parent().width(); var diffw = 0; var diffh = 0; var ratio = 0; if ( width > parent_width ) { diffw = width - parent_width + 11; ratio = ( width * 1.0 ) / ( height * 1.0 ); diffh = diffw / ratio; width -= diffw; height -= Math.round( diffh ); } if ( width < 60 || height < 60 ) { width = 400; height = 300; } jQuery.VideoPress.data[guid][count].dimensions = {}; if( 0 == ratio ) { jQuery.VideoPress.data[guid][count].dimensions.width = width; jQuery.VideoPress.data[guid][count].dimensions.height = height; } else { jQuery.VideoPress.data[guid][count].dimensions.width = width - 7; jQuery.VideoPress.data[guid][count].dimensions.height = height - Math.round( 7 / ratio ); jQuery( div_id ).width( width ); jQuery( div_id ).height( height + 50 ); jQuery( div_id + "-placeholder" ).width( jQuery.VideoPress.data[guid][count].dimensions.width ); jQuery( div_id + "-placeholder" ).height( jQuery.VideoPress.data[guid][count].dimensions.height ); jQuery( div_id + "-placeholder img.videopress-poster" ).width( jQuery.VideoPress.data[guid][count].dimensions.width ); jQuery( div_id + "-placeholder img.videopress-poster" ).height( jQuery.VideoPress.data[guid][count].dimensions.height ); } config.container.data( "guid", guid ); config.container.data( "count", count ); if ( jQuery.VideoPress.video.playerSupport === undefined ) { jQuery.VideoPress.video.canPlay(); } if ( config.freedom===true && jQuery.type(video.ogv)==="string" ) { jQuery.VideoPress.video.insert( config.container, guid, count, video, "ogv", jQuery.VideoPress.data[guid][count].dimensions.width, jQuery.VideoPress.data[guid].dimensions.height ); config.container.data( "player", "ogv" ); } else if ( jQuery.VideoPress.video.playerSupport === "flash" ) { config.container.data( "player", "flash" ); config.container.append( '' + jQuery.VideoPress.error.messages.incompatible + '
'); return false; } return true; }, insert: function( container_el, guid, count, video_data, video_type, width, height ) { var video_id = "v-" + guid + "-" + count + "-video"; var video_el = jQuery(""); video_el.attr( "id", video_id ); video_el.attr( "width", width ); video_el.attr( "height", height ); video_el.attr( "poster", video_data.poster ); if ( video_type==="ogv" ) { video_el.attr( "preload", "metadata" ); } else { video_el.attr( "preload", "none" ); } video_el.attr( "controls", "true" ); video_el.attr( "x-webkit-airplay", "allow" ); if ( video_type==="mp4" && video_data.mp4!==undefined && jQuery.type(video_data.mp4.uri)==="string" ) { video_el.attr( "src", video_data.mp4.uri ); } else if ( video_type==="ogv" && video_data.ogv!==undefined && jQuery.type(video_data.ogv.uri)==="string" ) { video_el.attr( "src", video_data.ogv.uri ); } else { // Purposely omit source type attribute since the browser does not seem to support specifics such as canPlayType if ( video_data.mp4!==undefined && jQuery.type(video_data.mp4.uri)==="string" ) { video_el.append( '' + jQuery.VideoPress.error.messages.incompatible + "
" ); video_el.hide(); container_el.append( video_el ); video_el=null; video_id=null; }, play: function( container_el ) { var player = container_el.data( "player" ); if ( player===undefined ) { player="flash"; } var guid = container_el.data( "guid" ); var count = container_el.data( "count" ); if ( player === "flash" ) { jQuery( "#" + container_el.attr("id") + "-placeholder", container_el ).remove(); var player_uri = jQuery.VideoPress.video.flash.player_uri; var expressinstall = jQuery.VideoPress.video.flash.expressinstall; swfobject.embedSWF( player_uri, "v-" + guid + "-" + count + "-video", jQuery.VideoPress.data[guid][count].dimensions.width, jQuery.VideoPress.data[guid][count].dimensions.height, jQuery.VideoPress.video.flash.min_version, expressinstall, {guid:guid,autoPlay:"true",isDynamicSeeking:"true",hd:jQuery.VideoPress.data[guid][count].hd}, jQuery.VideoPress.video.flash.params, null, jQuery.VideoPress.video.flash.embedCallback ); } else if ( jQuery.inArray( player, ["html5", "mp4", "ogv"] ) ) { var video_el = jQuery("video", container_el); if ( video_el ) { jQuery( "#" + container_el.attr("id") + "-placeholder", container_el ).remove(); if ( player==="html5" ) { player = "mp4"; } jQuery.VideoPress.video.playHTML5( video_el, guid, player ); } } else { jQuery( "#" + container_el.attr("id") + "-placeholder", container_el ).remove(); container_el.append( 'Unable to play video. No suitable player.
' ); } }, playHTML5: function( video_el, guid, filetype ) { video_el.show(); video_el[0].load(); /* It seems load() sometimes does not work, but play() will trigger load. * Tried attaching play() to a data event but data might not load * So we trigger play() even if there is not enough data loaded to begin playback */ video_el[0].play(); jQuery.VideoPress.analytics.played(guid, filetype); video_el.bind( "error stalled", function(e) { var message = jQuery.VideoPress.error.messages.error; try { // provide a more detailed error message if a failure reason is communicated switch (e.target.error.code) { case e.target.error.MEDIA_ERR_NETWORK: message = jQuery.VideoPress.error.messages.network; break; case e.target.error.MEDIA_ERR_DECODE: case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED: message = jQuery.VideoPress.error.messages.incapable + " " + filetype.toUpperCase() + "."; break; default: break; } } catch( err ){} // provide an opportunity to silence an error with an empty string if ( message.length > 0 ) { video_el.html( '' + message + "
" ); } message=null; } ); video_el.bind( "durationchange", {guid:guid}, function( event ) { var duration = jQuery(event.target).attr("duration"); if ( jQuery.type(duration)==="number" ) { jQuery.VideoPress.data[event.data.guid].duration = duration; } duration=null; } ); /* Only record stats after video data has loaded * If html5 video seems to work but we could not match on a specific codec descriptor then there may be multiple source elements. Browser chooses a source at runtime in source order. We check the loaded video filetype instead of assuming MP4. */ video_el.one( "loadeddata", {guid:guid, filetype:filetype}, function( event ){ var filetype = event.data.filetype; var loaded_file = jQuery(event.target).attr("currentSrc"); if ( jQuery.type(loaded_file)==="string" && loaded_file.length > 3 ) { var ext = loaded_file.substr( loaded_file.lastIndexOf(".") + 1 ).toLowerCase(); if ( jQuery.inArray( ext, ["mp4","ogv"] ) ) { filetype = ext; } ext=null; } video_el.bind( "play", {guid:event.data.guid,filetype:filetype}, function( event ) { jQuery.VideoPress.analytics.played(event.data.guid, event.data.filetype); } ); video_el.bind( "timeupdate", {guid:event.data.guid,filetype:filetype}, function( event ) { var target = jQuery(event.target); jQuery.VideoPress.analytics.watched( event.data.guid, event.data.filetype, target.attr("currentTime"), target.attr("initialTime") ); target=null; } ); video_el.bind( "ended", {guid:event.data.guid,filetype:filetype}, function( event ) { jQuery.VideoPress.analytics.watched( event.data.guid, event.data.filetype, jQuery.VideoPress.data[guid].duration, jQuery(event.target).attr("initialTime") ); } ); } ); } } }}); ; // @start-hide-in-jetpack if (typeof wpcom === "undefined") { var wpcom = {}; } wpcom.carousel = (function($) { var prebuilt_widths = jetpackCarouselStrings.widths; var pageviews_stats_args = jetpackCarouselStrings.stats_query_args; var findFirstLargeEnoughWidth = function(original_w, original_h, dest_w, dest_h) { var inverse_ratio = original_h / original_w; for ( var i = 0; i < prebuilt_widths.length; ++i ) { if ( prebuilt_widths[i] >= dest_w || prebuilt_widths[i] * inverse_ratio >= dest_h ) return prebuilt_widths[i]; } return original_w; }; var addWidthToImageURL = function(url, width) { width = parseInt(width, 10); // Give devices with a higher devicePixelRatio higher-res images (Retina display = 2, Android phones = 1.5, etc) if ('undefined' != typeof window.devicePixelRatio && window.devicePixelRatio > 1) width = Math.round( width * window.devicePixelRatio ); url = addArgToURL(url, 'w', width); url = addArgToURL(url, 'h', ''); return url; }; var addArgToURL = function(url, arg, value) { var re = new RegExp(arg+'=[^?&]+'); if ( url.match(re) ) { return url.replace(re, arg + '=' + value); } else { var divider = url.indexOf('?') !== -1 ? '&' : '?'; return url + divider + arg + '=' + value; } }; var stat = function ( names ) { if ( typeof names != 'string' ) names = names.join( ',' ); new Image().src = window.location.protocol + '//stats.wordpress.com/g.gif?v=wpcom-no-pv' + '&x_carousel=' + names + '&baba=' + Math.random(); }; var pageview = function ( post_id ) { new Image().src = window.location.protocol + '//stats.wordpress.com/g.gif?host=' + encodeURIComponent( window.location.host ) + '&ref=' + encodeURIComponent( document.referrer ) + '&rand=' + Math.random() + '&' + pageviews_stats_args + '&post=' + encodeURIComponent( post_id ); }; return { findFirstLargeEnoughWidth: findFirstLargeEnoughWidth, addWidthToImageURL: addWidthToImageURL, stat: stat, pageview: pageview }; })(jQuery); // @end-hide-in-jetpack jQuery(document).ready(function($) { // gallery faded layer and container elements var overlay, comments, gallery, container, nextButton, previousButton, info, title, transitionBegin, caption, resizeTimeout, mouseTimeout, photo_info, close_hint, commentInterval, screenPadding = 110, originalOverflow = $('body').css('overflow'), originalHOverflow = $('html').css('overflow'), proportion = 85, last_known_location_hash = ''; if ( window.innerWidth <= 760 ) { screenPadding = Math.round( ( window.innerWidth / 760 ) * 110 ); if ( screenPadding < 40 && ( ( 'ontouchstart' in window ) || window.DocumentTouch && document instanceof DocumentTouch ) ) screenPadding = 0; } var keyListener = function(e){ switch(e.which){ case 38: // up e.preventDefault(); container.scrollTop(container.scrollTop() - 100); break; case 40: // down e.preventDefault(); container.scrollTop(container.scrollTop() + 100); break; case 39: // right e.preventDefault(); gallery.jp_carousel('clearCommentTextAreaValue'); gallery.jp_carousel('next'); break; case 37: // left e.preventDefault(); gallery.jp_carousel('clearCommentTextAreaValue'); gallery.jp_carousel('previous'); break; case 27: // escape e.preventDefault(); gallery.jp_carousel('clearCommentTextAreaValue'); container.jp_carousel('close'); break; default: // making jslint happy break; } }; var resizeListener = function(e){ clearTimeout(resizeTimeout); resizeTimeout = setTimeout(function(){ gallery .jp_carousel('slides') .jp_carousel('fitSlide', true); gallery .jp_carousel('fitInfo', true) .jp_carousel('fitMeta', true); }, 200); }; var prepareGallery = function( dataCarouselExtra ){ if (!overlay) { overlay = $('') .addClass('jp-carousel-overlay') .css({ 'position' : 'absolute', 'top' : 0, 'right' : 0, 'bottom' : 0, 'left' : 0 }); var buttons = '' + jetpackCarouselStrings.comment + ''; if ( 1 == jetpackCarouselStrings.is_logged_in ) { // @start-hide-in-jetpack if ( 1 == jetpackCarouselStrings.is_public ) buttons += '' + jetpackCarouselStrings.reblog + ''; // @end-hide-in-jetpack } buttons = $(' '); caption = $(''); photo_info = $('').append(caption); imageMeta = $('') .addClass('jp-carousel-image-meta') .css({ 'float' : 'right', 'margin-top' : '20px', 'width' : '250px' }); imageMeta .append( buttons ) .append( " " ) .append( " " ) .append( "" ); titleAndDescription = $('') .addClass('jp-carousel-titleanddesc') .css({ 'width' : '100%', 'margin-top' : imageMeta.css('margin-top') }); var commentFormMarkup = ' '; commentForm = $(commentFormMarkup) .css({ 'width' : '100%', 'margin-top' : '20px', 'color' : '#999' }); comments = $('') .addClass('jp-carousel-comments') .css({ 'width' : '100%', 'bottom' : '10px', 'margin-top' : '20px' }); commentsLoading = $(' ') .css({ 'width' : '100%', 'bottom' : '10px', 'margin-top' : '20px' }); leftWidth = ( $(window).width() - ( screenPadding * 2 ) ) - (imageMeta.width() + 40); leftWidth += 'px'; leftColWrapper = $('') .addClass('jp-carousel-left-column-wrapper') .css({ 'width' : Math.floor( leftWidth ) }) .append(titleAndDescription) .append(commentForm) .append(comments) .append(commentsLoading); fadeaway = $('') .addClass('jp-carousel-fadeaway'); info = $('') .addClass('jp-carousel-info') .css({ 'top' : Math.floor( ($(window).height() / 100) * proportion ), 'left' : screenPadding, 'right' : screenPadding }) .append(photo_info) .append(imageMeta); if ( window.innerWidth <= 760 ) { photo_info.remove().insertAfter( titleAndDescription ); info.prepend( leftColWrapper ); } else { info.append( leftColWrapper ); } targetBottomPos = ( $(window).height() - parseInt( info.css('top'), 10 ) ) + 'px'; nextButton = $("