summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/js')
-rw-r--r--plugins/jetpack/modules/shortcodes/js/facebook.js29
-rw-r--r--plugins/jetpack/modules/shortcodes/js/gist.js28
-rw-r--r--plugins/jetpack/modules/shortcodes/js/instagram.js19
-rw-r--r--plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js49
4 files changed, 91 insertions, 34 deletions
diff --git a/plugins/jetpack/modules/shortcodes/js/facebook.js b/plugins/jetpack/modules/shortcodes/js/facebook.js
new file mode 100644
index 00000000..f955effc
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/js/facebook.js
@@ -0,0 +1,29 @@
+/* global FB, jpfbembed */
+(function( window ) {
+ var facebookEmbed = function() {
+ if ( 'undefined' !== typeof FB && FB.XFBML ) {
+ FB.XFBML.parse();
+ } else {
+ var fbroot = document.createElement( 'div' );
+ fbroot.id = 'fb-root';
+ document.getElementsByTagName( 'body' )[0].appendChild( fbroot );
+
+ jQuery.getScript( '//connect.facebook.net/en_US/sdk.js' );
+ }
+ };
+
+ window.fbAsyncInit = function() {
+ FB.init( {
+ appId : jpfbembed.appid,
+ version: 'v2.3'
+ } );
+
+ FB.XFBML.parse();
+ };
+
+ if ( 'undefined' !== typeof infiniteScroll ) {
+ jQuery( document.body ).on( 'post-load', facebookEmbed );
+ }
+
+ facebookEmbed();
+})( this );
diff --git a/plugins/jetpack/modules/shortcodes/js/gist.js b/plugins/jetpack/modules/shortcodes/js/gist.js
new file mode 100644
index 00000000..2714add4
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/js/gist.js
@@ -0,0 +1,28 @@
+;(function( $, undefined ) {
+ var gistStylesheetLoaded = false,
+ gistEmbed = function() {
+ $( '.gist-oembed' ).each( function( i, el ) {
+ var url = 'https://gist.github.com/' + $( el ).data( 'gist' );
+
+ $.ajax( {
+ url: url,
+ dataType: 'jsonp'
+ } ).done( function( response ) {
+ $( el ).replaceWith( response.div );
+
+ if ( ! gistStylesheetLoaded ) {
+ var stylesheet = '<link rel="stylesheet" href="' +
+ response.stylesheet +
+ '" type="text/css" />';
+
+ $( 'head' ).append( stylesheet );
+
+ gistStylesheetLoaded = true;
+ }
+ } );
+ } );
+ };
+
+ $( document ).ready( gistEmbed );
+ $( 'body' ).on( 'post-load', gistEmbed );
+})( jQuery );
diff --git a/plugins/jetpack/modules/shortcodes/js/instagram.js b/plugins/jetpack/modules/shortcodes/js/instagram.js
new file mode 100644
index 00000000..ab7d9668
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/js/instagram.js
@@ -0,0 +1,19 @@
+(function( instgrm ) {
+ var instagramEmbed = function() {
+ if ( 'undefined' !== typeof instgrm && instgrm.Embeds && instgrm.Embeds.process ) {
+ instgrm.Embeds.process();
+ } else {
+ var s = document.createElement( 'script' );
+ s.async = true;
+ s.defer = true;
+ s.src = '//platform.instagram.com/en_US/embeds.js';
+ document.getElementsByTagName( 'body' )[0].appendChild( s );
+ }
+ };
+
+ if ( 'undefined' !== typeof jQuery && 'undefined' !== typeof infiniteScroll ) {
+ jQuery( document.body ).on( 'post-load', instagramEmbed );
+ }
+
+ instagramEmbed();
+})(); \ No newline at end of file
diff --git a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
index 8bee063f..38531e0c 100644
--- a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
+++ b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
@@ -1,22 +1,12 @@
/* jshint onevar:false, loopfunc:true */
/* global jetpackSlideshowSettings, escape */
-function JetpackSlideshow( element, width, height, transition ) {
+function JetpackSlideshow( element, transition, autostart ) {
this.element = element;
this.images = [];
this.controls = {};
this.transition = transition || 'fade';
-
- var currentWidth = this.element.width();
- if ( !width || width > currentWidth ) {
- width = currentWidth;
- }
-
- this.width = width;
- this.height = height;
- this.element.css( {
- 'height': this.height + 'px'
- } );
+ this.autostart = autostart;
}
JetpackSlideshow.prototype.showLoadingImage = function( toggle ) {
@@ -27,7 +17,6 @@ JetpackSlideshow.prototype.showLoadingImage = function( toggle ) {
img.src = jetpackSlideshowSettings.spinner;
this.loadingImage_.appendChild( img );
this.loadingImage_.appendChild( this.makeZeroWidthSpan() );
- this.loadingImage_.style.lineHeight = this.height + 'px';
this.element.append( this.loadingImage_ );
} else if ( this.loadingImage_ ) {
this.loadingImage_.parentNode.removeChild( this.loadingImage_ );
@@ -43,16 +32,16 @@ JetpackSlideshow.prototype.init = function() {
for ( var i = 0; i < this.images.length; i++ ) {
var imageInfo = this.images[i];
var img = document.createElement( 'img' );
- img.src = imageInfo.src + '?w=' + this.width;
- img.title = imageInfo.title;
- img.alt = imageInfo.alt;
+ img.src = imageInfo.src;
+ img.title = typeof( imageInfo.title ) !== 'undefined' ? imageInfo.title : '';
+ img.alt = typeof( imageInfo.alt ) !== 'undefined' ? imageInfo.alt : '';
img.align = 'middle';
+ img.nopin = 'nopin';
var caption = document.createElement( 'div' );
caption.className = 'slideshow-slide-caption';
caption.innerHTML = imageInfo.caption;
var container = document.createElement('div');
container.className = 'slideshow-slide';
- container.style.lineHeight = this.height + 'px';
// Hide loading image once first image has loaded.
if ( i === 0 ) {
@@ -83,7 +72,7 @@ JetpackSlideshow.prototype.makeZeroWidthSpan = function() {
emptySpan.className = 'slideshow-line-height-hack';
// Having a NBSP makes IE act weird during transitions, but other
// browsers ignore a text node with a space in it as whitespace.
- if (jQuery.browser.msie) {
+ if ( -1 !== window.navigator.userAgent.indexOf( 'MSIE ' ) ) {
emptySpan.appendChild( document.createTextNode(' ') );
} else {
emptySpan.innerHTML = '&nbsp;';
@@ -109,6 +98,13 @@ JetpackSlideshow.prototype.finishInit_ = function() {
} );
var slideshow = this.element;
+
+ if ( ! this.autostart ) {
+ slideshow.cycle( 'pause' );
+ jQuery(this.controls.stop).removeClass( 'running' );
+ jQuery(this.controls.stop).addClass( 'paused' );
+ }
+
jQuery( this.controls.stop ).click( function() {
var button = jQuery(this);
if ( ! button.hasClass( 'paused' ) ) {
@@ -122,21 +118,6 @@ JetpackSlideshow.prototype.finishInit_ = function() {
}
return false;
} );
-
- var controls = jQuery( this.controlsDiv_ );
- slideshow.on( 'mouseenter focusin', function() {
- controls.stop( true, false ).fadeTo( 200, 1 );
- } );
- slideshow.on( 'mouseleave', function() {
- if ( ! jQuery( document.activeElement.parentNode ).hasClass( 'slideshow-controls' ) ) {
- controls.fadeTo( 200, 0 );
- }
- } );
- slideshow.on( 'focusout', function() {
- if ( ! slideshow.is( ':hover' ) ) {
- controls.fadeTo( 200, 0 );
- }
- } );
} else {
this.element.children( ':first' ).show();
this.element.css( 'position', 'relative' );
@@ -194,7 +175,7 @@ JetpackSlideshow.prototype.onCyclePrevNextClick_ = function( isNext, i/*, slideE
return;
}
- var slideshow = new JetpackSlideshow( container, container.data( 'width' ), container.data( 'height' ), container.data( 'trans' ) );
+ var slideshow = new JetpackSlideshow( container, container.data( 'trans' ), container.data( 'autostart' ) );
slideshow.images = container.data( 'gallery' );
slideshow.init();