Wheel.js

Why everyone should make their
own JavaScript framework, now
“I tend to liken
JavaScript to water”
“… alone it's painfully
simple but it can take
   the form of its
     container”
- John Resig
author of jQuery
jQuery
jQuery + Plugins
jQuery + Plugins + a little app code
Then js grew up
• Rendering
• Logic
:(
Tools Proliferate
Tools Proliferate
•   jQuery UI    •   JavaScriptMVC
•   Backbone     •   AngularJS
•   Sammy.js     •   Ext.js
•   Ember.js     •   Agility.js
•   Spine.js     •   KnockoutJS
•   Underscore   •   Knockback.js
•   Can.js       •   …
What’s the clear path?
But wait … there is more




      < 2007 :)
> 2007 :(
And I want things
                          Form widgets
Dialogs




               Menus




                                etc …
Wish List
•   Platform for big or small js
•   Cross-device & Cross-browser compatibility
•   Install and code, sensible default app
•   Ability to customize what I don’t like
•   Library add-ons
Wheel.js

I am trying to build my wishlist.
        You should too!
Wheel = Object-Oriented
Instance Methods/Variables
Class Methods/Variables
Subclassing
Got _super?
Keep it dry with modules
Why is OO important?
Why is OO important?



              Because customizing this
              means copy/paste
Wheel is View-centric!
        (and flexible)
Views can …
• be attached to existing browser DOM
• be built with a string
    • received via ajax
    • hand-built
• generate own DOM from a template
Gathering Views from DOM
Given HTML in the browser
Gathering Views from DOM


               A simple view class for todo tasks
View Anatomy
Switching to DOM Generation
View Niceties
Superclass initialization automatically
  – Finds/generates DOM
  – Provides a handy this.$ for DOM manipulation
  – Calls ‘listen’ after subclass ‘init’ block is called
  – Sets options passed in as instance variables
  – Automatically appends to parent, when parent
    option provided
Adding Persistence
Ajax Mixin
• ‘data’ method to specify what will be sent to
  the server
• ‘onComplete’, ‘onSuccess’, ‘onError’ methods
• prototype/instance can set the http method
• Module converts ‘put’ and ‘delete’ to ‘post’
  with _method attribute
• Needs a ‘url’ attribute
Ajaxing For the Mobile Era
•   Request queue instead of direct requests
•   Queue stored in LocalStorage or polyfill
•   Application tracks connectivity
•   Sends requests and executes callbacks as
    possible
More Mobile
•   Touch/Gesture events
•   Event Unification
•   Drag/Drop Conventions
•   Dynamic application loader (bandwidth)
•   ??
++
Helpers                 Widgets
• Poller                • Tabs
• Cookie Manager        • Dialog
• Models                • Searcher
• Router/History        • Autocomplete
Rails                   • Form Stuff
• Generators            • Tooltips
• Better deps           • Time ago helper
  manager??
Github:
https://github.com/baccigalupi/wheel.js

Wheel.js