Plugin Directory

Changeset 429211


Ignore:
Timestamp:
08/26/2011 07:53:27 PM (14 years ago)
Author:
pastispractice
Message:

cleaned up JS and switched to jQuery

Location:
vimeo-album/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • vimeo-album/trunk/readme.txt

    r382669 r429211  
    11=== Vimeo Album ===
    2 Plugin URI: http://www.robertpasquini.com/nerd/2011/vimeo_album/
    3 Description: Allows the user to embed Vimeo albums by entering a shortcode ([vimeoAlbum album_id="**id from vimeo here**"]) into the post area.
    4 Contributors: Pastispractice
    5 Author: Robert Pasquini
    6 Donate link: http://www.robertpasquini.com/nerd/2011/vimeo_album/
    7 Tags: vimeo, album, gallery
    8 Requires at least: 2.0.2
    9 Tested up to: 3.1.2
    10 Stable tag: 0.2
     2Contributors: pastispractice
     3Donate link: http://
     4Tags: vimeo, album, video, plugin
     5Requires at least: 3
     6Tested up to: 3
     7Stable tag: .2
    118
    12 Create a player with an vimeo album id that has links (thumbs optional), for all videos in the album.
     9Add a vimeo player with a list of all videos in the album that load into player on click
    1310
    1411== Description ==
    1512
    16 This Shortcode takes the album id from a vimeo album and creates 1 player with links for all the videos in the album.
    17 It can be called multiple times and will create multiple players with links on a page.
    18 
    19 To change the size of the videos change vidHeight and vidWidth in vimeo_album.js
    20 To enable thumbnails remove the commented out line in vimeo_album.php
    21 
    22 Don't change the structure of the area in vimeo_album.php commented like this:
    23 
    24     //put the html on page whenever shortcode is called
    25 
    26 unless you understand DOM and are confident you can fix the .js file
     13Add a vimeo player with a list of all videos in the album that load
     14into player on click.
    2715
    2816
    2917== Installation ==
    3018
    31 1. Upload `vimeo_album` folder to the `/wp-content/plugins/` directory
     19This section describes how to install the plugin and get it working.
     20
     21e.g.
     22
     231. Upload `vimeo-album` folder to the `/wp-content/plugins/` directory
    32242. Activate the plugin through the 'Plugins' menu in WordPress
    33 3. ready to use shortcode in [vimeo_album album_id='album id from vimeo goes here'] format
     253. add shortcode tag [vimeoAlbum album_id="your_album_id"]
    3426
    3527== Frequently Asked Questions ==
    3628
    37 = What about by channel or user? =
    38 
    39 If someone else doesn't make it happen soon I may. I'm not sure I have use for those so it may be a while
    40 
    41 = What about css =
    42 
    43 Coming. I just got this working for my site, user friendly features are coming later
     29na
    4430
    4531== Screenshots ==
    46 none
    4732
     331. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
     34the directory of the stable readme.txt, so in this case, `/tags/4.3/screenshot-1.png` (or jpg, jpeg, gif)
     352. This is the second screen shot
    4836
    4937== Changelog ==
    5038
    51 = 0.1 =
    52 * vimeo_album released
     39= 0.01 =
     40* initial release.
    5341
    5442== Upgrade Notice ==
    55 = 0.1 =
    56 * vimeo_album released
     43
     44= 0.01 =
     45initial release.
  • vimeo-album/trunk/vimeo_album.js

    r382669 r429211  
     1var $va = jQuery.noConflict();
     2
     3var vidHeight = 280;
     4var vidWidth = 504;
    15var embedTarget ;   
    2 
    3        
    4 // Tell Vimeo what function to call
    56var oEmbedCallback = 'embedVideo' ;
    6 var firstOEmbedCallback = ['embedVideo', 'test']
    7    
    8 // Set up the URL
    97var oEmbedUrl = 'http://vimeo.com/api/oembed.json';
    10 
    11 // Load the first one in automatically?
    12 var loadFirst = true;
    138   
    149// This function puts the video on the page
    1510function embedVideo(video) {
    16         //alert(embedTarget);
    1711        var videoEmbedCode = video.html;
    18         jQuery('#' + embedTarget).html(unescape(videoEmbedCode));
    19         }
     12        $va(embedTarget).html(unescape(videoEmbedCode));
     13}
     14
     15// This function loads the data from Vimeo
     16function loadScript(url, embedTarget) {
     17        var js = document.createElement('script');
     18        js.setAttribute('src', url);
     19        if ( document.getElementsByTagName('head').item(0).lastChild.getAttribute('src') !== js.getAttribute('src'))
     20        {   document.getElementsByTagName('head').item(0).appendChild(js);  }               
     21}
     22
     23function va_init() {
     24    var links = $va('#content').find('.vimeo_album_wrapper').find('a.vimeoAlbumA');
     25    $va(links).click(function(e){
     26        embedTarget =  '#embed'+ $va(this).closest('div').attr('id').substring(5) ;
     27        loadScript(oEmbedUrl + '?url=' + $va(this).attr('href') + '&width=' + vidWidth + '&height=' + vidHeight + '&callback=' + oEmbedCallback);
     28        e.preventDefault();
     29        return false;       
     30    });
     31}           
     32           
     33$va(document).ready(function() {
     34    va_init();
     35});
     36   
     37
    2038       
    21            
    22             // This function runs when the page loads and adds click events to the links
    23 function init() {
    24     var links = jQuery('#content').find('.vimeo_album_wrapper div:nth-child(2)').find('a');
    25    
    26     for (var i = 0; i < links.size(); i++) {
    27         // Load a video using oEmbed when you click on a thumb
    28         if (document.addEventListener) {
    29             links[i].addEventListener('click', function(e) {
    30             var link = jQuery(this).attr('href');
    31             embedTarget = (jQuery(this).parent().parent().parent().prev().attr('id'));
    32             loadScript(oEmbedUrl + '?url=' + link + '&width=504&height=280&callback=' + oEmbedCallback);
    33             e.preventDefault();
    34             return false;
    35             }, false);
    36         }
    37         // IE (sucks)
    38         else {
    39             links[i].attachEvent('onclick', function(e) {
    40             var link = e.srcElement.parentNode;
    41             loadScript(oEmbedUrl + '?url=' + link.href + '&width=504&height=280&callback=' + oEmbedCallback);
    42             return false;
    43             });
    44         }
    45     } // close for loop
    46            
    47                 // Load in the first videos -- Uses a simpler method then the rest
    48     if (loadFirst) {
    49         embedTargetCounter = jQuery('#content').find('.vimeo_album_wrapper div:first-child');
    50         loadFirstLink = jQuery('#content').find('.vimeo_album_wrapper div:nth-child(2)').find('li :first') ;
    51         for (var i = 0; i < jQuery(embedTargetCounter).size(); i++) {
    52             jQuery('#' + jQuery(embedTargetCounter[i]).attr('id')).html('<iframe src="http://player.vimeo.com/video/'+ jQuery(loadFirstLink[i]).attr('href').substr(17) +'" width="504" height="280" frameborder="0"></iframe>');
    53         }
    54     }
    55 }
    56        
    57         // This function loads the data from Vimeo
    58         function loadScript(url, embedTarget) {
    59             var js = document.createElement('script');
    60             js.setAttribute('src', url);
    61                
    62             if ( document.getElementsByTagName('head').item(0).lastChild.getAttribute('src') != js.getAttribute('src'))
    63                 {
    64                 document.getElementsByTagName('head').item(0).appendChild(js);
    65                 }
    66                
    67             }
    68        
    69 jQuery(document).ready(function() {
    70     init();
    71 });
    72        
    73    
  • vimeo-album/trunk/vimeo_album.php

    r382669 r429211  
    22/*
    33Plugin Name: Vimeo Album
    4 Plugin URI: http://robertpasquini.com/nerd/2011/vimeoalbum
     4Plugin URI: http://robertpasquini.com/code/VimeoAlbum
    55Description: Allows the user to embed Vimeo albums by entering a shortcode ([vimeoAlbum album_id="**id from vimeo here**"]) into the post area.
    66Author: Robert Pasquini
    7 Version: 0.1
     7Version: 0.2
    88Author URI: http://robertpasquini.com
    99License: GPL 2.0, @see http://www.gnu.org/licenses/gpl-2.0.html
    1010*/
     11add_action( 'wp_print_scripts', 'enqueue_vimeo_album_scripts' );
     12add_action( 'wp_print_styles', 'enqueue_vimeo_album_styles' );
     13
     14//http://www.lastlifemedia.com/wptest/testpluginjs.js?ver=3.2.1
     15function enqueue_vimeo_album_scripts(){
     16        wp_enqueue_script( 'vimeoalbumJs', '/wp-content/plugins/vimeo-album/vimeo_album.js', array( 'jquery' ));
     17        }
     18function enqueue_vimeo_album_styles(){
     19        wp_enqueue_style( 'vimeoalbumStyle', '/wp-content/plugins/vimeo-album/vastyle.css');
     20        }
    1121
    1222class vimeo_album {
     
    1424    function shortcode($atts, $content=null)
    1525    {
     26    ob_start();
     27    require_once('/home1/drinkin3/public_html/lastlifemedia/vimeo/vimeo.php');
     28    $vimeo = new phpVimeo('9507bd0c1539525bd6af485f4736355a', 'b99cca6e700fd428');
     29   
    1630    extract( shortcode_atts( array(
    1731        'album_id' => 'no album ID set, get it from vimeo',
     
    3549
    3650        // Load the videos and info
    37         $videos = simplexml_load_string(curl_get($api_endpoint . 'album/' . $album_id . '/videos.xml'));
     51        $videos = $vimeo->call('vimeo.albums.getVideos', array('album_id' => $album_id));
    3852        $info = simplexml_load_string(curl_get($api_endpoint . 'album/' . $album_id . '/info.xml'));
     53       
    3954       
    4055        // Thumbnail and title and album description
     
    4257        $title = $info->album->title;
    4358        $descrip = $info->album->description;
     59        $albumCover =  $info->album->thumbnail_large;
    4460
     61//put the html on page whenever shortcode is called
    4562//put the html on page whenever shortcode is called
    4663    echo "<p>".$descrip."</p>
    4764    <div class='vimeo_album_wrapper'>
    48         <div id='embed".$album_id."' class='embedTargetDiv'></div>
    49         <div id='thumbs".$album_id."' class='embed".$album_id."'>
     65        <div id='embed".$album_id."' class='embedTargetDiv'>
     66            <a href='http://vimeo.com/".$videos->videos->video[0]->id."' class='vimeoAlbumA'>
     67               
     68                <img class='vaAlbumCover' alt='' src='".$albumCover."' />
     69                <span class='va_title'><h2>".$title."</h2></span>   
     70            </a>
     71           
     72        </div>
     73        <div id='thumb".$album_id."' class='embeded".$album_id."'>
    5074            <ul class='vimeo_album-ul'>";
    51              foreach ($videos->video as $video):
     75             foreach ($videos->videos->video as $video):
    5276                echo"
    5377                <li class='vimeo_album-li'>
    54                     <a href='".$video->url."' class='vimeoAlbumA'>
    55                         <!--    <img src='".$video->thumbnail_medium."' class='thumb' /> -->
     78                    <a href='http://vimeo.com/".$video->id."' class='vimeoAlbumA'>
    5679                        ".$video->title."
    5780                    </a>
     
    6487    ";
    6588
    66         //set the location of the vimeo_album.js file
    67         $jsLocation = ('"'.WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__)).'vimeo_album.js'.'"');
    68     ?> 
    69        
    70         <script>
    71         // this will check if vimeo_album.js has been loaded on a previous shortcode call
    72         // and load it if it hasn't
    73         if (jQuery('.vimeo_album_wrapper').attr('class') != "vimeo_album_wrapper ready"){
    74             var vimeo_album_script   = document.createElement("script");
    75             vimeo_album_script.type  = "text/javascript";
    76             vimeo_album_script.src   = (<?php echo $jsLocation ?>);   
    77             document.body.appendChild(vimeo_album_script);
    78             //added a class as a marker to prevent script from loading multitple times.
    79             //There must be a better way to do this
    80             jQuery('.vimeo_album_wrapper').addClass('ready');
    81         }
    82         </script>
    83 <?php
     89$output_string = ob_get_contents();
     90 
     91ob_end_clean();
     92 
     93return $output_string;
    8494    }
    8595}
Note: See TracChangeset for help on using the changeset viewer.