Skip to content

Commit 91b6cef

Browse files
committed
added feature to automatically generate the popper element from a configuration
1 parent 8691a7d commit 91b6cef

12 files changed

Lines changed: 496 additions & 237 deletions

File tree

Gruntfile.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,19 @@ module.exports = function(grunt) {
2626
dist: {
2727
options: {
2828
sourceMap: true,
29-
sourceMapName: 'build/near.min.js.map',
29+
sourceMapName: 'build/popper.min.js.map',
3030
preserveComments: /(?:license|version)/
3131
},
3232
files: {
33-
'build/near.min.js': ['build/near.js']
33+
'build/popper.min.js': ['build/popper.js']
3434
}
3535
}
3636
},
3737
copy: {
3838
dist: {
3939
nonull: true,
40-
src: 'src/near.js',
41-
dest: 'build/near.js',
40+
src: 'src/popper.js',
41+
dest: 'build/popper.js',
4242
}
4343
},
4444
jsdoc2md: {
@@ -50,7 +50,7 @@ module.exports = function(grunt) {
5050
karma: {
5151
options: {
5252
frameworks: ['jasmine'],
53-
singleRun: true,
53+
singleRun: false,
5454
browsers: browsers,
5555
customLaunchers: {
5656
'ChromeTest': {
@@ -84,7 +84,7 @@ module.exports = function(grunt) {
8484
position: 'replace',
8585
},
8686
files: {
87-
src: [ 'build/near.js' ]
87+
src: [ 'build/popper.js' ]
8888
}
8989
}
9090
},

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Popper.js
44

55
<img src="popperjs.png" align="right" width=250>
6-
Popper.js is a set of libraries used to create **poppers** in web applications.
6+
Popper.js is a library used to create **poppers** in web applications.
77

88
### Wut? Poppers?
99
A popper is an element on the screen which "pops out" from the natural flow of your application.
@@ -15,46 +15,47 @@ Popper.js is built from the ground up to being modular and fully ~~hackable~~ **
1515
It supports a **plugin system** you can use to add particular behaviors to your poppers.
1616
It's **AMD** and **CommonJS** compatible and it's well documented thanks to our [JSDoc page](https://fezvrasta.github.io/popper.js/documentation.html).
1717

18-
<br>
19-
--------------
20-
<br>
18+
### The Library
2119

22-
# Popper.js Libraries
20+
Popper.js is mostly a library with the job of making sure your popper stays near the defined reference element (if you want so).
21+
Additionally, it provides an easy way to generate your popper element if you don't want to use one already in your DOM.
2322

24-
Popper.js is a set of libraries, but right now the only released one is Near.js.
25-
26-
## Near.js
23+
Ok, let's stop talking, I'll show you how to use it:
2724

28-
Near.js (*I wanted to call it "Together.js" but seems like Mozilla already used it... Thanks, Mozilla*) is the library with the job of making sure your popper stays near the defined reference element (if you want so).
2925

30-
Ok, let's stop talking, I'll show you how to use it:
26+
#### Basic usage
27+
create a popper near a button:
3128

3229
```js
3330
var reference = document.querySelector('.my-button');
34-
var popper = document.querySelector('.the-popper');
35-
var options = { /* more later... */ }
36-
37-
var thePopper = new Near(reference, popper, options); // that's all
31+
var thePopper = new Popper(
32+
reference,
33+
{
34+
content: 'My awesome popper!'
35+
},
36+
{
37+
// popper options here
38+
}
39+
});
3840
```
3941

40-
It's the real badass of the family, all the hard work is on its shoulders and we'll never thank it enough for all its work!
41-
42-
## Popper.js
43-
44-
This library is still work in progress, basically will allow you to automatically create tooltips and popovers just defining their reference element.
45-
All the hard work is done by **Near.js** under the hood, but we want to make even easier to create poppers and Popper.js will make this possible.
46-
47-
Here is an example of how the API will look like:
42+
#### "Advanced" usage
43+
given an existing popper, ask Popper.js to position it near its button
4844

4945
```js
5046
var reference = document.querySelector('.my-button');
51-
var options = { /* more later... */ };
52-
53-
var thePopper = new Popper(reference, options);
47+
var popper = document.querySelector('.my-popper');
48+
var anotherPopper = new Popper(
49+
reference,
50+
popper,
51+
{
52+
// popper options here
53+
}
54+
});
5455
```
5556

56-
These few lines will create a new element and will initialize it using Near.js.
57-
As you see, it's just a shorthand for what you can already do with **Near.js** right now.
57+
If you are wondering about the available options of the third argument, check out [our documentation](http://fezvrasta.github.io/popper.js/documentation.html#new_Popper_new)
58+
5859
Visit our [GitHub Page](https://fezvrasta.github.io/popper.js) to see a lot of examples of what you can already do right now!
5960

6061

build/near.min.js

Lines changed: 0 additions & 26 deletions
This file was deleted.

0 commit comments

Comments
 (0)