Skip to content

A yui3 module that replaces Y as object with Y as convenience function

Notifications You must be signed in to change notification settings

lsmith/yui3-sugar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 

Repository files navigation

Module for the byte conscious (read: obsessed) that creates a convenience function that wraps
* Y.get('window')       Y('win') or Y('window') or Y(window)
* Y.get('document')     Y('doc') or Y('document') or Y(document)
* Y.all(...)            Y('.some[sel=ctor]')
* Y.Node.create(...)    Y('<p>String of markup</p>')

Additionally, it overrides the default Y.use behavior to pass the convenience
function as the first parameter to the callback provided as the last arg.

E.g.

YUI({..}).use(...,'sugar', function (Y) {
    // Create the sugar method once (don't use $ if you'll share space with
    // another js lib that leverages the $ symbol)
    var $ = Y.sugar();

    // eq. Y.all('.x').addClass('foo');
    $('.x').addClass('foo');

    // $.use works the same as Y.use, but the first arg is the sugar function
    $.use('io-base', function ($) {
        // eq. Y.io(..)
        $.io('sugar.html', {on: { success: function (id, o) {
            // eq. Y.all('.x').item(0).appendChild(
            //         Y.Node.create(..));
            $('.x').item(0).appendChild($('<pre>' + o.responseText + '</pre>'));
        }}});
    });

});

About

A yui3 module that replaces Y as object with Y as convenience function

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published