daviferreira/medium-editor — pull request #331 by AidanThreadgold (2014-11-25 10:26:48+00:00)
Title: Static toolbar

Further to @Dayjo's original pull request #282.
In order to resolve the merge conflicts, I just ended up manually copying over all of @Dayjo's code into an branch that is up to date with master.

I have tested this on Chrome, Firefox, Safari and IE 9.

=======

### List of Changes

#### 1. Add Static Toolbar

Simply put, the toolbar appears above the editor and only disappears when the user leaves the editor.

This mostly consisted of adding` if ( !this.options.staticToolbar ) {` around places that the toolbar gets hidden, and rewriting the `setToolbarPosition` function for static positioning.

Configure with; `staticToolbar: true` in the editor options.

#### 2. Add Sticky Toolbar

Combined with `staticToolbar`, this will keep the toolbar at the top of the window while scrolling over the editor.

Configure with; `stickyToolbar: true` in the editor options.

#### 3. No longer use 'blur' on the editor to hide toolbar

This now uses event listeners and determines if you have clicked or focused outside of the editor, or the toolbar (the toolbar counts as part of the editor). Uses the new `isDescendant` function.

#### 4. Add Classes to toolbar types

The transition css caused issues with the static toolbar so I added new classes. `.static-toolbar` which is added to the static toolbar. `sticky-toolbar` for when the toolbar is stuck to the top of the window while scrolling, and `stalker-toolbar` which is the current toolbar that follows the selection.

#### 5. New demo page

A demo with two editors, one static, one stalker (/demos/static-toolbar.html)

#### 6. Various improvements / changes

I moved out the placeholder functions. I created a `bindElementActions` function which now runs all the element related bind functions which have been moved out along with a new `bindClick` function which 'activates' the editor toolbar.

Would love some help testing. Have tested in Chrome and Firefox only so far.