Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zurb/tribute-rb
Tribute.js @mentions for the Rails Asset Pipeline
https://github.com/zurb/tribute-rb
Last synced: 5 days ago
JSON representation
Tribute.js @mentions for the Rails Asset Pipeline
- Host: GitHub
- URL: https://github.com/zurb/tribute-rb
- Owner: zurb
- License: mit
- Created: 2016-07-28T16:21:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-10-15T16:36:42.000Z (about 5 years ago)
- Last Synced: 2024-07-31T21:56:39.326Z (3 months ago)
- Language: Ruby
- Homepage:
- Size: 133 KB
- Stars: 7
- Watchers: 16
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Tribute
[![Gem Version](https://badge.fury.io/rb/tribute.svg)](https://badge.fury.io/rb/tribute)
A cross-browser @mention engine written in native JS, no dependencies. Tested in Firefox, Chrome, iOS Safari, Safari, IE 9+, Edge 12+, Android 4+, and Windows Phone.
## Installation
Add this line to your application's Gemfile, then bundle:
```ruby
gem 'tribute'
```Add the following to your `app/assets/javascripts/application.js`:
```js
*= require tribute
```Then, in your `app/assets/stylesheets/application.css`:
```css
//= require tribute
```## Initializing
There are two ways to initialize Tribute, by passing an array of "collections" or by passing one collection object.
```js
var tribute = new Tribute({
values: [
{key: 'Phil Heartman', value: 'pheartman'},
{key: 'Gordon Ramsey', value: 'gramsey'}
]
})
```You can pass multiple collections on initialization by passing in an array of collection objects to `collection`.
```js
var tribute = new Tribute({
collection: []
})
```### Attaching to elements
Once initialized, Tribute can be attached to an `input`, `textarea`, or an element that supports `contenteditable`.
```html
I'm Mr. Meeseeks, look at me!Some text here.Some more text over here.tribute.attach(document.getElementById('caaanDo'));
// also works with NodeList
tribute.attach(document.querySelectorAll('.mentionable'));```
For more usage information, see the official [Tribute.js README](https://github.com/zurb/tribute#tribute).
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).