SlideShare a Scribd company logo
1 of 94
Download to read offline
YUI Evolved:
        YUI3 and Why It’s Good for You



Saturday, November 21, 2009
http://www.flickr.com/photos/valjk/634696442/




Saturday, November 21, 2009
document.onmousemove =       }                              ev = ev||window.event;
        mouseMove;                   function mouseUp(ev){          var mousePos =
        document.onmouseup   =         dragObject = null;             mouseCoords(ev);
        mouseUp;                     }                              if(dragObject){
        var dragObject = null;       function                     dragObject.style.position
        var mouseOffset = null;      getMouseOffset(target,ev){     = 'absolute';
                                       ev = ev || window.event;        dragObject.style.top
        function mouseCoords(ev){      var docPos =                 = mousePos.y -
          if(ev.pageX||ev.pageY){        getPosition(target);          mouseOffset.y;
             return {x:ev.pageX,       var mousePos =               dragObject.style.left
              y:ev.pageY};               mouseCoords(ev);           = mousePos.x -
          }                            return {x:mousePos.x -          mouseOffset.x;
          return {                   docPos.x, y:mousePos.y -          return false;
             x:ev.clientX +          docPos.y};                     }
        document.body.scrollLeft -   }                            }
        document.body.clientLeft,    function getPosition(e){     function mouseUp(){
             y:ev.clientY +            var left = 0;                dragObject = null;
        document.body.scrollTop -      var top = 0;               }
        document.body.clientTop        while (e.offsetParent){    function
          };                             left += e.offsetLeft;    makeDraggable(item){
        }                                top += e.offsetTop;        if(!item) return;
                                         e = e.offsetParent;        item.onmousedown =
        function                       }                          function(ev){
        makeClickable(object){         left += e.offsetLeft;           dragObject = this;
          object.onmousedown =         top += e.offsetTop;             mouseOffset =
          function(){                  return {x:left, y:top};    getMouseOffset(this, ev);
            dragObject = this;       }                                 return false;
          }                          function mouseMove(ev){        }


                                                                   http://www.flickr.com/photos/valjk/634696442/




Saturday, November 21, 2009
http://www.flickr.com/photos/funadium/2311851858/




Saturday, November 21, 2009
<script src="http://yui.yahooapis.com/3.0.0/build/yui/
         yui-min.js"></script>

         YUI().use('dd-drag', function(Y) {
             var dd = new Y.DD.Drag({
                 //Selector of the node to make draggable
                 node: '#demo'
             });
         });




                                             http://www.flickr.com/photos/funadium/2311851858/




Saturday, November 21, 2009
Change always comes bearing gi@s
              ‐ Price Pritche*



                              Lighter   Easier




Saturday, November 21, 2009
Change always comes bearing gi@s
              ‐ Price Pritche*



                              Lighter       Easier

              • Finer grained modules, 
                sub‐modules
              • Lazy‐loading
              • Emphasis on code reuse
                 - common base, plugins, 
                   extensions




Saturday, November 21, 2009
Change always comes bearing gi@s
              ‐ Price Pritche*



                              Lighter                  Easier

              • Finer grained modules,      • Sandboxed development
                sub‐modules
                                            • Consistent API
              • Lazy‐loading
                                            • Convenience
              • Emphasis on code reuse        - each, bind, nodelist, queue, 
                 - common base, plugins,        chainability, general sugar
                   extensions




Saturday, November 21, 2009
Change always comes bearing gi@s
              ‐ Price Pritche*



                              Lighter                  Easier

              • Finer grained modules,      • Sandboxed development
                sub‐modules
                                            • Consistent API
              • Lazy‐loading
                                            • Convenience
              • Emphasis on code reuse        - each, bind, nodelist, queue, 
                 - common base, plugins,        chainability, general sugar
                   extensions




Saturday, November 21, 2009
All in a day’s work
              (but taking less than a day, hopefully)




Saturday, November 21, 2009
All in a day’s work
              (but taking less than a day, hopefully)

                                         yui-min.js




Saturday, November 21, 2009
All in a day’s work
              (but taking less than a day, hopefully)

                                         yui-min.js

        node         event


         dom          selector




Saturday, November 21, 2009
All in a day’s work
              (but taking less than a day, hopefully)

                                         yui-min.js

        node         event


         dom          selector

       YUI().use("imageloader",

         function(Y){
           // magic!
         }

       );



Saturday, November 21, 2009
All in a day’s work
                 (but taking less than a day, hopefully)

                                            yui-min.js
add phase




            node       event


            dom         selector

            YUI().use("imageloader",
use phase




             function(Y){
               // magic!
             }

            );



Saturday, November 21, 2009
All in a day’s work
                 (but taking less than a day, hopefully)

                                            yui-min.js
add phase




            node       event        oop


            dom         selector                           imageloader

            YUI().use("imageloader",
use phase




             function(Y){
               // magic!
             }

            );



Saturday, November 21, 2009
All in a day’s work
               (but taking less than a day, hopefully)

                                          yui-min.js
add phase




            node     event        oop


            dom       selector                           imageloader

            YUI().use("imageloader",
use phase




             function(Y){
               // magic!
             }
                  oopevent
                         node
                          imageloader
            );



Saturday, November 21, 2009
All in a day’s work
               (but taking less than a day, hopefully)

                                          yui-min.js
add phase




            node     event        oop


            dom       selector                           imageloader

            YUI().use("imageloader",                     YUI().use("anim-base",
use phase




             function(Y){                                     function(Y){
               // magic!                                        // magic!
             }                                                }
                  oopevent
                         node
                          imageloader
            );                                           );



Saturday, November 21, 2009
All in a day’s work
               (but taking less than a day, hopefully)

                                          yui-min.js
                                            event-        attribute-   base-
add phase




            node     event        oop
                                            custom           base       base

                                          anim-
            dom       selector                           imageloader
                                           base

            YUI().use("imageloader",                     YUI().use("anim-base",
use phase




             function(Y){                                   function(Y){
               // magic!                                      // magic!
             }                                              }
                                                                    base-
                                                                attribute- anim-
                                                                 event-      event
                  oopevent
                         node
                          imageloader                         oop         dom node
                                                                        selector
                                                                     base
            );                                           );        base
                                                                 custom      base




Saturday, November 21, 2009
Playing in your own sandbox     Easie
              (but invite others too)              r


                                        yui

                      ...
add 




            node
use phase




Saturday, November 21, 2009
Playing in your own sandbox          Easie
                 (but invite others too)                   r


                                                yui

                        ...
add 




            node
            <script src="http://
            yui.yahooapis.com/3.4/build/yui/yui-
            min.js">

            <script>
use phase




            YUI().use("overlay", function(Y){

             Y.on("click", function(){
               new Y.Overlay({ … }).render();
             }, "#button" );

            });
            </script>




Saturday, November 21, 2009
Playing in your own sandbox                                      Easie
                 (but invite others too)                                               r


                                                yui

                        ...
add 




            node
            <script src="http://                   <script src="http://
            yui.yahooapis.com/3.4/build/yui/yui-   yui.yahooapis.com/3.0/build/overlay/
            min.js">                               overlay-min.js">

            <script>                               <script>
use phase




            YUI().use("overlay", function(Y){      YUI().use("overlay", function(Y){

             Y.on("click", function(){                new Y.Overlay({ … }).render();
               new Y.Overlay({ … }).render();
             }, "#button" );                       });
                                                   </script>
            });
            </script>




Saturday, November 21, 2009
Playing in your own sandbox                                      Easie
                 (but invite others too)                                               r


                                                yui

                        ...
add 




            node
            <script src="http://                   <script src="http://
            yui.yahooapis.com/3.4/build/yui/yui-   yui.yahooapis.com/3.0/build/overlay/
            min.js">                               overlay-min.js">

            <script>                               <script>
use phase




            YUI().use("overlay", function(Y){      YUI().use("overlay", function(Y){

             Y.on("click", function(){                new Y.Overlay({ … }).render();
               new Y.Overlay({ … }).render();
             }, "#button" );                       });
                                                   </script>
            });
            </script>




Saturday, November 21, 2009
Everything where you want them   Easie
              (a.k.a. event façades)                r

                                                        nt
                                                   Eve




Saturday, November 21, 2009
Everything where you want them   Easie
              (a.k.a. event façades)                r

                                                        nt
                                                   Eve
                         YUI2          YUI3




Saturday, November 21, 2009
Everything where you want them    Easie
              (a.k.a. event façades)                 r

                                                         nt
                                                    Eve
                         YUI2            YUI3
 var Dom = YAHOO.util.Dom;
 var Event = YAHOO.util.Event;

 var linkNode = Dom.get("id");

 Event.addListener( linkNode, "click",
   function(e) {

    var target = Event.getTarget(e);

    if( Dom.hasClass(
      target, "selector"
      )) {

       Event.preventDefault(e);

   }
 });




Saturday, November 21, 2009
Everything where you want them                           Easie
              (a.k.a. event façades)                                          r

                                                                                  nt
                                                                              Eve
                         YUI2                            YUI3
 var Dom = YAHOO.util.Dom;               linkNode.on("click", function(e) {
 var Event = YAHOO.util.Event;
                                           if(!e.target.hasClass("selector")){
 var linkNode = Dom.get("id");               e.preventDefault();
                                           }
 Event.addListener( linkNode, "click",
   function(e) {                         });

    var target = Event.getTarget(e);

    if( Dom.hasClass(
      target, "selector"
      )) {

       Event.preventDefault(e);

   }
 });




Saturday, November 21, 2009
One moment in Jme                 Easie
              (regarding on and aNer moments)        r

                                                         nt
                                                    Eve




                              ON

                              ON

                Default Behavior

                          After

                          After

                          After




Saturday, November 21, 2009
One moment in Jme                 Easie
              (regarding on and aNer moments)        r

                                                         nt
                                                    Eve

       this.fire("select");

                              ON

                              ON

                Default Behavior

                          After

                          After

                          After




Saturday, November 21, 2009
One moment in Jme                 Easie
              (regarding on and aNer moments)        r

                                                         nt
                                                    Eve

       this.fire("select");

                              ON

                              ON

                Default Behavior

                          After

                          After

                          After




Saturday, November 21, 2009
One moment in Jme                                        Easie
              (regarding on and aNer moments)                               r

                                                                                nt
                                                                           Eve

       this.fire("select");

                              ON

                              ON                e.stopImmediatePropagation()
                Default Behavior

                          After

                          After

                          After




Saturday, November 21, 2009
One moment in Jme                                        Easie
              (regarding on and aNer moments)                               r

                                                                                nt
                                                                           Eve

       this.fire("select");

                              ON

                              ON                e.stopImmediatePropagation()
                Default Behavior

                          After

                          After

                          After




Saturday, November 21, 2009
One moment in Jme                                      Easie
              (regarding on and aNer moments)                             r

                                                                              nt
                                                                         Eve

       this.fire("select");

                              ON

                              ON                e.preventDefault()
                Default Behavior

                          After

                          After

                          After




Saturday, November 21, 2009
One moment in Jme                                      Easie
              (regarding on and aNer moments)                             r

                                                                              nt
                                                                         Eve

       this.fire("select");

                              ON

                              ON                e.preventDefault()
                Default Behavior

                          After

                          After

                          After




Saturday, November 21, 2009
One moment in Jme                                      Easie
              (regarding on and aNer moments)                             r

                                                                              nt
                                                                         Eve

       this.fire("select");

                              ON

                              ON

                Default Behavior

                          After

                          After                 e.preventDefault()

                          After




Saturday, November 21, 2009
One moment in Jme                                      Easie
              (regarding on and aNer moments)                             r

                                                                              nt
                                                                         Eve

       this.fire("select");

                              ON

                              ON

                Default Behavior

                          After

                          After                 e.preventDefault()

                          After




Saturday, November 21, 2009
One moment in Jme                                        Easie
              (regarding on and aNer moments)                               r

                                                                                nt
                                                                           Eve

       this.fire("select");

                              ON

                              ON

                Default Behavior

                          After

                          After                 e.stopImmediatePropagation()

                          After




Saturday, November 21, 2009
One moment in Jme                                        Easie
              (regarding on and aNer moments)                               r

                                                                                nt
                                                                           Eve

       this.fire("select");

                              ON

                              ON

                Default Behavior

                          After

                          After                 e.stopImmediatePropagation()

                          After




Saturday, November 21, 2009
Too many events spoil the page   Easie
              (a.k.a. event delegaOon)              r

                                                        nt
                                                   Eve
                        HTML              JS




Saturday, November 21, 2009
Too many events spoil the page   Easie
              (a.k.a. event delegaOon)              r

                                                        nt
                                                   Eve
                        HTML              JS
 <div id=”menu”>
   <ul>

       <li class=”menuitem”>
         <em>Open file...</em>
       </li>

       <li class=”menuitem”>
         <em>Save file...</em>
       </li>

       <li class=”menuitem”>
         <em>Close file</em>
       </li>

       <li class=”menuitem stop”>
         <em>Quit</em>
       </li>

   </ul>
 </div>



Saturday, November 21, 2009
Too many events spoil the page                             Easie
              (a.k.a. event delegaOon)                                        r

                                                                                  nt
                                                                             Eve
                        HTML                                  JS
 <div id=”menu”>                         var menuDiv = Y.one(“#menu”);
   <ul>
                                         menuDiv.delegate("click", function(e){
       <li class=”menuitem”>
         <em>Open file...</em>
       </li>

       <li class=”menuitem”>
         <em>Save file...</em>
       </li>
                                         }, "li.menuitem");
       <li class=”menuitem”>
         <em>Close file</em>
       </li>

       <li class=”menuitem stop”>
         <em>Quit</em>
       </li>

   </ul>
 </div>



Saturday, November 21, 2009
Too many events spoil the page                             Easie
              (a.k.a. event delegaOon)                                        r

                                                                                  nt
                                                                             Eve
                        HTML                                  JS
 <div id=”menu”>                         var menuDiv = Y.one(“#menu”);
   <ul>
                                         menuDiv.delegate("click", function(e){
       <li class=”menuitem”>
         <em>Open file...</em>                Y.log( this.get(‘innerHTML’) );
       </li>                                  // <em>Quit</em>, etc

       <li class=”menuitem”>                  // this == e.currentTarget
         <em>Save file...</em>                // e.container == menuDiv
       </li>
                                         }, "li.menuitem");
       <li class=”menuitem”>
         <em>Close file</em>
       </li>

       <li class=”menuitem stop”>
         <em>Quit</em>
       </li>

   </ul>
 </div>



Saturday, November 21, 2009
Too many events spoil the page                             Easie
              (a.k.a. event delegaOon)                                        r

                                                                                  nt
                                                                             Eve
                        HTML                                  JS
 <div id=”menu”>                         var menuDiv = Y.one(“#menu”);
   <ul>
                                         menuDiv.delegate("click", function(e){
       <li class=”menuitem”>
         <em>Open file...</em>                Y.log( this.get(‘innerHTML’) );
       </li>                                  // <em>Quit</em>, etc

       <li class=”menuitem”>                  // this == e.currentTarget
         <em>Save file...</em>                // e.container == menuDiv
       </li>
                                         }, "li.menuitem");
       <li class=”menuitem”>
         <em>Close file</em>
       </li>                             // but maybe we want to stop
                                         Y.one(“li.stop”).on(“click”,
       <li class=”menuitem stop”>           function(e){
         <em>Quit</em>                        e.stopPropagation();
       </li>                                }
                                         );
   </ul>
 </div>



Saturday, November 21, 2009
NoJficaJon flow: Bubbling              Easie
              (Ony bubbles)                             r

                                                            nt
                                                        Eve

                              Menu
              MenuItem

                    ON                       ON

                    ON                  Def. Behavior

          Def. Behavior                    After

                 After                     After

                 After

                 After




Saturday, November 21, 2009
NoJficaJon flow: Bubbling              Easie
              (Ony bubbles)                             r

                                                            nt
                                                        Eve

                              Menu
              MenuItem

                    ON                       ON

                    ON                  Def. Behavior

          Def. Behavior                    After

                 After                     After

                 After

                 After




Saturday, November 21, 2009
NoJficaJon flow: Bubbling              Easie
              (Ony bubbles)                             r

                                                            nt
                                                        Eve

                              Menu
              MenuItem

                    ON                       ON

                    ON                  Def. Behavior

          Def. Behavior                    After

                 After                     After

                 After

                 After




Saturday, November 21, 2009
NoJficaJon flow: Bubbling              Easie
              (Ony bubbles)                             r

                                                            nt
                                                        Eve

                              Menu
              MenuItem

                    ON                       ON

                    ON                  Def. Behavior

          Def. Behavior                    After

                 After                     After

                 After

                 After




Saturday, November 21, 2009
NoJficaJon flow: Bubbling                          Easie
              (Ony bubbles)                                         r

                                                                        nt
                                                                    Eve

                                   Menu
              MenuItem

                    ON                                   ON

                    ON        e.stopPropagation()   Def. Behavior

          Def. Behavior                                After

                 After                                 After

                 After

                 After




Saturday, November 21, 2009
NoJficaJon flow: Bubbling                          Easie
              (Ony bubbles)                                         r

                                                                        nt
                                                                    Eve

                                   Menu
              MenuItem

                    ON                                   ON

                    ON        e.stopPropagation()   Def. Behavior

          Def. Behavior                                After

                 After                                 After

                 After

                 After




Saturday, November 21, 2009
Working with HTML Elements                   Easie
              (selectors, sugar, chaining, oh my)               r

                                                                      e
                                                                   Nod
                         YUI2                       YUI3




Saturday, November 21, 2009
Working with HTML Elements                   Easie
              (selectors, sugar, chaining, oh my)               r

                                                                      e
                                                                   Nod
                         YUI2                       YUI3
 var Dom = YAHOO.util.Dom;
 var Event = YAOO.util.Event;

 var elms = Dom.getElementsByClassName(
   "task", "li", "actions");

 for (var i = 0; i < elms.length; i++) {

     var elm = elms[i];

     if(Dom.hasClass(elm, "selected")){

         Dom.addClass(elm, "current");
         Event.on(elm, "click", handler);

     }

 }




Saturday, November 21, 2009
Working with HTML Elements                                             Easie
              (selectors, sugar, chaining, oh my)                                         r

                                                                                                e
                                                                                             Nod
                         YUI2                                        YUI3
 var Dom = YAHOO.util.Dom;                          var elm = Y.Node.get(
 var Event = YAOO.util.Event;                          ".actions li.task.selected"
                                                    );
 var elms = Dom.getElementsByClassName(
   "task", "li", "actions");                        elm.addClass("current");
                                                    elm.on("click", handler);
 for (var i = 0; i < elms.length; i++) {

     var elm = elms[i];

     if(Dom.hasClass(elm, "selected")){

         Dom.addClass(elm, "current");
         Event.on(elm, "click", handler);

     }

 }




Saturday, November 21, 2009
Working with HTML Elements                                             Easie
              (selectors, sugar, chaining, oh my)                                         r

                                                                                                e
                                                                                             Nod
                         YUI2                                        YUI3
 var Dom = YAHOO.util.Dom;                          var elm = Y.Node.get(
 var Event = YAOO.util.Event;                          ".actions li.task.selected"
                                                    );
 var elms = Dom.getElementsByClassName(
   "task", "li", "actions");                        elm.addClass("current");
                                                    elm.on("click", handler);
 for (var i = 0; i < elms.length; i++) {

     var elm = elms[i];                             // want something shorter?
                                                    Y.Node.get(…).addClass("current").on(
     if(Dom.hasClass(elm, "selected")){               "click",handler);

         Dom.addClass(elm, "current");
         Event.on(elm, "click", handler);

     }

 }




Saturday, November 21, 2009
HTML Elements made easier                      Easie
              (HTMLElement API improved)                          r

                                                                        e
                                                                     Nod
         Supports                    Normalizes       Enhances

                                     Bulk operaOons




Saturday, November 21, 2009
HTML Elements made easier                     Easie
              (HTMLElement API improved)                         r

                                                                       e
                                                                    Nod
         Supports                    Normalizes      Enhances
 node.appendChild(new)

 node.cloneNode(node)

 node.scrollIntoView()

 node.get("parentNode")

 node.set("innerHTML",
   "Hello world!")


                                    Bulk operaOons




Saturday, November 21, 2009
HTML Elements made easier                            Easie
              (HTMLElement API improved)                                r

                                                                              e
                                                                           Nod
         Supports                    Normalizes             Enhances
 node.appendChild(new)        node.getAttribute("href")

 node.cloneNode(node)         node.contains(node)

 node.scrollIntoView()        node.getText()

 node.get("parentNode")       node.getStyle("paddingTop")

 node.set("innerHTML",        node.previous()
   "Hello world!")


                                    Bulk operaOons




Saturday, November 21, 2009
HTML Elements made easier                                          Easie
              (HTMLElement API improved)                                              r

                                                                                            e
                                                                                         Nod
         Supports                    Normalizes                    Enhances
 node.appendChild(new)        node.getAttribute("href")     node.addClass("selectable")

 node.cloneNode(node)         node.contains(node)           node.toggleClass("enabled")

 node.scrollIntoView()        node.getText()                node.getXY()

 node.get("parentNode")       node.getStyle("paddingTop")   node.get("region")

 node.set("innerHTML",        node.previous()
   "Hello world!")


                                    Bulk operaOons




Saturday, November 21, 2009
HTML Elements made easier                                           Easie
              (HTMLElement API improved)                                               r

                                                                                             e
                                                                                          Nod
         Supports                     Normalizes                     Enhances
 node.appendChild(new)         node.getAttribute("href")     node.addClass("selectable")

 node.cloneNode(node)          node.contains(node)           node.toggleClass("enabled")

 node.scrollIntoView()         node.getText()                node.getXY()

 node.get("parentNode")        node.getStyle("paddingTop")   node.get("region")

 node.set("innerHTML",         node.previous()
   "Hello world!")


                                      Bulk operaOons
 var items = Y.Node.all(".actions li");                      nodeList.filter(‘a[href]’);
 items.addClass("disabled");                                 nodeList.odd();
 items.set("title", "Item Disabled");                        nodeList.even();

                   items.each(function(node) {
                       node.addClass("disabled);
                       node.set("title", "Item Disabled");
                   });


Saturday, November 21, 2009
CreaJon, removal, and ancestry   Easie
              (a couple of last points)             r

                                                          e
                                                       Nod
                 Node creaOon

                 Node removal

                 Node ancestry




Saturday, November 21, 2009
CreaJon, removal, and ancestry              Easie
              (a couple of last points)                        r

                                                                     e
                                                                  Nod
                 Node creaOon             Node removal
 var fieldset =
   document.createElement("fieldset");    Node ancestry
 var input =
   document.createElement("input");
 input.type = "checkbox";
 input.name = "myCheckBox";
 ...
 fieldset.appendChild("input");
 form.appendChild(fieldset);




Saturday, November 21, 2009
CreaJon, removal, and ancestry              Easie
              (a couple of last points)                        r

                                                                     e
                                                                  Nod
                 Node creaOon             Node removal
 var fieldset =
   document.createElement("fieldset");    Node ancestry
 var input =
   document.createElement("input");
 input.type = "checkbox";
 input.name = "myCheckBox";
 ...
 fieldset.appendChild("input");
 form.appendChild(fieldset);

 var html = '<fieldset><input
 type="checkbox" ... ></fieldset>';

 // create the node and append
 var node = Y.node.create( html );
 form.appendChild( node );

 // or do it right away
 form.append( html );




Saturday, November 21, 2009
CreaJon, removal, and ancestry                              Easie
              (a couple of last points)                                        r

                                                                                     e
                                                                                  Nod
                 Node creaOon                        Node removal
 var fieldset =                           var parent = node.parentNode;
   document.createElement("fieldset");    parent.removeChild( node );
 var input =
   document.createElement("input");
 input.type = "checkbox";
 input.name = "myCheckBox";
 ...                                                 Node ancestry
 fieldset.appendChild("input");
 form.appendChild(fieldset);

 var html = '<fieldset><input
 type="checkbox" ... ></fieldset>';

 // create the node and append
 var node = Y.node.create( html );
 form.appendChild( node );

 // or do it right away
 form.append( html );




Saturday, November 21, 2009
CreaJon, removal, and ancestry                              Easie
              (a couple of last points)                                        r

                                                                                     e
                                                                                  Nod
                 Node creaOon                        Node removal
 var fieldset =                           var parent = node.parentNode;
   document.createElement("fieldset");    parent.removeChild( node );
 var input =
   document.createElement("input");       node.remove();
 input.type = "checkbox";
 input.name = "myCheckBox";
 ...                                                 Node ancestry
 fieldset.appendChild("input");
 form.appendChild(fieldset);

 var html = '<fieldset><input
 type="checkbox" ... ></fieldset>';

 // create the node and append
 var node = Y.node.create( html );
 form.appendChild( node );

 // or do it right away
 form.append( html );




Saturday, November 21, 2009
CreaJon, removal, and ancestry                              Easie
              (a couple of last points)                                        r

                                                                                     e
                                                                                  Nod
                 Node creaOon                        Node removal
 var fieldset =                           var parent = node.parentNode;
   document.createElement("fieldset");    parent.removeChild( node );
 var input =
   document.createElement("input");       node.remove();
 input.type = "checkbox";
 input.name = "myCheckBox";
 ...                                                 Node ancestry
 fieldset.appendChild("input");
 form.appendChild(fieldset);
                                          var root = li.ancestor('.root');
 var html = '<fieldset><input
                                          <ul class="root">
 type="checkbox" ... ></fieldset>';
                                            <li>One</li>
                                            <li>Two</li>
 // create the node and append
                                            <li>
 var node = Y.node.create( html );
                                              <ul>
 form.appendChild( node );
                                                 <li>Sub One</li>
                                                 <li>Sub Two</li>
 // or do it right away
                                              </ul>
 form.append( html );
                                            </li>
                                          </ul>




Saturday, November 21, 2009
Sugar is sweet     Easie
              (and so are you)        r




Saturday, November 21, 2009
Sugar is sweet                                   Easie
              (and so are you)                                      r




                       Y.log     Y.Object           oop
                                                   Y.clone
                     Y.later      Y.mix
                                                 Y.aggregate
                    Y.cached     Y.merge
                                                  Y.augment
                        Y.UA      Y.each
                                                  Y.extend
                      Y.Lang      Y.bind

                     Y.Array                ++




Saturday, November 21, 2009
screenshot by me :)




Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)




Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)




                                   http://whimsical.nu/hack/openhacksea.php

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)




Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)

        The HTML

        Datasource

         Animation




Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              <div id="show"><div id="current">
        The HTML                <?php echo $show ?>
                              </div></div>
        Datasource            <div id="imageDump" style="display: none;">
                                <?= $dump ?>
                              </div>
         Animation




Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource

         Animation




                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource

         Animation




                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource             var myDataSource = new Y.DataSource.Get({
                                 source:"flickrcall.php?tag=openhacksea",
         Animation               scriptCallbackParam:'jsoncallback'
                               });




                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource             var myDataSource = new Y.DataSource.Get({
                                 source:"flickrcall.php?tag=openhacksea",
         Animation               scriptCallbackParam:'jsoncallback'
                               });
                               var myCallback = {
                                 success: function(e){
                                   // magic!
                                   // (add stuff to a custom PhotoReel obj)
                                   Y.later( 5000, myPhotoReel,
                                     myPhotoReel.advance, Array( Y ), true );
                                 }};




                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource             var myDataSource = new Y.DataSource.Get({
                                 source:"flickrcall.php?tag=openhacksea",
         Animation               scriptCallbackParam:'jsoncallback'
                               });
                               var myCallback = {
                                 success: function(e){
                                   // magic!
                                   // (add stuff to a custom PhotoReel obj)
                                   Y.later( 5000, myPhotoReel,
                                     myPhotoReel.advance, Array( Y ), true );
                                 }};

                               myDataSource.plug(Y.Plugin.DataSourceJSONSchema, {
                                 schema: {
                                   resultListLocator: "photos.photo",
                                   resultFields: ["id", "owner", "secret", "server",
                                     "farm", "title","ownername"]
                                 }
                               });



                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource

         Animation




                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource
                                    Y.on( 'domready', function(e){
         Animation                    myDataSource.sendRequest("", myCallback);
                                    });




                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource

         Animation




                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource
                                 PhotoReel.prototype = { ...
         Animation                   advance : function(Y) {



                                       Y.one( "#show" ).append(
                                         '<div id="next" style="opacity:0;">'
                                         + this.photos[this.current]
                                         + '</div>' );




                                     ... }
                                 }


                              });

Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource            PhotoReel.prototype = { ...

         Animation                advance : function(Y) {




                               ... }
                              }

                              });


Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource            PhotoReel.prototype = { ...

         Animation                advance : function(Y) {



                                     fadeInAnim = new Y.Anim({
                                         node : "#next",
                                         to : { opacity: 1 }
                                      });
                                     fadeOutAnim = new Y.Anim({
                                         node : "#current",
                                         to : { opacity: 0 }
                                      })




                               ... }
                              }

                              });


Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource            PhotoReel.prototype = { ...

         Animation                advance : function(Y) {




                               ... }
                              }

                              });


Saturday, November 21, 2009
Photo slideshow
              (because pictures are pre*eh)
                              YUI().use("datasource","node","substitute","anim",
        The HTML                function(Y){ ...

        Datasource            PhotoReel.prototype = { ...

         Animation                advance : function(Y) {

                                       fadeInAnim.on( 'run', function(e) {
                                         fadeOutAnim.run();
                                       });

                                       fadeInAnim.on( 'end', function(e) {

                                         Y.one( "#current" ).setContent(
                                           this.photos[this.current] );
                                         Y.one( "#next" ).remove();

                                       }, this );

                                       fadeInAnim.run();
                               ... }
                              }

                              });


Saturday, November 21, 2009
http://www.flickr.com/photos/kandyjaxx/2012468692/




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)


  Tutorials, samples, and guides
  h*p://developer.yahoo.com/yui/3/




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)


  Tutorials, samples, and guides
  h*p://developer.yahoo.com/yui/3/




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)


  Tutorials, samples, and guides
  h*p://developer.yahoo.com/yui/3/


  YUI API DocumentaJon
  h*p://developer.yahoo.com/yui/3/api/




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)


  Tutorials, samples, and guides
  h*p://developer.yahoo.com/yui/3/


  YUI API DocumentaJon
  h*p://developer.yahoo.com/yui/3/api/




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)


  Tutorials, samples, and guides
  h*p://developer.yahoo.com/yui/3/


  YUI API DocumentaJon
  h*p://developer.yahoo.com/yui/3/api/


  YUI3 Gallery
  h*p://yuilibrary.com/gallery/ 




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)


  Tutorials, samples, and guides
  h*p://developer.yahoo.com/yui/3/


  YUI API DocumentaJon
  h*p://developer.yahoo.com/yui/3/api/


  YUI3 Gallery
  h*p://yuilibrary.com/gallery/ 




Saturday, November 21, 2009
Making life easier
              (for you and for me and the enOre human race)


  Tutorials, samples, and guides
  h*p://developer.yahoo.com/yui/3/


  YUI API DocumentaJon
  h*p://developer.yahoo.com/yui/3/api/


  YUI3 Gallery
  h*p://yuilibrary.com/gallery/ 


  YUI Forum
  h*p://yuilibrary.com/forum/ 




Saturday, November 21, 2009
Go forth and hack!


                                                                            Or, do you have any 
                                                                            quesOons?
                                                                            http://whimsical.nu/hack/openhacksea.php




                                                                            Angela Sabas
                                                                            Frontend Engineer, Yahoo!
                                                                            amari@yahoo-inc.com
                                                                            http://whimsical.nu
                                                                            @angelamaria

                          http://www.flickr.com/photos/bzedan/2905906576/




Saturday, November 21, 2009

More Related Content

What's hot

14multithreaded Graphics
14multithreaded Graphics14multithreaded Graphics
14multithreaded GraphicsAdil Jafri
 
NeXTPLAN: Enterprise software that rocks!
NeXTPLAN: Enterprise software that rocks!NeXTPLAN: Enterprise software that rocks!
NeXTPLAN: Enterprise software that rocks!ESUG
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame AnimationJussi Pohjolainen
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDXJussi Pohjolainen
 
Kotlin Mullets
Kotlin MulletsKotlin Mullets
Kotlin MulletsJames Ward
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with UnityPetri Lankoski
 

What's hot (7)

14multithreaded Graphics
14multithreaded Graphics14multithreaded Graphics
14multithreaded Graphics
 
NeXTPLAN: Enterprise software that rocks!
NeXTPLAN: Enterprise software that rocks!NeXTPLAN: Enterprise software that rocks!
NeXTPLAN: Enterprise software that rocks!
 
libGDX: Simple Frame Animation
libGDX: Simple Frame AnimationlibGDX: Simple Frame Animation
libGDX: Simple Frame Animation
 
Implementing a Simple Game using libGDX
Implementing a Simple Game using libGDXImplementing a Simple Game using libGDX
Implementing a Simple Game using libGDX
 
Kotlin Mullets
Kotlin MulletsKotlin Mullets
Kotlin Mullets
 
A More Flash Like Web?
A More Flash Like Web?A More Flash Like Web?
A More Flash Like Web?
 
Game Project / Working with Unity
Game Project / Working with UnityGame Project / Working with Unity
Game Project / Working with Unity
 

Viewers also liked

In what ways does your media product use
In what ways does your media product useIn what ways does your media product use
In what ways does your media product usehurtwoodhousemedia5
 
12 days of_christmas
12 days of_christmas12 days of_christmas
12 days of_christmasSpeedyeagle10
 
Je transforming collections
Je transforming collectionsJe transforming collections
Je transforming collectionsJill Emery
 
лекция 12. слайды
лекция 12. слайдылекция 12. слайды
лекция 12. слайдыviborodkin
 
тема 3. правовое регулирование финансового контроля
тема 3. правовое регулирование финансового контролятема 3. правовое регулирование финансового контроля
тема 3. правовое регулирование финансового контроляviborodkin
 
Manual Ubuntu Karmic Koala
Manual Ubuntu Karmic KoalaManual Ubuntu Karmic Koala
Manual Ubuntu Karmic KoalaUdem
 

Viewers also liked (7)

What is a thriller oj
What is a thriller ojWhat is a thriller oj
What is a thriller oj
 
In what ways does your media product use
In what ways does your media product useIn what ways does your media product use
In what ways does your media product use
 
12 days of_christmas
12 days of_christmas12 days of_christmas
12 days of_christmas
 
Je transforming collections
Je transforming collectionsJe transforming collections
Je transforming collections
 
лекция 12. слайды
лекция 12. слайдылекция 12. слайды
лекция 12. слайды
 
тема 3. правовое регулирование финансового контроля
тема 3. правовое регулирование финансового контролятема 3. правовое регулирование финансового контроля
тема 3. правовое регулирование финансового контроля
 
Manual Ubuntu Karmic Koala
Manual Ubuntu Karmic KoalaManual Ubuntu Karmic Koala
Manual Ubuntu Karmic Koala
 

Similar to YUI Evolved

Using Objects to Organize your jQuery Code
Using Objects to Organize your jQuery CodeUsing Objects to Organize your jQuery Code
Using Objects to Organize your jQuery CodeRebecca Murphey
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUIAdam Lu
 
Achieving Performance Zen with YUI 3
Achieving Performance Zen with YUI 3Achieving Performance Zen with YUI 3
Achieving Performance Zen with YUI 3Ryan Grove
 
Hack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT KharagpurHack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT KharagpurSumana Hariharan
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLgerbille
 
JavaScript Everywhere! Creating a 100% JavaScript web stack
JavaScript Everywhere! Creating a 100% JavaScript web stackJavaScript Everywhere! Creating a 100% JavaScript web stack
JavaScript Everywhere! Creating a 100% JavaScript web stackTom Croucher
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-futureyiming he
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天tblanlan
 
The next step, part 2
The next step, part 2The next step, part 2
The next step, part 2Pat Cavit
 
夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》Koubei Banquet
 
从YUI2到YUI3看前端的演变
从YUI2到YUI3看前端的演变从YUI2到YUI3看前端的演变
从YUI2到YUI3看前端的演变Kejun Zhang
 
Yui3在美团 2
Yui3在美团 2Yui3在美团 2
Yui3在美团 2Kai Cui
 

Similar to YUI Evolved (20)

Using Objects to Organize your jQuery Code
Using Objects to Organize your jQuery CodeUsing Objects to Organize your jQuery Code
Using Objects to Organize your jQuery Code
 
Testable Javascript
Testable JavascriptTestable Javascript
Testable Javascript
 
YUI Hidden Gems
YUI Hidden GemsYUI Hidden Gems
YUI Hidden Gems
 
Get started with YUI
Get started with YUIGet started with YUI
Get started with YUI
 
Achieving Performance Zen with YUI 3
Achieving Performance Zen with YUI 3Achieving Performance Zen with YUI 3
Achieving Performance Zen with YUI 3
 
dojo.things()
dojo.things()dojo.things()
dojo.things()
 
Hack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT KharagpurHack U - YUI - 2012 IIT Kharagpur
Hack U - YUI - 2012 IIT Kharagpur
 
YUI (Advanced)
YUI (Advanced)YUI (Advanced)
YUI (Advanced)
 
Leaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGLLeaving Flatland: getting started with WebGL
Leaving Flatland: getting started with WebGL
 
JavaScript Everywhere! Creating a 100% JavaScript web stack
JavaScript Everywhere! Creating a 100% JavaScript web stackJavaScript Everywhere! Creating a 100% JavaScript web stack
JavaScript Everywhere! Creating a 100% JavaScript web stack
 
RubyConf 2009
RubyConf 2009RubyConf 2009
RubyConf 2009
 
kissy-past-now-future
kissy-past-now-futurekissy-past-now-future
kissy-past-now-future
 
KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天KISSY 的昨天、今天与明天
KISSY 的昨天、今天与明天
 
YUI for your Hacks
YUI for your Hacks YUI for your Hacks
YUI for your Hacks
 
The next step, part 2
The next step, part 2The next step, part 2
The next step, part 2
 
夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》夜宴52期《从函数构造到YUI沙箱》
夜宴52期《从函数构造到YUI沙箱》
 
Yui3在美团
Yui3在美团Yui3在美团
Yui3在美团
 
从YUI2到YUI3看前端的演变
从YUI2到YUI3看前端的演变从YUI2到YUI3看前端的演变
从YUI2到YUI3看前端的演变
 
Yui3在美团 2
Yui3在美团 2Yui3在美团 2
Yui3在美团 2
 
Advanced JavaScript
Advanced JavaScript Advanced JavaScript
Advanced JavaScript
 

More from Michael Smith Jr.

More from Michael Smith Jr. (11)

How to pitch
How to pitchHow to pitch
How to pitch
 
Leveraging on scalable technology to expand regionally
Leveraging on scalable technology to expand regionallyLeveraging on scalable technology to expand regionally
Leveraging on scalable technology to expand regionally
 
Escape velocity from singapore aws '17
Escape velocity from singapore   aws '17Escape velocity from singapore   aws '17
Escape velocity from singapore aws '17
 
Mobile Marketing Conference 2011
Mobile Marketing Conference 2011Mobile Marketing Conference 2011
Mobile Marketing Conference 2011
 
Sparxup
SparxupSparxup
Sparxup
 
Web Product Innovation in Emerging Markets
Web Product Innovation in Emerging MarketsWeb Product Innovation in Emerging Markets
Web Product Innovation in Emerging Markets
 
YQL talk at OHD Jakarta
YQL talk at OHD JakartaYQL talk at OHD Jakarta
YQL talk at OHD Jakarta
 
Open Hack Indonesia Keynote
Open Hack Indonesia KeynoteOpen Hack Indonesia Keynote
Open Hack Indonesia Keynote
 
Mobile Mondays Indonesia
Mobile Mondays IndonesiaMobile Mondays Indonesia
Mobile Mondays Indonesia
 
Echelon Slide Deck
Echelon Slide DeckEchelon Slide Deck
Echelon Slide Deck
 
The Trend is your frend!
The Trend is your frend!The Trend is your frend!
The Trend is your frend!
 

Recently uploaded

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 

Recently uploaded (20)

Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

YUI Evolved

  • 1. YUI Evolved: YUI3 and Why It’s Good for You Saturday, November 21, 2009
  • 3. document.onmousemove = } ev = ev||window.event; mouseMove; function mouseUp(ev){ var mousePos = document.onmouseup = dragObject = null; mouseCoords(ev); mouseUp; } if(dragObject){ var dragObject = null; function dragObject.style.position var mouseOffset = null; getMouseOffset(target,ev){ = 'absolute'; ev = ev || window.event; dragObject.style.top function mouseCoords(ev){ var docPos = = mousePos.y - if(ev.pageX||ev.pageY){ getPosition(target); mouseOffset.y; return {x:ev.pageX, var mousePos = dragObject.style.left y:ev.pageY}; mouseCoords(ev); = mousePos.x - } return {x:mousePos.x - mouseOffset.x; return { docPos.x, y:mousePos.y - return false; x:ev.clientX + docPos.y}; } document.body.scrollLeft - } } document.body.clientLeft, function getPosition(e){ function mouseUp(){ y:ev.clientY + var left = 0; dragObject = null; document.body.scrollTop - var top = 0; } document.body.clientTop while (e.offsetParent){ function }; left += e.offsetLeft; makeDraggable(item){ } top += e.offsetTop; if(!item) return; e = e.offsetParent; item.onmousedown = function } function(ev){ makeClickable(object){ left += e.offsetLeft; dragObject = this; object.onmousedown = top += e.offsetTop; mouseOffset = function(){ return {x:left, y:top}; getMouseOffset(this, ev); dragObject = this; } return false; } function mouseMove(ev){ } http://www.flickr.com/photos/valjk/634696442/ Saturday, November 21, 2009
  • 5. <script src="http://yui.yahooapis.com/3.0.0/build/yui/ yui-min.js"></script> YUI().use('dd-drag', function(Y) { var dd = new Y.DD.Drag({ //Selector of the node to make draggable node: '#demo' }); }); http://www.flickr.com/photos/funadium/2311851858/ Saturday, November 21, 2009
  • 6. Change always comes bearing gi@s ‐ Price Pritche* Lighter Easier Saturday, November 21, 2009
  • 7. Change always comes bearing gi@s ‐ Price Pritche* Lighter Easier • Finer grained modules,  sub‐modules • Lazy‐loading • Emphasis on code reuse - common base, plugins,  extensions Saturday, November 21, 2009
  • 8. Change always comes bearing gi@s ‐ Price Pritche* Lighter Easier • Finer grained modules,  • Sandboxed development sub‐modules • Consistent API • Lazy‐loading • Convenience • Emphasis on code reuse - each, bind, nodelist, queue,  - common base, plugins,  chainability, general sugar extensions Saturday, November 21, 2009
  • 9. Change always comes bearing gi@s ‐ Price Pritche* Lighter Easier • Finer grained modules,  • Sandboxed development sub‐modules • Consistent API • Lazy‐loading • Convenience • Emphasis on code reuse - each, bind, nodelist, queue,  - common base, plugins,  chainability, general sugar extensions Saturday, November 21, 2009
  • 10. All in a day’s work (but taking less than a day, hopefully) Saturday, November 21, 2009
  • 11. All in a day’s work (but taking less than a day, hopefully) yui-min.js Saturday, November 21, 2009
  • 12. All in a day’s work (but taking less than a day, hopefully) yui-min.js node event dom selector Saturday, November 21, 2009
  • 13. All in a day’s work (but taking less than a day, hopefully) yui-min.js node event dom selector YUI().use("imageloader", function(Y){ // magic! } ); Saturday, November 21, 2009
  • 14. All in a day’s work (but taking less than a day, hopefully) yui-min.js add phase node event dom selector YUI().use("imageloader", use phase function(Y){ // magic! } ); Saturday, November 21, 2009
  • 15. All in a day’s work (but taking less than a day, hopefully) yui-min.js add phase node event oop dom selector imageloader YUI().use("imageloader", use phase function(Y){ // magic! } ); Saturday, November 21, 2009
  • 16. All in a day’s work (but taking less than a day, hopefully) yui-min.js add phase node event oop dom selector imageloader YUI().use("imageloader", use phase function(Y){ // magic! } oopevent node imageloader ); Saturday, November 21, 2009
  • 17. All in a day’s work (but taking less than a day, hopefully) yui-min.js add phase node event oop dom selector imageloader YUI().use("imageloader", YUI().use("anim-base", use phase function(Y){ function(Y){ // magic! // magic! } } oopevent node imageloader ); ); Saturday, November 21, 2009
  • 18. All in a day’s work (but taking less than a day, hopefully) yui-min.js event- attribute- base- add phase node event oop custom base base anim- dom selector imageloader base YUI().use("imageloader", YUI().use("anim-base", use phase function(Y){ function(Y){ // magic! // magic! } } base- attribute- anim- event- event oopevent node imageloader oop dom node selector base ); ); base custom base Saturday, November 21, 2009
  • 19. Playing in your own sandbox Easie (but invite others too) r yui ... add  node use phase Saturday, November 21, 2009
  • 20. Playing in your own sandbox Easie (but invite others too) r yui ... add  node <script src="http:// yui.yahooapis.com/3.4/build/yui/yui- min.js"> <script> use phase YUI().use("overlay", function(Y){ Y.on("click", function(){ new Y.Overlay({ … }).render(); }, "#button" ); }); </script> Saturday, November 21, 2009
  • 21. Playing in your own sandbox Easie (but invite others too) r yui ... add  node <script src="http:// <script src="http:// yui.yahooapis.com/3.4/build/yui/yui- yui.yahooapis.com/3.0/build/overlay/ min.js"> overlay-min.js"> <script> <script> use phase YUI().use("overlay", function(Y){ YUI().use("overlay", function(Y){ Y.on("click", function(){ new Y.Overlay({ … }).render(); new Y.Overlay({ … }).render(); }, "#button" ); }); </script> }); </script> Saturday, November 21, 2009
  • 22. Playing in your own sandbox Easie (but invite others too) r yui ... add  node <script src="http:// <script src="http:// yui.yahooapis.com/3.4/build/yui/yui- yui.yahooapis.com/3.0/build/overlay/ min.js"> overlay-min.js"> <script> <script> use phase YUI().use("overlay", function(Y){ YUI().use("overlay", function(Y){ Y.on("click", function(){ new Y.Overlay({ … }).render(); new Y.Overlay({ … }).render(); }, "#button" ); }); </script> }); </script> Saturday, November 21, 2009
  • 23. Everything where you want them Easie (a.k.a. event façades) r nt Eve Saturday, November 21, 2009
  • 24. Everything where you want them Easie (a.k.a. event façades) r nt Eve YUI2 YUI3 Saturday, November 21, 2009
  • 25. Everything where you want them Easie (a.k.a. event façades) r nt Eve YUI2 YUI3 var Dom = YAHOO.util.Dom; var Event = YAHOO.util.Event; var linkNode = Dom.get("id"); Event.addListener( linkNode, "click", function(e) { var target = Event.getTarget(e); if( Dom.hasClass( target, "selector" )) { Event.preventDefault(e); } }); Saturday, November 21, 2009
  • 26. Everything where you want them Easie (a.k.a. event façades) r nt Eve YUI2 YUI3 var Dom = YAHOO.util.Dom; linkNode.on("click", function(e) { var Event = YAHOO.util.Event; if(!e.target.hasClass("selector")){ var linkNode = Dom.get("id"); e.preventDefault(); } Event.addListener( linkNode, "click", function(e) { }); var target = Event.getTarget(e); if( Dom.hasClass( target, "selector" )) { Event.preventDefault(e); } }); Saturday, November 21, 2009
  • 27. One moment in Jme Easie (regarding on and aNer moments) r nt Eve ON ON Default Behavior After After After Saturday, November 21, 2009
  • 28. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON Default Behavior After After After Saturday, November 21, 2009
  • 29. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON Default Behavior After After After Saturday, November 21, 2009
  • 30. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON e.stopImmediatePropagation() Default Behavior After After After Saturday, November 21, 2009
  • 31. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON e.stopImmediatePropagation() Default Behavior After After After Saturday, November 21, 2009
  • 32. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON e.preventDefault() Default Behavior After After After Saturday, November 21, 2009
  • 33. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON e.preventDefault() Default Behavior After After After Saturday, November 21, 2009
  • 34. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON Default Behavior After After e.preventDefault() After Saturday, November 21, 2009
  • 35. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON Default Behavior After After e.preventDefault() After Saturday, November 21, 2009
  • 36. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON Default Behavior After After e.stopImmediatePropagation() After Saturday, November 21, 2009
  • 37. One moment in Jme Easie (regarding on and aNer moments) r nt Eve this.fire("select"); ON ON Default Behavior After After e.stopImmediatePropagation() After Saturday, November 21, 2009
  • 38. Too many events spoil the page Easie (a.k.a. event delegaOon) r nt Eve HTML JS Saturday, November 21, 2009
  • 39. Too many events spoil the page Easie (a.k.a. event delegaOon) r nt Eve HTML JS <div id=”menu”> <ul> <li class=”menuitem”> <em>Open file...</em> </li> <li class=”menuitem”> <em>Save file...</em> </li> <li class=”menuitem”> <em>Close file</em> </li> <li class=”menuitem stop”> <em>Quit</em> </li> </ul> </div> Saturday, November 21, 2009
  • 40. Too many events spoil the page Easie (a.k.a. event delegaOon) r nt Eve HTML JS <div id=”menu”> var menuDiv = Y.one(“#menu”); <ul> menuDiv.delegate("click", function(e){ <li class=”menuitem”> <em>Open file...</em> </li> <li class=”menuitem”> <em>Save file...</em> </li> }, "li.menuitem"); <li class=”menuitem”> <em>Close file</em> </li> <li class=”menuitem stop”> <em>Quit</em> </li> </ul> </div> Saturday, November 21, 2009
  • 41. Too many events spoil the page Easie (a.k.a. event delegaOon) r nt Eve HTML JS <div id=”menu”> var menuDiv = Y.one(“#menu”); <ul> menuDiv.delegate("click", function(e){ <li class=”menuitem”> <em>Open file...</em> Y.log( this.get(‘innerHTML’) ); </li> // <em>Quit</em>, etc <li class=”menuitem”> // this == e.currentTarget <em>Save file...</em> // e.container == menuDiv </li> }, "li.menuitem"); <li class=”menuitem”> <em>Close file</em> </li> <li class=”menuitem stop”> <em>Quit</em> </li> </ul> </div> Saturday, November 21, 2009
  • 42. Too many events spoil the page Easie (a.k.a. event delegaOon) r nt Eve HTML JS <div id=”menu”> var menuDiv = Y.one(“#menu”); <ul> menuDiv.delegate("click", function(e){ <li class=”menuitem”> <em>Open file...</em> Y.log( this.get(‘innerHTML’) ); </li> // <em>Quit</em>, etc <li class=”menuitem”> // this == e.currentTarget <em>Save file...</em> // e.container == menuDiv </li> }, "li.menuitem"); <li class=”menuitem”> <em>Close file</em> </li> // but maybe we want to stop Y.one(“li.stop”).on(“click”, <li class=”menuitem stop”> function(e){ <em>Quit</em> e.stopPropagation(); </li> } ); </ul> </div> Saturday, November 21, 2009
  • 43. NoJficaJon flow: Bubbling Easie (Ony bubbles) r nt Eve Menu MenuItem ON ON ON Def. Behavior Def. Behavior After After After After After Saturday, November 21, 2009
  • 44. NoJficaJon flow: Bubbling Easie (Ony bubbles) r nt Eve Menu MenuItem ON ON ON Def. Behavior Def. Behavior After After After After After Saturday, November 21, 2009
  • 45. NoJficaJon flow: Bubbling Easie (Ony bubbles) r nt Eve Menu MenuItem ON ON ON Def. Behavior Def. Behavior After After After After After Saturday, November 21, 2009
  • 46. NoJficaJon flow: Bubbling Easie (Ony bubbles) r nt Eve Menu MenuItem ON ON ON Def. Behavior Def. Behavior After After After After After Saturday, November 21, 2009
  • 47. NoJficaJon flow: Bubbling Easie (Ony bubbles) r nt Eve Menu MenuItem ON ON ON e.stopPropagation() Def. Behavior Def. Behavior After After After After After Saturday, November 21, 2009
  • 48. NoJficaJon flow: Bubbling Easie (Ony bubbles) r nt Eve Menu MenuItem ON ON ON e.stopPropagation() Def. Behavior Def. Behavior After After After After After Saturday, November 21, 2009
  • 49. Working with HTML Elements Easie (selectors, sugar, chaining, oh my) r e Nod YUI2 YUI3 Saturday, November 21, 2009
  • 50. Working with HTML Elements Easie (selectors, sugar, chaining, oh my) r e Nod YUI2 YUI3 var Dom = YAHOO.util.Dom; var Event = YAOO.util.Event; var elms = Dom.getElementsByClassName( "task", "li", "actions"); for (var i = 0; i < elms.length; i++) { var elm = elms[i]; if(Dom.hasClass(elm, "selected")){ Dom.addClass(elm, "current"); Event.on(elm, "click", handler); } } Saturday, November 21, 2009
  • 51. Working with HTML Elements Easie (selectors, sugar, chaining, oh my) r e Nod YUI2 YUI3 var Dom = YAHOO.util.Dom; var elm = Y.Node.get( var Event = YAOO.util.Event; ".actions li.task.selected" ); var elms = Dom.getElementsByClassName( "task", "li", "actions"); elm.addClass("current"); elm.on("click", handler); for (var i = 0; i < elms.length; i++) { var elm = elms[i]; if(Dom.hasClass(elm, "selected")){ Dom.addClass(elm, "current"); Event.on(elm, "click", handler); } } Saturday, November 21, 2009
  • 52. Working with HTML Elements Easie (selectors, sugar, chaining, oh my) r e Nod YUI2 YUI3 var Dom = YAHOO.util.Dom; var elm = Y.Node.get( var Event = YAOO.util.Event; ".actions li.task.selected" ); var elms = Dom.getElementsByClassName( "task", "li", "actions"); elm.addClass("current"); elm.on("click", handler); for (var i = 0; i < elms.length; i++) { var elm = elms[i]; // want something shorter? Y.Node.get(…).addClass("current").on( if(Dom.hasClass(elm, "selected")){ "click",handler); Dom.addClass(elm, "current"); Event.on(elm, "click", handler); } } Saturday, November 21, 2009
  • 53. HTML Elements made easier Easie (HTMLElement API improved) r e Nod Supports Normalizes Enhances Bulk operaOons Saturday, November 21, 2009
  • 54. HTML Elements made easier Easie (HTMLElement API improved) r e Nod Supports Normalizes Enhances node.appendChild(new) node.cloneNode(node) node.scrollIntoView() node.get("parentNode") node.set("innerHTML", "Hello world!") Bulk operaOons Saturday, November 21, 2009
  • 55. HTML Elements made easier Easie (HTMLElement API improved) r e Nod Supports Normalizes Enhances node.appendChild(new) node.getAttribute("href") node.cloneNode(node) node.contains(node) node.scrollIntoView() node.getText() node.get("parentNode") node.getStyle("paddingTop") node.set("innerHTML", node.previous() "Hello world!") Bulk operaOons Saturday, November 21, 2009
  • 56. HTML Elements made easier Easie (HTMLElement API improved) r e Nod Supports Normalizes Enhances node.appendChild(new) node.getAttribute("href") node.addClass("selectable") node.cloneNode(node) node.contains(node) node.toggleClass("enabled") node.scrollIntoView() node.getText() node.getXY() node.get("parentNode") node.getStyle("paddingTop") node.get("region") node.set("innerHTML", node.previous() "Hello world!") Bulk operaOons Saturday, November 21, 2009
  • 57. HTML Elements made easier Easie (HTMLElement API improved) r e Nod Supports Normalizes Enhances node.appendChild(new) node.getAttribute("href") node.addClass("selectable") node.cloneNode(node) node.contains(node) node.toggleClass("enabled") node.scrollIntoView() node.getText() node.getXY() node.get("parentNode") node.getStyle("paddingTop") node.get("region") node.set("innerHTML", node.previous() "Hello world!") Bulk operaOons var items = Y.Node.all(".actions li"); nodeList.filter(‘a[href]’); items.addClass("disabled"); nodeList.odd(); items.set("title", "Item Disabled"); nodeList.even(); items.each(function(node) { node.addClass("disabled); node.set("title", "Item Disabled"); }); Saturday, November 21, 2009
  • 58. CreaJon, removal, and ancestry Easie (a couple of last points) r e Nod Node creaOon Node removal Node ancestry Saturday, November 21, 2009
  • 59. CreaJon, removal, and ancestry Easie (a couple of last points) r e Nod Node creaOon Node removal var fieldset = document.createElement("fieldset"); Node ancestry var input = document.createElement("input"); input.type = "checkbox"; input.name = "myCheckBox"; ... fieldset.appendChild("input"); form.appendChild(fieldset); Saturday, November 21, 2009
  • 60. CreaJon, removal, and ancestry Easie (a couple of last points) r e Nod Node creaOon Node removal var fieldset = document.createElement("fieldset"); Node ancestry var input = document.createElement("input"); input.type = "checkbox"; input.name = "myCheckBox"; ... fieldset.appendChild("input"); form.appendChild(fieldset); var html = '<fieldset><input type="checkbox" ... ></fieldset>'; // create the node and append var node = Y.node.create( html ); form.appendChild( node ); // or do it right away form.append( html ); Saturday, November 21, 2009
  • 61. CreaJon, removal, and ancestry Easie (a couple of last points) r e Nod Node creaOon Node removal var fieldset = var parent = node.parentNode; document.createElement("fieldset"); parent.removeChild( node ); var input = document.createElement("input"); input.type = "checkbox"; input.name = "myCheckBox"; ... Node ancestry fieldset.appendChild("input"); form.appendChild(fieldset); var html = '<fieldset><input type="checkbox" ... ></fieldset>'; // create the node and append var node = Y.node.create( html ); form.appendChild( node ); // or do it right away form.append( html ); Saturday, November 21, 2009
  • 62. CreaJon, removal, and ancestry Easie (a couple of last points) r e Nod Node creaOon Node removal var fieldset = var parent = node.parentNode; document.createElement("fieldset"); parent.removeChild( node ); var input = document.createElement("input"); node.remove(); input.type = "checkbox"; input.name = "myCheckBox"; ... Node ancestry fieldset.appendChild("input"); form.appendChild(fieldset); var html = '<fieldset><input type="checkbox" ... ></fieldset>'; // create the node and append var node = Y.node.create( html ); form.appendChild( node ); // or do it right away form.append( html ); Saturday, November 21, 2009
  • 63. CreaJon, removal, and ancestry Easie (a couple of last points) r e Nod Node creaOon Node removal var fieldset = var parent = node.parentNode; document.createElement("fieldset"); parent.removeChild( node ); var input = document.createElement("input"); node.remove(); input.type = "checkbox"; input.name = "myCheckBox"; ... Node ancestry fieldset.appendChild("input"); form.appendChild(fieldset); var root = li.ancestor('.root'); var html = '<fieldset><input <ul class="root"> type="checkbox" ... ></fieldset>'; <li>One</li> <li>Two</li> // create the node and append <li> var node = Y.node.create( html ); <ul> form.appendChild( node ); <li>Sub One</li> <li>Sub Two</li> // or do it right away </ul> form.append( html ); </li> </ul> Saturday, November 21, 2009
  • 64. Sugar is sweet Easie (and so are you) r Saturday, November 21, 2009
  • 65. Sugar is sweet Easie (and so are you) r Y.log Y.Object oop Y.clone Y.later Y.mix Y.aggregate Y.cached Y.merge Y.augment Y.UA Y.each Y.extend Y.Lang Y.bind Y.Array ++ Saturday, November 21, 2009
  • 66. screenshot by me :) Saturday, November 21, 2009
  • 67. Photo slideshow (because pictures are pre*eh) Saturday, November 21, 2009
  • 68. Photo slideshow (because pictures are pre*eh) http://whimsical.nu/hack/openhacksea.php Saturday, November 21, 2009
  • 69. Photo slideshow (because pictures are pre*eh) Saturday, November 21, 2009
  • 70. Photo slideshow (because pictures are pre*eh) The HTML Datasource Animation Saturday, November 21, 2009
  • 71. Photo slideshow (because pictures are pre*eh) <div id="show"><div id="current"> The HTML <?php echo $show ?> </div></div> Datasource <div id="imageDump" style="display: none;"> <?= $dump ?> </div> Animation Saturday, November 21, 2009
  • 72. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource Animation }); Saturday, November 21, 2009
  • 73. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource Animation }); Saturday, November 21, 2009
  • 74. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource var myDataSource = new Y.DataSource.Get({ source:"flickrcall.php?tag=openhacksea", Animation scriptCallbackParam:'jsoncallback' }); }); Saturday, November 21, 2009
  • 75. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource var myDataSource = new Y.DataSource.Get({ source:"flickrcall.php?tag=openhacksea", Animation scriptCallbackParam:'jsoncallback' }); var myCallback = { success: function(e){ // magic! // (add stuff to a custom PhotoReel obj) Y.later( 5000, myPhotoReel, myPhotoReel.advance, Array( Y ), true ); }}; }); Saturday, November 21, 2009
  • 76. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource var myDataSource = new Y.DataSource.Get({ source:"flickrcall.php?tag=openhacksea", Animation scriptCallbackParam:'jsoncallback' }); var myCallback = { success: function(e){ // magic! // (add stuff to a custom PhotoReel obj) Y.later( 5000, myPhotoReel, myPhotoReel.advance, Array( Y ), true ); }}; myDataSource.plug(Y.Plugin.DataSourceJSONSchema, { schema: { resultListLocator: "photos.photo", resultFields: ["id", "owner", "secret", "server", "farm", "title","ownername"] } }); }); Saturday, November 21, 2009
  • 77. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource Animation }); Saturday, November 21, 2009
  • 78. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource Y.on( 'domready', function(e){ Animation myDataSource.sendRequest("", myCallback); }); }); Saturday, November 21, 2009
  • 79. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource Animation }); Saturday, November 21, 2009
  • 80. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource PhotoReel.prototype = { ... Animation advance : function(Y) { Y.one( "#show" ).append( '<div id="next" style="opacity:0;">' + this.photos[this.current] + '</div>' ); ... } } }); Saturday, November 21, 2009
  • 81. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource PhotoReel.prototype = { ... Animation advance : function(Y) { ... } } }); Saturday, November 21, 2009
  • 82. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource PhotoReel.prototype = { ... Animation advance : function(Y) { fadeInAnim = new Y.Anim({ node : "#next", to : { opacity: 1 } }); fadeOutAnim = new Y.Anim({ node : "#current", to : { opacity: 0 } }) ... } } }); Saturday, November 21, 2009
  • 83. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource PhotoReel.prototype = { ... Animation advance : function(Y) { ... } } }); Saturday, November 21, 2009
  • 84. Photo slideshow (because pictures are pre*eh) YUI().use("datasource","node","substitute","anim", The HTML function(Y){ ... Datasource PhotoReel.prototype = { ... Animation advance : function(Y) { fadeInAnim.on( 'run', function(e) { fadeOutAnim.run(); }); fadeInAnim.on( 'end', function(e) { Y.one( "#current" ).setContent( this.photos[this.current] ); Y.one( "#next" ).remove(); }, this ); fadeInAnim.run(); ... } } }); Saturday, November 21, 2009
  • 86. Making life easier (for you and for me and the enOre human race) Saturday, November 21, 2009
  • 87. Making life easier (for you and for me and the enOre human race) Tutorials, samples, and guides h*p://developer.yahoo.com/yui/3/ Saturday, November 21, 2009
  • 88. Making life easier (for you and for me and the enOre human race) Tutorials, samples, and guides h*p://developer.yahoo.com/yui/3/ Saturday, November 21, 2009
  • 89. Making life easier (for you and for me and the enOre human race) Tutorials, samples, and guides h*p://developer.yahoo.com/yui/3/ YUI API DocumentaJon h*p://developer.yahoo.com/yui/3/api/ Saturday, November 21, 2009
  • 90. Making life easier (for you and for me and the enOre human race) Tutorials, samples, and guides h*p://developer.yahoo.com/yui/3/ YUI API DocumentaJon h*p://developer.yahoo.com/yui/3/api/ Saturday, November 21, 2009
  • 91. Making life easier (for you and for me and the enOre human race) Tutorials, samples, and guides h*p://developer.yahoo.com/yui/3/ YUI API DocumentaJon h*p://developer.yahoo.com/yui/3/api/ YUI3 Gallery h*p://yuilibrary.com/gallery/  Saturday, November 21, 2009
  • 92. Making life easier (for you and for me and the enOre human race) Tutorials, samples, and guides h*p://developer.yahoo.com/yui/3/ YUI API DocumentaJon h*p://developer.yahoo.com/yui/3/api/ YUI3 Gallery h*p://yuilibrary.com/gallery/  Saturday, November 21, 2009
  • 93. Making life easier (for you and for me and the enOre human race) Tutorials, samples, and guides h*p://developer.yahoo.com/yui/3/ YUI API DocumentaJon h*p://developer.yahoo.com/yui/3/api/ YUI3 Gallery h*p://yuilibrary.com/gallery/  YUI Forum h*p://yuilibrary.com/forum/  Saturday, November 21, 2009
  • 94. Go forth and hack! Or, do you have any  quesOons? http://whimsical.nu/hack/openhacksea.php Angela Sabas Frontend Engineer, Yahoo! amari@yahoo-inc.com http://whimsical.nu @angelamaria http://www.flickr.com/photos/bzedan/2905906576/ Saturday, November 21, 2009