server-generated-popups 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: baf7362c3fe5c33e8c3cf9aa52e17064a58e6a65
4
- data.tar.gz: 7c58c29aeefb7480eaa55c19d91249ab5585fad7
3
+ metadata.gz: bb6b9600caf59f4efd9d0c83732071e4332dc886
4
+ data.tar.gz: da263b8c14a01eade9560e84a3719aaa80bb9eb9
5
5
  SHA512:
6
- metadata.gz: 8fcf5c3ade6743dcd2e25573b71abe28334782dbf6d9ef1d6adeffe99ad77c1f9b7fbd249925fec217781938f01084bed0244e2bd8ea027312f224a5d37ed77d
7
- data.tar.gz: 77a50f306b605524d6ce7036b554fa4559fa359e6c60b232d3216c1dce75cefd017b30c9b615186545a5d62377743d19c50da0114b8bfb9b1c5167365c353835
6
+ metadata.gz: 533142827a77e44b7210a45552e3e8a65cd326aa431375dc81191bb53bb07e37e18887a0096f55116cebc6167a23234e135d379c38c692869145c8aa0f9b1148
7
+ data.tar.gz: e4faa66bbffa25621591768e4f496cdb76950113933720ed7c82ead530e8e9c7d80f1353e728054ed80626e25d052a2f1b881607658b63b2620218d718f44ac8
data/README.md CHANGED
@@ -6,7 +6,7 @@ Now you can do this:
6
6
  Popup("<%=j render @invoice %>").show('up')
7
7
  ```
8
8
 
9
- ![Animated demonstration](http://i.giphy.com/l46CkomqcgLa1SWWI.gif)
9
+ ![Animated demonstration](http://i.giphy.com/3oEjI0kLsPZ7u6l8ru.gif)
10
10
 
11
11
  Animations, styles — all included. One line gets you a fully working solution.
12
12
 
@@ -14,18 +14,28 @@ Perfect with [Server-generated JavaScript Responses](https://signalvnoise.com/po
14
14
 
15
15
  ## Installation
16
16
 
17
+ The plugin depends on jQuery, but you already have it, do you?
18
+
17
19
  ### Rails
18
20
 
19
21
  ```ruby
20
22
  gem 'server-generated-popups'
21
23
  ```
22
24
 
25
+ Then `require popup` into both your styleheet and javascript files.
26
+
23
27
  ### Any framework
24
28
 
25
29
  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
30
 
27
31
  ## Usage
28
32
 
33
+ Create a popup of a custom size by passing those options (values in %):
34
+
35
+ ```javascript
36
+ Popup("<div>Hello</div>", {width: 60, fromTop: 20})
37
+ ```
38
+
29
39
  Raise a popup from the bottom of the screen:
30
40
 
31
41
  ```javascript
@@ -54,4 +64,4 @@ That's all I ever need from it. Do you need something else? Feel free to contrib
54
64
 
55
65
  ## Credits
56
66
 
57
- [Anton Khamets](http://colorfulfool.github.io)
67
+ [Anton Khamets](http://colorfulfool.github.io)
@@ -1,7 +1,15 @@
1
- function Popup(html) {
1
+ function Popup(html, options) {
2
2
  contents = $(html)
3
3
  popupWindow = $('<div class="popup"></div>')
4
+
5
+ options = $.extend({}, {width: 70, fromTop: 20}, options || {})
6
+ popupWindow.css({
7
+ 'width': options.width.toString() + '%',
8
+ 'margin-left': (options.width/2 * -1).toString() + '%'
9
+ })
4
10
  popupWindow.append(contents)
11
+
12
+ distanceFromTop = options.fromTop.toString() + '%'
5
13
 
6
14
  function move(from, to, callback) {
7
15
  $(popupWindow).css('top', from)
@@ -11,12 +19,12 @@ function Popup(html) {
11
19
  this.show = function (direction) {
12
20
  $('body').append(popupWindow)
13
21
  startFrom = (direction == 'up') ? '150%' : '-50%'
14
- move(startFrom, '30%')
22
+ move(startFrom, distanceFromTop)
15
23
  return this;
16
24
  }
17
25
  this.hide = function (direction) {
18
26
  moveTo = (direction == 'down') ? '150%' : '-50%'
19
- move('30%', moveTo, function () {
27
+ move(distanceFromTop, moveTo, function () {
20
28
  popupWindow.remove()
21
29
  })
22
30
  }
@@ -1,7 +1,6 @@
1
1
  .popup {
2
- position: fixed;
2
+ position: fixed; z-index: 999;
3
3
  background: white;
4
- width: 80%; margin-left: -40%;
5
4
  left: 50%;
6
5
  box-shadow: 0px 10px 20px rgba(0,0,0,0.3);
7
6
  }
@@ -12,5 +12,5 @@ Gem::Specification.new do |gem|
12
12
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
13
13
  gem.name = "server-generated-popups"
14
14
  gem.require_paths = ["lib"]
15
- gem.version = "1.0.0"
15
+ gem.version = "1.1.0"
16
16
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: server-generated-popups
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Khamets