• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Sergey Ilinsky Presentation Ample Sdk

Sergey Ilinsky Presentation Ample Sdk






Total Views
Views on SlideShare
Embed Views



1 Embed 7

http://www.slideshare.net 7



Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
Post Comment
Edit your comment

    Sergey Ilinsky Presentation Ample Sdk Sergey Ilinsky Presentation Ample Sdk Presentation Transcript

    • Ample SDK: Standards-based GUI Framework for Client-side Applications The Ajax Experience 2009 September 14-16 in Boston, MA
    • Sergey Ilinsky http://www.ilinsky.com http://twitter.com/ilinsky
    • 1. The Landscape of Client-side GUI Technologies 2. Ample SDK: Das Experiment 3. Using Ample SDK: Basics 4. Extending on Ample SDK 5. Showcase 6. Resources 7. Q&A Agenda
    • October 17, 2007, Ajaxian.com Re-inventing XMLHttpRequest: Cross-browser implementation with sniffing capabilities
    • Highlights: Fully functional implementation of XHR for IE7- Some 20 issues fixed in native implementations. (New reports are still coming) Extended to support [transparent] request sniffing.
    • So I took on to re-inventing (re-implementing) web browser
    • 1. The Landscape of Client-Side GUI Technologies 1.1 Server-Side vs. Client-Side 1.2 Libraries vs. Frameworks 1.3 Web Browsers
    • 1.1 Server-Side vs. Client-Side Server-Side - app is orchestrated on the server - data and UI communicated to client combined - client-side hooks are not welcome Client-Side - app is orchestrated on the client (browser) - data communicated separately from UI
    • 1.2 GUI Libraries vs. Frameworks Libraries: - help executing smaller development tasks - often used to «pimp-up» web-pages Frameworks: - bring another abstraction level - used to build «rich applications»
    • 1.3 Web Browsers Two camps: Internet Explorer vs. Modern Browsers Problems: - Incompatible (sometimes incomplete) APIs - Too many versions, cool stuf in latest versions - Poor GUI facilities
    • Hm.. But don't many libraries and frameworks clean that mess successfully while adding missing glyphs?
    • Yes, they do. Every in its own way.
    • 2. Ample SDK: Das Experiment 2.1 Objectives 2.2 Solution Architecture 2.3 Browser-within-a-browser? 2.4 Ample SDK Application Lifetime 2.5 Technologies Breakdown
    • 2.1 Objectives Do not have: - new programming model - new APIs Do have: - ease of use (eliminate learning curve if possible) - better GUI technologies - separation of concerns - extensible architecture
    • Meet Ample SDK Ample SDK is a piece of software that runs transparently in the layer between web browser and application. While running it provides the Logic of the application with standard cross-browser access to the User Interface.
    • 2.2 Solution Architecture Runtime - runtime.js UI Languages - xhtml/xhtml.js - xul/xul.js+xul/xul.css - svg/svg.js - ...
    • 2.3 Browser-within-a-browser? Ample SDK is in a way a web-browser (GUI aspect) - understands MLs (XHTML, XUL, SVG..) - provides DOM APIs (Core, Events, Selectors APIs) - uses CSS for styling (pseudo-classes, pseudo-elemnts)
    • 2.4 Ample SDK Application Lifetime
    • 2.5 Technologies Breakdown - Runtime - Scripting Technologies - XML Technologies - Styling Technologies - UI Markup Technologies
    • Runtime: Scripting Technologies - Document Object Model - DOM Core (Level 2) - DOM Events (Level 3) - Selectors API - XML APIs - DOMParser, XMLSerializer - XSLTProcessor - XMLHttpRequest - UI Managers - Focus Manager - Drag&Drop Manager - Resize Manager - Capture Manager - SPI History Manager - Componentization Model
    • Runtime: XML technologies - Xinclude 1.0 - SMIL3.0 (selected modules) - XML Schema 1.1 (datatypes module)
    • Runtime: Styling Technologies - CSS 2.1 - CSS3 Namespaces - CSS3-UI (pseudo-classes, pseudo-elements)
    • UI Markup Technologies - XHTML1 - XUL - SVG 1.2 Tiny - XHTML5 (in development) - XForms 1.1 (planned)
    • 3. Using Ample SDK: Basics - XML for UI - CSS for Style - JavaScript for Logic
    • Hello World! <!DOCTYPE html> <html xmlns=&quot;http://www.w3.org/1999/xhtml&quot;> <head> <title>Hello, World!</title> <!-- (A) Ample SDK runtime and UI language --> <script type=&quot;text/javascript&quot; src=&quot;ample/runtime.js&quot;></script> <script type=&quot;text/javascript&quot; src=&quot;ample/languages/xhtml/xhtml.js&quot;></script> <!-- (1) Styling --> <style type=&quot;text/ample+css&quot;> b { color: red; } </style> <!-- (2) Logic --> <script type=&quot;text/javascript&quot;> function alertHelloWorld(oEvent) { alert('Element &quot;' + oEvent.target.tagName + '&quot; was clicked'); } </script> </head> <body> <!-- (3) Layout --> <script type=&quot;application/ample+xml&quot;> <b onclick=&quot;alertHelloWorld(event)&quot;>Hello, World!</b> </script> </body> </html>
    • The Programming Model Programming against Ample SDK is as simple as doing it against... right, cross-browser browser!
    • 3.1 Laying out Application UI Application GUI is created with XML or JS staticly: XML (XHTML, XUL, SVG..) dynamicly: JavaScript (DOM) or XML + importNode
    • Embedding XML UI into a web page a) Inline, using a script tag with type=&quot;application/ample+xml&quot; <body> <!-- other HTML code --> <script type=&quot;application/ample+xml&quot;> <!-- Ample SDK inline XML markup --> </script> <!-- other HTML code --> </body> b) Referencing a resource, using a script tag with src attribute <body> <!-- other HTML code --> <script type=&quot;application/ample+xml&quot; src=&quot;ui.xml&quot;></script> <!-- other HTML code --> </body> c) Inline, using ample.open() and ample.close() <body> <!-- other HTML code --> <script type=&quot;text/javascript&quot;>ample.open()</script> <!-- Ample SDK inline XML markup --> <script type=&quot;text/javascript&quot;>ample.close()</script> <!-- other HTML code --> </body>
    • Using XHTML 1 and XHTML 5 <article> <header> <h1>Apples</h1> <p>Tasty, delicious fruit!</p> </header> <p>The apple is the pomaceous fruit of the apple tree.</p> <section> <h1>Red Delicious</h1> <p>These bright red apples are the most common found in many supermarkets.</p> </section> <section> <h1>Granny Smith</h1> <p>These juicy, green apples and make a great filling for apple pies.</p> </section> <footer> <h1>Apples</h1> <p>Tasty, delicious fruit!</p> </footer> </article>
    • Using XUL (Mozilla technology) <xul:tabbox xmlns:xul=&quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&quot;> <xul:tabs> <xul:tab label=&quot;checkbox&quot; /> <xul:tab label=&quot;textbox&quot; /> <xul:tab label=&quot;datepicker&quot; /> </xul:tabs> <xul:tabpanels> <xul:tabpanel> <xul:checkbox /> </xul:tabpanel> <xul:tabpanel> <xul:textbox /> </xul:tabpanel> <xul:tabpanel> <xul:datepicker /> </xul:tabpanel> </xul:tabpanels> </xul:tabbox>
    • Using SVG1.2 Tiny <svg:svg viewBox=&quot;0,0 400,400&quot; height=&quot;400px&quot; width=&quot;400px&quot; xmlns:svg=&quot;http://www.w3.org/2000/svg&quot; xmlns:smil=&quot;http://www.w3.org/2008/SMIL30/&quot;> <svg:circle cx=&quot;200&quot; cy=&quot;200&quot; r=&quot;10&quot; fill=&quot;red&quot; opacity=&quot;1&quot; stroke=&quot;black&quot; stroke-width=&quot;1&quot;> <smil:animate begin=&quot;click&quot; decelerate=&quot;0.5&quot; to=&quot;200&quot; attributeName=&quot;r&quot; dur=&quot;500ms&quot;/> </svg:circle> </svg:svg> Works in Internet Explorer 5.5 too Modules Implemented: 5. Document Structure 8. Paths 9. Basic Shapes 10. Text 12. Animation (SMIL)
    • Using DOM-Core for building UI dynamically var sXULNameSpace = &quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&quot;; var popup = ample.getElementById(&quot;items-popup&quot;); var item4 = ample.createElementNS (sXULNameSpace, &quot;xul:menuitem&quot;); popup.appendChild(item4); item3.setAttribute(&quot;label&quot;, &quot;Item 3&quot;); item3.setAttribute(&quot;value&quot;, &quot;3&quot;); var oRequest = new XMLHttpRequest; oRequest.open(&quot;GET&quot;, &quot;wizard.xml&quot;, false); oRequest.onreadystatechange = function() { if (oRequest.readyState == 4) { var oFragment = ample.importNode (oRequest.responseXML.documentElement, true); ample.querySelector(&quot;#target&quot;).appendChild(oFragment); } }
    • Using XInclude to merge XML documents 1. <div xmlns:xi=&quot;http://www.w3.org/2001/XInclude&quot;> 2. <xi:include href=&quot;Menubar.xml&quot; /> 3. <xi:include href=&quot;Editor.xml&quot; /> 4. <xi:include href=&quot;Statusbar.xml&quot; /> 5. </div>
    • 3.2 Styling Application UI Styling GUI is done with CSS... nicely.
    • Embedding CSS stylesheets in a web page a) Inline, using a style tag with type=&quot;text/ample+css&quot; <style type=&quot;text/ample+css&quot;> /* Ample SDK inline stylesheet */ </style> b) Referencing a resource, using a link tag with href attribute <link type=&quot;text/ample+css&quot; rel=&quot;stylesheet&quot; href=&quot;stylesheet.css&quot;/>
    • Using CSS for styling UI 1) Namespaced selectors for styling component @namespace xul &quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&quot;; xul|menulist { width: 200px; } 2) Pseudo-class selectors for styling component state @namespace xul &quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&quot;; xul|datepicker:focus { background-color: pink; } 3) Pseudo-element selectors for styling component view @namespace xul &quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&quot;; xul|colorpicker::input { border: solid 1px blue; } xul|colorpicker::button { background-image: url(&quot;colorpicker.png&quot;); }
    • 3.3 Writing Application Logic Implementing application [View] logic is about receiving UI events and updating UI state appropriately. In Ample SDK the Application UI is represented by a DOM tree (mainly built with UI elements), that you can access or modify in a standard and consistent way. UI events are fired on elements in the tree with which the user interacts. Once dispatched they propagate through the tree and can be picked up for handling.
    • Embedding JavaScript GUI Logic into a web page a) Inline, using a script tag with type=&quot;text/javascript&quot; <script type=&quot;text/javascript&quot;> /* JavaScript UI Logic */ </script> b) Referencing a resource, using script tag with src attribute <script type=&quot;text/javascript&quot; src=&quot;application.js&quot;></script>
    • The ample scripting object The ample scripting object in the Ample SDK is similar to the document scripting object available in the browser
    • Navigating / Altering UI Document Tree a) Navigating the tree - firstChild, lastChild, previousSibling, nextSibling, childNodes, parentNode etc. - getElementById, getElementsByTagName and getElementsByTagNameNS - querySelector and querySelectorAll b) Altering the tree - setAttribute / setAttributeNS, getAttribute / getAttributeNS and removeAttribute / removeAttributeNS - createElement / createElementNS, createTextNode, appendChild, insertBefore, removeChild and replaceChild - importNode
    • Registering Event Handlers and Handling UI Events a) Dynamically, using the DOM Events API // Alert event current target tagName oElement.addEventListener(&quot;click&quot;, function(oEvent) { alert(oEvent.currentTarget.tagName) }, true ); // Cancel user selection (Also in IE) oElement.addEventListener(&quot;mousedown&quot;, function(oEvent) { oEvent.preventDefault(); }, false) b) Inline, using a on{event} attribute <xul:scale onchange=&quot;alert(this.getAttribute('value'))&quot; min=&quot;0&quot; max=&quot;100&quot; value=&quot;50&quot;/>
    • Using Drag And Drop Manager Events: dragstart, drag, dragend, dragenter, dragleave, drop Properties: $draggable, $droppable Pseudo-classes: drag, drop <div xmlns:aml=&quot;http://www.amplesdk.com/ns/aml&quot; ondrop=&quot;if (event.relatedTarget.parentNode != event.target) event.target.appendChild(event.relatedTarget)&quot;> <div aml:droppable=&quot;true&quot; class=&quot;droppable&quot;> <div aml:draggable=&quot;true&quot; class=&quot;draggable&quot;> Container 1: drag me and drop to another container </div> <div aml:draggable=&quot;true&quot; class=&quot;draggable&quot;> Container 2: drag me and drop to another container </div> </div> <div aml:droppable=&quot;true&quot; class=&quot;droppable&quot;> </div> </div> .draggable { width: 100px; height: 100px; background-color: pink; border: solid 1px red; cursor: move; } .droppable { width: 300px; height: 320px; padding: 10px; float: left; background-color: lightgreen; border: solid 1px green; } div:drag { border-color: black; position: relative; } div:drop { border-style: dashed; }
    • Using Resize Manager Events: resizestart, resize, resizeend CSS Pseudo-classes: resize Properties: $resizable <div aml:resizable=&quot;true&quot; class=&quot;resizable&quot; xmlns:aml=&quot;http://www.amplesdk.com/ns/aml&quot;> Resize me </div> @namespace &quot;http://www.w3.org/1999/xhtml&quot;; div.resizable { width: 250px; height: 250px; background-color: pink; border: solid 1px red; max-width: 500px; } div.resizable:resize { background-color: lightyellow; }
    • Using History Manager Methods: $bookmark(state) Events: hashchange ample.addEventListener(&quot;hashchange&quot;, function(oEvent) { // Implement logic alert(navigator.location.hash) }, false);
    • Using Capture Manager Methods: $setCapture/$releaseCapture, $setModal/$releaseModal Events: capture, modal <div> <button onclick=&quot;alert('Hello')&quot;>alert</button> <div id=&quot;dialog&quot; style=&quot;border: solid 1px red&quot;> <button onclick=&quot;this.parentNode.$releaseCapture(true)&quot;>release capture</button> </div> <button onclick=&quot;ample.getElementById('dialog').$setCapture(true)&quot;>set capture</button> </div>
    • Using XML APIs Transforming XML document with XSL-T example // Load stylesheet document oXMLHttpRequest.open(&quot;GET&quot;, &quot;stylesheet.xsl&quot;, false); oXMLHttpRequest.send(null); var oStylesheet = oXMLHttpRequest.responseXML; // Load input document oXMLHttpRequest.open(&quot;GET&quot;, &quot;input.xml&quot;, false); oXMLHttpRequest.send(null); var oInput = oXMLHttpRequest.responseXML; // Create XSLTProcessor and import stylesheet into it var oXSLTProcessor = new XSLTProcessor; oXSLTProcessor.importStylesheet(oStylesheet); // Transform input document to output document and alert result var oOutput = oXSLTProcessor.transformToDocument(oInput); alert(new XMLSerializer().serializeToString(oOutput));
    • JSON vs. XML JSON/XML for data XML/JSON for UI Whatever you like!
    • 4. Extending on Ample SDK 4.1 Prototyping Objects / Creating new APIs 4.2 Creating Custom Markup Languages 4.3 Implementing Global UI Managers
    • 4.1 Prototyping objects/ Defining new APIs Objects inheritance in Ample SDK (simplified): AMLNode:: AMLDocument AMLCharacterData:: AMLText AMLElement:: MyComponent AMLElement.prototype.listenOnce = function(sEvent, fHandler) { this.addEventListener(sEvent, function(oEvent) { // Remove event listener this.removeEventListener(sEvent, arguments.callee, false); // Handle Event fHandler.call(this, oEvent); }, false) }
    • 4.2 Creating Custom Markup Language // Create new Namespace object var MyNamespace = new AMLNamespace; // Register new Namespace with Ample SDK ample.domConfig.setNamespace(&quot;http://www.mysite.com/ns/ui&quot;);
    • Creating Custom Component // Define Component Constructor var MyButton = function() { // This is the constructor }; // Set Component Prototype MyButton.prototype = new AMLElement; // Register new Component with Namespace MyNamespace.setElement(&quot;button&quot;, MyButton);
    • Defining Component Presentation MyCombobox.prototype.$getTagOpen = function() { return '<div class=&quot;my-combobox&quot;> <input type=&quot;text&quot; value=&quot;' + this.getAttribute(&quot;text&quot;)+ '&quot; class=&quot;my-combobox—input&quot; /> <div class=&quot;my-combobox—button&quot;/> <div class=&quot;my-combobox—gateway&quot;>'; } MyCombobox.prototype.$getTagClose = function() { return ' </div> </div>'; }
    • Specifing attribute default values MyCombobox.attributes = { disabled: &quot;false&quot; }
    • Handling UI Events at the Component Level Event handlers defined on component classes are executed at the bubbling or target phase only if event default action was not prevented MyCombobox.handlers = { focus: function(oEvent) { // TODO: dispatch DOMActivate event } }
    • Handling Attribute changes MyCombobox.handlers = { &quot;DOMAttrModified&quot;: function(oEvent) { } }
    • Handling Component Insertion / Removal MyCombobox.handlers = { // Component inserted into document &quot;DOMNodeInsertedIntoDocument&quot;: function(oEvent) { }, // Component removed from document &quot;DOMNodeRemovedFromDocument&quot;: function(oEvent) { } }
    • Defining Properties and Methods // Property MyCombobox.prototype.tabIndex = 0; // Method MyCombobox.prototype.selectItem = function(oItem) { }
    • A domain-specific UI markup technology?
    • Maybe &quot;CocoaML&quot;?
    • 4.3 Writing Global UI Managers A UI Manager is a plugin that reacts to primitive UI events and synthetizes other more enhanced ones Mouse Gesture UI Manager?
    • 5. Showcase
    • Implementation Aspects: Application Logic: PAC approach UI Technology: XHTML+XUL+Custom components Server-side — 2 services: - Static for UI - Dynamic for Data (JSON to SOAP)
    • Wrapping up: Why Ample SDK is relevant? - Natural programming model - Uses APIs that will stay - Better UI building bricks — XUL et alii - Enables quite a bit of SVG in Internet Explorer - Allows creating DS markup technologies
    • 6. Resources IRC Channels #amplesdk on irc.freenode.net #amplesdk-dev on irc.freenode.net (Framework Developers) Mailing Lists / Discussion Groups http://groups.google.com/group/amplesdk http://groups.google.com/group/amplesdk-dev (Framework Developers) Bugtracker http://www.amplesdk.com/bugtracker/ Documentation (online/offline) http://www.amplesdk.com/reference/ Developer Tools Aptana IDE plugin Firebug plugin (in development)
    • Questions?
    • Thanks!