From e158a56553f8601ba55eba82410a7a71ebb3f264 Mon Sep 17 00:00:00 2001 From: Ben Byrne Date: Fri, 17 May 2013 14:58:41 -0600 Subject: [PATCH 1/5] Fixing max of 5, image linkage --- js/navis-slideshows.js | 32 +-- navis-slideshows.php | 520 ++++++++++++++++++++++------------------- 2 files changed, 299 insertions(+), 253 deletions(-) diff --git a/js/navis-slideshows.js b/js/navis-slideshows.js index b0d9ce1..96f2285 100644 --- a/js/navis-slideshows.js +++ b/js/navis-slideshows.js @@ -16,11 +16,11 @@ function loadSlideshow( postID, permalink, totalSlides ) { startSlide = slideNum; ensureImageIsLoaded( postID, slideNum ); - ensureImageIsLoaded( postID, - getNextSlideNum( slideNum, totalSlides ) + ensureImageIsLoaded( postID, + getNextSlideNum( slideNum, totalSlides ) ); - ensureImageIsLoaded( postID, - getPrevSlideNum( slideNum, totalSlides ) + ensureImageIsLoaded( postID, + getPrevSlideNum( slideNum, totalSlides ) ); jQuery( slidePermalinkElement ).attr( "href", permalink + "#" + startSlide ); @@ -40,8 +40,8 @@ function loadSlideshow( postID, permalink, totalSlides ) { var curSlide = "#" + current; ensureImageIsLoaded( postID, current ); - ensureImageIsLoaded( - postID, getNextSlideNum( current, totalSlides ) + ensureImageIsLoaded( + postID, getNextSlideNum( current, totalSlides ) ); jQuery( slidePermalinkElement ).attr( "href", permalink + curSlide @@ -60,15 +60,15 @@ function loadSlideshow( postID, permalink, totalSlides ) { // Ensure the previous image is loaded when the user goes back jQuery( ".navis-slideshow .slide-nav .prev" ).click( function( evt ) { - ensureImageIsLoaded( - postID, getPrevSlideNum( currentSlide, totalSlides ) + ensureImageIsLoaded( + postID, getPrevSlideNum( currentSlide, totalSlides ) ); }); // Ensure the previous image is loaded when the user goes back jQuery( ".navis-slideshow .slide-nav .next" ).click( function( evt ) { - ensureImageIsLoaded( - postID, getNextSlideNum( currentSlide, totalSlides ) + ensureImageIsLoaded( + postID, getNextSlideNum( currentSlide, totalSlides ) ); }); } @@ -93,14 +93,16 @@ function ensureImageIsLoaded( postID, slideNum ) { var slideDiv = jQuery( "#" + getSlideElement( postID, slideNum ) ); // Do nothing if the slide image already exists - if ( slideDiv.has( "img" ).length ) - return; + if ( slideDiv.has( "img" ).length ) return; - var imgData = slideDiv.attr( "data-src" ); + var imgData = slideDiv.attr( "data-src" ), + urlData = slideDiv.attr( "data-href" ); if ( imgData ) { var parts = imgData.split( "*" ); var img = jQuery( "" ) - .attr( "src", parts[0] ) + .attr( "src", parts[0] ); + if ( urlData ) img = img.wrap("").parent(); + console.log( img.get() ); slideDiv.prepend( img ); } } @@ -110,4 +112,4 @@ function ensureAllImagesAreLoaded( postID, count ) { for ( i = 1; i <= count; i++ ) { ensureImageIsLoaded( getSlideElement( postID, i ) ); } -} +} \ No newline at end of file diff --git a/navis-slideshows.php b/navis-slideshows.php index 10d0ef7..7ff16f3 100644 --- a/navis-slideshows.php +++ b/navis-slideshows.php @@ -2,252 +2,296 @@ /** * Plugin Name: Navis Slideshows * Description: Slideshows that take advantage of the Slides jQuery plugin. - * Version: 0.1 - * Author: Project Argo + * Version: 0.2 + * Author: Project Argo, Crowd Favorite, Cornershop Creative * License: GPLv2 */ /* - Copyright 2011 National Public Radio, Inc. + Copyright 2011 National Public Radio, Inc. - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License, version 2, as - published by the Free Software Foundation. + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License, version 2, as + published by the Free Software Foundation. - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ class Navis_Slideshows { - static $include_slideshow_deps; - - function __construct() { - add_action( 'init', array( &$this, 'add_slideshow_header' ) ); - add_action('wp_head', array( &$this, 'argo_slideshow_css' ) ); - - add_filter( - 'wp_footer', array( &$this, 'conditionally_add_slideshow_deps' ) - ); - - add_filter( - 'post_gallery', array( &$this, 'handle_slideshow' ), 10, 2 - ); - - if ( ! is_admin() ) - return; - - add_action( - 'save_post', array( &$this, 'tag_post_as_slideshow' ), 10, 2 - ); - - } - - - function add_slideshow_header() { - // slides-specific CSS - $slides_css = plugins_url( 'css/slides.css', __FILE__ ); - wp_enqueue_style( - 'navis-slides', $slides_css, array(), '1.0' - ); - } - - //add slideshow width to header - function argo_slideshow_css() { - ?> - - 'ASC', - 'orderby' => 'menu_order ID', - 'id' => $post->ID, - 'itemtag' => 'dl', - 'icontag' => 'dt', - 'captiontag' => 'dd', - 'columns' => 3, - 'size' => 'thumbnail', - ), $attr ) ); - - $id = intval( $id ); - // XXX: this could be factored out to a common function for getting - // a post's images - $attachments = get_children( array( - 'post_parent' => $id, - 'post_status' => 'inherit', - 'post_type' => 'attachment', - 'post_mime_type' => 'image', - 'order' => $order, - 'orderby' => $orderby - ) ); - - if ( empty( $attachments ) ) - return ''; - - if ( is_feed() ) { - $output = "\n"; - foreach ( $attachments as $id => $attachment ) - $output .= wp_get_attachment_link( $id, $size, true ) . "\n"; - return $output; - } - - $postid = $post->ID; - $plink = get_permalink(); - - $output .= ' -