SlideShare uma empresa Scribd logo
1 de 70
Baixar para ler offline
JavaScript Libraries Overview

          Siarhei Barysiuk
   s.barysiuk@sam-solutions.net
Our roadmap
Libraries: What we will cover today...
5 great open source libraries for your project.
  • prototype
  • jQuery
  • dojo
  • qooxdoo
Libraries: General picture
Global picture




    Lightweight              Widgets   One-page Applications
Prototype
Prototype: Overview
                      http://prototypejs.org
Prototype: Focus
• DOM manipulation
• Ajax transport
• Utility methods for built-in objects
• Class-based OOP
Prototype: DOM manipulation
Say goodbye to getElementById()

 document.getElementById(quot;idquot;).innerHTML = quot;<li>node</li>quot;;



Say hello to $()


  $(quot;idquot;).innerHTML = quot;<li>node</li>quot;;


  $(element)                      extended DOM element
Prototype: DOM Element extension
                            * extend                   * makePositioned
 * absolutize                                                                 * select
                            * fire                      * match
 * addClassName                                                               * setOpacity
                            * firstDescendant           * next
 * addMethods                                                                 * setStyle
                            * getDimensions            * nextSiblings
 * adjacent                                                                   * show
                            * getElementsByClassName   * observe
 * ancestors                                                                  * siblings
                            * getElementsBySelector    * positionedOffset
 * childElements                                                              * stopObserving
                            * getHeight                * previous
 * classNames                                                                 * toggle
                            * getOffsetParent          * previousSiblings
 * cleanWhitespace                                                            * toggleClassName
                            * getStyle                 * readAttribute
 * clonePosition                                                              * undoClipping
                            * getWidth                 * recursivelyCollect
 * cumulativeOffset                                                           * undoPositioned
                            * hasClassName             * relativize
 * cumulativeScrollOffset                                                     * up
                            * hide                     * remove
 * descendantOf                                                               * update
                            * identify                 * removeClassName
 * descendants                                                                * viewportOffset
                            * immediateDescendants     * replace
 * down                                                                       * visible
                            * insert                   * scrollTo
 * empty                                                                      * wrap
                            * inspect                                         * writeAttribute
                            * makeClipping


 $('message').addClassName('read').update('I read this message!').setStyle({opacity: 0.5});
Prototype: Creating a DOM element
The old way:
var a = document.createElement('a');
a.setAttribute('class', 'foo');
a.setAttribute('href', '/foo.html');
a.appendChild(document.createTextNode(quot;Next pagequot;));


The new way:

var a = new Element('a', { 'class': 'foo', href: '/foo.html' }).update(quot;Next pagequot;);
Prototype: Even more bucks
$((id | element)...) -> [HTMLElement...]
$$(cssRule...) -> [HTMLElement...]
$A(iterable) -> actualArray

$F(element) -> value
$H([obj]) -> Hash

$R(start, end[, exclusive = false]) -> ObjectRange

$w(String) -> Array
Prototype: Event handling
$('foo').observe('click', respondToClick);

function respondToClick(event) {
  var element = event.element();
  element.addClassName('active');
}
Prototype: Ajax transport
new Ajax.Request('/some_url',{
		       method:'get',
		       onSuccess: function(transport){
		          var response = transport.responseText || quot;no response textquot;;
		          alert(quot;Success! nnquot; + response);
		       },
		       onFailure: function(){ alert('Something went wrong...') }
		     });



Also available are onXXX callbacks, where XXX is the HTTP response status
like 200 or 404.
Prototype: Ajax transport
new   Ajax.Request('/some_url', {
		     	   method: 'get',
		     	   parameters: {company: 'example', limit: 12}
		     	   });



new Ajax.Request('/some_url', {
			      parameters: $('id_of_form_element').serialize(true)
			      });


                                             form serialization
Prototype: Ajax magic
        new Ajax.Updater(
	   	   			{
	   	   	 	 	 	 success: 'products', 3.1
	   	   	 	 	 	 failure: 'errors'           3.2
	   	   	 	 	 },
	   	   	 	 	 '/some_url', 1
	   	   			{
	   	   			      method: 'get', 2
	   	   			      insertion: Insertion.Top   4
	   	   			}
	   	   	 );
Prototype: Built-in object extensions
                                                             * all
                                                             * any
                                                             * collect
        var myObject = {};                                   * detect
                                                             * each
                                                             * eachSlice
	   	   ['foo', 'bar', 'baz'].each(function(name, index) {
                                                             * entries
	   	     this[name] = index;                                * find
	   	   }, myObject); // we have specified the context       * findAll
                                                             * grep
	   	                                                        * inGroupsOf
	   	   myObject                                             * include
                                                             * inject
	   	   //-> { foo: 0, bar: 1, baz: 2}
                                                             * invoke
                                                             * map
                                                             * max
                                                             * member
                                                             * min
                                                             * partition
                                                             * pluck
                                                             * reject
                                                             * select
                                                             * size
                                                             * sortBy
                                                             * toArray
                                                             * zip
Prototype: Built-in object extensions                    * blank
                                                         * camelize
                                                         * capitalize
                                                         * dasherize
quot;<h1>hello, i'm HTML</h1>quot;.escapeHTML()                  * empty
                                                         * endsWith
//-> quot;&lt;h1&gt;hello, i'm HTML&lt;/h1&gt;quot;              * escapeHTML
                                                         * evalJSON
                                                         * evalScripts
'background-color'.camelize(); // -> 'backgroundColor'   * extractScripts
                                                         * gsub
                                                         * include
'Prototype framework'.include('frame'); //-> true        * inspect
'Prototype framework'.include('frameset');//-> false     * interpolate
                                                         * isJSON
                                                         * parseQuery
                                                         * scan
quot;echo quot;.times(3);   //-> quot;echo echo echo quot;
                                                         * startsWith
                                                         * strip
                                                         * stripScripts
quot;#{animals} on a #{transport}quot;.interpolate({
                                                         * stripTags
                    animals: quot;Pigsquot;,                     * sub
                                                         * succ
                    transport: quot;Surfboardquot; });           * times
//-> quot;Pigs on a Surfboardquot;                               * toArray
                                                         * toJSON
                                                         * toQueryParams
                                                         * truncate
                                                         * underscore
                                                         * unescapeHTML
                                                         * unfilterJSON
Prototype: Class-based OOP
var Person = Class.create({
  initialize: function(name) {
     this.name = name;
  },
  say: function(message) {
     return this.name + ': ' + message;
  }
});




var Pirate = Class.create(Person, {
  // redefine the speak method
  say: function($super, message) {
    return $super(message) + ', yarr!';
  }
});

var john = new Pirate('Long John');
john.say('ahoy matey');
// -> quot;Long John: ahoy matey, yarr!quot;
Prototype: Real life example
            http://gmx.com http://web.de http://gmx.de
Prototype: Conclusion

• lightweight
• good for small projects
• a lot of useful methods
• transport support
• effects with script.aculo.us
• good documented
• a lot of real project which use prototype
Questions?
jQuery
jQuery: Overview
                   http://jquery.com
jQuery: Focus
Motto: Write less, do more.
• DOM manipulation
• Ajax transport
• Effects
• Other functionality with plugins
jQuery: DOM manipulation
Very powerful selectors.

$(quot;#myDivquot;).css(quot;borderquot;,quot;3px solid redquot;);

$(quot;divquot;).css(quot;borderquot;,quot;3px solid redquot;);

$(quot;.myClassquot;).css(quot;borderquot;,quot;3px solid redquot;);

$(quot;*quot;).css(quot;borderquot;,quot;3px solid redquot;);

$(quot;div,span,p.myClassquot;).css(quot;borderquot;,quot;3px solid redquot;);
jQuery: DOM manipulation
Even more powerful than you expect.
$('li:eq(0)')

$('li:even')

$('li:lt(3)')

$('li:not(.goofy)')

$('p a[href*=#]')

$('code, li.goofy')

$('ol .goofy > strong')

$('li + li > a[href$=pdf]')

$('span:hidden')
jQuery: DOM manipulation
Attributes:                 Text:
     attr( name )             text( )
     attr( properties   )     text( val )
     attr( key, value   )
                            HTML:
     attr( key, value   )
     removeAttr( name   )
                               html( )
Classes:                       html( val )
     addClass( class )
                            Value:
     hasClass( class )
     removeClass( class )      val( )
     toggleClass( class )      val( val )
jQuery: DOM manipulation
append( content )
appendTo( content )

prepend( content )
prependTo( content )

after( content )
before( content )

insertAfter( content )
insertBefore( content )

wrap( html )

replaceWith( content )

clone( )
jQuery: Events
Very convenient event handling system.

  3 main methods:

   bind( type, data, fn )

   trigger( type, data )

   unbind( type, data )
jQuery: Binding event handlers
$(quot;pquot;).bind(quot;clickquot;, function(e){
  var str = quot;( quot; + e.pageX + quot;, quot; + e.pageY + quot; )quot;;
  $(quot;spanquot;).text(quot;Click happened! quot; + str);
});

$(quot;pquot;).bind(quot;dblclickquot;, function(){
  $(quot;spanquot;).text(quot;Double-click happened in quot; + this.tagName);
});

$(quot;pquot;).bind(quot;mouseenter mouseleavequot;, function(e){
    $(this).toggleClass(quot;overquot;);
});


$(quot;pquot;).trigger(quot;clickquot;);
jQuery: Binding event handlers
$(quot;pquot;).click(function(e){
  var str = quot;( quot; + e.pageX + quot;, quot; + e.pageY + quot; )quot;;
  $(quot;spanquot;).text(quot;Click happened! quot; + str);
});

$(quot;pquot;).dblclick(function(){
  $(quot;spanquot;).text(quot;Double-click happened in quot; + this.tagName);
});


$(quot;pquot;).click();
jQuery: Custom events
$(quot;pquot;).bind(quot;myCustomEventquot;, function(e, myName, myValue){
  $(this).text(myName + quot;, hi there!quot;);
  $(quot;spanquot;).stop().css(quot;opacityquot;, 1)
           .text(quot;myName = quot; + myName)
           .fadeIn(30).fadeOut(1000);
});




$(quot;buttonquot;).click(function () {
  $(quot;pquot;).trigger(quot;myCustomEventquot;, [ quot;Johnquot; ]);
});
jQuery: onload event
$(document).ready(function () {
    $(quot;pquot;).text(quot;The DOM is now loaded and can be manipulated.quot;);
});
jQuery: Ajax transport
$.ajax({
   type: quot;POSTquot;,
   url: quot;some.phpquot;,
   data: quot;name=John&location=Bostonquot;,
   success: function(msg){
     alert( quot;Data Saved: quot; + msg );
   }
 });

$.ajax({
  url: quot;test.htmlquot;,
  cache: false,
  success: function(html){
    $(quot;#resultsquot;).append(html);
  }
});
jQuery: Ajax transport
$.ajax({
	 url:quot;http://api.flickr.com/services/feeds/photos_public.gne?
tags=cat&tagmode=any&format=jsonquot;,
	 dataType:quot;jsonpquot;,
	 jsonp:quot;jsoncallbackquot;,
	 success: function(data){
          //...
	 	 	 	 })
	}
})
jQuery: Effects
show/hide
toggle

slideDown/slideUp
slideToggle

fadeIn/fadeOut
fadeTo

animate
jQuery: Conclusion
• lightweight
• powerful CSS selectors
• ‘less code’ way
• built-in effects and animation
• transport support (including cross-domain)
• a lot of real-life examples
Questions?
Dojo
Dojo: Overview
                 http://dojotoolkit.org
Dojo: Focus
• DOM manipulation
• Animations
• Ajax
• Event and keyboard normalization
• Internationalization (i18n)
• Widgets
Dojo: Package system
Dojo has a package system built-in to load all the code you need,
and is controlled by dojo.require().
This function allows us to pull in parts of the Dojo Toolkit not provided for
in the Base dojo.js, such as Drag and Drop, additional animations, Dijit widgets,
DojoX projects, or even your own code.

dojo.require(quot;dijit.form.Buttonquot;);
dojo.require(quot;dijit.TitlePanequot;);
Dojo: Selectors
dojo.addOnLoad(function(){
	 // our dom is ready, get the node:
	 dojo.query(quot;#testHeadingquot;)
		    // add quot;testClassquot; to its class=quot;quot; attribute
	 	 .addClass(quot;testClassquot;)
		    // and fade it out after 500 ms
	 	 .fadeOut({ delay:500 }).play();
});
Dojo: Event handling
dojo.addOnLoad(function(){
    var node = dojo.byId(quot;testHeadingquot;);
    dojo.connect(node,quot;onclickquot;,function(){
	    node.innerHTML = quot;I've been clickedquot;;     	
    });	
});

dojo.addOnLoad(function(){
     dojo.query(quot;#testHeadingquot;)
	   .style(quot;cursorquot;,quot;pointerquot;)
	   .connect(quot;onclickquot;,function(){
	      this.innerHTML = quot;I've been clickedquot;;
	 });	
});
Dojo: Ajax transport
var init = function(){
	 var contentNode = dojo.byId(quot;contentquot;);
	 dojo.xhrGet({
	 	 url: quot;js/sample.txtquot;,
	 	 handleAs: quot;textquot;,
	 	 load: function(data,args){
	 	 	 // fade out the node we're modifying
	 	 	 dojo.fadeOut({
	 	 	 	 node: contentNode,
	 	 	 	 onEnd: function(){
				          // set the data, fade it back in
				          contentNode.innerHTML = data;
				          dojo.fadeIn({node: contentNode}).play();
				}
	 	 	 }).play();
	 	 },
	 	 // if any error occurs, it goes here:
	 	 error: function(error,args){
	 	 	 console.warn(quot;error!quot;,error);
		}
	 });
};
dojo.addOnLoad(init);
Dojo: Ajax transport
// sumbit the form
var formSubmit = function(e){
	   // prevent the form from actually submitting
	   e.preventDefault();
	   // submit the form in the background	
	   dojo.xhrPost({
	   	   url: quot;alternate-submit.phpquot;,
	   	   form: quot;mainFormquot;,
	   	   handleAs: quot;textquot;,
	   	   handle: function(data,args){
	   	   	   if(typeof data == quot;errorquot;){
	   	   	   	   console.warn(quot;error!quot;,args);
	   	   	   }else{
	   	   	   	   // show our response
	   	   	   	   console.log(data);
	   	   	   }
	   	   }
	   });
};
dojo.addOnLoad(function(){
	   var theForm = dojo.byId(quot;mainFormquot;);
	   // another dojo.connect syntax: call a function directly	
	   dojo.connect(theForm,quot;onsubmitquot;,formSubmit);
});
Dojo: Widgets
First Name:
<input type=quot;textquot; size=quot;20quot; name=quot;firstquot;
dojoType=quot;dijit.form.TextBoxquot;
            trim=quot;truequot; propercase=quot;truequot; />

Price:	 	
<input type=quot;textquot;
    maxlength=quot;12quot;
    class=quot;fillwidth currencyquot;
    id=quot;grossincomequot; name=quot;grossincomequot;
    value=quot;0.00quot;
    dojoType=quot;dijit.form.CurrencyTextBoxquot;
    required=quot;truequot;
    onChange=quot;updateTotals()quot;
    currency=quot;USDquot;/>


dojo.require(quot;dijit.form.TextBoxquot;);
dojo.require(quot;dijit.form.CurrencyTextquot;);
Dojo: Dijit at a Glance

                Border Container          AccordionContainer
  ContentPane                                                      Toolbar

  Slider         ComboBox           CurrencyTextBox       NumberTextBox
                 CheckBox         DateTextBox
 Textarea                                           ValidationTextBox
                FilteringSelect     InlineEditBox
 TimeTextBox                                              TabContainer
                NumberSpinner           StackContainer
                                                            Menu
      Dialog
                Tree   ProgressBar         Editor        Grid
Dojo: DojoX - Dojo eXtensions

   Cometd                             Cryptography
                                                                 Widgets
                  Charting
                                                                               FX
                               Data                 Layout
    Collections
                                                                        Wire
                                        Grid
                             I/O
              Image                                            Timing
  XML Utilities                                 Offline                         GFX
                             String Utilities
                                                             Validate
              UUID
Dojo: Dojo custom build

1. groups together modules into layers
2. interns external non-JavaScript files
3. smooshes the layer down with ShrinkSafe
4. copies all non-layered scripts to the appropriate places
Dojo: Conclusion
• not so lightweight as previous
• tons of features
• separate packages
• custom build
Questions?
qooxdoo
qooxdoo: Overview
                    http://qooxdo.org
qooxdoo: Focus

• One page Rich Internet Applications
• A lot of ideas from Qt
• OOP approach
• No HTML and CSS programming
qooxdoo: The power is in OOP
The main actors of qooxdoo OO are:

• Classes
• Interfaces
• Mixins
qooxdoo: Classes
qx.Class.define(quot;qx.test.Catquot;, {
  construct : function() { ... }
});

qx.Class.define(quot;qx.test.Catquot;, {
  ...
  statics : {
    LEGS: 4,
    makeSound : function() { ... }
  }
});

qx.Class.define(quot;qx.test.Catquot;, {
  ...
  members: {
    name : quot;Kittyquot;,
    getName: function() { return this.name }
  }
});
qooxdoo: Special Types of Classes
qx.Class.define(quot;qx.test.Catquot;, {
  type : quot;staticquot;
  ...
});

qx.Class.define(quot;qx.test.Catquot;, {
  type : quot;abstractquot;
  ...
});

qx.Class.define(quot;qx.test.Catquot;, {
  type : quot;singletonquot;
  ...
});
qooxdoo: Inheritance
qx.Class.define(quot;qx.test.Animalquot;, {
  members: {
    makeSound : function(howManyTimes) {
       ....
    }
  }
});

qx.Class.define(quot;qx.test.Catquot;, {
  extend: qx.test.Animal,
  members: {
    makeSound : function() {
      this.debug(quot;I'm a catquot;);
      /* howManyTimes or any other parameter are passed.   We
don't need to know how many parameters are used. */
      arguments.callee.base.apply(this, arguments);
    }
  }
});
qooxdoo: Interfaces
Defining interface:
qx.Interface.define(quot;qx.test.ISamplequot;,
 {
   extend: [SuperInterfaces],

      properties: {quot;colorquot;: {}, quot;namequot;: {} },

      members:
      {
         meth1: function() { return true; },
         meth2: function(a, b) { return arguments.length == 2; },
         meth3: function(c) { return qx.Class.hasInterface(c.constructor, qx.some.IInterface); }
      },

      statics:
      {
         PI : 3.14,
         staticMethod: function(z) { return typeof z == quot;stringquot;; }
      },

});
qooxdoo: Interfaces
Implementing interface:
qx.Class.define(quot;qx.test.Samplequot;,
 {
   implement: [qx.test.ISample],

      properties: {
         quot;colorquot;: { check: quot;colorquot;},
         quot;namequot;: { check: quot;Stringquot;}
      },

      members:
      {
        meth1: function() { return 42; },
        meth2: function(a, b) { return a+b },
        meth3: function(c) { c.foo() }
      }
});
qooxdoo: Mixins
Defining mixin:
qx.Mixin.define(quot;namequot;,
{
  include: [SuperMixins],

  properties: {
     quot;tabIndexquot;: {check: quot;Numberquot;, init: -1}
  },

  members:
  {
    prop1: quot;fooquot;,
    meth1: function() {},
    meth2: function() {}
  }
});
qooxdoo: Mixins
Attaching mixin:
qx.Class.define(quot;my.cool.Classquot;,
{
  include : [my.cool.MMixin, my.other.cool.MMixin]
  ...
});


qx.Class.include(qx.ui.core.Widget, qx.MWidgetExtensions);
qooxdoo: Properties
...
properties : {
  width : { check : quot;Numberquot;, apply : quot;applyWidthquot; }
}

members :
{
  applyWidth : function(value) {
    this.setStyleProperty(quot;widthquot;, value + quot;pxquot;);
  }
}
...


widget.addEventListener(quot;changeWidthquot;, function(e) {
  e.getValue().innerHTML = quot;Hello Worldquot;;
});
qooxdoo: GUI
qooxdoo: GUI and even more features
• Layouting
• Widgets
• Interaction
• Selection Handling
• Drag & Drop
• Theming
• Low-level Ajax Transport
• RPC
• Logging and Debugging
• Unit testing
qooxdoo: Tooling
Generator:

• Optimization
• Compressing
• Internalization
• API Documentation
• More
XML description for UI - qxtransformer



    http://qxtransformer.org
qooxdoo: Real life example
                      http://gmx.com
Questions?

Mais conteúdo relacionado

Mais procurados

Create a Customized GMF DnD Framework
Create a Customized GMF DnD FrameworkCreate a Customized GMF DnD Framework
Create a Customized GMF DnD FrameworkKaniska Mandal
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends旻琦 潘
 
Nodejs mongoose
Nodejs mongooseNodejs mongoose
Nodejs mongooseFin Chen
 
JS Level Up: Prototypes
JS Level Up: PrototypesJS Level Up: Prototypes
JS Level Up: PrototypesVernon Kesner
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design PatternsDerek Brown
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryRebecca Murphey
 
Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Wilson Su
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonfRafael Dohms
 
Surviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and TaxonomiesSurviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and TaxonomiesBrad Williams
 
Node.js for PHP developers
Node.js for PHP developersNode.js for PHP developers
Node.js for PHP developersAndrew Eddie
 
Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Fwdays
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил АнохинFwdays
 
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesDesarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesLuis Curo Salvatierra
 
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product DevelopmentTom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product DevelopmentVincenzo Barone
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...Rafael Dohms
 
Et si on en finissait avec CRUD ?
Et si on en finissait avec CRUD ?Et si on en finissait avec CRUD ?
Et si on en finissait avec CRUD ?Julien Vinber
 

Mais procurados (19)

Create a Customized GMF DnD Framework
Create a Customized GMF DnD FrameworkCreate a Customized GMF DnD Framework
Create a Customized GMF DnD Framework
 
A tour on ruby and friends
A tour on ruby and friendsA tour on ruby and friends
A tour on ruby and friends
 
JavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talkJavaScript Neednt Hurt - JavaBin talk
JavaScript Neednt Hurt - JavaBin talk
 
Nodejs mongoose
Nodejs mongooseNodejs mongoose
Nodejs mongoose
 
JS Level Up: Prototypes
JS Level Up: PrototypesJS Level Up: Prototypes
JS Level Up: Prototypes
 
JavaScript Design Patterns
JavaScript Design PatternsJavaScript Design Patterns
JavaScript Design Patterns
 
Cleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQueryCleaner, Leaner, Meaner: Refactoring your jQuery
Cleaner, Leaner, Meaner: Refactoring your jQuery
 
Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8Practical JavaScript Programming - Session 1/8
Practical JavaScript Programming - Session 1/8
 
Implementing New Web
Implementing New WebImplementing New Web
Implementing New Web
 
BVJS
BVJSBVJS
BVJS
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHPKonf
 
Surviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and TaxonomiesSurviving the Zombie Apocalypse using Custom Post Types and Taxonomies
Surviving the Zombie Apocalypse using Custom Post Types and Taxonomies
 
Node.js for PHP developers
Node.js for PHP developersNode.js for PHP developers
Node.js for PHP developers
 
Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"Михаил Анохин "Data binding 2.0"
Михаил Анохин "Data binding 2.0"
 
"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин"Android Data Binding в массы" Михаил Анохин
"Android Data Binding в массы" Михаил Анохин
 
Desarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móvilesDesarrollo de módulos en Drupal e integración con dispositivos móviles
Desarrollo de módulos en Drupal e integración con dispositivos móviles
 
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product DevelopmentTom Lazar   Using Zope3 Views And Viewlets For Plone 3.0 Product Development
Tom Lazar Using Zope3 Views And Viewlets For Plone 3.0 Product Development
 
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
“Writing code that lasts” … or writing code you won’t hate tomorrow. - PHP Yo...
 
Et si on en finissait avec CRUD ?
Et si on en finissait avec CRUD ?Et si on en finissait avec CRUD ?
Et si on en finissait avec CRUD ?
 

Semelhante a JavaScript Libraries Overview

case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxtidwellveronique
 
dcs plus Catalogue 2015
dcs plus Catalogue 2015dcs plus Catalogue 2015
dcs plus Catalogue 2015dcs plus
 
Building DSLs With Eclipse
Building DSLs With EclipseBuilding DSLs With Eclipse
Building DSLs With EclipsePeter Friese
 
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docxMARRY7
 
運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScripttaobao.com
 
Grain final border one
Grain final border oneGrain final border one
Grain final border oneAshish Gupta
 
node.js Module Development
node.js Module Developmentnode.js Module Development
node.js Module DevelopmentJay Harris
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Developmentjsmith92
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Tsuyoshi Yamamoto
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6Dmitry Soshnikov
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Tsuyoshi Yamamoto
 
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)Ryan Mauger
 
Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipsePeter Friese
 

Semelhante a JavaScript Libraries Overview (20)

Posfix
PosfixPosfix
Posfix
 
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docxcase3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
case3h231diamond.gifcase3h231energy.jpgcase3h231moder.docx
 
dcs plus Catalogue 2015
dcs plus Catalogue 2015dcs plus Catalogue 2015
dcs plus Catalogue 2015
 
Building DSLs With Eclipse
Building DSLs With EclipseBuilding DSLs With Eclipse
Building DSLs With Eclipse
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
Email Program By Marcelo
Email Program By MarceloEmail Program By Marcelo
Email Program By Marcelo
 
"this" in JavaScript
"this" in JavaScript"this" in JavaScript
"this" in JavaScript
 
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx!  Modernizr v2.0.6  httpwww.modernizr.com   Copyri.docx
! Modernizr v2.0.6 httpwww.modernizr.com Copyri.docx
 
運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript運用Closure Compiler 打造高品質的JavaScript
運用Closure Compiler 打造高品質的JavaScript
 
Grain final border one
Grain final border oneGrain final border one
Grain final border one
 
node.js Module Development
node.js Module Developmentnode.js Module Development
node.js Module Development
 
SPL: The Missing Link in Development
SPL: The Missing Link in DevelopmentSPL: The Missing Link in Development
SPL: The Missing Link in Development
 
Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察Jggug 2010 330 Grails 1.3 観察
Jggug 2010 330 Grails 1.3 観察
 
jQuery introduction
jQuery introductionjQuery introduction
jQuery introduction
 
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
HelsinkiJS meet-up. Dmitry Soshnikov - ECMAScript 6
 
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
Grails 1.2 探検隊 -新たな聖杯をもとめて・・・-
 
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
Zend Framework and the Doctrine2 MongoDB ODM (ZF1)
 
Jazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with EclipseJazoon 2010 - Building DSLs with Eclipse
Jazoon 2010 - Building DSLs with Eclipse
 
Beautiful code
Beautiful codeBeautiful code
Beautiful code
 

Mais de Siarhei Barysiuk

Pure css skinning with menu box and menu
Pure css skinning with menu box and menuPure css skinning with menu box and menu
Pure css skinning with menu box and menuSiarhei Barysiuk
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax ApplicationsSiarhei Barysiuk
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesSiarhei Barysiuk
 
JavaScript Basics And DOM Manipulation
JavaScript Basics And DOM ManipulationJavaScript Basics And DOM Manipulation
JavaScript Basics And DOM ManipulationSiarhei Barysiuk
 

Mais de Siarhei Barysiuk (6)

Pure css skinning with menu box and menu
Pure css skinning with menu box and menuPure css skinning with menu box and menu
Pure css skinning with menu box and menu
 
Web Application Security
Web Application SecurityWeb Application Security
Web Application Security
 
High Performance Ajax Applications
High Performance Ajax ApplicationsHigh Performance Ajax Applications
High Performance Ajax Applications
 
JavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best PracticesJavaScript and UI Architecture Best Practices
JavaScript and UI Architecture Best Practices
 
AJAX Transport Layer
AJAX Transport LayerAJAX Transport Layer
AJAX Transport Layer
 
JavaScript Basics And DOM Manipulation
JavaScript Basics And DOM ManipulationJavaScript Basics And DOM Manipulation
JavaScript Basics And DOM Manipulation
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 

JavaScript Libraries Overview

  • 1.
  • 2. JavaScript Libraries Overview Siarhei Barysiuk s.barysiuk@sam-solutions.net
  • 4. Libraries: What we will cover today... 5 great open source libraries for your project. • prototype • jQuery • dojo • qooxdoo
  • 5. Libraries: General picture Global picture Lightweight Widgets One-page Applications
  • 7. Prototype: Overview http://prototypejs.org
  • 8. Prototype: Focus • DOM manipulation • Ajax transport • Utility methods for built-in objects • Class-based OOP
  • 9. Prototype: DOM manipulation Say goodbye to getElementById() document.getElementById(quot;idquot;).innerHTML = quot;<li>node</li>quot;; Say hello to $() $(quot;idquot;).innerHTML = quot;<li>node</li>quot;; $(element) extended DOM element
  • 10. Prototype: DOM Element extension * extend * makePositioned * absolutize * select * fire * match * addClassName * setOpacity * firstDescendant * next * addMethods * setStyle * getDimensions * nextSiblings * adjacent * show * getElementsByClassName * observe * ancestors * siblings * getElementsBySelector * positionedOffset * childElements * stopObserving * getHeight * previous * classNames * toggle * getOffsetParent * previousSiblings * cleanWhitespace * toggleClassName * getStyle * readAttribute * clonePosition * undoClipping * getWidth * recursivelyCollect * cumulativeOffset * undoPositioned * hasClassName * relativize * cumulativeScrollOffset * up * hide * remove * descendantOf * update * identify * removeClassName * descendants * viewportOffset * immediateDescendants * replace * down * visible * insert * scrollTo * empty * wrap * inspect * writeAttribute * makeClipping $('message').addClassName('read').update('I read this message!').setStyle({opacity: 0.5});
  • 11. Prototype: Creating a DOM element The old way: var a = document.createElement('a'); a.setAttribute('class', 'foo'); a.setAttribute('href', '/foo.html'); a.appendChild(document.createTextNode(quot;Next pagequot;)); The new way: var a = new Element('a', { 'class': 'foo', href: '/foo.html' }).update(quot;Next pagequot;);
  • 12. Prototype: Even more bucks $((id | element)...) -> [HTMLElement...] $$(cssRule...) -> [HTMLElement...] $A(iterable) -> actualArray $F(element) -> value $H([obj]) -> Hash $R(start, end[, exclusive = false]) -> ObjectRange $w(String) -> Array
  • 13. Prototype: Event handling $('foo').observe('click', respondToClick); function respondToClick(event) { var element = event.element(); element.addClassName('active'); }
  • 14. Prototype: Ajax transport new Ajax.Request('/some_url',{ method:'get', onSuccess: function(transport){ var response = transport.responseText || quot;no response textquot;; alert(quot;Success! nnquot; + response); }, onFailure: function(){ alert('Something went wrong...') } }); Also available are onXXX callbacks, where XXX is the HTTP response status like 200 or 404.
  • 15. Prototype: Ajax transport new Ajax.Request('/some_url', { method: 'get', parameters: {company: 'example', limit: 12} }); new Ajax.Request('/some_url', { parameters: $('id_of_form_element').serialize(true) }); form serialization
  • 16. Prototype: Ajax magic new Ajax.Updater( { success: 'products', 3.1 failure: 'errors' 3.2 }, '/some_url', 1 { method: 'get', 2 insertion: Insertion.Top 4 } );
  • 17. Prototype: Built-in object extensions * all * any * collect var myObject = {}; * detect * each * eachSlice ['foo', 'bar', 'baz'].each(function(name, index) { * entries this[name] = index; * find }, myObject); // we have specified the context * findAll * grep * inGroupsOf myObject * include * inject //-> { foo: 0, bar: 1, baz: 2} * invoke * map * max * member * min * partition * pluck * reject * select * size * sortBy * toArray * zip
  • 18. Prototype: Built-in object extensions * blank * camelize * capitalize * dasherize quot;<h1>hello, i'm HTML</h1>quot;.escapeHTML() * empty * endsWith //-> quot;&lt;h1&gt;hello, i'm HTML&lt;/h1&gt;quot; * escapeHTML * evalJSON * evalScripts 'background-color'.camelize(); // -> 'backgroundColor' * extractScripts * gsub * include 'Prototype framework'.include('frame'); //-> true * inspect 'Prototype framework'.include('frameset');//-> false * interpolate * isJSON * parseQuery * scan quot;echo quot;.times(3); //-> quot;echo echo echo quot; * startsWith * strip * stripScripts quot;#{animals} on a #{transport}quot;.interpolate({ * stripTags animals: quot;Pigsquot;, * sub * succ transport: quot;Surfboardquot; }); * times //-> quot;Pigs on a Surfboardquot; * toArray * toJSON * toQueryParams * truncate * underscore * unescapeHTML * unfilterJSON
  • 19. Prototype: Class-based OOP var Person = Class.create({ initialize: function(name) { this.name = name; }, say: function(message) { return this.name + ': ' + message; } }); var Pirate = Class.create(Person, { // redefine the speak method say: function($super, message) { return $super(message) + ', yarr!'; } }); var john = new Pirate('Long John'); john.say('ahoy matey'); // -> quot;Long John: ahoy matey, yarr!quot;
  • 20. Prototype: Real life example http://gmx.com http://web.de http://gmx.de
  • 21. Prototype: Conclusion • lightweight • good for small projects • a lot of useful methods • transport support • effects with script.aculo.us • good documented • a lot of real project which use prototype
  • 24. jQuery: Overview http://jquery.com
  • 25. jQuery: Focus Motto: Write less, do more. • DOM manipulation • Ajax transport • Effects • Other functionality with plugins
  • 26. jQuery: DOM manipulation Very powerful selectors. $(quot;#myDivquot;).css(quot;borderquot;,quot;3px solid redquot;); $(quot;divquot;).css(quot;borderquot;,quot;3px solid redquot;); $(quot;.myClassquot;).css(quot;borderquot;,quot;3px solid redquot;); $(quot;*quot;).css(quot;borderquot;,quot;3px solid redquot;); $(quot;div,span,p.myClassquot;).css(quot;borderquot;,quot;3px solid redquot;);
  • 27. jQuery: DOM manipulation Even more powerful than you expect. $('li:eq(0)') $('li:even') $('li:lt(3)') $('li:not(.goofy)') $('p a[href*=#]') $('code, li.goofy') $('ol .goofy > strong') $('li + li > a[href$=pdf]') $('span:hidden')
  • 28. jQuery: DOM manipulation Attributes: Text: attr( name ) text( ) attr( properties ) text( val ) attr( key, value ) HTML: attr( key, value ) removeAttr( name ) html( ) Classes: html( val ) addClass( class ) Value: hasClass( class ) removeClass( class ) val( ) toggleClass( class ) val( val )
  • 29. jQuery: DOM manipulation append( content ) appendTo( content ) prepend( content ) prependTo( content ) after( content ) before( content ) insertAfter( content ) insertBefore( content ) wrap( html ) replaceWith( content ) clone( )
  • 30. jQuery: Events Very convenient event handling system. 3 main methods: bind( type, data, fn ) trigger( type, data ) unbind( type, data )
  • 31. jQuery: Binding event handlers $(quot;pquot;).bind(quot;clickquot;, function(e){ var str = quot;( quot; + e.pageX + quot;, quot; + e.pageY + quot; )quot;; $(quot;spanquot;).text(quot;Click happened! quot; + str); }); $(quot;pquot;).bind(quot;dblclickquot;, function(){ $(quot;spanquot;).text(quot;Double-click happened in quot; + this.tagName); }); $(quot;pquot;).bind(quot;mouseenter mouseleavequot;, function(e){ $(this).toggleClass(quot;overquot;); }); $(quot;pquot;).trigger(quot;clickquot;);
  • 32. jQuery: Binding event handlers $(quot;pquot;).click(function(e){ var str = quot;( quot; + e.pageX + quot;, quot; + e.pageY + quot; )quot;; $(quot;spanquot;).text(quot;Click happened! quot; + str); }); $(quot;pquot;).dblclick(function(){ $(quot;spanquot;).text(quot;Double-click happened in quot; + this.tagName); }); $(quot;pquot;).click();
  • 33. jQuery: Custom events $(quot;pquot;).bind(quot;myCustomEventquot;, function(e, myName, myValue){ $(this).text(myName + quot;, hi there!quot;); $(quot;spanquot;).stop().css(quot;opacityquot;, 1) .text(quot;myName = quot; + myName) .fadeIn(30).fadeOut(1000); }); $(quot;buttonquot;).click(function () { $(quot;pquot;).trigger(quot;myCustomEventquot;, [ quot;Johnquot; ]); });
  • 34. jQuery: onload event $(document).ready(function () { $(quot;pquot;).text(quot;The DOM is now loaded and can be manipulated.quot;); });
  • 35. jQuery: Ajax transport $.ajax({ type: quot;POSTquot;, url: quot;some.phpquot;, data: quot;name=John&location=Bostonquot;, success: function(msg){ alert( quot;Data Saved: quot; + msg ); } }); $.ajax({ url: quot;test.htmlquot;, cache: false, success: function(html){ $(quot;#resultsquot;).append(html); } });
  • 36. jQuery: Ajax transport $.ajax({ url:quot;http://api.flickr.com/services/feeds/photos_public.gne? tags=cat&tagmode=any&format=jsonquot;, dataType:quot;jsonpquot;, jsonp:quot;jsoncallbackquot;, success: function(data){ //... }) } })
  • 38. jQuery: Conclusion • lightweight • powerful CSS selectors • ‘less code’ way • built-in effects and animation • transport support (including cross-domain) • a lot of real-life examples
  • 40. Dojo
  • 41. Dojo: Overview http://dojotoolkit.org
  • 42. Dojo: Focus • DOM manipulation • Animations • Ajax • Event and keyboard normalization • Internationalization (i18n) • Widgets
  • 43. Dojo: Package system Dojo has a package system built-in to load all the code you need, and is controlled by dojo.require(). This function allows us to pull in parts of the Dojo Toolkit not provided for in the Base dojo.js, such as Drag and Drop, additional animations, Dijit widgets, DojoX projects, or even your own code. dojo.require(quot;dijit.form.Buttonquot;); dojo.require(quot;dijit.TitlePanequot;);
  • 44. Dojo: Selectors dojo.addOnLoad(function(){ // our dom is ready, get the node: dojo.query(quot;#testHeadingquot;) // add quot;testClassquot; to its class=quot;quot; attribute .addClass(quot;testClassquot;) // and fade it out after 500 ms .fadeOut({ delay:500 }).play(); });
  • 45. Dojo: Event handling dojo.addOnLoad(function(){ var node = dojo.byId(quot;testHeadingquot;); dojo.connect(node,quot;onclickquot;,function(){ node.innerHTML = quot;I've been clickedquot;; }); }); dojo.addOnLoad(function(){ dojo.query(quot;#testHeadingquot;) .style(quot;cursorquot;,quot;pointerquot;) .connect(quot;onclickquot;,function(){ this.innerHTML = quot;I've been clickedquot;; }); });
  • 46. Dojo: Ajax transport var init = function(){ var contentNode = dojo.byId(quot;contentquot;); dojo.xhrGet({ url: quot;js/sample.txtquot;, handleAs: quot;textquot;, load: function(data,args){ // fade out the node we're modifying dojo.fadeOut({ node: contentNode, onEnd: function(){ // set the data, fade it back in contentNode.innerHTML = data; dojo.fadeIn({node: contentNode}).play(); } }).play(); }, // if any error occurs, it goes here: error: function(error,args){ console.warn(quot;error!quot;,error); } }); }; dojo.addOnLoad(init);
  • 47. Dojo: Ajax transport // sumbit the form var formSubmit = function(e){ // prevent the form from actually submitting e.preventDefault(); // submit the form in the background dojo.xhrPost({ url: quot;alternate-submit.phpquot;, form: quot;mainFormquot;, handleAs: quot;textquot;, handle: function(data,args){ if(typeof data == quot;errorquot;){ console.warn(quot;error!quot;,args); }else{ // show our response console.log(data); } } }); }; dojo.addOnLoad(function(){ var theForm = dojo.byId(quot;mainFormquot;); // another dojo.connect syntax: call a function directly dojo.connect(theForm,quot;onsubmitquot;,formSubmit); });
  • 48. Dojo: Widgets First Name: <input type=quot;textquot; size=quot;20quot; name=quot;firstquot; dojoType=quot;dijit.form.TextBoxquot; trim=quot;truequot; propercase=quot;truequot; /> Price: <input type=quot;textquot; maxlength=quot;12quot; class=quot;fillwidth currencyquot; id=quot;grossincomequot; name=quot;grossincomequot; value=quot;0.00quot; dojoType=quot;dijit.form.CurrencyTextBoxquot; required=quot;truequot; onChange=quot;updateTotals()quot; currency=quot;USDquot;/> dojo.require(quot;dijit.form.TextBoxquot;); dojo.require(quot;dijit.form.CurrencyTextquot;);
  • 49. Dojo: Dijit at a Glance Border Container AccordionContainer ContentPane Toolbar Slider ComboBox CurrencyTextBox NumberTextBox CheckBox DateTextBox Textarea ValidationTextBox FilteringSelect InlineEditBox TimeTextBox TabContainer NumberSpinner StackContainer Menu Dialog Tree ProgressBar Editor Grid
  • 50. Dojo: DojoX - Dojo eXtensions Cometd Cryptography Widgets Charting FX Data Layout Collections Wire Grid I/O Image Timing XML Utilities Offline GFX String Utilities Validate UUID
  • 51. Dojo: Dojo custom build 1. groups together modules into layers 2. interns external non-JavaScript files 3. smooshes the layer down with ShrinkSafe 4. copies all non-layered scripts to the appropriate places
  • 52. Dojo: Conclusion • not so lightweight as previous • tons of features • separate packages • custom build
  • 55. qooxdoo: Overview http://qooxdo.org
  • 56. qooxdoo: Focus • One page Rich Internet Applications • A lot of ideas from Qt • OOP approach • No HTML and CSS programming
  • 57. qooxdoo: The power is in OOP The main actors of qooxdoo OO are: • Classes • Interfaces • Mixins
  • 58. qooxdoo: Classes qx.Class.define(quot;qx.test.Catquot;, { construct : function() { ... } }); qx.Class.define(quot;qx.test.Catquot;, { ... statics : { LEGS: 4, makeSound : function() { ... } } }); qx.Class.define(quot;qx.test.Catquot;, { ... members: { name : quot;Kittyquot;, getName: function() { return this.name } } });
  • 59. qooxdoo: Special Types of Classes qx.Class.define(quot;qx.test.Catquot;, { type : quot;staticquot; ... }); qx.Class.define(quot;qx.test.Catquot;, { type : quot;abstractquot; ... }); qx.Class.define(quot;qx.test.Catquot;, { type : quot;singletonquot; ... });
  • 60. qooxdoo: Inheritance qx.Class.define(quot;qx.test.Animalquot;, { members: { makeSound : function(howManyTimes) { .... } } }); qx.Class.define(quot;qx.test.Catquot;, { extend: qx.test.Animal, members: { makeSound : function() { this.debug(quot;I'm a catquot;); /* howManyTimes or any other parameter are passed. We don't need to know how many parameters are used. */ arguments.callee.base.apply(this, arguments); } } });
  • 61. qooxdoo: Interfaces Defining interface: qx.Interface.define(quot;qx.test.ISamplequot;, { extend: [SuperInterfaces], properties: {quot;colorquot;: {}, quot;namequot;: {} }, members: { meth1: function() { return true; }, meth2: function(a, b) { return arguments.length == 2; }, meth3: function(c) { return qx.Class.hasInterface(c.constructor, qx.some.IInterface); } }, statics: { PI : 3.14, staticMethod: function(z) { return typeof z == quot;stringquot;; } }, });
  • 62. qooxdoo: Interfaces Implementing interface: qx.Class.define(quot;qx.test.Samplequot;, { implement: [qx.test.ISample], properties: { quot;colorquot;: { check: quot;colorquot;}, quot;namequot;: { check: quot;Stringquot;} }, members: { meth1: function() { return 42; }, meth2: function(a, b) { return a+b }, meth3: function(c) { c.foo() } } });
  • 63. qooxdoo: Mixins Defining mixin: qx.Mixin.define(quot;namequot;, { include: [SuperMixins], properties: { quot;tabIndexquot;: {check: quot;Numberquot;, init: -1} }, members: { prop1: quot;fooquot;, meth1: function() {}, meth2: function() {} } });
  • 64. qooxdoo: Mixins Attaching mixin: qx.Class.define(quot;my.cool.Classquot;, { include : [my.cool.MMixin, my.other.cool.MMixin] ... }); qx.Class.include(qx.ui.core.Widget, qx.MWidgetExtensions);
  • 65. qooxdoo: Properties ... properties : { width : { check : quot;Numberquot;, apply : quot;applyWidthquot; } } members : { applyWidth : function(value) { this.setStyleProperty(quot;widthquot;, value + quot;pxquot;); } } ... widget.addEventListener(quot;changeWidthquot;, function(e) { e.getValue().innerHTML = quot;Hello Worldquot;; });
  • 67. qooxdoo: GUI and even more features • Layouting • Widgets • Interaction • Selection Handling • Drag & Drop • Theming • Low-level Ajax Transport • RPC • Logging and Debugging • Unit testing
  • 68. qooxdoo: Tooling Generator: • Optimization • Compressing • Internalization • API Documentation • More XML description for UI - qxtransformer http://qxtransformer.org
  • 69. qooxdoo: Real life example http://gmx.com