YUI is a collection of JavaScript components available for use as shortcuts to website programming. Yahoo! opened it to the public in 2006 in hopes that releasing it freely would allow people to generate new ideas and further advance website programming. On the YUI homepage the full YUI documentation is available for download and use, along with the complete API. As an alternative, Yahoo opened up free YUI hosting from the Yahoo! network via yui.yahooapis.com and they created an easy-to-use YUI Dependency Configurator which generates the needed dependency scripts and tags based off your YUI usage selections. Another extremely helpful feature YAHOO supplies are cheatsheets for every component which act as a quick reference guide to the key methods, properties, and syntax patterns
YUI provides its users with a very useful developer tool called Logger Control which may help debug any YUI Library Component. You can easily read and write log messages or even tap into the debug files.
YUI also provides a standard 'skin' for all the YUI Controls called Sam (after its developer). Sam skin gives the controls a cohesive look and feel. In order to apply this skin to you page or your elements simply add class="yui-skin-sam" into your element tag.
Here is an example of the Animation Utility. Animation can be applied to any member of an element's style object that takes a numeric value. The demonstration below shows two types of animation: motion and color animation. Together these two animations can be chained together by the onComplete event in which the second animation suscribes to, this allows for the animations to take place sequentially. This utility uses the Event Utility as well to create a response to the button being clicked.
Here is the code used to create this animation using YUI.
<script type="text/javascript">
(function() {
var changes = {points: { to: [500,380] } };
var move = new YAHOO.util.Motion('box', changes,4, YAHOO.util.Easing.elasticOut);
var color = new YAHOO.util.ColorAnim('box',{backgroundColor: {to: '#D0A9F5'}},1.5);
move.onComplete.subscribe(function() { color.animate(); });
YAHOO.util.Event.on('button', 'click', function() { move.animate();});
})();</script>
YUI Animation Cheat SheetYAHOO Global Object:
This object provides a single global namespace within which all YUI Library code resides. A reference to its source file must be included in all files that that use the YUI library.
<script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo/yahoo-min.js"></script>
DOM Collection
This part of the library was created to help programmers by simplifying some of the common DOM-scripting tasks. It provides methods to position HTML elements, set styles, manage class names and get the viewport size.
Event Utility
This is an extemely useful piece of the library that helps with event-driven applications by simplifying tasks such as subscribing to DOM events or dealing with the properties of the browser's Event object.
DOM Collection
Event Utility
<script type="text/javascript">
(function() {
var Dom=YAHOO.util.Dom, Event=YAHOO.util.Event;
var crop= new YAHOO.widget.ImageCropper('pic', {initialXY: [100,100], initHeight: (Dom.get('pic').height/3), initWidth: (Dom.get('pic').width/3)});
})();
</script>