SlideShare ist ein Scribd-Unternehmen logo
1 von 23
Downloaden Sie, um offline zu lesen
YUI
The Yahoo! User Interface Library
How is quot;YUIquot; pronounced?

  Within the YUI team, we tend to pronounce
  it quot;why-you-eyequot;. However, in the wider world
  we more often hear it pronounced quot;yooey.quot;
  There's no wrong answer here.
developer.yahoo.com/yui
YUI = JS + CSS
A-graded browsers
Controls/
Core            Utilities                            CSS tools
                                  Widgets
                                  AutoComplete
YAHOO           Animation                            CSS Reset
global object
                                  Calendar
                Browser history                      CSS Base
DOM
                                  ColorPicker
collection      Connection                           CSS Fonts
                manager (Ajax)
                                  Container
Event utility                                        CSS Grids
                Drag & drop
                                  Logger
                Image loader
                                  Menu
                YUI loader
                                  Rich text editor

                                  Slider

                                  TabView

                                  TreeView
Events
<script
src=quot;/js/yui/yahoo‐dom‐event/yahoo‐dom‐event.jsquot;></script>

<div
id=quot;containerquot;>
  <p>Click
for
Hello
World
alert.</p>
</div>



var
helloWorld
=
function
(e)
{

   alert
(quot;Hello
World!quot;);
}

YAHOO.util.Event.addListener
(quot;containerquot;,
quot;clickquot;,
helloWorld);
Events
<script
src=quot;/js/yui/yahoo‐dom‐event/yahoo‐dom‐event.jsquot;></script>

<a
href=quot;...quot;
id=quot;firstAquot;>...</a>
<a
href=quot;...quot;
id=quot;secondAquot;>...</a>


var
interceptLink
=
function(e)
{

   YAHOO.util.Event.preventDefault
(e);

   alert
(quot;You
clicked
on
the
second
YUI
link.quot;);
}


YAHOO.util.Event.addListener
(quot;secondAquot;,
quot;clickquot;,
interceptLink);
<script>

(function()
{


  var
helloWorld
=
function(e)
{
  

  
     alert(quot;Hello
World!quot;);
  }

  YAHOO.util.Event.addListener(quot;containerquot;,
quot;clickquot;,
helloWorld);

  var
interceptLink
=
function(e)
{
  
     YAHOO.util.Event.preventDefault(e);

  
    alert(quot;You
clicked
on
the
second
YUI
link.quot;);
  }

  YAHOO.util.Event.addListener(quot;secondAquot;,
quot;clickquot;,
interceptLink);




})();
</script>
<script>

(function()
{


  var
helloWorld
=
function(e)
{
  
     YAHOO.log(quot;helloWorld
function
firing.quot;,
quot;infoquot;,
quot;examplequot;);
  
     alert(quot;Hello
World!quot;);
  }

  YAHOO.util.Event.addListener(quot;containerquot;,
quot;clickquot;,
helloWorld);

  var
interceptLink
=
function(e)
{
  
     YAHOO.util.Event.preventDefault(e);
  
     YAHOO.log(quot;You
clicked
on
the
second
YUI
link.quot;,
quot;infoquot;,
quot;examplequot;);
  
     alert(quot;You
clicked
on
the
second
YUI
link.quot;);
  }

  YAHOO.util.Event.addListener(quot;secondAquot;,
quot;clickquot;,
interceptLink);

  YAHOO.log(quot;When
you
begin
interacting
with
the
example
at
left,
you'll
see
log

  messages
appear
here.quot;,
quot;infoquot;,
quot;examplequot;);

})();
</script>
Custom events
var
onSizeChange
=
new
YAHOO.util.CustomEvent
(quot;onSizeChangequot;);

function
fnClick(e)
{
     .
.
.

  onSizeChange.fire
({width:
newWidth,
            









height:
newHeight});

}


onSizeChange.subscribe
(fnSubscriberWidth);
onSizeChange.subscribe
(fnSubscriberHeight);


fnSubscriberWidth
=
function
(type,
args)
{

   var
newWidth
=
args[0].width;
  

.
.
.
}

fnSubscriberHeight
=
function(type,
args)
{


   var
newHeight
=
args[0].height;

   .
.
.
}

DOM collection
<script
src=quot;/js/yui/yahoo‐dom‐event/yahoo‐dom‐event.jsquot;></script>


<script
src=quot;/js/yui/yahoo/yahoo.jsquot;></script>
<script
src=quot;/js/yui/dom/dom.jsquot;></script>



YAHOO.util.Event.on
(document,
quot;clickquot;,
move);

var
move
=
function
(e)
{
   YAHOO.util.Dom.setXY
('foo',
YAHOO.util.Event.getXY
(e));
};


var
move
=
function()
{
   var
xy
=
YAHOO.util.Dom.getXY
('bar');


YAHOO.util.Dom.setXY
('foo',
xy);
};



YAHOO.util.Dom.setStyle
('foo',
'opacity',
0.5);


var
bgcolor
=
YAHOO.util.Dom.getStyle
('bar',
'backgroundColor');
YAHOO.util.Dom.setStyle
('foo',
'backgroundColor',
bgcolor);
DOM collection
var
testClass
=
function
(e)
{
   alert
(YAHOO.util.Dom.hasClass
('foo',
'baz'));
};


var
addClass
=
function
(e)
{
   YAHOO.util.Dom.addClass
('foo',
'baz');
   alert
(YAHOO.util.Dom.get
('foo').className);
};


var
removeClass
=
function
(e)
{
   YAHOO.util.Dom.removeClass
('foo',
'baz');
   alert
(YAHOO.util.Dom.get('foo').className);
};

var
getByClass
=
function
(e)
{
   alert
('found:
'
+
   






YAHOO.util.Dom.getElementsByClassName
('bar',
'div').length
+
   





'
elements');
};
Drag & drop
<script
src=quot;/js/yui/yahoo‐dom‐event/yahoo‐dom‐event.jsquot;></script>
<script
src=quot;/js/yui/dragdrop/dragdrop.jsquot;></script>



<div
id=quot;dd‐demo‐1quot;
class=quot;dd‐demoquot;></div>
<div
id=quot;dd‐demo‐2quot;
class=quot;dd‐demoquot;></div>
<div
id=quot;dd‐demo‐3quot;
class=quot;dd‐demoquot;></div>



<script
type=quot;text/javascriptquot;>




(function()
{








var
dd,
dd2,
dd3;








YAHOO.util.Event.onDOMReady
(function()
{












dd
=
new
YAHOO.util.DD
(quot;dd‐demo‐1quot;);












dd2
=
new
YAHOO.util.DD
(quot;dd‐demo‐2quot;);












dd3
=
new
YAHOO.util.DD
(quot;dd‐demo‐3quot;);








});




})();
</script>
Animation
<script
src=quot;/js/yui/yahoo‐dom‐event/yahoo‐dom‐event.jsquot;></script>
<script
src=quot;/js/yui/animation/animation.jsquot;></script>



var
attributes
=
{
   width:
{
to:
0
}
};

var
anim
=
new
YAHOO.util.Anim
('demo',
attributes);

YAHOO.util.Event.on
('demo‐run',
'click',
function()
{
  anim.animate();
});



var
attributes
=
{
   width:
{
from:
30,
to:
10,
unit:'em'
}
};



var
attributes
=
{
   height:
{
to:
50
},
   width:
{
to:
50
}
};
Animating motion; animated scrolling
<script
type=quot;text/javascriptquot;>
(function()
{





var
attributes
=
{








points:
{
to:
[600,
10]
}




};




var
anim
=
new
YAHOO.util.Motion
('demo',
attributes);





YAHOO.util.Event.on
('demo‐run',
'click',
function()
{








anim.animate();




});

})();
</script>



var
attributes
=
{
   points:
{
to:
[600,
10],
control:
[
[300,
100],
[800,
800]
]
}
};



var
attributes
=
{
   scroll:
{
to:
[0,
200]
}
};
var
anim
=
new
YAHOO.util.Scroll('demo',
attributes);
developer.yahoo.com/yui/examples

Weitere ähnliche Inhalte

Andere mochten auch (18)

Hong kong 10101
Hong kong 10101Hong kong 10101
Hong kong 10101
 
Edad Moderna
Edad ModernaEdad Moderna
Edad Moderna
 
Esw2008 Simo
Esw2008 SimoEsw2008 Simo
Esw2008 Simo
 
Conector 4 vias pwm
Conector 4 vias pwmConector 4 vias pwm
Conector 4 vias pwm
 
Figfoz1
Figfoz1Figfoz1
Figfoz1
 
aula
aulaaula
aula
 
Elit 48 c class 2 post qhq accidentally
Elit 48 c class 2 post qhq accidentallyElit 48 c class 2 post qhq accidentally
Elit 48 c class 2 post qhq accidentally
 
13908241 almanaque-de-brincadeiras-eliseu-de-oliveira
13908241 almanaque-de-brincadeiras-eliseu-de-oliveira13908241 almanaque-de-brincadeiras-eliseu-de-oliveira
13908241 almanaque-de-brincadeiras-eliseu-de-oliveira
 
Vizinova 2
Vizinova 2Vizinova 2
Vizinova 2
 
Q4M Microblogcon
Q4M MicroblogconQ4M Microblogcon
Q4M Microblogcon
 
O Povoamento do Reino
O Povoamento do ReinoO Povoamento do Reino
O Povoamento do Reino
 
9
99
9
 
Dossier 15M.cc CATALÀ v.0.91
Dossier 15M.cc CATALÀ v.0.91Dossier 15M.cc CATALÀ v.0.91
Dossier 15M.cc CATALÀ v.0.91
 
Tit@
Tit@Tit@
Tit@
 
11
1111
11
 
новый 2013
новый 2013 новый 2013
новый 2013
 
Fell Kyle - AF Experience Hours Package (3)
Fell Kyle - AF Experience Hours Package (3)Fell Kyle - AF Experience Hours Package (3)
Fell Kyle - AF Experience Hours Package (3)
 
1 c class 1
1 c class 11 c class 1
1 c class 1
 

Mehr von Andrew Shitov

Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6Andrew Shitov
 
Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Andrew Shitov
 
Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Andrew Shitov
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingAndrew Shitov
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of SmartmatchAndrew Shitov
 
Perl 7, the story of
Perl 7, the story ofPerl 7, the story of
Perl 7, the story ofAndrew Shitov
 
Язык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовЯзык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовAndrew Shitov
 
Как очистить массив
Как очистить массивКак очистить массив
Как очистить массивAndrew Shitov
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14Andrew Shitov
 
Что нового в Perl 5.14
Что нового в Perl 5.14Что нового в Perl 5.14
Что нового в Perl 5.14Andrew Shitov
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Andrew Shitov
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty itAndrew Shitov
 
How to clean an array
How to clean an arrayHow to clean an array
How to clean an arrayAndrew Shitov
 

Mehr von Andrew Shitov (20)

Perl6 one-liners
Perl6 one-linersPerl6 one-liners
Perl6 one-liners
 
Creating a compiler in Perl 6
Creating a compiler in Perl 6Creating a compiler in Perl 6
Creating a compiler in Perl 6
 
Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)Fun with Raspberry PI (and Perl)
Fun with Raspberry PI (and Perl)
 
Perl6 in-production
Perl6 in-productionPerl6 in-production
Perl6 in-production
 
Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6Параллельные вычисления в Perl 6
Параллельные вычисления в Perl 6
 
AllPerlBooks.com
AllPerlBooks.comAllPerlBooks.com
AllPerlBooks.com
 
Perl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel ComputingPerl 6 for Concurrency and Parallel Computing
Perl 6 for Concurrency and Parallel Computing
 
The Joy of Smartmatch
The Joy of SmartmatchThe Joy of Smartmatch
The Joy of Smartmatch
 
YAPC::Europe 2013
YAPC::Europe 2013YAPC::Europe 2013
YAPC::Europe 2013
 
Perl 7, the story of
Perl 7, the story ofPerl 7, the story of
Perl 7, the story of
 
Язык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистовЯзык программирования Go для Perl-программистов
Язык программирования Go для Perl-программистов
 
Как очистить массив
Как очистить массивКак очистить массив
Как очистить массив
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14
 
Что нового в Perl 5.14
Что нового в Perl 5.14Что нового в Perl 5.14
Что нового в Perl 5.14
 
Perl6 grammars
Perl6 grammarsPerl6 grammars
Perl6 grammars
 
Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6Text in search queries with examples in Perl 6
Text in search queries with examples in Perl 6
 
There's more than one way to empty it
There's more than one way to empty itThere's more than one way to empty it
There's more than one way to empty it
 
Perl 6 by example
Perl 6 by examplePerl 6 by example
Perl 6 by example
 
How to clean an array
How to clean an arrayHow to clean an array
How to clean an array
 
Perl 5.10 и 5.12
Perl 5.10 и 5.12Perl 5.10 и 5.12
Perl 5.10 и 5.12
 

Краткий обзор библиотеки YUI