16
Sumana H Frontend Engineer, Data And Analytics Hack with YUI

Yuihacku iitd-sumana

Embed Size (px)

DESCRIPTION

My YUI ppt - IIT Delhi Aug 17th 2012

Citation preview

Page 1: Yuihacku iitd-sumana

Sumana H Frontend Engineer, Data And Analytics

HackwithYUI

Page 2: Yuihacku iitd-sumana

“The browser is the most futile deployment environment…”

- Douglas Crockford

Page 3: Yuihacku iitd-sumana

Don’t reinvent the wheel

Use tools which are already available

Page 4: Yuihacku iitd-sumana

A comprehensive suite of tools to help you code like a pro!!

http://yuilibrary.com/

Page 5: Yuihacku iitd-sumana

• YUI Library is a set of utilities and controls, written with JS and CSS , for building rich interactive web applications.

• Free for all users

• Scalable, Fast and Robust

• Most popular, best documented, more examples.

Page 6: Yuihacku iitd-sumana

YUI Library• Low level DOM utilities to high level user

Interface widgets

• Core – Global Object, Node, Events

• Utilities – Animation, drag Drop, get Utility – to get js/css dynamically.

• Widgets – Autocomplete, calendar, carousel, Overlay…

• CSS http://yuilibrary.com/yui/docs/guides/

Page 7: Yuihacku iitd-sumana

Global Object<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>

<div id="demo">Click me</div><script>// Create a new YUI sandbox and load the "node" module.YUI().use('node','datatable', function (Y) {var demo = Y.one('#demo'); demo.on('click', function (e) { demo.set('text', 'You clicked me!'); });});</script>

Page 8: Yuihacku iitd-sumana

NodeGetting a Node <div id="main" class="mainclass"/>

// Use Y.one( [css selector string] )var node = Y.one('#main');var node = Y.one(.mainclass);

// Or pass an HTML elementvar bodyNode = Y.one(document.body);

Page 9: Yuihacku iitd-sumana

Creating Nodes and Modifying Content

// Create a new Nodevar item = Y.Node.create('<li id="step3"

class="highlight"><em>Profit</em></li>');

// Replace the content in a NodeY.one("#hello").setContent("<h1>Hello,

<em>World</em>!</h1>");

// Append new markup inside a NodebodyNode.append("<p>This is the end, beautiful friend,

the end.</p>");

Page 10: Yuihacku iitd-sumana

Nodelist var doneTasks = Y.all('#tasklist .completed');

// NodeLists host most Node methods for simple iterative operationsdoneTasks.removeClass('highlight');

// or call each() to do more work on each NodedoneTasks.each(function (taskNode) { taskNode.transition({ opacity: 0 }, function () { …….. });});

Page 11: Yuihacku iitd-sumana

EventYUI().use('event', function (Y) { // Step 1. Capture a button node

var button = Y.one("#readygo");

// Step 2. Subscribe to its click event with a callback functionbutton.on("click", function (e) {

// Step 3. do stuff when the button is clicked

});});

Page 12: Yuihacku iitd-sumana

Examples

- Factorial example - Widget - Carousel

Gallery – http://github.com/yahoo

Page 13: Yuihacku iitd-sumana

CSS• <link rel="stylesheet" type="text/css"

href="http://yui.yahooapis.com/gallery-2010.10.20-19-33/build/gallery-carousel/assets/skins/sam/gallery-carousel.css"/>

• Grids - <link rel="stylesheet" type="text/css" href="http://yui.yahooapis.com/3.6.0/build/cssgrids/grids-min.css">

Page 14: Yuihacku iitd-sumana

CSS Grids

Examples http://developer.yahoo.com/yui/grids/builder/

Class Description

.yui3-u-1 Fills 100% of the available width.

.yui3-u-1-3 Fills 1/3 of available width.

.yui3-u-4-5 Fills 4/5 of available width.

Page 15: Yuihacku iitd-sumana

Resources• http://www.slideshare.net/SumanaHariharan/

yuihacku-iitdsumana

Page 16: Yuihacku iitd-sumana

THANK YOU