• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010
 

Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010

on

  • 4,246 views

Slides from my talk at the SWDC 2010

Slides from my talk at the SWDC 2010

Statistics

Views

Total Views
4,246
Views on SlideShare
4,211
Embed Views
35

Actions

Likes
2
Downloads
38
Comments
0

2 Embeds 35

http://www.slideshare.net 34
http://www.slashdocs.com 1

Accessibility

Categories

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.

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

    Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010 Building Complex GUI Apps The Right Way. With Ample SDK - SWDC2010 Presentation Transcript

    • Building Complex GUI Apps The Right Way with Ample SDK The Scandinavian Web Developers Conference 2-3 June 2010, Stockholm, Sweden Sergey Ilinsky
    • 1. Web Application Architecture Transition Server-Side Client-Side Back-End (Business Logic) Front-End (UI Logic +Rendering +Auth.) Browser Server-Side Client-Side Back-End (Business Logic) Front-End (Auth.) Front-End (UI Logic +Rendering) Previously Now UI&Data Data (Form data) UI Data (JSON/XML) Data (JSON/XML) Browser
    • 2. HTML5 and client-side GUI Technologies HTML5 [GUI concerns] 1) Limited amount of UI elements 2) Poor-to-none UI elements styling facilities 3) Hardly or not implemented in most of web browsers 4) No extensibility (until XBL2 lands) 5) Too low-level abstraction for applications needs JavaScript GUI Frameworks (ExtJS, Dojo, Qooxdoo, jQuery UI..) 1) Proprietary (hence->inconsistent) APIs 2) GUI is programmed (in JS+HTML), not declared
    • 3. Demos first! - SVG in Internet Explorer - XUL Cross-Browser - Charts - HTML5
    • 4. Introduction to the Ample SDK Ample SDK is a JavaScript GUI Framework that smartly re-uses concepts and technologies of web-browsers but also brings them to a new level, closer to client-side apps needs. Original goals of the experiment: - equalize browsers APIs without introducing new ones - extend browser UI technologies stacks - provide a platform for reusable UI components
    • 4. Introduction to the Ample SDK : Hello World! <!DOCTYPE html> <html xmlns:xul=&quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&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/xul/xul.js&quot;></script> <link type=&quot;text/ample+css&quot; src=&quot;ample/languages/xul/themes/default/xul.css&quot;/> <!-- (1) Styling --> <style type=&quot;text/ample+css&quot;> @namespace xul &quot;http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul&quot;; xul|button { color: red; } </style> <!-- (2) Logic --> <script type=&quot;text/javascript&quot;> function alertHelloWorld(oEvent) { alert('Element &quot;' + oEvent.target.localName + '&quot; was clicked'); } </script> </head> <body> <!-- (3) Layout --> <script type=&quot;application/ample+xml&quot;> <xul:button onclick=&quot;alertHelloWorld(event)&quot;>Hello, World!</b> </script> </body> </html>
    • 4. Introduction to the Ample SDK : The Big Picture Virtualizing browser technologies: - pass through if available - implement if not - fix if broken
    • 5. Building GUI apps with Ample SDK Programming model is that of web-browser: 1) XML for UI (declarative UIs) 2) CSS for Style 3) JavaScript (DOM API) for Logic
    • 5.1 XML for UI layout: Embedding Ample XML in HTML a) Inline, using a script tag with type=&quot;application/ample+xml&quot; <script type=&quot;application/ ample+ xml&quot;> <!-- Ample SDK inline XML markup --> </script> b) Referencing a resource, using a script tag with src attribute <script type=&quot;application/ ample+ xml&quot; src=&quot;ui.xml&quot;></script> c) Inline, using ample.open() and ample.close() <script type=&quot;text/javascript&quot;>ample.open()</script> <!-- Ample SDK inline XML markup --> <script type=&quot;text/javascript&quot;>ample.close()</script>
    • 5.1 XML for UI layout: Code Sample < xul:toolbox > < xul:toolbar > < xul:toolbargrippy /> < xul:toolbarbutton type = &quot;menu&quot; image = &quot;img/statuses/jab/off.gif&quot; tooltiptext = &quot;Click to change status&quot; > < xul:menupopup > < xul:menuitem type = &quot;checkbox&quot; label = &quot;Invisible&quot; /> < xul:menuseparator /> < xul:menuitem label = &quot;Online&quot; image = &quot;img/statuses/jab/on.gif&quot; /> < xul:menuitem label = &quot;Away&quot; image = &quot;img/statuses/jab/away.gif&quot; /> < xul:menuitem label = &quot;Don't disturb&quot; image = &quot;img/statuses/jab/dnd.gif&quot; /> < xul:menuitem label = &quot;Not available&quot; image = &quot;img/statuses/jab/xa.gif&quot; /> < xul:menuitem label = &quot;Offline&quot; image = &quot;img/statuses/jab/off.gif&quot; /> </ xul:menupopup > </ xul:toolbarbutton > </ xul:toolbar > </ xul:toolbox >
    • 5.1 XML for UI layout: Technologies - HTML 5 (in development) - SVG 1.1 (Scalable Vector Graphics, W3C) - XHTML (eXtensible Hyper Text Markup Language, W3C) - XUL (XML User interface Language, Mozilla) - Charts (in development) - your own?
    • 5.2 CSS for Style: Embedding Ample CSS in HTML a) Inline, using a style tag with type=&quot;text/ample+css&quot; <style type=&quot; text/ ample+ css &quot;> @namespace xul url(http://...only.xul); xul|menu:hover { font-variant: italic; } xul|datepicker::value { background-color: red; } </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;/>
    • 5.2 CSS for Style: Code Sample xul|menuitem:disabled { color: GrayText; } xul|menuitem[type]::image { background-repeat: no-repeat; width: 16px; height: 16px; vertical-align: middle; } xul|menuitem[type=checkbox]::image { background-position: 0px 16px; /* hidden */ background-image: url(media/menuitem_checkbox.gif); } xul|menuitem[type=radio]::image { background-position: 0px 16px; /* hidden */ background-image: url(media/menuitem_radio.gif); } xul|menuitem::image:checked { background-position: 0px 0px; }
    • 5.2 CSS for Style: Technologies - CSS3 Namespaces @namespace xul url(http://...only.xul); xul| menuitem {font: normal 1em Verdana} - CSS3 UI xul|datepicker ::input {background-color:pink} - Pseudo-classes (:drag, :resize..) .mytarget :drop {border: dashed 1px red}
    • 5.3 JS/DOM for UI Logic: Embedding JS in HTML <script type=&quot; text/javascript &quot;> ample .addEventListener(&quot;load&quot;, function(oEvent) { var oNode = this .querySelector(&quot;svg|circle&quot;); oNode.setAttribute(&quot;r&quot;, 10); }, false); </script> &quot; ample &quot; is an object in Ample SDK similar to &quot;document&quot; object in web browser, it provides access to the document built of all XML fragments found on the page.
    • 5.3 JS/DOM for UI Logic: Technologies Document Object Model - Core (Level 2) - Events (Level 3) - Selectors API Componentization Model API UI Managers - Focus - Drag&Drop - Resize - Capture - SPI History - Text selection
    • 5.3 JS/DOM for UI Logic: More Technologies JavaScript objects - DOMParser, XMLSerializer - XSLTProcessor - XMLHttpRequest - JSON - JavaScript up to 1.8 objects prototypes XML APIs - SMIL3.0 (selected modules) , - XInclude 1.0 - XML Schema 1.1 (Part 2 - Datatypes) CSS pre-processors - CSS2.1 (fixes) - CSS3-Namespaces - CSS3-UI
    • 6. Extending Ample SDK 1) Prototyping DOM Objects 2) Creating new UI elements / languages 3) Creating new UI managers
    • 6.1 Prototyping DOM Objects Prototype method on base AMLNode object: AMLNode.prototype.on = function(sType, fHandler) { this.addEventListener(sType, fHandler, false); } function _(sQuery) { return ample.querySelector(sQuery); } Use it for any element: _(“#myelement”).on(“click”, function(event) { alert(event.target.tagName); });
    • 6.2 Creating new UI elements function cMyCombobox() { this.options = new AMLNodeList; } cMyCombobox.prototype = new AMLElement; cMyCombobox.prototype.options = null; // Class-level event handlers cMyCombobox.handlers = { &quot;DOMNodeInsertedIntoDocument&quot;: function(oEvent) { }, &quot;click&quot;: function(oEvent) { } } // Presentation cMyCombobox.prototype.$getTagOpen = function() { return '<div class=&quot;my-combobox&quot;> <div> <input class=&quot;my-combobox--input&quot;/> <button class=&quot;my-combobox--button&quot;/> </div> <div class=&quot;my-combobox--gateway&quot;>'; } cMyCombobox.prototype.$getTagClose = function() { return '</div> </div>'; }
    • 6.2 Componentization model explained Web-browser DOM (shadow tree) (HTML4, SVG/VML) Ample SDK DOM (XHTML, XUL, SVG) select option option div div div div div input button div div
    • 6.3 Creating new UI managers // Adding base element object prototype member AMLElement.prototype.$selectable = null; // Registering Event Handlers with document ample.addEventListener(&quot;mousedown&quot;, function(oEvent) { for (var oElement = oEvent.target, bAllow = false; oElement.nodeType != AMLNode.DOCUMENT_NODE; oElement = oElement.parentNode) { if (oElement.$selectable === true) bAllow = true; else if (oElement.$selectable === false) return !bAllow && oEvent.preventDefault(); } }, false);
    • Wrapping up: Why Ample SDK is relevant? 1) Uses standard APIs that will stay 2) Natural Programming Model (W3C) 3) Provides better UI building blocks, such as XUL 4) Fast rendering 5) Enables quite a bit of SVG1.1 in IE5.5, IE6-8 6) Enables creation of Domain Specific markup
    • Ample SDK Web-Site: http://www.amplesdk.com Source-Code: http://github.com/clientside/amplesdk Reference: http://www.amplesdk.com/reference Discussions: http://groups.google.com/group/amplesdk Sergey Ilinsky http://www.ilinsky.com http://twitter.com/ilinsky Thank you!