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

Gallery

Modules

  • Home
  • Featured
  • Popular
  • New
  • All

Documentation

  • Yogi Documentation
  • Shifter Documentation
  • Developer Guide
  • Module Setup

Tag Cloud

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.

    History Lite (gallery-history-lite) on cdn

    Last Updated: 01/4/11
    + 4 -

    Ryan Grove

    YUI Developer

    See 3 more by this user.

    Featured Item

    Created: 10/30/09
    Last CDN Push: 12/15/09
    Build Tag: gallery-2009.12.15-22
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.3.0 PR3
    Free for use.

    History Lite is similar in purpose to the YUI Browser History module, but with a more flexible API, no initialization or markup requirements, limited IE6/7 support, and a much smaller footprint.

    Note: History Lite became the core History Utility in YUI 3.2.0. You can still use the gallery module, but it will no longer be maintained, and you should consider migrating to the History Utility.

    The primary differences between History Lite and the BHM are:

    • You don't need to add any markup to the page (although, as a consequence, back/forward history is not maintained in IE6 and 7 after the user navigates away from the page).
    • You don't need to initialize the History Lite component. It's ready to use as soon as it's on the page.
    • You don't need to register history parameters before using them.
    • You may add parameters to the history state at any time, since there's no initialization step and no parameter registration requirement. This makes it easy for multiple discrete components to share the history state without having to be aware of one another's needs ahead of time.
    • Smaller code footprint than the BHM as a result of the minimal API and lack of IE6/7 support. This makes History Lite a good fit in situations where performance is critical (it's currently used on Yahoo! Search).
    • Tags:
    • ajax
    • history
    • rgrove
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    The sample below is a brief tour of the History Lite API, which consists of the add() and get() methods and the global history-lite:change event. Yes, that's the entire API!

    Note that you don't need to include the Console module in order to use History Lite; it's included here for demonstration purposes.

    Code Sample

    <script src="http://yui.yahooapis.com/3.3.0 PR3/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2009.12.15-22'
    }).use('gallery-history-lite', 'console', function (Y) {
     
        // Create a logging console so we can watch the awesomeness happen.
        Y.one(document.body).addClass('yui-skin-sam');
        new Y.Console().render();
     
        // Listen for history changes.
        Y.on('history-lite:change', function (e) {
            // Properties on e.changed represent new or changed history parameters.
            Y.each(e.changed, function (value, name) {
                Y.log(name + ' changed to "' + value + '"', 'debug', 'history-lite');
            });
     
            // Properties on e.removed represent history parameters that have been
            // removed.
            Y.each(e.removed, function (value, name) {
                Y.log(name + ' was removed', 'debug', 'history-lite');
            });
     
            // The get() method returns the current value of the specified history
            // parameter. If you call get() without specifying a parameter name,
            // it'll return an object containing all current history parameters and
            // their values.
            Y.log('current value of foo is ' + Y.HistoryLite.get('foo'), 'debug', 'history-lite');
        });
     
        // Simulate some history change events (watch the browser's location bar and
        // the debug console to see what's happening).
        setTimeout(function () {
            // The add() method accepts an object containing key/value pairs of
            // history parameter names and values. Each call to add() creates a new
            // browser history entry.
            Y.HistoryLite.add({foo: 'bar', baz: 'quux'});
        }, 1000);
     
        setTimeout(function () {
            // The add() method will also accept a query string.
            Y.HistoryLite.add('foo=kittens');
        }, 2000);
     
        setTimeout(function () {
            // A null or undefined value causes that parameter to be removed from
            // the history state.
            Y.HistoryLite.add({foo: null, baz: 'monkeys'});
        }, 3000);
     
    });
     

    Forum Posts

    No forum posts for this module.

    © 2006-2013 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