Git Product home page Git Product logo

titanium-backbone's Introduction

titanium-backbone

Titanium-backbone is a framework for building native iOS and Android apps using Titanium and Backbone.

Current status

This project is in very early stages of extraction from a production mobile banking application, but the ideas and patterns extracted have worked very well within this large app. We're taking the time to refactor as we extract so it should be even cleaner.

We have a Google Group at http://groups.google.com/group/titanium-backbone if you'd like to participate.

Installation

Install Titanium SDK

Visit the Titanium download page and follow the instructions from there to download Titanium Studio (and the Titanium SDK), or clone the GitHub repository at https://github.com/appcelerator/titanium_mobile.

Clone the project to your development machine:

$ git clone https://github.com/trabian/titanium-backbone.git
$ cd titanium-backbone

Install package dependencies

$ npm install

Run the app generator to create a new mobile app

$ ./bin/tb new [app name]
# Run ./bin/tb new --help for instructions

Optional: Install and run the app generator globally by running:

$ npm install -g
$ tb new --help

Running the tests

The test suite can be run using npm:

$ npm test

testem

During development it can be helpful to use testem for monitoring the source files and rerunning the tests as the underlying files are changed.

To use testem, run the following in the titanium-backbone directory:

$ npm install -g testem
$ testem

titanium-backbone's People

Contributors

chrisachard avatar tonydewan avatar trabianmatt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

titanium-backbone's Issues

Remove need for View class - use Backbone.View directly

Recent additions have allowed us to move most of the Titanium-specific functionality out of the base View class to Backbone.$. With that change it should be possible for View classes to extend Backbone.View directly instead of a base View class:

Current:

View = require 'tb/views/base'

class Button extends View

Goal:

class Button extends Backbone.View

Currently tb/views/base is responsible for:

  • setting Backbone.$ to ti.$
  • aliasing tagName to viewName
  • setting the default viewName to 'View'
  • Overriding _configure to merge attributes passed via the constructor

These should be easy to include in Backbone.View via composition rather than inheritance.

$.ajax should accept a single parameter

Backbone uses $.ajax(options) instead of $.ajax(url, options), which is certainly understandable. We need to support this method of calling $.ajax as well.

discussion goup?

Should we setup a discussion list? Some matters doesn't fit the issues. For example, have you guys looked at kranium? It integrates backbone and a lot of other stuff. It's open source too. Maybe we could learn some lessons from it, or even fork it. I don't know.

Build $.ajax similar to the jQuery version but using Ti.Network.HTTPClient

This should support:

Supported Settings

  • accepts
  • async (Only supported on iOS according to the Titanium documentation)
  • beforeSend
  • cache
  • complete
  • contents
  • contentType
  • context
  • converters
  • data
  • dataFilter
  • dataType
  • error
  • global
  • headers
  • ifModified
  • processData
  • statusCode
  • success
  • timeout
  • type (also method)
  • url
  • xhrFields

To consider:

  • password
  • username

Running npm install on created app fails

I don't know if its a problem with the build script or with stitch-up but, after running

titanium-backbone new myapp
cd myapp
npm install

I get the following error:

/path/to/myapp/node_modules/titanium-backbone/node_modules/stitch-up/lib/utils/merge.coffee:51
for (_i = 0, _len = deps.length; _i < _len; _i++) {

Consider a shorter name

@svallory and @tonydewan have both been part of discussions regarding the project name. I'm no huge fan of titanium-backbone but haven't really come up with an alternative.

What about keeping the name as 'titanium-backbone' but shortening the command to 'tb'? Any other ideas?

Bind models and views using Backbone.stickit

Backbone.stitckit is a library for binding models to views:

class SampleView extends Backbone.View

  # Any time the `name` attribute of @model is updated, the text of the element matching .name will be updated as well.
  bindings:
    '.name': 'name'

It would be helpful to have this integrated with titanium-backbone.

When events are declared on a Backbone View an error is being thrown if the event doesn't match the specified selector

For example:

View = require 'tb/views/base'

$ = Backbone.$

module.exports = class Window extends View

  viewName: 'Window'

  attributes:
    layout: 'vertical'
    backgroundColor: '#'

  events:
    'click Button': 'showAlert'

  showAlert: ->
    alert 'click'

  render: ->

    $('<Button>')
      .attr('title', 'Testing')
      .appendTo @$el

    $('<Label>')
      .attr('text', 'Test Label')
      .appendTo @$el

    @

If I click on the button then the alert shows as expected. If I click anywhere else then I get the following error:

Script Error = Can't find variable: context at app-impl.js (line 5017).

The offending code is in closest():

      closest: function(selector) {
        var node;
        node = this[0];
        while (node && !_matches(node, selector)) {
          node = (node !== context) && node.parent;
        }
        return $(node);
      },

It looks like I accidentally copied over the 'context' variable even though we're not using context yet.

Investigate TiInspector

This looks promising: https://github.com/omorandi/TiInspector

Ti Inspector allows debugging Appcelerator Titanium applications in the Chrome DevTools web interface.

It shouldn't require any additions to the titanium-backbone framework but could make its way into our documentation as a recommended tool.

$.append and $.remove should handle special-purpose containers and non-container views

Some views such as TableViews only handle special types of children (e.g. TableViewRows and TableViewSections as children of TableView). In the case of TableView the name of the method used to add these special children is appendRow and appendSection.

$.append should use the appropriate method depending on the type of container being added to and should throw an exception if the view being added is not acceptable or if the container should not accept any children.

Non-containers

  • Throw an error on 'append' for these view types.

Views that are not intended to act as containers for other views:

  • ActivityIndicator
  • Button
  • ImageView
  • Label
  • ProgressBar
  • SearchBar
  • Slider
  • Switch
  • TextArea
  • TextField
  • WebView

Special-purpose containers

  • ButtonBar and TabbedBar should not accept append with a child view because items are added as elements of a special-purpose 'labels' array.
  • Picker can only hold PickerRows and PickerColumns, which are added using the add method. Throw error if anything else is added.
  • TableView is a specialized container for TableViewSection (appendSection and deleteSection) and TableViewRow (appendRow and deleteRow) objects. Throw error on others.
  • TableViewSection is a specialized container for TableViewRow objects, which are added using the add method. The add method on TableViewSection can only be used to add TableViewRow objects.
  • Toolbar is designed to hold buttons and certain other controls, added to its items array.
  • The Tab, TabGroup, NavigationGroup and SplitWindow objects are special containers that manage windows and should not be added to arbitrary views.

Update README to reflect most recent changes

With changes in the 'refactor' branch, the README is no longer accurate. It should include:

  • A summary of the purpose and motivation of the framework
  • An overview of the current status of development
  • Instructions for:
    • Installation
    • Running the tests
    • Running the kitchen sink

Also acceptable would be links within the README pointing to this information within the wiki.

Creation of elements using XML syntax (to allow use of template engines such as jade)

I would like to be able to create views using a template engine such as jade. This might look something like:

View.heading
  Label This is a heading
  Label= subheading
Button Click me!
template = require './template'

class SampleView extends Backbone.View

  render: ->

    @$el.append template { subheading: 'And this is a subheading' }

    @

This has proved to be a very helpful pattern when building Backbone apps on the web and should be fairly easy to implement in titanium-backbone.

As a first step we should extend the $('') creation syntax to support attributes, nesting, and text nodes:

Update $('') syntax to support:

  • Attributes: $("<View height='50''>")
  • Nesting: $("<View><Label height='20' /><Button title='Click me!' /></View>")
  • Text nodes: $("<Label>Label Text</Label>") should create a label with a text attribute of 'Label Text' while $("<Button>Click Me!</Label>") should create a button with a title attribute of 'Click Me!'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.