• 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.

    ZUI attribute (gallery-zui-attribute) on cdn

    Last Updated: 01/4/13
    + 0 -

    Zordius

    YUI Contributor

    See 5 more by this user.

    Created: 07/4/12
    Last CDN Push: 02/7/13
    Build Tag: gallery-2013.02.07-15-27
    Project: YUI 3
    License: YUI BSD
    YUI Version: 3.8.0
    Free for use.

    Description


    This module provides 5 more methods for Attribute:

    • revert() : rollback attribute value to previous one
    • toggle() : set attribute value to opposite boolean
    • set_again() : set attribute value to current value, use this to trigger setter function or change event again.
    • sync() : sync an attribute from other Object when the attribute value of other object changed, everytime.
    • unsync() : remove the sync binding.

    Note


    • do not use toggle() on none boolean value. It works, but the result may changed in future version.
    • Now revert() is disabled by default for performance. You can set _doRevert property to true to enable revert() for all properties, or set _revertList as {propertyName: true, ...} hash for specified properties.
    • YUI Base object mixed Attribute when Y.use('base') , if you try to Y.mix(Y.AttributeCore.prototype, Y.zui.Attribute.prototype, true) , it seens not work. 2 ways to resolve this:

    1 Y.mix(Y.Base.prototype, Y.zui.Attribute.prototype, true);

    2 Y.mix(Y.AttributeCore.prototype, Y.zui.Attribute.prototype, true); then Y.use('base', ...);

    • Same with previous, you may need to Y.mix() Widget or all other Base child classes.
    • You may use Y.mix(ClassA, ClassB, true, null, 1) to mix on prototype, check document: http://yuilibrary.com/yui/docs/api/classes/YUI.html#method_mix . I like to use .protype directly, it makes code more readable.

    Known Issue


    • set() will be tracked after Y.zui.Attribute mix into your class, then revert() use tracked value information to work. So, revert() can not get older values before Y.zui.Attribute mixed.
    • Tags:
    • sync
    • toggle
    • attribute
    • zordius
    • set_again
    • revert
    • unsync
    • change event
    • Download
    • Docs
    • Homepage
    • Bugs
    • Source
    • Example
    • Forum
    • History

    Code Sample

    <script src="http://yui.yahooapis.com/3.8.0/build/yui/yui-min.js"></script>
    YUI({
        //Last Gallery Build of this module
        gallery: 'gallery-2013.02.07-15-27'
    }).use('gallery-zui-attribute', function(Y) {
     
        // Add ZUI attribute support to one instance
        Y.mix(myInstance, Y.zui.Attribute.prototype);
     
        // enable revert() on 'testAttr2'
        myInstance._revertList = {testAttr2: true};
     
        // Or, enable revert() on all attributes
        myInstance._doRevert = true;
     
        // Now, set an attribute
        myInstance.set('testAttr', 3);
     
        // And you can revert the attribute
        myInstance.revert('testAttr');
     
        // Sync an attribute from another object
        // Everytime objterObject.get('testAttr') changed, set() the value to myInstance
        myInstance.sync('testAttr', otherObject);
     
        // Sync an attribute from another object, specify a different attribute name
        // Everytime objterObject.get('Attr2') changed, set() the value to myInstance
        myInstance.sync('testAttr', otherObject, 'Attr2');
     
        // Stop to monitering the attribute change
        myInstance.unsync('testAttr', otherObject);
     
     
        // Or, add ZUI attribute support to a class (before creating any instance)
        Y.mix(myClass.prototype, Y.zui.Attribute.prototype);
     
        // Now, all myClass instances support revert(), toggle(), etc ...
        var testInstance = new myClass();
        testInstance.toggle('testAttr');
     
        // Add ZUI attribute support for all Attribute object
        Y.mix(Y.Attribute.prototype, Y.zui.Attribute.prototype, true);
     
        // Add ZUI attribute support for all Base object
        Y.mix(Y.Base.prototype, Y.zui.Attribute.prototype, true);
    });

    © 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