Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
root = true

[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = true

[Makefile]
charset = utf-8
indent_style = tabs
indent_size = 2
end_of_line = lf
trim_trailing_whitespace = true
insert_final_newline = false
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.DS_Store
node_modules
node_modules
npm-debug.log
9 changes: 1 addition & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
node_js:
- "0.10"
before_install:
- npm install -g grunt-cli
- "export PHANTOMJS_BIN=`which phantomjs`"
install:
- "npm install"
script:
- grunt test
- "0.10"
80 changes: 0 additions & 80 deletions Gruntfile.js

This file was deleted.

3 changes: 2 additions & 1 deletion LICENCE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
The MIT License (MIT)

Copyright (c) 2014 Hector Leon Zarco Garcia
Copyright (c) 2015 Hector Leon Zarco Garcia
Copyright (c) 2015 Tomas Aparicio

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
25 changes: 25 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
VERSION = 0.1.0
UGLIFYJS = ./node_modules/.bin/uglifyjs
MOCHA_PHANTOM = ./node_modules/.bin/mocha-phantomjs
HTTP_SERVER = ./node_modules/.bin/http-server
BANNER = "/*! focusable - v$(VERSION) - MIT License - https://github.com/zzarcon/focusable */"

default: all
all: test
browser: uglify
test: browser mocha

uglify:
$(UGLIFYJS) focusable.js --mangle --preamble $(BANNER) --source-map focusable.min.js.map --source-map-url http://cdn.rawgit.com/zzarcon/focusable/$(VERSION)/focusable.min.js.map > focusable.min.js

mocha:
#$(MOCHA_PHANTOM) --reporter spec --ui bdd test/runner.html

demo: browser
$(HTTP_SERVER) -p 8000 .

loc:
wc -l focusable.js

gzip:
gzip -c focusable.js | wc -c
119 changes: 90 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,127 @@
Focusable [![Build Status](https://travis-ci.org/zzarcon/focusable.svg?branch=master)](https://travis-ci.org/zzarcon/focusable)
=============
An awesome and lightweight library for performing spotlight in your DOM elements, setting an animated overlay to the rest of the page.
You can find a [live demo here](http://zzarcon.github.io/focusable/).
# Focusable [![Build Status](https://travis-ci.org/zzarcon/focusable.svg?branch=master)](https://travis-ci.org/zzarcon/focusable) [![Version](https://img.shields.io/bower/v/focusable.svg)](https://github.com/zzarcon/focusable/releases) [![Gitter chat](https://badges.gitter.im/zzarcon/focusable.png)](https://gitter.im/zzarcon/focusable) [![Stories in Ready](https://badge.waffle.io/zzarcon/focusable.png?label=ready&title=Ready)](https://waffle.io/zzarcon/focusable)

### Showcase
A lightweight and dependency-free micro library to easily spotlight DOM elements

You can find a live demo [here](http://zzarcon.github.io/focusable/)

## Showcase

![](https://raw.github.com/zzarcon/focus-element-overlay/master/showcase/list.gif)

![](https://raw.github.com/zzarcon/focus-element-overlay/master/showcase/header.gif)

![](https://raw.github.com/zzarcon/focus-element-overlay/master/showcase/elements.gif)

### API
###### Set spotlight (jQuery style)
```javascript
$('#my-element').setFocus(options);
## Installation

Install via [Bower](http://bower.io)
```bash
bower install focusable
```

Install via [Component](http://component.github.io)
```bash
component install zzarcon/focusable
```

Install via [npm](http://npmjs.org)
```bash
npm install focuable
```

Or loading the script remotely
```html
<script src="//cdn.rawgit.com/zzarcon/focusable/0.1.0/focusable.js"></script>
```
###### Set spotlight (through library)

## Browser Support

![Chrome](https://raw.github.com/alrra/browser-logos/master/chrome/chrome_48x48.png) | ![Firefox](https://raw.github.com/alrra/browser-logos/master/firefox/firefox_48x48.png) | ![IE](https://raw.github.com/alrra/browser-logos/master/internet-explorer/internet-explorer_48x48.png) | ![Opera](https://raw.github.com/alrra/browser-logos/master/opera/opera_48x48.png) | ![Safari](https://raw.github.com/alrra/browser-logos/master/safari/safari_48x48.png)
--- | --- | --- | --- | --- |
+5 | +3.5 | +9 | +10 | +5 |

## API

###### Set spotlight using jQuery/Zepto selector

```javascript
Focusable.setFocus($('#my-element'), options);
Focusable($('#my-element'), options)
```
###### Refresh current focused element

###### Set spotlight

```javascript
Focusable.refresh();
Focusable(document.querySelector('#my-element'), options)
```

###### Hide spotlight

```javascript
Focusable.hide();
Focusable.hideAll()
```
###### Get focused element

###### Get focused DOM elements

```javascript
Focusable.getActiveElement();
Focusable.getActiveElements()
```

###### Get options

```javascript
Focusable.getOptions();
Focusable.getOptions()
```

###### Options
##### Options

Property | Value | Default | Description
------------ | ------------- | ------------- | -------------
fadeDuration | Number | 700 | Duration of the overlay transition (milliseconds).
hideOnClick | Boolean | false | Hides the overlay when the user click into it.
hideOnESC | Boolean | false | Hides the overlay when the user press Esc.
findOnResize | Boolean | false | Refind the element in the DOM in case that the element don't still exists.

###### Runing tests
* `npm install`
* `grunt`
* See the result of testsuite in [http://localhost:9092](http://localhost:9092)
## Development

Clone this repository and switch into it
```bash
git clone https://github.com/zzarcon/focusable && cd focusable
```

Install development dependencies
```bash
npm install
```

Run tests
```bash
make test
```

###### Dependencies
- jQuery
Run the example demo and open [localhost:8000](http://localhost:8000)
```
make demo
```

###### Contributing
## Contributing

0. Check [open issues](https://github.com/zzarcon/focusable/issues)

1. [Fork it](https://github.com/zzarcon/focusable/fork)

2. Create your feature branch (`git checkout -b my-new-feature`)
3. Commit your changes (`git commit -am 'Add some feature'`)

3. Commit your changes (`git commit -am 'feat(name): description'`)

4. Push to the branch (`git push origin my-new-feature`)
5. Create a new Pull Request

###### Author
You can follow me on Twitter - https://twitter.com/zzarcon
5. Create a new [Pull Request](https://github.com/zzarcon/focusable/compare/)

## Authors

- [Hector Zarcon](https://github.com/zzarcon)
- [Tomas Aparicio](https://github.com/h2non)

## License

MIT (c) 2015 - Hector Zarco and contributors
Loading