0.01
No commit activity in last 3 years
No release in over 3 years
Flight javascript framework for Rails assets pipeline
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

>= 2.1.4
>= 3.1.0
 Project Readme

FlightForRails

FlightForRails is a plugin for Rails assets pipeline, which integrates your applicaiton with Twitter Flight javascript framework. Flight is a lightweight, component-based javascript framework that maps behavior to DOM nodes. Twitter uses it for their web applications. Why do not you try it? :)

For more information see official Flight page and changelog.

Browser Support

Flight has been tested on all major browsers: Chrome, Firefox, Safari, Opera and IE7 and upwards.

Installation

This gem vendors Flight files and dependecies for Rails assets pipeline.

First add the following lines to your application Gemfile:

gem 'flight-for-rails', '~> 1.5.1'

Then run bundle install to update your's gems bundle.

Now you need to edit your manifest file (usualy app/assets/javascripts/application.js) and add the following lines:

//= require jquery
//= require flight-for-rails

Done!

Usage

  1. Define a component
  2. Attach a component instance to a DOM node

Simple example:

# app/assets/javascript/components/my-component.js.coffee
$ ->
  MyComponent = flight.component ->
    @after 'initialize', ->
      @on 'click', @triggerMyEvent

    @triggerMyEvent = ->
      @trigger document, 'myEvent', text: 'My event'

  MyComponent.attachTo '#my-component'
# app/assets/javascript/components/my-component-2.js.coffee
$ ->
  MyComponent2 = flight.component ->
    @after 'initialize', ->
      @on 'myEvent', @handleMyEvent

    @handleMyEvent = (event, data) ->
      console.log "#{data.text} event is triggered!"

  MyComponent2.attachTo '#my-component2'

And don't forget add the following line to your manifest file (usualy app/assets/javascript/application.js):

//= require_directory ./components

Pretty awesome! Enjoy!

Copyright

See LICENSE file.