summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto@gentoo.org>2015-05-01 00:40:49 +0000
committerJorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto@gentoo.org>2015-05-01 00:40:49 +0000
commitc64ce3ae8de09092f9570ab88a68fe920b0fd970 (patch)
treea9959002055a8bdff0ee46bf82ca6a2a39bf00cd /plugins/jetpack/modules/shortcodes/js
parentAdd easy-table plugin, requested by hwoarang (diff)
downloadblogs-gentoo-c64ce3ae8de09092f9570ab88a68fe920b0fd970.tar.gz
blogs-gentoo-c64ce3ae8de09092f9570ab88a68fe920b0fd970.tar.bz2
blogs-gentoo-c64ce3ae8de09092f9570ab88a68fe920b0fd970.zip
Update plugins and themes to the latest versions.
Signed-off-by: Jorge Manuel B. S. Vicetto (jmbsvicetto) <jmbsvicetto@gentoo.org>
Diffstat (limited to 'plugins/jetpack/modules/shortcodes/js')
-rw-r--r--plugins/jetpack/modules/shortcodes/js/audio-shortcode.js11
-rw-r--r--plugins/jetpack/modules/shortcodes/js/jmpress.js2
-rw-r--r--plugins/jetpack/modules/shortcodes/js/main.js13
-rw-r--r--plugins/jetpack/modules/shortcodes/js/recipes-printthis.js170
-rw-r--r--plugins/jetpack/modules/shortcodes/js/recipes.js11
-rw-r--r--plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js102
6 files changed, 259 insertions, 50 deletions
diff --git a/plugins/jetpack/modules/shortcodes/js/audio-shortcode.js b/plugins/jetpack/modules/shortcodes/js/audio-shortcode.js
index 400219e4..511fd1bf 100644
--- a/plugins/jetpack/modules/shortcodes/js/audio-shortcode.js
+++ b/plugins/jetpack/modules/shortcodes/js/audio-shortcode.js
@@ -1,3 +1,8 @@
+/* jshint onevar:false */
+/* global audioshortcode */
+
+// Note: This file no longer exists on wpcom.
+
(function($) {
window.audioshortcode = {
@@ -19,7 +24,7 @@ window.audioshortcode = {
}
// if the browser removed the script, no-op
- player = $( '#wp-as-' + player_id ).get(0);
+ var player = $( '#wp-as-' + player_id ).get(0);
if ( typeof player === 'undefined' ) {
return;
}
@@ -94,7 +99,7 @@ window.audioshortcode = {
if ( 0 === this[player_id].files.length ) {
$( '#wp-as-' + player_id + '-container' ).html( $( '#wp-as-' + player_id + '-nope' ).html() );
$( '#wp-as-' + player_id + '-controls' ).html( '' );
- } else if ( 1 == this[player_id].files.length ) {
+ } else if ( 1 === this[player_id].files.length ) {
$( '#wp-as-' + player_id + '-controls' ).html( '' );
}
},
@@ -132,7 +137,7 @@ window.audioshortcode = {
next_track: function( player_id, fromClick, loop ) {
var player = $( '#wp-as-' + player_id ).get(0);
var files = this[player_id].files;
- if ( fromClick && ( player.paused || files.length-1 == this[player_id].i ) ) {
+ if ( fromClick && ( player.paused || files.length-1 === this[player_id].i ) ) {
return;
}
diff --git a/plugins/jetpack/modules/shortcodes/js/jmpress.js b/plugins/jetpack/modules/shortcodes/js/jmpress.js
index 294e1fd6..b84bd0ef 100644
--- a/plugins/jetpack/modules/shortcodes/js/jmpress.js
+++ b/plugins/jetpack/modules/shortcodes/js/jmpress.js
@@ -1607,7 +1607,7 @@
current = eventData.current,
jmpress = $(this);
- // tabindex make it focusable so that it can recieve key events
+ // tabindex make it focusable so that it can receive key events
if(!settings.fullscreen) {
jmpress.attr("tabindex", 0);
}
diff --git a/plugins/jetpack/modules/shortcodes/js/main.js b/plugins/jetpack/modules/shortcodes/js/main.js
index a6913f78..c6ed9d07 100644
--- a/plugins/jetpack/modules/shortcodes/js/main.js
+++ b/plugins/jetpack/modules/shortcodes/js/main.js
@@ -16,7 +16,7 @@
* Presentation constructor
*/
function Presentation (wrapper) {
- var _self, size, duration, new_css, ie_regex, matches;
+ var _self, duration, new_css, ie_regex, matches;
_self = this;
@@ -69,8 +69,9 @@
// Register resizing to window when fullscreen
$(window).resize(function() {
- if ( _self.fullscreen )
+ if ( _self.fullscreen ) {
_self.resizePresentation();
+ }
});
// Register the nav bars to move the slides
@@ -111,8 +112,9 @@
// Register ESC key to exit fullscreen
$(window).on('keydown', function( event ) {
- if ( event.which == 27 )
+ if ( event.which === 27 ) {
_self.setFullscreen( false );
+ }
});
// Start the presentation
@@ -176,7 +178,7 @@
$.extend(new_css, {
'-moz-transform' : scale,
'-ms-transform' : scale,
- 'transform' : scale,
+ 'transform' : scale
});
} else {
// webkit scales everything with zoom so we need to offset the right amount
@@ -228,8 +230,9 @@
setAutoplay: function ( on ) {
var _self = this, newAutoplayTime;
- if ( _self.autoPlaying == on )
+ if ( _self.autoPlaying === on ) {
return;
+ }
newAutoplayTime = (on && _self.autoplayTime > 0) ? _self.autoplayTime : 0;
_self.slideshow.jmpress('settings').duration.defaultValue = newAutoplayTime;
diff --git a/plugins/jetpack/modules/shortcodes/js/recipes-printthis.js b/plugins/jetpack/modules/shortcodes/js/recipes-printthis.js
new file mode 100644
index 00000000..a8a52555
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/js/recipes-printthis.js
@@ -0,0 +1,170 @@
+/*
+* printThis v1.3
+* @desc Printing plug-in for jQuery
+* @author Jason Day
+*
+* Resources (based on) :
+* jPrintArea: http://plugins.jquery.com/project/jPrintArea
+* jqPrint: https://github.com/permanenttourist/jquery.jqprint
+* Ben Nadal: http://www.bennadel.com/blog/1591-Ask-Ben-Print-Part-Of-A-Web-Page-With-jQuery.htm
+*
+* Dual licensed under the MIT and GPL licenses:
+* http://www.opensource.org/licenses/mit-license.php
+* http://www.gnu.org/licenses/gpl.html
+*
+* (c) Jason Day 2013
+*
+* Usage:
+*
+* $("#mySelector").printThis({
+* debug: false, * show the iframe for debugging
+* importCSS: true, * import page CSS
+* printContainer: true, * grab outer container as well as the contents of the selector
+* loadCSS: "path/to/my.css", * path to additional css file
+* pageTitle: "", * add title to print page
+* removeInline: false, * remove all inline styles from print elements
+* printDelay: 333, * variable print delay S. Vance
+* header: null * prefix to html
+* });
+*
+* Notes:
+* - the loadCSS will load additional css (with or without @media print) into the iframe, adjusting layout
+*/
+/* jshint onevar: false, smarttabs: true, devel: true */
+;(function ($) {
+ var opt;
+ $.fn.printThis = function (options) {
+ opt = $.extend({}, $.fn.printThis.defaults, options);
+ var $element = this instanceof jQuery ? this : $(this);
+
+ var strFrameName = 'printThis-' + (new Date()).getTime();
+
+ if(window.location.hostname !== document.domain && navigator.userAgent.match(/msie/i)){
+ // Ugly IE hacks due to IE not inheriting document.domain from parent
+ // checks if document.domain is set by comparing the host name against document.domain
+ var iframeContents = '<head><script>document.domain=\\\'' + document.domain + '\\\';</script></head><body></body>';
+ var iframeSrc = 'data:text/html;charset=utf-8,' + encodeURI(iframeContents);
+ var printI= document.createElement('iframe');
+ printI.name = 'printIframe';
+ printI.id = strFrameName;
+ printI.className = 'MSIE';
+ document.body.appendChild(printI);
+ printI.src = iframeSrc;
+
+ } else {
+ // other browsers inherit document.domain, and IE works if document.domain is not explicitly set
+ var $frame = $('<iframe id="' + strFrameName +'" name="printIframe" />');
+ $frame.appendTo('body');
+ }
+
+
+ var $iframe = $('#' + strFrameName);
+
+ // show frame if in debug mode
+ if (!opt.debug) {
+ $iframe.css({
+ position: 'absolute',
+ width: '0px',
+ height: '0px',
+ left: '-600px',
+ top: '-600px'
+ });
+ }
+
+
+ // $iframe.ready() and $iframe.load were inconsistent between browsers
+ setTimeout ( function () {
+
+ var $doc = $iframe.contents();
+
+ // import page stylesheets
+ if (opt.importCSS) {
+ $('link[rel=stylesheet]').each(function () {
+ var href = $(this).attr('href');
+ if (href) {
+ var media = $(this).attr('media') || 'all';
+ $doc.find('head').append('<link type="text/css" rel="stylesheet" href="' + href + '" media="' + media + '">');
+ }
+ });
+ }
+
+ //add title of the page
+ if (opt.pageTitle) {
+ $doc.find('head').append('<title>' + opt.pageTitle + '</title>');
+ }
+
+ // import additional stylesheet
+ if (opt.loadCSS) {
+ $doc.find('head').append('<link type="text/css" rel="stylesheet" href="' + opt.loadCSS + '">');
+ }
+
+ // print header
+ if (opt.header) {
+ $doc.find('body').append(opt.header);
+ }
+
+ // grab $.selector as container
+ if (opt.printContainer) {
+ $doc.find('body').append($element.outer());
+ }
+
+ // otherwise just print interior elements of container
+ else {
+ $element.each(function () {
+ $doc.find('body').append($(this).html());
+ });
+ }
+
+ // remove inline styles
+ if (opt.removeInline) {
+ // $.removeAttr available jQuery 1.7+
+ if ($.isFunction($.removeAttr)) {
+ $doc.find('body *').removeAttr('style');
+ } else {
+ $doc.find('body *').attr('style', '');
+ }
+ }
+
+ setTimeout(function () {
+ if($iframe.hasClass('MSIE')){
+ // check if the iframe was created with the ugly hack
+ // and perform another ugly hack out of neccessity
+ window.frames.printIframe.focus();
+ $doc.find('head').append('<script> window.print(); </script>');
+ } else {
+ // proper method
+ $iframe[0].contentWindow.focus();
+ $iframe[0].contentWindow.print();
+ }
+
+ $element.trigger( 'done');
+ //remove iframe after print
+ if (!opt.debug) {
+ setTimeout(function () {
+ $iframe.remove();
+ }, 1000);
+ }
+
+ }, opt.printDelay);
+
+ }, 333 );
+
+ };
+
+ // defaults
+ $.fn.printThis.defaults = {
+ debug: false, // show the iframe for debugging
+ importCSS: false, // import parent page css
+ printContainer: true, // print outer container/$.selector
+ loadCSS: '', // load an additional css file
+ pageTitle: '', // add title to print page
+ removeInline: false, // remove all inline styles
+ printDelay: 333, // variable print delay S. Vance
+ header: null // prefix to html
+ };
+
+ // $.selector container
+ jQuery.fn.outer = function () {
+ return $($('<div></div>').html(this.clone())).html();
+ };
+})(jQuery);
diff --git a/plugins/jetpack/modules/shortcodes/js/recipes.js b/plugins/jetpack/modules/shortcodes/js/recipes.js
new file mode 100644
index 00000000..3c987acc
--- /dev/null
+++ b/plugins/jetpack/modules/shortcodes/js/recipes.js
@@ -0,0 +1,11 @@
+/* global jetpack_recipes_vars */
+( function( $ ) {
+ $( window ).load( function() {
+ $( '.jetpack-recipe-print a' ).click( function( event ) {
+ event.preventDefault();
+
+ // Print the DIV.
+ $( this ).closest( '.jetpack-recipe' ).printThis( { pageTitle: jetpack_recipes_vars.pageTitle, loadCSS: jetpack_recipes_vars.loadCSS } );
+ } );
+ } );
+} )( jQuery );
diff --git a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
index 5e132097..8bee063f 100644
--- a/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
+++ b/plugins/jetpack/modules/shortcodes/js/slideshow-shortcode.js
@@ -1,3 +1,6 @@
+/* jshint onevar:false, loopfunc:true */
+/* global jetpackSlideshowSettings, escape */
+
function JetpackSlideshow( element, width, height, transition ) {
this.element = element;
this.images = [];
@@ -5,8 +8,9 @@ function JetpackSlideshow( element, width, height, transition ) {
this.transition = transition || 'fade';
var currentWidth = this.element.width();
- if ( !width || width > currentWidth )
+ if ( !width || width > currentWidth ) {
width = currentWidth;
+ }
this.width = width;
this.height = height;
@@ -40,6 +44,8 @@ JetpackSlideshow.prototype.init = function() {
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.align = 'middle';
var caption = document.createElement( 'div' );
caption.className = 'slideshow-slide-caption';
@@ -49,7 +55,7 @@ JetpackSlideshow.prototype.init = function() {
container.style.lineHeight = this.height + 'px';
// Hide loading image once first image has loaded.
- if ( i == 0 ) {
+ if ( i === 0 ) {
if ( img.complete ) {
// IE, image in cache
setTimeout( function() {
@@ -90,51 +96,63 @@ JetpackSlideshow.prototype.finishInit_ = function() {
this.renderControls_();
var self = this;
- // Initialize Cycle instance.
- this.element.cycle( {
- fx: this.transition,
- prev: this.controls.prev,
- next: this.controls.next,
- slideExpr: '.slideshow-slide',
- onPrevNextEvent: function() {
- return self.onCyclePrevNextClick_.apply( self, arguments );
- }
- } );
-
- var slideshow = this.element;
- jQuery( this.controls['stop'] ).click( function() {
- var button = jQuery(this);
- if ( ! button.hasClass( 'paused' ) ) {
- slideshow.cycle( 'pause' );
- button.removeClass( 'running' );
- button.addClass( 'paused' );
- } else {
- button.addClass( 'running' );
- button.removeClass( 'paused' );
- slideshow.cycle( 'resume', true );
- }
- return false;
- } );
+ if ( this.images.length > 1 ) {
+ // Initialize Cycle instance.
+ this.element.cycle( {
+ fx: this.transition,
+ prev: this.controls.prev,
+ next: this.controls.next,
+ slideExpr: '.slideshow-slide',
+ onPrevNextEvent: function() {
+ return self.onCyclePrevNextClick_.apply( self, arguments );
+ }
+ } );
- var controls = jQuery( this.controlsDiv_ );
- slideshow.mouseenter( function() {
- controls.fadeIn();
- } );
- slideshow.mouseleave( function() {
- controls.fadeOut();
- } );
+ var slideshow = this.element;
+ jQuery( this.controls.stop ).click( function() {
+ var button = jQuery(this);
+ if ( ! button.hasClass( 'paused' ) ) {
+ slideshow.cycle( 'pause' );
+ button.removeClass( 'running' );
+ button.addClass( 'paused' );
+ } else {
+ button.addClass( 'running' );
+ button.removeClass( 'paused' );
+ slideshow.cycle( 'resume', true );
+ }
+ 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' );
+ }
this.initialized_ = true;
};
JetpackSlideshow.prototype.renderControls_ = function() {
- if ( this.controlsDiv_ )
+ if ( this.controlsDiv_ ) {
return;
+ }
var controlsDiv = document.createElement( 'div' );
controlsDiv.className = 'slideshow-controls';
- controls = [ 'prev', 'stop', 'next' ];
+ var controls = [ 'prev', 'stop', 'next' ];
for ( var i = 0; i < controls.length; i++ ) {
var controlName = controls[i];
var a = document.createElement( 'a' );
@@ -146,15 +164,16 @@ JetpackSlideshow.prototype.renderControls_ = function() {
this.controlsDiv_ = controlsDiv;
};
-JetpackSlideshow.prototype.onCyclePrevNextClick_ = function( isNext, i, slideElement ) {
+JetpackSlideshow.prototype.onCyclePrevNextClick_ = function( isNext, i/*, slideElement*/ ) {
// If blog_id not present don't track page views
- if ( ! jetpackSlideshowSettings.blog_id )
+ if ( ! jetpackSlideshowSettings.blog_id ) {
return;
+ }
var postid = this.images[i].id;
var stats = new Image();
stats.src = document.location.protocol +
- '//stats.wordpress.com/g.gif?host=' +
+ '//pixel.wp.com/g.gif?host=' +
escape( document.location.host ) +
'&rand=' + Math.random() +
'&blog=' + jetpackSlideshowSettings.blog_id +
@@ -171,8 +190,9 @@ JetpackSlideshow.prototype.onCyclePrevNextClick_ = function( isNext, i, slideEle
$( '.jetpack-slideshow' ).each( function () {
var container = $( this );
- if ( container.data( 'processed' ) )
+ if ( container.data( 'processed' ) ) {
return;
+ }
var slideshow = new JetpackSlideshow( container, container.data( 'width' ), container.data( 'height' ), container.data( 'trans' ) );
slideshow.images = container.data( 'gallery' );
@@ -184,4 +204,4 @@ JetpackSlideshow.prototype.onCyclePrevNextClick_ = function( isNext, i, slideEle
$( document ).ready( jetpack_slideshow_init );
$( 'body' ).on( 'post-load', jetpack_slideshow_init );
-} )( jQuery ); \ No newline at end of file
+} )( jQuery );