This repository has been archived by the owner on Jun 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1c61c4e
commit 271eaf0
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
# Backpack | ||
|
||
Backpack is for building custom apps for use with Movable Ink | ||
|
||
## Installation | ||
|
||
Backpack is on bower. Install it with: | ||
|
||
```bash | ||
npm install -g bower # if bower is not installed yet | ||
bower init | ||
bower install --save mi-backpack | ||
``` | ||
|
||
Then use it by referencing it from your HTML page: | ||
|
||
```html | ||
<script src="bower_components/mi-backpack/lib/backpack.js"></script> | ||
``` | ||
|
||
And from your JS: | ||
|
||
```javascript | ||
var myApp = new Backpack(); | ||
``` | ||
|
||
## API | ||
|
||
### Trigger the fallback image | ||
|
||
`.forceFallback()` is useful for triggering the static fallback image associated with the block. Note: by default it will remove the `#mi_size_container` element from the DOM. | ||
|
||
Example: | ||
|
||
```javascript | ||
myApp.forceFallback() | ||
``` | ||
|
||
|
||
### Logging to console | ||
|
||
`.logger()` makes it easier to follow `console.logs()` inside the app debug console. | ||
|
||
Example: | ||
|
||
```javascript | ||
myApp.logger('hello world') | ||
``` | ||
|
||
|
||
### Trigger an event | ||
|
||
`.trigger()` creates a synthetic event that bubbles up to the `document`. | ||
|
||
Example: | ||
|
||
```javascript | ||
myApp.trigger('error', 'some helpful error comment'); | ||
``` | ||
|
||
|
||
### Listen for an event | ||
|
||
`.on()` attaches an event handler. Note: Any information associated with the event will be in the `detail` property of the response. | ||
|
||
Example: | ||
|
||
```javascript | ||
myApp.on('error', function(msg){ | ||
// msg.detail -- 'some helpful error comment' | ||
}); | ||
``` |