server-generated-popups 1.4.4 → 1.4.5

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: 77a129a4f2fe7976e47938264e5704f2e7ee2516
4
- data.tar.gz: 8841edc0b8ebb55b2d610089340ee706681dfe1b
3
+ metadata.gz: 54c644a0cbd5e4594be54e5aa1fb197c1fe606f6
4
+ data.tar.gz: e64730d032cef7af4f10b046cfb6e345c283d0f9
5
5
  SHA512:
6
- metadata.gz: 9aca30e986f88b5ef2953727acd5b6d051676ca6dde398a1f42cfac34fee85608d4c9e245388877db622f10963b6463983db94c9cbdaeaf0206d83323d495441
7
- data.tar.gz: 022a1524f774eb0ecd752bef906bdefd9580f52a8456e39f1b207cd1fd908ee6fa4f676572aafce698968bef43bfb5fcbbd437ec8769373b4dd43a1b479299f5
6
+ metadata.gz: 6cee06105c58275ab2ed8afd117aa41faf7f4bb646920d30fc5ad1d2fe150146421e76e5d6ca771b2c23c3ceb6a556d15891d52abd80af51749f6a72c0d428a5
7
+ data.tar.gz: f153297179c790ce05e9f3c6ba87fcea6154b89c109b95cff7c8404dec289ce5f0ef6a2f263a30b1940f36ad72eef716aae739dce0128e20d74bb2ff7777cb24
data/README.md CHANGED
@@ -33,16 +33,16 @@ Download this repo. Grab `popup.js` and `popup.css` from the `assets` directory
33
33
 
34
34
  ## Usage
35
35
 
36
- Show a popup from the bottom of the screen:
36
+ Raise a popup from the bottom of the screen:
37
37
 
38
38
  ```javascript
39
39
  popup = Popup("<div>Hello</div>").show('up')
40
40
  ```
41
41
 
42
- Launch the popup away through the top of the screen:
42
+ Sink the popup down through the bottom of the screen:
43
43
 
44
44
  ```javascript
45
- popup.hide('up')
45
+ popup.hide('down')
46
46
  ```
47
47
 
48
48
  ### Options
@@ -63,7 +63,7 @@ Popup("<div>Hello</div>", {width: 300})
63
63
 
64
64
  #### show method options
65
65
 
66
- By default the popup will show with a close button in the top right corner and a semi-transparent backdrop beind ([like this](https://colorfulfool.github.io/server-generated-popups/demo/)). You can disable either or both:
66
+ By default the popup will show with a **close button** in the top right corner and a **semi-transparent backdrop** beind ([like this](https://colorfulfool.github.io/server-generated-popups/demo/)). You can disable either or both:
67
67
 
68
68
  ```javascript
69
69
  Popup("<div>Hello</div>").show({closeButton: false, backdrop: false})
@@ -79,7 +79,7 @@ editInvoiceDetails = Popup("<%=j render @invoice %>").show('up', {
79
79
  })
80
80
  ```
81
81
 
82
- ## Deleveopment
82
+ ## Development
83
83
 
84
84
  ### Roadmap
85
85
 
@@ -1,134 +1,139 @@
1
- function Popup(html, options) {
2
- return new PopupClass(html, options)
3
- }
4
-
5
- function createElement(html, style) {
6
- div = document.createElement('div')
7
- div.innerHTML = html
8
- generated = div.firstChild
9
- if (style)
10
- setStyle(generated, style)
11
- return generated
12
- }
13
- function removeElement(element) {
14
- element.outerHTML = ''
15
- }
16
- function appendToBody(element) {
17
- document.body.appendChild(element)
18
- }
19
- function setStyle(element, properties) {
20
- Object.assign(element.style, properties)
21
- }
22
-
23
- function defaultsFor(options, defaultOptions) {
24
- return Object.assign(defaultOptions, options)
25
- }
26
-
27
-
28
- // Constructs a Popup object.
29
- // Options: width, padding
30
- function PopupClass(html, options) {
31
- this.options = defaultsFor(options, {width: 600})
32
-
33
- this.popupWindow = createElement('<div class="popup">' + html + '</div>')
34
-
35
- actualWidth = Math.min(window.innerWidth, this.options.width)
36
- setStyle(this.popupWindow, {
37
- 'width': actualWidth.toString() + 'px',
38
- 'margin-left': (actualWidth/2 * -1).toString() + 'px',
39
- 'padding': this.options.padding
40
- })
41
-
42
- this.createBackdrop()
43
- }
44
-
45
-
46
- PopupClass.prototype.distanceFromTop = function () {
47
- return (window.innerHeight - this.popupWindow.offsetHeight)/2
48
- }
49
- PopupClass.prototype.translate = function (start, finish, callback) {
50
- if (start)
51
- this.popupWindow.classList.add(start)
52
-
53
- popupWindow = this.popupWindow
54
- setTimeout( // wait for CSS to notice `start` class
55
- function () { // trigger the CSS animation
56
- if (isNaN(finish)) {
57
- setStyle(popupWindow, {top: null}) // discard hard-coded `top` to make way
58
- popupWindow.classList.add(finish) // for this CSS class' `top`
59
- }
60
- else {
61
- setStyle(popupWindow, {top: finish + 'px'})
62
- }
63
- setTimeout( // wait for it to finish
64
- function () {
65
- popupWindow.classList.remove(start)
66
- if (callback)
67
- callback()
68
- }, 400)
69
- }, 1
70
- )
71
- }
72
-
73
-
74
- PopupClass.prototype.createBackdrop = function () {
75
- this.backdrop = createElement('<div id="popup-backdrop"></div>')
76
- this.hideByClickOn(this.backdrop)
77
- appendToBody(this.backdrop)
78
- }
79
- PopupClass.prototype.showBackdrop = function () {
80
- setStyle(this.backdrop, {visibility: 'visible', opacity: 0.5})
81
- }
82
- PopupClass.prototype.hideBackdrop = function () {
83
- backdrop = this.backdrop
84
- setStyle(backdrop, {opacity: 0})
85
- setTimeout(function () {
86
- setStyle(backdrop, {visibility: 'hidden'})
87
- }, 400)
88
- }
89
-
90
- PopupClass.prototype.createCloseButton = function () {
91
- closeButton = createElement('<div class="closeButton"></div>')
92
- margin = this.options.closeButtonPadding || this.options.padding || '16px'
93
- setStyle(closeButton, {top: margin, right: margin})
94
-
95
- this.hideByClickOn(closeButton)
96
- this.popupWindow.appendChild(closeButton)
97
- }
98
- PopupClass.prototype.hideByClickOn = function (element) {
99
- thisObject = this
100
- element.onclick = function () {
101
- thisObject.hide('down')
102
- }
103
- }
104
-
105
-
106
- // Slides the popup onto the screen.
107
- // Options: backdrop, closeButton, callback
108
- PopupClass.prototype.show = function (direction, options) {
109
- options = defaultsFor(options, {backdrop: true, closeButton: true})
110
-
111
- appendToBody(this.popupWindow)
112
- start = direction == 'up' ? 'below-screen' : 'above-screen'
113
- this.translate(start, this.distanceFromTop(), options.callback)
114
-
115
- if (options.backdrop)
116
- this.showBackdrop()
117
- if (options.closeButton)
118
- this.createCloseButton()
119
- return this
120
- }
121
-
122
-
123
- // Slides the popup out of the screen.
124
- // Accepts no options.
125
- PopupClass.prototype.hide = function (direction) {
126
- popupWindow = this.popupWindow
127
-
128
- finish = direction == 'up' ? 'above-screen' : 'below-screen'
129
- this.translate(null, finish, function () {
130
- removeElement(popupWindow)
131
- })
132
-
133
- this.hideBackdrop()
134
- }
1
+ (function (global) {
2
+ global['Popup'] = function (html, options) {
3
+ return new PopupClass(html, options)
4
+ }
5
+
6
+
7
+ function createElement(html, style) {
8
+ div = document.createElement('div')
9
+ div.innerHTML = html
10
+ generated = div.firstChild
11
+ if (style)
12
+ setStyle(generated, style)
13
+ return generated
14
+ }
15
+ function removeElement(element) {
16
+ element.outerHTML = ''
17
+ }
18
+ function appendToBody(element) {
19
+ document.body.appendChild(element)
20
+ }
21
+ function setStyle(element, properties) {
22
+ Object.assign(element.style, properties)
23
+ }
24
+
25
+ function defaultsFor(options, defaultOptions) {
26
+ return Object.assign(defaultOptions, options)
27
+ }
28
+
29
+
30
+ // Constructs a Popup object.
31
+ // Options: width, padding
32
+ function PopupClass(html, options) {
33
+ this.options = defaultsFor(options, {width: 600})
34
+
35
+ this.popupWindow = createElement('<div class="popup">' + html + '</div>')
36
+
37
+ actualWidth = Math.min(window.innerWidth, this.options.width)
38
+ setStyle(this.popupWindow, {
39
+ 'width': actualWidth.toString() + 'px',
40
+ 'margin-left': (actualWidth/2 * -1).toString() + 'px',
41
+ 'padding': this.options.padding
42
+ })
43
+
44
+ this.createBackdrop()
45
+ }
46
+
47
+
48
+ PopupClass.prototype.distanceFromTop = function () {
49
+ return (window.innerHeight - this.popupWindow.offsetHeight)/2
50
+ }
51
+ PopupClass.prototype.translate = function (start, finish, callback) {
52
+ if (start)
53
+ this.popupWindow.classList.add(start)
54
+
55
+ popupWindow = this.popupWindow
56
+ setTimeout( // wait for CSS to notice `start` class
57
+ function () { // trigger the CSS animation
58
+ if (isNaN(finish)) {
59
+ setStyle(popupWindow, {top: null}) // discard hard-coded `top` to make way
60
+ popupWindow.classList.add(finish) // for this CSS class' `top`
61
+ }
62
+ else {
63
+ setStyle(popupWindow, {top: finish + 'px'})
64
+ }
65
+ setTimeout( // wait for it to finish
66
+ function () {
67
+ popupWindow.classList.remove(start)
68
+ if (callback)
69
+ callback()
70
+ }, 400)
71
+ }, 1
72
+ )
73
+ }
74
+
75
+
76
+ PopupClass.prototype.createBackdrop = function () {
77
+ this.backdrop = createElement('<div id="popup-backdrop"></div>')
78
+ this.hideByClickOn(this.backdrop)
79
+ appendToBody(this.backdrop)
80
+ }
81
+ PopupClass.prototype.showBackdrop = function () {
82
+ setStyle(this.backdrop, {visibility: 'visible', opacity: 0.5})
83
+ }
84
+ PopupClass.prototype.hideBackdrop = function () {
85
+ backdrop = this.backdrop
86
+ setStyle(backdrop, {opacity: 0})
87
+ setTimeout(function () {
88
+ setStyle(backdrop, {visibility: 'hidden'})
89
+ }, 400)
90
+ }
91
+
92
+ PopupClass.prototype.createCloseButton = function () {
93
+ closeButton = createElement('<div class="closeButton"></div>')
94
+ margin = this.options.closeButtonPadding || this.options.padding || '16px'
95
+ setStyle(closeButton, {top: margin, right: margin})
96
+
97
+ this.hideByClickOn(closeButton)
98
+ this.popupWindow.appendChild(closeButton)
99
+ }
100
+ PopupClass.prototype.hideByClickOn = function (element) {
101
+ thisObject = this
102
+ element.onclick = function () {
103
+ thisObject.hide('down')
104
+ }
105
+ }
106
+
107
+
108
+ // Slides the popup onto the screen.
109
+ // Options: backdrop, closeButton, callback
110
+ PopupClass.prototype.show = function (direction, options) {
111
+ options = defaultsFor(options, {backdrop: true, closeButton: true})
112
+
113
+ appendToBody(this.popupWindow)
114
+ start = direction == 'up' ? 'below-screen' : 'above-screen'
115
+ this.translate(start, this.distanceFromTop(), options.callback)
116
+
117
+ if (options.backdrop)
118
+ this.showBackdrop()
119
+ if (options.closeButton)
120
+ this.createCloseButton()
121
+ return this
122
+ }
123
+
124
+
125
+ // Slides the popup out of the screen.
126
+ // Accepts no options.
127
+ PopupClass.prototype.hide = function (direction) {
128
+ popupWindow = this.popupWindow
129
+
130
+ finish = direction == 'up' ? 'above-screen' : 'below-screen'
131
+ this.translate(null, finish, function () {
132
+ removeElement(popupWindow)
133
+ })
134
+
135
+ this.hideBackdrop()
136
+ }
137
+
138
+
139
+ })(window)
@@ -12,6 +12,6 @@ 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.4.4"
15
+ gem.version = "1.4.5"
16
16
  gem.license = 'MIT'
17
17
  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.4.4
4
+ version: 1.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Khamets