0.3.0 • Published 9 years ago

shoeshine v0.3.0

Weekly downloads
5
License
MIT
Repository
github
Last release
9 years ago

Shoeshine

Widget framework

Wiki

Reference

Npm package

Shoeshine serves as the basis of building a modular, and event-driven view-controller layer for front end applications based on troop for OOP, sntls for data structures, and evan for universal events.

For a set of common widgets (labels, buttons, dropdowns, forms) based on shoeshine, look into candystore.

The Widget class implements a life cycle, plus incorporates a number of traits that augment its behavior:

  • evan.Evented so that widget instances may trigger and capture events on themselves
  • sntls.Documented so that widget classes may have class names assigned, and instances unique instance IDs
  • sntls.Managed so that widget instances may be stored in and retrieved from a global registry
  • shoeshine.Progenitor so that widget instances may be arranged in a parent-children relation
  • shoeshine.Renderable so that widgets may be rendered into the DOM

In order to implement your own widget classes, subclass shoeshine.Widget. Make sure to supply a class name to .extend(), as Widget overrides troop.Base.extend() to make it more widget-specific. The class name will end up on the new widget class as static property (.className), as well as a CSS class name on the markup generated for its instances.

var MyWidget = shoeshine.Widget.extend('MyWidget')
    .addPublic({
        contentTemplate: '<div class="child-container"></div>'.toMarkupTemplate()
    })
    .addMethods({
        init: function () {
            // initialize instance properties, add non-volatile child widgets
            // eg. this one will end up in the specified container in the markup
            OtherWidget.create()
                .setContainerCssClass('child-container')
                .addToParent(this);
        },

        afterAdd: function () {
            base.afterAdd.call(this);
            // (re-)initialize state, subscribe to events
        },

        afterRemove: function () {
            base.afterRemove.call(this);
            // clean up state, unsubscribe from events
        },

        afterRender: function () {
            base.afterRender.call(this);
            // start animations, subscribe to DOM events
        }
    });

To use the widget, simply set it as a root widget, or add it as a child to a widget already existing in the hierarchy.

MyWidget.create().setRootWidget();

or,

MyWidget.create().addToParent(parentWidget);

Sample code

To see shoeshine in action, check out Hills.

0.3.0

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.26

9 years ago

0.1.25

9 years ago

0.1.24

9 years ago

0.1.23

9 years ago

0.1.22

9 years ago

0.1.21

9 years ago

0.1.20

9 years ago

0.1.19

9 years ago

0.1.18

9 years ago

0.1.17

9 years ago

0.1.16

9 years ago

0.1.15

9 years ago

0.1.14

9 years ago

0.1.13

9 years ago

0.1.12

9 years ago

0.1.11

9 years ago

0.1.10

10 years ago

0.1.9

10 years ago

0.1.8

10 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago