server-generated-popups 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/README.md +57 -0
- data/app/assets/javascripts/popup.js +24 -0
- data/app/assets/stylesheets/popup.css +11 -0
- data/lib/server-generated-popups.rb +4 -0
- data/server-generated-popups.gemspec +16 -0
- metadata +49 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: baf7362c3fe5c33e8c3cf9aa52e17064a58e6a65
|
4
|
+
data.tar.gz: 7c58c29aeefb7480eaa55c19d91249ab5585fad7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8fcf5c3ade6743dcd2e25573b71abe28334782dbf6d9ef1d6adeffe99ad77c1f9b7fbd249925fec217781938f01084bed0244e2bd8ea027312f224a5d37ed77d
|
7
|
+
data.tar.gz: 77a50f306b605524d6ce7036b554fa4559fa359e6c60b232d3216c1dce75cefd017b30c9b615186545a5d62377743d19c50da0114b8bfb9b1c5167365c353835
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/README.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
You need to briefly show something to the user. You decide on a popup. You look at your options: `window.open()` is easy, but is blocked by the browser when called not in a `click` handler; JavaScript plugins are over-engineered and want you to create dedicated routes, hidden links or embed your content where it doesn't belong just to accomodate them. Oh boy. Does it have to be that bad? No.
|
2
|
+
|
3
|
+
Now you can do this:
|
4
|
+
|
5
|
+
```javascript
|
6
|
+
Popup("<%=j render @invoice %>").show('up')
|
7
|
+
```
|
8
|
+
|
9
|
+
![Animated demonstration](http://i.giphy.com/l46CkomqcgLa1SWWI.gif)
|
10
|
+
|
11
|
+
Animations, styles — all included. One line gets you a fully working solution.
|
12
|
+
|
13
|
+
Perfect with [Server-generated JavaScript Responses](https://signalvnoise.com/posts/3697-server-generated-javascript-responses) and [Turbolinks™](https://github.com/turbolinks/turbolinks), but not limited to them.
|
14
|
+
|
15
|
+
## Installation
|
16
|
+
|
17
|
+
### Rails
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
gem 'server-generated-popups'
|
21
|
+
```
|
22
|
+
|
23
|
+
### Any framework
|
24
|
+
|
25
|
+
Download this repo. Grab `popup.js` and `popup.css` from the `assets` directory and put them wherever you put JS and CSS in your framework.
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Raise a popup from the bottom of the screen:
|
30
|
+
|
31
|
+
```javascript
|
32
|
+
popup = Popup("<div>Hello</div>").show('up')
|
33
|
+
```
|
34
|
+
|
35
|
+
Fall a popup from the top of the screen:
|
36
|
+
|
37
|
+
```javascript
|
38
|
+
popup = Popup("<div>Hello</div>").show('down')
|
39
|
+
```
|
40
|
+
|
41
|
+
Launch the popup away through the top of the screen:
|
42
|
+
|
43
|
+
```javascript
|
44
|
+
popup.hide('up')
|
45
|
+
```
|
46
|
+
|
47
|
+
Sink the popup down through the bottom of the screen:
|
48
|
+
|
49
|
+
```javascript
|
50
|
+
popup.hide('down')
|
51
|
+
```
|
52
|
+
|
53
|
+
That's all I ever need from it. Do you need something else? Feel free to contribute.
|
54
|
+
|
55
|
+
## Credits
|
56
|
+
|
57
|
+
[Anton Khamets](http://colorfulfool.github.io)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
function Popup(html) {
|
2
|
+
contents = $(html)
|
3
|
+
popupWindow = $('<div class="popup"></div>')
|
4
|
+
popupWindow.append(contents)
|
5
|
+
|
6
|
+
function move(from, to, callback) {
|
7
|
+
$(popupWindow).css('top', from)
|
8
|
+
$(popupWindow).animate({top: to}, callback)
|
9
|
+
}
|
10
|
+
|
11
|
+
this.show = function (direction) {
|
12
|
+
$('body').append(popupWindow)
|
13
|
+
startFrom = (direction == 'up') ? '150%' : '-50%'
|
14
|
+
move(startFrom, '30%')
|
15
|
+
return this;
|
16
|
+
}
|
17
|
+
this.hide = function (direction) {
|
18
|
+
moveTo = (direction == 'down') ? '150%' : '-50%'
|
19
|
+
move('30%', moveTo, function () {
|
20
|
+
popupWindow.remove()
|
21
|
+
})
|
22
|
+
}
|
23
|
+
return this;
|
24
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.authors = ["Anton Khamets"]
|
5
|
+
gem.email = ["colorfulfool@gmail.com"]
|
6
|
+
gem.description = %q{Show a popup with one line of code}
|
7
|
+
gem.summary = %q{Show a popup with one of code. Not blocked by browsers. Plug-and-play.}
|
8
|
+
gem.homepage = "https://github.com/colorfulfool/rails-popup"
|
9
|
+
|
10
|
+
gem.files = `git ls-files`.split($\)
|
11
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
13
|
+
gem.name = "server-generated-popups"
|
14
|
+
gem.require_paths = ["lib"]
|
15
|
+
gem.version = "1.0.0"
|
16
|
+
end
|
metadata
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: server-generated-popups
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Anton Khamets
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-20 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Show a popup with one line of code
|
14
|
+
email:
|
15
|
+
- colorfulfool@gmail.com
|
16
|
+
executables: []
|
17
|
+
extensions: []
|
18
|
+
extra_rdoc_files: []
|
19
|
+
files:
|
20
|
+
- ".gitignore"
|
21
|
+
- README.md
|
22
|
+
- app/assets/javascripts/popup.js
|
23
|
+
- app/assets/stylesheets/popup.css
|
24
|
+
- lib/server-generated-popups.rb
|
25
|
+
- server-generated-popups.gemspec
|
26
|
+
homepage: https://github.com/colorfulfool/rails-popup
|
27
|
+
licenses: []
|
28
|
+
metadata: {}
|
29
|
+
post_install_message:
|
30
|
+
rdoc_options: []
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '0'
|
43
|
+
requirements: []
|
44
|
+
rubyforge_project:
|
45
|
+
rubygems_version: 2.4.8
|
46
|
+
signing_key:
|
47
|
+
specification_version: 4
|
48
|
+
summary: Show a popup with one of code. Not blocked by browsers. Plug-and-play.
|
49
|
+
test_files: []
|