• Register
  • Log In
  • Home
  • Quick Start
    • Configurator
    • Download YUI 3
  • Documentation
    • User Guides
    • Examples
    • Tutorials
    • API Docs
  • Community
    • Gallery
    • Blog »
    • Forums
    • YUI Theater
    • Calendar
  • Contribute
    • YUI on GitHub »
    • File a Ticket
    • View Tickets
    • Dashboard
  • Other Projects
    • YUI 2
    • YUI Compressor
    • YUI Doc »
    • YUI Builder
    • YUI PHP Loader
    • YUI Test
    • YUI Website
  • YUI
  • >
  • Community
  • >
  • Gallery

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • FAQ
  • Developer FAQ
  • Developer Guide
  • Module Setup

Tag Cloud

liferay io event foxxtrot davglass node form plugin satyam lsmith model apipkin greghinch async caridy yql jafl animation widget ericf solmsted nzakas css datatable table

Context Navigation

    YUI Library is not responsible for bugs or support with this module. It is available as a free service. For support please contact the module owner with the provided links.

    Shoveler (gallery-shoveler) on cdn

    Last Updated: 03/23/10
    + 0 -

    Greg Schechter

    YUI Contributor

    Created: 03/23/10
    Last CDN Push: 03/23/10
    Build Tag: gallery-2010.03.23-17-54
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.0.0
    Free for use.

    The shoveler is a carousel like module that allows you to shovel back and forth between content. For all your shoveling of item needs. Cycle through products, images, movies, whatever you want. Load things dynamically or have it scroll forever. The Shoveler is made for all your item cycling needs.
    (It's got some browser issues at this point in time but I'm working on fixing them)

    • Tags:
    • gregthebusker
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    There are a lot of options for the use of the shoveler. They are detailed in the code but to get started here's what you need to know.

    First you need your HTML to look right. You need to have a yui-shoveler-body and UL for yui-shoveler-cells. This UL may contain LI.yui-shoveler-cell who's content will be the cell.
    yui-shoveler-page-text is for the page text, and yui-shoveler-button-left/right are the scroll left/right buttons

    <div id="shoveler">
    <div class="yui-shoveler-header">
    <span class="yui-shoveler-page-text"></span>
    <h2>Shoveler Header</h2>
    </div>
    <div class="yui-shoveler-body">
    <div class="yui-shoveler-button-left"></div>
    <ul class="yui-shoveler-cells">
    <li class="yui-shoveler-cell">
    </li>
    </ul>
    <div class="yui-shoveler-button-right"></div>
    </div>
    </div>

    Next we have some options for you to set. Here are the main functions and more can be found documented in the code

    numberOfCells - this is the number of cells the shoveler will have. You only need to set this if you're cells will be dynamic
    dynamic - tells if the cells should load dynamically
    infinite - should the shoveler have an end
    numberOfVisibleCells - this is the number of cells to show at a time
    cyclical - should the shoveler be cyclical. If so the end will point to the beginning
    prefetch - Tells if the shoveler should prefetch dynamic content that is not currently being rendered.
    contructDataSrc - Function to create data src for an ajax request to get dynammic content.
    handleData - Function to handle the data retrieved by the dynamic call

    Check out the examples for good uses of these attributes

    Code Sample

    <script src="http://yui.yahooapis.com/3.0.0/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2010.03.23-17-54'
    }).use('gallery-shoveler', function(Y) {
     
    shoveler1 = new Y.Shoveler( {
            contentBox: "#shoveler1",
    		numberOfVisibleCells: 3,
    		cyclical: true,
    		renderFunctionName: "renderCellsWithPop"
        });
     
        shoveler1.render();
     
    	shoveler2 = new Y.Shoveler( {
            contentBox: "#shoveler2",
    		numberOfVisibleCells: 4,
    		cyclical: true,
    		numberOfCells: 20,
    		dynamic: true,
    		renderFunctionName: "renderCellsWithPop",
    		prefetch: true,
    		contructDataSrc: function(start, numberOfVisibleCells) {
    			var url = "http://query.yahooapis.com/v1/public/yql?"+
    				"q=select%20*%20from%20flickr.photos.search("+
    				start+"%2C"+numberOfVisibleCells+
    				")%20where%20user_id%20%3D%20%2217004938%40N00%22&format=json&callback=shoveler2.handleDataRetrieval";
    			return url;
    		},
     
    		handleData: function(data) {
    			var photos = data.query.results.photo, imageUrl, photo, i, len;
    			for(i = 0, len = photos.length; i < len; i++) {
    				photo = photos[i];
     
    				imageUrl = "http://farm"+photo.farm+
    					".static.flickr.com/"+photo.server+
    					"/"+photo.id+"_"+photo.secret+"_t.jpg";
     
    				this.replaceCell("<img src='"+imageUrl+"'/>"+photo.title, this.get("fetchStart")+i);
     
    			}
    		}
        });
     
        shoveler2.render();
     
    	shoveler3 = new Y.Shoveler( {
            contentBox: "#shoveler3",
    		numberOfVisibleCells: 3,
    		cyclical: true
        });
     
        shoveler3.render();
     
    	Y.get("#shoveler3AddCell").on("click", function() {
    		shoveler3.addCell(shoveler3.get("numberOfCells"));
    	});
     
    	Y.get("#shoveler3RemoveCell").on("click", function() {
    		shoveler3.removeCell(shoveler3.get("numberOfCells")-1);
    	});
     
    	Y.get("#shoveler3AddCell5").on("click", function() {
    		shoveler3.addCell(shoveler3.get("numberOfCells"), 5);
    	});
     
    	shoveler4 = new Y.Shoveler( {
            contentBox: "#shoveler4",
    		numberOfVisibleCells: 3
        });
     
        shoveler4.render();
     
    	shoveler5 = new Y.Shoveler( {
            contentBox: "#shoveler5",
    		numberOfVisibleCells: 5,
    		infinite: true,
    		dynamic: true,
    		contructDataSrc: function(start, numberOfVisibleCells) {
    			var url = "http://query.yahooapis.com/v1/public/yql?"+
    				"q=select%20*%20from%20flickr.photos.search("+
    				start+"%2C"+numberOfVisibleCells+
    				")%20where%20tags%20%3D%20%22monkey%22&format=json&callback=shoveler5.handleDataRetrieval";
    			return url;
    		},
     
    		handleData: function(data) {
    			var photos = data.query.results.photo, imageUrl, photo, i, len;
    			for(i = 0, len = photos.length; i < len; i++) {
    				photo = photos[i];
     
    				imageUrl = "http://farm"+photo.farm+
    					".static.flickr.com/"+photo.server+
    					"/"+photo.id+"_"+photo.secret+"_t.jpg";
     
    				this.replaceCell("<img src='"+imageUrl+"'/>"+photo.title, this.get("fetchStart")+i);
     
    			}
    		}
        });
     
        shoveler5.render();
     
    });

    Forum Posts

    No forum posts for this module.

    © 2006-2011 Yahoo! Inc. All rights reserved.
    All code on this site is licensed under the BSD License unless stated otherwise.
    About This Site · Security Contact Info