Skip to content

Latest commit

 

History

History
170 lines (117 loc) · 5.42 KB

README.md

File metadata and controls

170 lines (117 loc) · 5.42 KB

Werkzeug

Client side components base on Google Closure. Lot of UI component are base on Closure components, or use Closure components internally.

Build Status

UI components

Independent components

Werkzeug provides an architecture for independent components. Basic idea is calling one function from HTML template and register components via CSS3 selector. Werkzeug provides wzk.app.App class. Every component is registered via on method.

app = wzk.app.buildApp()
app.on '.my-class', (element, dom, xhrFactory) ->
  # do stuff

Where:

Every registered component is loaded asynchronously and independently to others. If the component fails (throws an exception etc.) occured errors are handled automatically and it does not block other components.

wzk.net.XhrFactory by default shows a loading message via wzk.net.FlashMiddleware when a XHR is in progress.

The application structure follows:

  • start.coffee
  • app/base.coffee
  • index.html

A whole example could be (start.coffee):

goog.require 'app'

app.start = (win, msgs) ->

  flash = wzk.ui.buildFlash win.document # decorates or builds Flash component
  app._app.registerStandardComponents flash # registers standard UI components from Werkzeug
  app._app.run win, flash, msgs # runs the application

# ensure the symbol will be visible after compiler renaming
goog.exportSymbol 'app.start', app.start

And app/base.coffee file:

goog.provide 'app'

goog.require 'wzk.app'

app._app = wzk.app.buildApp()

index.html

<html>
<head><title>Werkzeug</title></head>
<body>
<script type="text/javascript">
app.start(window, {error: 'Internal error occurred, sorry.', loading: 'Loading...'});
</body>
</html>

wzk.app.App.registerStandardComponents registers follow components:

  • flash messages
  • UI grids
  • remote button for AJAX buttons
  • AJAX forms
  • autocomplete components
  • dynamic inline forms
  • rich tooltips
  • Bootstrap navbar-toggle buttons
  • snippet loaders
  • related object lookup buttons
  • more details wzk.app.App

Demos

See demos in `wzk-demo/index.html.

Run demos via grunt --gruntfile wzk-demo/Gruntfile.coffee and wzk-demo/index.html in a browser.