SlideShare a Scribd company logo
Kranium	
  
Webifying	
  Titanium	
  Development	
  

              Jacob	
  Waller	
  
Jacob Waller: Webifying Titanium Development
+!   +!   +!   →!
+
http://flic.kr/p/9wLZkJ!




               Kranium
•    Webifying Titanium Development!
"    Cross platform apps using javascript!

"    Shared business logic!

"    Native UI!

"    Device API:s!
Why cross-platform?


"    One codebase!

     "    Faster development → cheaper development!

     "    Less code → less bugs!

     "    Focus on one language and one tool!
Why not cross-platform?


"    Potential bugs in cross-platform frameworks!

"    Somewhat harder stepping outside the box!

"    Might still need platform branching!

"    Less speed and more memory usage!
Cross Platform is Hard


 "    iOS!                "    Android!

      "    Objective-C!   "    Java!

      "    XCode!         "    Eclipse!
Titanium takes the hit




              http://flic.kr/p/91Zydu!
Cross Platform Medicine


                          http://flic.kr/p/8dZbk4!




"    Must use lowest common denominator!

"    Go with a low-level API!

"    Must focus on getting the “atoms” behave
     the same across platforms!
Low-level




                  http://flic.kr/p/75b2DJ!




Means powerful!
Low-level




                    http://flic.kr/p/5JDvZM!




Also means annoying to build large stuff!
Low-level




                   http://flic.kr/p/nyxCW!




Is it therefore wrong?!
NO
High-level


"    Low level building blocks let us build high-
     level abstractions!

"    Upon which we can build awesome stuff!
High-level




         http://flic.kr/p/8ovJYH!
Titanium

"    Titanium Mobile has a low-level
     core API:s for each platform it
     supports!

"    Lets cover it in platform-
     independent high-level
     awesome-sauce!
But how?




    http://flic.kr/p/9wfuUh!
Parallel



"    Web development has low-level API:s!

     "    document.createElement!

     "    element.style.backgroundColor!
Web development

if (el.addEventListener) {	
    el.addEventListener("mouseover", myFunction, false);	
    el.addEventListener("mouseout", myFunction, false);	
} else if (el.attachEvent) {	
    el.attachEvent("onmouseover", myFunction);	
    el.attachEvent("onmouseout", myFunction);	
} else {	
    el.onmouseover = myFunction;	
    el.onmouseout = myFunction;	
}	




 Used to be painful, slow and ugly!
Web development
 $(el).bind("mouseover mouseout", myFunction);	




Is now pleasant, quick and sexy!
Ecosystem
Titanium development
var tabGroup = Ti.UI.createTabGroup(),	          shadowColor: '#fff',	
                                                 shadowOffset: { 	
    win1 = Ti.UI.createWindow({	                     y: -1, 	
         backgroundColor: '#ccc',	                   x: 0	
         barColor: '#00a',	                      },	
         title: 'My window'	                     font: {	
    }),	                                             fontSize: 20,	
                                                     fontWeight: 'bold'	
    tab1 = Ti.UI.createTab({	                    }	
         icon: 'path/to/my/icon',	        });	
         title: 'My tab',	
         window: win1	                win1.add(label1);	
    }),	                              label1.addEventListener('click', function(e){	
                                           alert('You clicked me!');	
    label1 = Ti.UI.createLabel({	     });	
        text: 'Hello world!',	
        textAlign: 'center',	         tabGroup.addTab(tab1);	
        color: '#333',	               tabGroup.open();	




   Used to be somewhat painful, slow and ugly!
Welcome Kranium




        http://flic.kr/p/9wLZkJ!
Titanium development

      K({	
          type: 'tabgroup',	
          tabs: [{	
              cls: 'myTab',	
              window: {	
                  cls: 'myWindow',	
                  children: [{	
                      text: 'Hello world!',	
                      cls: 'mylabel',	
                      click: function(){	
                          alert('You clicked me!');	
                      }	
                  }]	
              }	
          }]	
      }).open();	




 Is now more pleasant, quick and sexy!
Titanium development

          .myTab { 	
              icon: path/to/my/icon; 	
          }	
          window {	
              background-color: #ccc;	
              bar-color: #00a;	
          }	
          .myLabel {	
              text-align: center;	
              color: #333;	
              shadow-color: #fff;	
              shadow-offset-y: -1;	
              font-size: 20;	
              font-weight: bold;	
          }	




 Is now more pleasant, quick and sexy!
Titanium development
                                     Stylus


K(	                              .myTab	
  type: "tabgroup"	                  icon path/to/my/icon	
  tabs: [ 	
     className: "myTab"	         window	
     window: 	                       background-color #ccc	
       className: "myWindow"	        bar-color #00a	
       children: [ 	
         text: "Hello world!"	   .myLabel	
         className: "mylabel"	       text-align center	
        ]	                           color #333	
    ]	                               shadow-color #fff	
).open()	                            shadow-offset-y -1	
                                     font-size 20	
                                     font-weight bold	




              With lots of possibilities!
Kranium
"    Lovechild of the following stunning web frameworks:!
     "    jQuery / Zepto!
     "    Backbone!
     "    Jade!
     "    Livetanium / Livereload!
     "    Sizzle / mini.js!
     "    Jasmine!                                    http://bit.ly/3vVcI!




     "    JSS / Stylus / Sass / LESS!
     "    JSConsole / Weinre!
Comparison
jQuery / Zepto

"    Easy access selector engine!


     $('.content > .label, .hello').text('hello!');	
     $(el).find('.content');	
     $('.content', el);
jQuery / Zepto
"    Chainable collections with helper functions!



     $(el)	
         .text('hey')	
         .css({ color: '#f00' })	
         .parent('.row')	
             .bind('click', onClick)	
             .append(stuff);
jQuery / Zepto
"    Simplified API:s!


     $.ajax({	
          type: 'GET',	
          url: 'http://some/url',	
          success: function(data, status, xhr){	
              alert(data);	
          }	
     });
Titanium


"    Let’s see how these look in the low-level
     Titanium API!
Titanium

"    Easy access selector engine?!

     N/A
Titanium
"    Chainable collections with helper functions?!




     el.text = 'hey';	
     el.color = '#f00';	
     var parent = el.getParent().getParent().children().filter
     (function(el){	
          return /(^|s+)row(s+|$)/.test(el.className);	
     });	
     parent.addEventListener('click', onClick);	
     stuff.forEach(function(toAdd){	
          el.add(toAdd);	
     });
Titanium
"    Simplified API:s?!



     var xhr = Ti.Network.createHTTPClient();	
     xhr.open('GET', 'http://some/url');	
     xhr.onload = function(data, status, xhr){	
          alert(data);	
     });	
     xhr.send();
Kranium


"    Lets look at the same functionality using
     Kranium!
Kranium

"    Easy access selector engine!


     $('.content > .label, .hello').text('hello!');	
     $(el).find('.content');	
     $('.content', el);
Kranium
"    Chainable collections with helper functions!



     $(el)	
         .text('hey')	
         .css({ color: '#f00' })	
         .parent('.row')	
             .bind('click', onClick)	
             .append(stuff);
Kranium
"    Simplified API:s!


     $.ajax({	
          type: 'GET',	
          url: 'http://some/url',	
          success: function(data, status, xhr){	
              alert(data);	
          }	
     });
Kranium



                                 http://bit.ly/bW1zP5!




"    Tries to invent as few wheels as possible!

"    Instead piggyback on the ideas and momentum of
     existing great web frameworks!
What to piggyback?
                               "    jQuery / Zepto!
                               "    Backbone!
                               "    Jade!
                               "    Livetanium / Livereload!
                               "    Sizzle / mini.js!
                               "    Jasmine!
                               "    JSS / Stylus / Sass / LESS!

     http://flic.kr/p/7dpmyF!
                               "    JSConsole / Weinre!
What IS Kranium?


"    A utility library to include in your app!
"    A command line program!
Utility library
"    Exposes a jQuery-like object called K (or $)!
"    Exposes Backbone integration!
"    Exposes Jade template engine!
"    Implements simple selector engine!
"    Implements enhanced styling!
"    Implements extendable modules!
Command line program

 "    Built on NodeJS and NPM!
 "    Initiates Kranium resources in project!
 "    Pipes live updates!
 "    Two-way console!
 "    Jasmine reporter!
Template engine
A great template engine is a huge
help in keeping your code:!


"    DRY!

"    separated!

"    consise!
Jade
"    Lightweight!

"    Supports custom compilers!

"    Compiles templates to functions!

"    Beautiful syntax!

"    Consise!

"    In active development!
Jade example
// test.jade	
view.board	
  label.boardTitle Board	
  view.boardMessages	
    - each msg, user in users	
      label.boardMessage= user + ' says ' + msg
K.jade('test.jade', { 	
     users: { 	
         jacob: 'yeah',	
         david: 'what',	
         conny: 'hi', 	
         aida: 'hello',	
         calle: 'yup'	
     }	
});
.board {	
    top: 10;	
    left: 10;	
}	
.boardMessages {	
    top: 30;	
    layout: vertical;	
}	
.boardMessage {	
    height: 20;	
    top: 10;	
}	
.boardTitle {	
    top: 0;	
    height: auto;	
    font-weight: bold;	
}
JSS

"    Great feature in theory - gives Separation of
     Concerns!

"    Hasn’t always been working well !

"    Not powerful and extendable enough!
KSS
"    A styling layer implemented in the javascript
     context!

"    Everything created using K function is styled
     appropriately!

"    Style based on Types, Classes and IDs!

"    Platform branching using psuedo selectors!

"    Variable evaluation!
KSS
label {	
    color: #000;	
    font-size: 16dp;	
}	
label:android {	
    font-size: 17dp;	
    text-align: left;	
}	
tableview:ios {	
    style: Ti.UI.iPhone.TableViewStyle.GROUPED;	
}
KUI


                              http://flic.kr/p/6a3wzw!




"    Extendable UI Modules!

"    Simple Inheritance!

"    Automatic KSS loading!
Example
kui/loginstatus.js!


   exports.Class = Label.extend({	
       className: "loginstatus",	
       init: function(opts) {	
           this.events = {	
               app: {	
                   authchange: this.updateStatus.bind(this)	
               }	
           };	
                this._super.call(this, opts);	
                this.updateStatus();	
          },	
          updateStatus: function(e) {	
              this.el.text = "Logged " + (e && e.loggedIn ? "in" : "out");	
          }	
   });
Example
kui/loginstatus.kss!




   .loginstatus {	
       color: #f00;	
   }
Example
app.js!



   K({	
       type: 'window',	
       children: [{	
           type: 'loggedinstatus'	
       }]	
   }).open();	
   var i = 0;	
   setInterval(function(){	
       Ti.App.fireEvent('authchange', {	
            loggedIn: !!(++i % 2)	
       });	
   }, 1000);
Example
app.js!


   K({	
       type: 'window',	
       children: [{	
           top: 10,	
           type: 'loggedinstatus'	
       },	
       {	
           bottom: 10,	
           type: 'loggedinstatus'	
       }]	
   }).open();	
   var i = 0;	
   setInterval(function(){	
       Ti.App.fireEvent('authchange', {	
            loggedIn: !!(++i % 2)	
       });	
   }, 1000);
Backbone supplies structure to JavaScript-heavy
applications by providing models with key-value
binding and custom events, collections with a rich
API of enumerable functions and views with
declarative event handling...
Jacob Waller: Webifying Titanium Development
Code walkthrough
// Define model	
RowModel = Backbone.Model.extend({	
     type: 'tableviewrow'	
});	
// Define collection	
RowCollection = Backbone.Collection.extend({	
     model: RowModel,    	
     comparator: function(model) {	
         return model.get("title");	
     }	
});	
// Create todos collection	
todos = new RowCollection();	
todos.add([	
     { title: "An example todo" },	
     { title: "Another example todo" },	
]);	
// Create todolist	
var todolist = K.create({	
     type: 'todolist',	
     collection: todos	
});
// kui/todolist.js	
exports.Class = BackboneView.extend({	
    type: 'tableview',	
    editable: true, 	
       events: {	
           click: function(e){	
               var model = todos.getByCid(e.rowData._modelCid);	
               model.set({ hasCheck: !model.get('hasCheck') });	
           },	
           "delete": function(e){	
               var model = todos.getByCid(e.rowData._modelCid);	
               todos.remove(model);	
           }	
       }	
});
exports.Class = Window.extend({	
    navBarHidden: true,	
    init: function(o){	

             this.titleLabel = K.createLabel({	
                  className: 'titleLabel'	
             });	
             todos.bind('all', this.updateTitleLabel.bind(this));	
             this.updateTitleLabel();	

             this.children = [{	
                     type: 'toolbar',	
                     className: 'todoToolbar',	
                     items: [{	
                         type: 'textfield',	
                         className: 'todoInputTextField',	
                         events: {	
                             "return": function(e){	
                                 todos.add({ title: e.value });	
                             }	
                         }	
                     },	
                     'spacer',	
                     this.titleLabel]	
                 }, todolist];	
             this._super(o);	
       },	

       updateTitleLabel: function(){	
           var completed = todos.filter(function(m){ return m.get('hasCheck') }).length;	
           this.titleLabel.text = completed + ' / ' + todos.length + ' todos';	
       }	
});
Jacob Waller: Webifying Titanium Development
Polyfill missing UI
"    Android lacks many simple UI modules!

     "    Navbar!

     "    TabbedBar!

     "    ButtonBar!

     "    Toolbar!

     "    Extendable TabBar"


"    Kranium implements these!
Polyfill missing UI
Polyfill missing UI
Extend Base UI

    K.createTableview({	
        pullToRefresh: true,	
        refresh: function(){	
            K.ajax({	
                 url: 'http://example.com/service.json',	
                 success: this.render	
            });	
        },	
           render: function(data){	
               this.setData(data.rows.map(this.createRow));	
           },	
           createRow: function(o){	
               return K.createTableViewRow({	
                    title: o.name	
               });	
           }	
    });
Livetanium


"    Kranium integrates Livetanium!

"    Gives you live updates of KSS style changes as
     well as module updates!
Jacob Waller: Webifying Titanium Development
Jasmine
describe('Demo', function() {	
    describe('Titanium Object', function(){	
        it('Ti == Titanium', function(){ expect(Titanium).toEqual(Ti); });	
        it('Ti.App', function(){ expect(Titanium).toBeDefined(); });	
    }); 	
       describe('TabGroup', function(){	
            it('Has tabgroup', function(){ 	
                 expect(K('tabgroup').length).toBeGreaterThan(0); 	
            });	
            it('TabGroup.activeTab.title === "test"', function(){ 	
                 expect(K('tabgroup').get(0).activeTab.title).toEqual("test"); 	
            });	
       });	
});
Jacob Waller: Webifying Titanium Development
Console
Jacob Waller: Webifying Titanium Development
Summary
"    Consists of a command line program and an
     includable library!

"    Ports the best web development libraries and
     technologies to Titanium!

"    Polyfills parts missing between platforms!

"    Helps you with your KISS:ing and keeps you
     DRY!
Available now
"    Currently in open beta!

     "    Source under MIT License!

     "    Hosted on GitHub!

     "    Pull requests and co-maintainers welcome"


"    http://github.com/krawaller/kranium!
Available now


"    Beware!

     "    There will be bugs!

     "    API far from frozen!
Available now

"    Works best with iOS, but Android getting
     there!

"    CLI works best on Mac OSX!

     "    Will be tested and fixed for Linux and
          Windows !
http://kraniumjs.com
Installation


"    1. Install NodeJS and NPM!

"    2. Run `npm install kranium`!

"    3. There is no step 3!
Questions?




  http://flic.kr/p/7vB7fR!
Thank you

                   +

       @litenjacob!
   jacob@krawaller.se!
jacob.waller@logica.com!
Go contribute please!




           http://flic.kr/p/9C7DZZ!

More Related Content

What's hot (20)

PDF
jQuery Features to Avoid
dmethvin
 
PDF
jQuery (DrupalCamp Toronto)
jeresig
 
PDF
jQuery (MeshU)
jeresig
 
KEY
jQuery('#knowledge').appendTo('#you');
mikehostetler
 
PDF
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
PPTX
JavaScript Advanced - Useful methods to power up your code
Laurence Svekis ✔
 
PDF
jQuery: Nuts, Bolts and Bling
Doug Neiner
 
KEY
The jQuery Library
LearnNowOnline
 
PDF
Bootstrap과 UI-Bootstrap
WebFrameworks
 
PPT
WordPress and Ajax
Ronald Huereca
 
PDF
DrupalCon jQuery
Nathan Smith
 
PDF
Write Less Do More
Remy Sharp
 
PDF
HTML 5 - Overview
Marcelio Leal
 
PDF
APIdays Zurich 2019 - Specification Driven Development for REST APIS Alexande...
apidays
 
PPTX
Maintainable JavaScript 2012
Nicholas Zakas
 
KEY
JavaScript For People Who Don't Code
Christopher Schmitt
 
PDF
HTML5: friend or foe (to Flash)?
Remy Sharp
 
PDF
HTML5: where flash isn't needed anymore
Remy Sharp
 
KEY
Bcblackpool jquery tips
Jack Franklin
 
PDF
Building iPad apps with Flex - 360Flex
danielwanja
 
jQuery Features to Avoid
dmethvin
 
jQuery (DrupalCamp Toronto)
jeresig
 
jQuery (MeshU)
jeresig
 
jQuery('#knowledge').appendTo('#you');
mikehostetler
 
Angular를 활용한 웹 프론트단 개발과 2.0에서 달라진점
Jeado Ko
 
JavaScript Advanced - Useful methods to power up your code
Laurence Svekis ✔
 
jQuery: Nuts, Bolts and Bling
Doug Neiner
 
The jQuery Library
LearnNowOnline
 
Bootstrap과 UI-Bootstrap
WebFrameworks
 
WordPress and Ajax
Ronald Huereca
 
DrupalCon jQuery
Nathan Smith
 
Write Less Do More
Remy Sharp
 
HTML 5 - Overview
Marcelio Leal
 
APIdays Zurich 2019 - Specification Driven Development for REST APIS Alexande...
apidays
 
Maintainable JavaScript 2012
Nicholas Zakas
 
JavaScript For People Who Don't Code
Christopher Schmitt
 
HTML5: friend or foe (to Flash)?
Remy Sharp
 
HTML5: where flash isn't needed anymore
Remy Sharp
 
Bcblackpool jquery tips
Jack Franklin
 
Building iPad apps with Flex - 360Flex
danielwanja
 

Viewers also liked (20)

PDF
5 Secrets to Successfully Publishing in Appcelerator's Marketplace
Axway Appcelerator
 
PPTX
Appcelerator Acquires Aptana
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session android internals and best practices
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session leveraging titanium as part of your mobile...
Axway Appcelerator
 
PPT
Ajax World 2008
Axway Appcelerator
 
PDF
Ted Patrick: Developing Apps for the Barnes & Noble NOOK
Axway Appcelerator
 
PDF
Fred Spencer: Designing a Great UI
Axway Appcelerator
 
ZIP
iPhone/iPad Development with Titanium
Axway Appcelerator
 
PDF
Appcelerator’s Cocoafish Acquisition and the Future of the Mobile Cloud
Axway Appcelerator
 
PDF
Advanced titanium for i os
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session how to win bigger mobile deals
Axway Appcelerator
 
PDF
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session exploring the new titanium command line in...
Axway Appcelerator
 
PDF
Desktop Applications Using HTML & JavaScript (and Python & Ruby
Axway Appcelerator
 
ZIP
Mobile for the rest of us
Axway Appcelerator
 
PDF
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Axway Appcelerator
 
PPTX
Mobile & The New Experience Economy (And What it Means for IT)
Axway Appcelerator
 
PDF
Gőgös Gúnár Gedeon
vago61
 
DOCX
Nouran El Kiki - Sept 2016
Nouran Adel
 
PDF
Arabella Booklet
Lindsay Mitchell
 
5 Secrets to Successfully Publishing in Appcelerator's Marketplace
Axway Appcelerator
 
Appcelerator Acquires Aptana
Axway Appcelerator
 
Codestrong 2012 breakout session android internals and best practices
Axway Appcelerator
 
Codestrong 2012 breakout session leveraging titanium as part of your mobile...
Axway Appcelerator
 
Ajax World 2008
Axway Appcelerator
 
Ted Patrick: Developing Apps for the Barnes & Noble NOOK
Axway Appcelerator
 
Fred Spencer: Designing a Great UI
Axway Appcelerator
 
iPhone/iPad Development with Titanium
Axway Appcelerator
 
Appcelerator’s Cocoafish Acquisition and the Future of the Mobile Cloud
Axway Appcelerator
 
Advanced titanium for i os
Axway Appcelerator
 
Codestrong 2012 breakout session how to win bigger mobile deals
Axway Appcelerator
 
Kevin Whinnery: Best Practices for Cross-Platform Mobile Development
Axway Appcelerator
 
Codestrong 2012 breakout session exploring the new titanium command line in...
Axway Appcelerator
 
Desktop Applications Using HTML & JavaScript (and Python & Ruby
Axway Appcelerator
 
Mobile for the rest of us
Axway Appcelerator
 
Rick Blalock: Your Apps are Leaking - Controlling Memory Leaks
Axway Appcelerator
 
Mobile & The New Experience Economy (And What it Means for IT)
Axway Appcelerator
 
Gőgös Gúnár Gedeon
vago61
 
Nouran El Kiki - Sept 2016
Nouran Adel
 
Arabella Booklet
Lindsay Mitchell
 
Ad

Similar to Jacob Waller: Webifying Titanium Development (20)

PDF
Declarative and standards-based web application development with the Ample SDK
Béla Varga
 
PDF
Building mobile web apps with Mobello
Jeong-Geun Kim
 
PDF
mobl presentation @ IHomer
zefhemel
 
KEY
Palm Developer Day PhoneGap
Brian LeRoux
 
PDF
An introduction to Titanium
Graham Weldon
 
PDF
Develop your first mobile App for iOS and Android
ralcocer
 
PDF
Develop your first mobile App for iOS and Android
Ricardo Alcocer
 
PDF
HTML5 and the dawn of rich mobile web applications pt 1
James Pearce
 
PPTX
Titanium Introduction
chortlehoort
 
PPTX
Titanium Introduction
chortlehoort
 
PDF
There's more than web
Matt Evans
 
PPTX
Building single page applications
SC5.io
 
KEY
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
PDF
Create a mobile web app with Sencha Touch
James Pearce
 
PDF
Building a Mobile App with Sencha Touch
James Pearce
 
KEY
Txjs
Brian LeRoux
 
PDF
Cross platform mobile web apps
James Pearce
 
PDF
Maintainable Frontend Development with BEM
Varya Stepanova
 
PPTX
Basic of Titanium
Nazmus Dip
 
PPTX
Basic of tianium
A. F. M. Nazmus Sakib
 
Declarative and standards-based web application development with the Ample SDK
Béla Varga
 
Building mobile web apps with Mobello
Jeong-Geun Kim
 
mobl presentation @ IHomer
zefhemel
 
Palm Developer Day PhoneGap
Brian LeRoux
 
An introduction to Titanium
Graham Weldon
 
Develop your first mobile App for iOS and Android
ralcocer
 
Develop your first mobile App for iOS and Android
Ricardo Alcocer
 
HTML5 and the dawn of rich mobile web applications pt 1
James Pearce
 
Titanium Introduction
chortlehoort
 
Titanium Introduction
chortlehoort
 
There's more than web
Matt Evans
 
Building single page applications
SC5.io
 
Html5 For Jjugccc2009fall
Shumpei Shiraishi
 
Create a mobile web app with Sencha Touch
James Pearce
 
Building a Mobile App with Sencha Touch
James Pearce
 
Cross platform mobile web apps
James Pearce
 
Maintainable Frontend Development with BEM
Varya Stepanova
 
Basic of Titanium
Nazmus Dip
 
Basic of tianium
A. F. M. Nazmus Sakib
 
Ad

More from Axway Appcelerator (20)

PDF
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator
 
PPTX
2014 Dublin Web Summit by Jeff Haynie
Axway Appcelerator
 
PPTX
Making the Mobile Mind Shift
Axway Appcelerator
 
PPTX
Stop Debating, Start Measuring
Axway Appcelerator
 
PPTX
Apps, APIs & Analytics: What "Mobile First" Really Means
Axway Appcelerator
 
PPTX
Appcelerator Presentation Template
Axway Appcelerator
 
PPTX
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Axway Appcelerator
 
PPTX
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Axway Appcelerator
 
PPTX
Codestrong 2012 keynote how to build a top ten app
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session at&t api platform and trends
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session what's new in titanium studio
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session the role of cloud services in your next ge...
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session new device platform support for titanium
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session mobile platform and infrastructure
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session making money on appcelerator's marketplace
Axway Appcelerator
 
PDF
Codestrong 2012 breakout session live multi-platform testing
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session i os internals and best practices
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session introduction to mobile web and best practices
Axway Appcelerator
 
PPTX
Codestrong 2012 breakout session how to develop your own modules
Axway Appcelerator
 
Axway Appcelerator - Titanium SDK 6.1.0 - Status, Releases & Roadmap
Axway Appcelerator
 
2014 Dublin Web Summit by Jeff Haynie
Axway Appcelerator
 
Making the Mobile Mind Shift
Axway Appcelerator
 
Stop Debating, Start Measuring
Axway Appcelerator
 
Apps, APIs & Analytics: What "Mobile First" Really Means
Axway Appcelerator
 
Appcelerator Presentation Template
Axway Appcelerator
 
Codestrong 2012 keynote jonathan rende, appcelerator's vp of products
Axway Appcelerator
 
Codestrong 2012 keynote jeff haynie, appcelerator's ceo
Axway Appcelerator
 
Codestrong 2012 keynote how to build a top ten app
Axway Appcelerator
 
Codestrong 2012 breakout session at&t api platform and trends
Axway Appcelerator
 
Codestrong 2012 breakout session what's new in titanium studio
Axway Appcelerator
 
Codestrong 2012 breakout session using appcelerator cloud services in your ...
Axway Appcelerator
 
Codestrong 2012 breakout session the role of cloud services in your next ge...
Axway Appcelerator
 
Codestrong 2012 breakout session new device platform support for titanium
Axway Appcelerator
 
Codestrong 2012 breakout session mobile platform and infrastructure
Axway Appcelerator
 
Codestrong 2012 breakout session making money on appcelerator's marketplace
Axway Appcelerator
 
Codestrong 2012 breakout session live multi-platform testing
Axway Appcelerator
 
Codestrong 2012 breakout session i os internals and best practices
Axway Appcelerator
 
Codestrong 2012 breakout session introduction to mobile web and best practices
Axway Appcelerator
 
Codestrong 2012 breakout session how to develop your own modules
Axway Appcelerator
 

Recently uploaded (20)

PPTX
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
PPTX
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
PDF
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
PPTX
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
PDF
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
PDF
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
PDF
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
PDF
Market Insight : ETH Dominance Returns
CIFDAQ
 
PPTX
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
PDF
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
PPTX
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
PPTX
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
PDF
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
PPTX
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
PDF
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
PDF
The Future of Artificial Intelligence (AI)
Mukul
 
PPTX
The Future of AI & Machine Learning.pptx
pritsen4700
 
PPTX
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
PDF
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
PDF
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 
OA presentation.pptx OA presentation.pptx
pateldhruv002338
 
Applied-Statistics-Mastering-Data-Driven-Decisions.pptx
parmaryashparmaryash
 
GDG Cloud Munich - Intro - Luiz Carneiro - #BuildWithAI - July - Abdel.pdf
Luiz Carneiro
 
Dev Dives: Automate, test, and deploy in one place—with Unified Developer Exp...
AndreeaTom
 
AI Unleashed - Shaping the Future -Starting Today - AIOUG Yatra 2025 - For Co...
Sandesh Rao
 
Structs to JSON: How Go Powers REST APIs
Emily Achieng
 
Research-Fundamentals-and-Topic-Development.pdf
ayesha butalia
 
Market Insight : ETH Dominance Returns
CIFDAQ
 
Agile Chennai 18-19 July 2025 Ideathon | AI Powered Microfinance Literacy Gui...
AgileNetwork
 
Responsible AI and AI Ethics - By Sylvester Ebhonu
Sylvester Ebhonu
 
AVL ( audio, visuals or led ), technology.
Rajeshwri Panchal
 
Agile Chennai 18-19 July 2025 | Emerging patterns in Agentic AI by Bharani Su...
AgileNetwork
 
The Future of Mobile Is Context-Aware—Are You Ready?
iProgrammer Solutions Private Limited
 
Agile Chennai 18-19 July 2025 | Workshop - Enhancing Agile Collaboration with...
AgileNetwork
 
Economic Impact of Data Centres to the Malaysian Economy
flintglobalapac
 
The Future of Artificial Intelligence (AI)
Mukul
 
The Future of AI & Machine Learning.pptx
pritsen4700
 
AI and Robotics for Human Well-being.pptx
JAYMIN SUTHAR
 
State-Dependent Conformal Perception Bounds for Neuro-Symbolic Verification
Ivan Ruchkin
 
OFFOFFBOX™ – A New Era for African Film | Startup Presentation
ambaicciwalkerbrian
 

Jacob Waller: Webifying Titanium Development

  • 1. Kranium   Webifying  Titanium  Development   Jacob  Waller  
  • 3. +! +! +! →!
  • 4. +
  • 5. http://flic.kr/p/9wLZkJ! Kranium •  Webifying Titanium Development!
  • 6. "  Cross platform apps using javascript! "  Shared business logic! "  Native UI! "  Device API:s!
  • 7. Why cross-platform? "  One codebase! "  Faster development → cheaper development! "  Less code → less bugs! "  Focus on one language and one tool!
  • 8. Why not cross-platform? "  Potential bugs in cross-platform frameworks! "  Somewhat harder stepping outside the box! "  Might still need platform branching! "  Less speed and more memory usage!
  • 9. Cross Platform is Hard "  iOS! "  Android! "  Objective-C! "  Java! "  XCode! "  Eclipse!
  • 10. Titanium takes the hit http://flic.kr/p/91Zydu!
  • 11. Cross Platform Medicine http://flic.kr/p/8dZbk4! "  Must use lowest common denominator! "  Go with a low-level API! "  Must focus on getting the “atoms” behave the same across platforms!
  • 12. Low-level http://flic.kr/p/75b2DJ! Means powerful!
  • 13. Low-level http://flic.kr/p/5JDvZM! Also means annoying to build large stuff!
  • 14. Low-level http://flic.kr/p/nyxCW! Is it therefore wrong?!
  • 15. NO
  • 16. High-level "  Low level building blocks let us build high- level abstractions! "  Upon which we can build awesome stuff!
  • 17. High-level http://flic.kr/p/8ovJYH!
  • 18. Titanium "  Titanium Mobile has a low-level core API:s for each platform it supports! "  Lets cover it in platform- independent high-level awesome-sauce!
  • 19. But how? http://flic.kr/p/9wfuUh!
  • 20. Parallel "  Web development has low-level API:s! "  document.createElement! "  element.style.backgroundColor!
  • 21. Web development if (el.addEventListener) { el.addEventListener("mouseover", myFunction, false); el.addEventListener("mouseout", myFunction, false); } else if (el.attachEvent) { el.attachEvent("onmouseover", myFunction); el.attachEvent("onmouseout", myFunction); } else { el.onmouseover = myFunction; el.onmouseout = myFunction; } Used to be painful, slow and ugly!
  • 22. Web development $(el).bind("mouseover mouseout", myFunction); Is now pleasant, quick and sexy!
  • 24. Titanium development var tabGroup = Ti.UI.createTabGroup(), shadowColor: '#fff', shadowOffset: { win1 = Ti.UI.createWindow({ y: -1, backgroundColor: '#ccc', x: 0 barColor: '#00a', }, title: 'My window' font: { }), fontSize: 20, fontWeight: 'bold' tab1 = Ti.UI.createTab({ } icon: 'path/to/my/icon', }); title: 'My tab', window: win1 win1.add(label1); }), label1.addEventListener('click', function(e){ alert('You clicked me!'); label1 = Ti.UI.createLabel({ }); text: 'Hello world!', textAlign: 'center', tabGroup.addTab(tab1); color: '#333', tabGroup.open(); Used to be somewhat painful, slow and ugly!
  • 25. Welcome Kranium http://flic.kr/p/9wLZkJ!
  • 26. Titanium development K({ type: 'tabgroup', tabs: [{ cls: 'myTab', window: { cls: 'myWindow', children: [{ text: 'Hello world!', cls: 'mylabel', click: function(){ alert('You clicked me!'); } }] } }] }).open(); Is now more pleasant, quick and sexy!
  • 27. Titanium development .myTab { icon: path/to/my/icon; } window { background-color: #ccc; bar-color: #00a; } .myLabel { text-align: center; color: #333; shadow-color: #fff; shadow-offset-y: -1; font-size: 20; font-weight: bold; } Is now more pleasant, quick and sexy!
  • 28. Titanium development Stylus K( .myTab type: "tabgroup" icon path/to/my/icon tabs: [ className: "myTab" window window: background-color #ccc className: "myWindow" bar-color #00a children: [ text: "Hello world!" .myLabel className: "mylabel" text-align center ] color #333 ] shadow-color #fff ).open() shadow-offset-y -1 font-size 20 font-weight bold With lots of possibilities!
  • 29. Kranium "  Lovechild of the following stunning web frameworks:! "  jQuery / Zepto! "  Backbone! "  Jade! "  Livetanium / Livereload! "  Sizzle / mini.js! "  Jasmine! http://bit.ly/3vVcI! "  JSS / Stylus / Sass / LESS! "  JSConsole / Weinre!
  • 31. jQuery / Zepto "  Easy access selector engine! $('.content > .label, .hello').text('hello!'); $(el).find('.content'); $('.content', el);
  • 32. jQuery / Zepto "  Chainable collections with helper functions! $(el) .text('hey') .css({ color: '#f00' }) .parent('.row') .bind('click', onClick) .append(stuff);
  • 33. jQuery / Zepto "  Simplified API:s! $.ajax({ type: 'GET', url: 'http://some/url', success: function(data, status, xhr){ alert(data); } });
  • 34. Titanium "  Let’s see how these look in the low-level Titanium API!
  • 35. Titanium "  Easy access selector engine?! N/A
  • 36. Titanium "  Chainable collections with helper functions?! el.text = 'hey'; el.color = '#f00'; var parent = el.getParent().getParent().children().filter (function(el){ return /(^|s+)row(s+|$)/.test(el.className); }); parent.addEventListener('click', onClick); stuff.forEach(function(toAdd){ el.add(toAdd); });
  • 37. Titanium "  Simplified API:s?! var xhr = Ti.Network.createHTTPClient(); xhr.open('GET', 'http://some/url'); xhr.onload = function(data, status, xhr){ alert(data); }); xhr.send();
  • 38. Kranium "  Lets look at the same functionality using Kranium!
  • 39. Kranium "  Easy access selector engine! $('.content > .label, .hello').text('hello!'); $(el).find('.content'); $('.content', el);
  • 40. Kranium "  Chainable collections with helper functions! $(el) .text('hey') .css({ color: '#f00' }) .parent('.row') .bind('click', onClick) .append(stuff);
  • 41. Kranium "  Simplified API:s! $.ajax({ type: 'GET', url: 'http://some/url', success: function(data, status, xhr){ alert(data); } });
  • 42. Kranium http://bit.ly/bW1zP5! "  Tries to invent as few wheels as possible! "  Instead piggyback on the ideas and momentum of existing great web frameworks!
  • 43. What to piggyback? "  jQuery / Zepto! "  Backbone! "  Jade! "  Livetanium / Livereload! "  Sizzle / mini.js! "  Jasmine! "  JSS / Stylus / Sass / LESS! http://flic.kr/p/7dpmyF! "  JSConsole / Weinre!
  • 44. What IS Kranium? "  A utility library to include in your app! "  A command line program!
  • 45. Utility library "  Exposes a jQuery-like object called K (or $)! "  Exposes Backbone integration! "  Exposes Jade template engine! "  Implements simple selector engine! "  Implements enhanced styling! "  Implements extendable modules!
  • 46. Command line program "  Built on NodeJS and NPM! "  Initiates Kranium resources in project! "  Pipes live updates! "  Two-way console! "  Jasmine reporter!
  • 47. Template engine A great template engine is a huge help in keeping your code:! "  DRY! "  separated! "  consise!
  • 48. Jade "  Lightweight! "  Supports custom compilers! "  Compiles templates to functions! "  Beautiful syntax! "  Consise! "  In active development!
  • 50. // test.jade view.board label.boardTitle Board view.boardMessages - each msg, user in users label.boardMessage= user + ' says ' + msg
  • 51. K.jade('test.jade', { users: { jacob: 'yeah', david: 'what', conny: 'hi', aida: 'hello', calle: 'yup' } });
  • 52. .board { top: 10; left: 10; } .boardMessages { top: 30; layout: vertical; } .boardMessage { height: 20; top: 10; } .boardTitle { top: 0; height: auto; font-weight: bold; }
  • 53. JSS "  Great feature in theory - gives Separation of Concerns! "  Hasn’t always been working well ! "  Not powerful and extendable enough!
  • 54. KSS "  A styling layer implemented in the javascript context! "  Everything created using K function is styled appropriately! "  Style based on Types, Classes and IDs! "  Platform branching using psuedo selectors! "  Variable evaluation!
  • 55. KSS label { color: #000; font-size: 16dp; } label:android { font-size: 17dp; text-align: left; } tableview:ios { style: Ti.UI.iPhone.TableViewStyle.GROUPED; }
  • 56. KUI http://flic.kr/p/6a3wzw! "  Extendable UI Modules! "  Simple Inheritance! "  Automatic KSS loading!
  • 57. Example kui/loginstatus.js! exports.Class = Label.extend({ className: "loginstatus", init: function(opts) { this.events = { app: { authchange: this.updateStatus.bind(this) } }; this._super.call(this, opts); this.updateStatus(); }, updateStatus: function(e) { this.el.text = "Logged " + (e && e.loggedIn ? "in" : "out"); } });
  • 58. Example kui/loginstatus.kss! .loginstatus { color: #f00; }
  • 59. Example app.js! K({ type: 'window', children: [{ type: 'loggedinstatus' }] }).open(); var i = 0; setInterval(function(){ Ti.App.fireEvent('authchange', { loggedIn: !!(++i % 2) }); }, 1000);
  • 60. Example app.js! K({ type: 'window', children: [{ top: 10, type: 'loggedinstatus' }, { bottom: 10, type: 'loggedinstatus' }] }).open(); var i = 0; setInterval(function(){ Ti.App.fireEvent('authchange', { loggedIn: !!(++i % 2) }); }, 1000);
  • 61. Backbone supplies structure to JavaScript-heavy applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions and views with declarative event handling...
  • 64. // Define model RowModel = Backbone.Model.extend({ type: 'tableviewrow' }); // Define collection RowCollection = Backbone.Collection.extend({ model: RowModel, comparator: function(model) { return model.get("title"); } }); // Create todos collection todos = new RowCollection(); todos.add([ { title: "An example todo" }, { title: "Another example todo" }, ]); // Create todolist var todolist = K.create({ type: 'todolist', collection: todos });
  • 65. // kui/todolist.js exports.Class = BackboneView.extend({ type: 'tableview', editable: true, events: { click: function(e){ var model = todos.getByCid(e.rowData._modelCid); model.set({ hasCheck: !model.get('hasCheck') }); }, "delete": function(e){ var model = todos.getByCid(e.rowData._modelCid); todos.remove(model); } } });
  • 66. exports.Class = Window.extend({ navBarHidden: true, init: function(o){ this.titleLabel = K.createLabel({ className: 'titleLabel' }); todos.bind('all', this.updateTitleLabel.bind(this)); this.updateTitleLabel(); this.children = [{ type: 'toolbar', className: 'todoToolbar', items: [{ type: 'textfield', className: 'todoInputTextField', events: { "return": function(e){ todos.add({ title: e.value }); } } }, 'spacer', this.titleLabel] }, todolist]; this._super(o); }, updateTitleLabel: function(){ var completed = todos.filter(function(m){ return m.get('hasCheck') }).length; this.titleLabel.text = completed + ' / ' + todos.length + ' todos'; } });
  • 68. Polyfill missing UI "  Android lacks many simple UI modules! "  Navbar! "  TabbedBar! "  ButtonBar! "  Toolbar! "  Extendable TabBar" "  Kranium implements these!
  • 71. Extend Base UI K.createTableview({ pullToRefresh: true, refresh: function(){ K.ajax({ url: 'http://example.com/service.json', success: this.render }); }, render: function(data){ this.setData(data.rows.map(this.createRow)); }, createRow: function(o){ return K.createTableViewRow({ title: o.name }); } });
  • 72. Livetanium "  Kranium integrates Livetanium! "  Gives you live updates of KSS style changes as well as module updates!
  • 74. Jasmine describe('Demo', function() { describe('Titanium Object', function(){ it('Ti == Titanium', function(){ expect(Titanium).toEqual(Ti); }); it('Ti.App', function(){ expect(Titanium).toBeDefined(); }); }); describe('TabGroup', function(){ it('Has tabgroup', function(){ expect(K('tabgroup').length).toBeGreaterThan(0); }); it('TabGroup.activeTab.title === "test"', function(){ expect(K('tabgroup').get(0).activeTab.title).toEqual("test"); }); }); });
  • 78. Summary "  Consists of a command line program and an includable library! "  Ports the best web development libraries and technologies to Titanium! "  Polyfills parts missing between platforms! "  Helps you with your KISS:ing and keeps you DRY!
  • 79. Available now "  Currently in open beta! "  Source under MIT License! "  Hosted on GitHub! "  Pull requests and co-maintainers welcome" "  http://github.com/krawaller/kranium!
  • 80. Available now "  Beware! "  There will be bugs! "  API far from frozen!
  • 81. Available now "  Works best with iOS, but Android getting there! "  CLI works best on Mac OSX! "  Will be tested and fixed for Linux and Windows !
  • 83. Installation "  1. Install NodeJS and NPM! "  2. Run `npm install kranium`! "  3. There is no step 3!
  • 86. Go contribute please! http://flic.kr/p/9C7DZZ!