├── .gitignore
├── example
├── docs
│ ├── assets
│ │ ├── rsc.css
│ │ ├── script.js
│ │ └── custom.scss
│ ├── docpress.json
│ ├── styles
│ │ ├── big-h1.md
│ │ ├── big-h1-with-tagline.md
│ │ └── pull-box.md
│ ├── README.md
│ ├── cleanup.md
│ └── premise.md
├── docpress.json
├── metalsmith.js
├── package.json
└── README.md
├── README.md
├── LICENSE
└── style.css
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | _docpress
3 |
--------------------------------------------------------------------------------
/example/docs/assets/rsc.css:
--------------------------------------------------------------------------------
1 | ../../../style.css
--------------------------------------------------------------------------------
/example/docs/assets/script.js:
--------------------------------------------------------------------------------
1 | /* custom */
2 |
--------------------------------------------------------------------------------
/example/docs/assets/custom.scss:
--------------------------------------------------------------------------------
1 | @import './rsc.css';
2 |
--------------------------------------------------------------------------------
/example/docs/docpress.json:
--------------------------------------------------------------------------------
1 | {
2 | "github": "rstacruz/onmount"
3 | }
4 |
--------------------------------------------------------------------------------
/example/docpress.json:
--------------------------------------------------------------------------------
1 | {
2 | "markdown": {
3 | "plugins": {
4 | "decorate": {}
5 | }
6 | }
7 | }
8 |
--------------------------------------------------------------------------------
/example/docs/styles/big-h1.md:
--------------------------------------------------------------------------------
1 | # scrsc
2 |
3 |
4 | Use the `.massive-header` class.
5 |
--------------------------------------------------------------------------------
/example/docs/styles/big-h1-with-tagline.md:
--------------------------------------------------------------------------------
1 | # rscsc
2 |
3 |
4 | > Styling CSS without losing your sanity
5 |
6 | Use the `.massive-header` class with `.-with-tagline`.
7 |
--------------------------------------------------------------------------------
/example/metalsmith.js:
--------------------------------------------------------------------------------
1 | var app = require('docpress-core/ms')(__dirname)
2 | .use(require('docpress-core')())
3 | .use(require('../../')())
4 |
5 | if (module.parent) {
6 | module.exports = app
7 | } else {
8 | app.build(function (err) { if (err) throw err })
9 | }
10 |
--------------------------------------------------------------------------------
/example/docs/README.md:
--------------------------------------------------------------------------------
1 | # Table of contents
2 |
3 | * [onmount](/README.md)
4 | * Styles
5 | * [Big H1](styles/big-h1.md)
6 | * [Big H1 with tagline](styles/big-h1-with-tagline.md)
7 | * [Pull box](styles/pull-box.md)
8 | * From onmount
9 | * [Premise](/docs/premise.md)
10 | * [Preforming cleanups](/docs/cleanup.md)
11 |
--------------------------------------------------------------------------------
/example/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "example",
3 | "version": "1.0.0",
4 | "description": "Run something when a DOM element appears and when it exits. No dependencies. Legacy IE compatible. 1kb .min.gz.",
5 | "main": "metalsmith.js",
6 | "directories": {
7 | "doc": "docs"
8 | },
9 | "scripts": {
10 | "test": "echo \"Error: no test specified\" && exit 1"
11 | },
12 | "author": "Rico Sta. Cruz ",
13 | "license": "MIT",
14 | "dependencies": {
15 | "markdown-it-decorate": "0.3.1"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # docpress-rsc
2 |
3 | Rico's docpress theme.
4 |
5 | ```js
6 | /* docpress.json */
7 | {
8 | "css": "http://ricostacruz.com/docpress-rsc/style.css"
9 | }
10 | ```
11 |
12 | ## Docpress
13 |
14 | Docpress is a documentation website generator. See [docpress/docpress](http://docpress.github.io).
15 |
16 | ## As seen in
17 |
18 | - [rscss.io](http://rscss.io)
19 | - [docpress](http://docpress.github.io)
20 | - [rsjs](http://ricostacruz.com/rsjs)
21 | - [dom101](http://ricostacruz.com/dom101)
22 | - [scour](http://ricostacruz.com/scour)
23 | - [onmount](http://ricostacruz.com/onmount)
24 | - [backbone-patterns](http://ricostacruz.com/backbone-patterns)
25 | - [decca](http://ricostacruz.com/decca)
26 |
27 | ## Development
28 |
29 | Run docpress on `example/` to try it out.
30 |
--------------------------------------------------------------------------------
/example/docs/cleanup.md:
--------------------------------------------------------------------------------
1 | # Performing cleanups
2 |
3 | When your behavior modifies things outside itself (eg, binds events to the `document` element), you might want to clean up when the behavior is removed. Just pass a 2nd function to `onmount()`.
4 |
5 | In this example below, behaviors are checked once dialog boxes are opened and closed (`$.onmount()`). When it's called after closing, it will see that the old `.js-sticky` element is not part of the document anymore, and its exit callback will be called.
6 |
7 | ```js
8 | $.onmount('.js-sticky', function () {
9 | $(document).on('scroll.sticky', function () {
10 | // do stuff
11 | })
12 | }, function () {
13 | $(document).off('scroll.sticky')
14 | })
15 |
16 | $(function () { $.onmount() })
17 | $(document).on('show.bs.modal close.bs.modal', function () { $.onmount() })
18 | ```
19 |
--------------------------------------------------------------------------------
/example/docs/styles/pull-box.md:
--------------------------------------------------------------------------------
1 | # Pull box
2 |
3 | The pillow finishing a point will be bluntly the milkshake. A fillet mignon taking the delicious boar will be shapeless, and then a crab will have the alpaca. The grey bison will be an unabridged king. She is sending incredibly. The crab won't make. The morning bee gave a king for something, and then something stood yesterday.
4 |
5 | It is you. She can't smile, but definitely, a bug is detailed and easy nowadays. A blind eye changed me for it without a hereditary steak seeing a fuzzy crow.
6 |
7 | A spaghetti building a hyperactive eagle will be a bee bluntly. A divine intervention was running. They will have them. The arm creating a fresh vote can't shout. We will be inverted twice. We will have counter-clockwise whales. She was becoming yesterday.
8 |
9 | That's awesome. Let's continue.
10 | [Continue →](#)
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2016 Rico Sta. Cruz
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/example/docs/premise.md:
--------------------------------------------------------------------------------
1 | # Premise
2 |
3 | Onmount is a safe, reliable, idempotent, and testable way to attach JavaScript behaviors to DOM nodes. It's great for common websites that are not Single-Page Apps, and it goes hand-in-hand with Turbolinks.
4 |
5 | #### Once and only once
6 |
7 | It solves many problems that crop up on sites where the DOM changes often, such as when using with Turbolinks or Pjax. Onmount assures you that each behavior is only applied *once* to an element and never again so you don't get duplicate event handlers and such. This is a concept called [idempotence].
8 |
9 | [idempotence]: https://en.wikipedia.org/wiki/Idempotence
10 |
11 | #### Testability
12 |
13 | Onmount allows you to re-run certain behaviors. This is great for making isolated unit tests of your code.
14 |
15 | #### Reusable
16 |
17 | Code written in `onmount` blocks operate in the context of a single DOM element. It can be applied again other DOM elements later on and will be running in isolation from other instances.
18 |
19 | ## Example
20 |
21 | Let's build a navigation with some elements hidden under a *more...* button. Given this HTML snippet:
22 |
23 | ```html
24 |