hack u - yui - 2012 iit kharagpur

14
Sumana H Frontend Engineer, UDA Hack with YUI

Upload: sumana-hariharan

Post on 18-Dec-2014

848 views

Category:

Technology


1 download

DESCRIPTION

YUI ppt presented in IIT Kharagpur in Hack U 2012

TRANSCRIPT

Page 1: Hack U - YUI - 2012 IIT Kharagpur

Sumana H Frontend Engineer, UDA

Hack�with�YUI

Page 2: Hack U - YUI - 2012 IIT Kharagpur

“The browser is the most futile deployment environment…”

- Douglas Crockford

Page 3: Hack U - YUI - 2012 IIT Kharagpur

Don’t reinvent the wheel

Use tools which are already available

Page 4: Hack U - YUI - 2012 IIT Kharagpur

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

http://yuilibrary.com/

Page 5: Hack U - YUI - 2012 IIT Kharagpur

•  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: Hack U - YUI - 2012 IIT Kharagpur

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: Hack U - YUI - 2012 IIT Kharagpur

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: Hack U - YUI - 2012 IIT Kharagpur

Node Getting 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 element var bodyNode = Y.one(document.body);

Page 9: Hack U - YUI - 2012 IIT Kharagpur

Creating Nodes and Modifying Content

// Create a new Node

var item = Y.Node.create('<li id="step3" class="highlight"><em>Profit</em></li>');

// Replace the content in a Node Y.one("#hello").setContent("<h1>Hello, <em>World</

em>!</h1>");

// Append new markup inside a Node

bodyNode.append("<p>This is the end, beautiful friend, the end.</p>");

Page 10: Hack U - YUI - 2012 IIT Kharagpur

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

// NodeLists host most Node methods for simple iterative operations

doneTasks.removeClass('highlight');

// or call each() to do more work on each Node

doneTasks.each(function (taskNode) { taskNode.transition({ opacity: 0 }, function () {

completedTasklist.appendChild(this);

}); });

Page 11: Hack U - YUI - 2012 IIT Kharagpur

Event YUI().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 function button.on("click", function (e) {

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

}); });

Page 12: Hack U - YUI - 2012 IIT Kharagpur

Examples

- Factorial example - Widget - Carousel

- YQL in YUI

Gallery – http://github.com/yahoo

Page 13: Hack U - YUI - 2012 IIT Kharagpur

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"/>

Page 14: Hack U - YUI - 2012 IIT Kharagpur

THANK YOU