├── .editorconfig
├── .gitignore
├── LICENSE
├── dist
├── spop.css
├── spop.js
├── spop.min.css
├── spop.min.js
└── spop.scss
├── gulpfile.js
├── index.html
├── package.json
├── readme.md
└── src
├── _normalize.scss
├── _prism.scss
├── _variables.scss
├── favicon.ico
├── index.jade
├── prism.js
├── scripts.js
├── scripts.min.js
├── styles.min.css
└── styles.scss
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 | root = true
3 |
4 | [*]
5 | indent_style = tab
6 | indent_size = 2
7 | end_of_line = lf
8 | charset = utf-8
9 | trim_trailing_whitespace = true
10 | insert_final_newline = true
11 |
12 | [*.{css,scss,js,jade}]
13 | indent_size = 4
14 |
15 | [*.{md,jade}]
16 | trim_trailing_whitespace = false
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | lib-cov
2 | *.cache
3 | *.seed
4 | *.log
5 | *.csv
6 | *.dat
7 | *.out
8 | *.pid
9 | *.gz
10 | *.bak
11 | *.tmp
12 |
13 | pids
14 | logs
15 | results
16 |
17 | .sass-cache
18 | *.css.map
19 |
20 | npm-debug.log
21 | node_modules
22 |
23 | # Sublime Text
24 | *.sublime-workspace
25 | *.sublime-project
26 | sftp-config.json
27 |
28 | # Windows image file caches
29 | Thumbs.db
30 | ehthumbs.db
31 |
32 | # Folder config file
33 | Desktop.ini
34 |
35 | # Windows shortcuts
36 | *.lnk
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Sílvio Rosa
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/dist/spop.css:
--------------------------------------------------------------------------------
1 | @charset "UTF-8";
2 | /*!
3 | * smallPop 0.1.2 | https://github.com/silvio-r/spop
4 | * Copyright (c) 2015 Sílvio Rosa @silvior_
5 | * MIT license
6 | */
7 | .spop-container {
8 | z-index: 2000;
9 | position: fixed; }
10 | .spop-container,
11 | .spop-container *,
12 | .spop-container *:after,
13 | .spop-container *:before {
14 | box-sizing: border-box; }
15 |
16 | .spop--top-left {
17 | top: 0;
18 | left: 0; }
19 | .spop--top-left .spop {
20 | -webkit-transform-origin: 0 0;
21 | -ms-transform-origin: 0 0;
22 | transform-origin: 0 0; }
23 |
24 | .spop--top-center {
25 | top: 0;
26 | left: 50%;
27 | -webkit-transform: translateX(-50%);
28 | -ms-transform: translateX(-50%);
29 | transform: translateX(-50%); }
30 | .spop--top-center .spop {
31 | -webkit-transform-origin: 50% 0;
32 | -ms-transform-origin: 50% 0;
33 | transform-origin: 50% 0; }
34 |
35 | .spop--top-right {
36 | top: 0;
37 | right: 0; }
38 | .spop--top-right .spop {
39 | -webkit-transform-origin: 100% 0;
40 | -ms-transform-origin: 100% 0;
41 | transform-origin: 100% 0; }
42 |
43 | .spop--center {
44 | top: 50%;
45 | left: 50%;
46 | -webkit-transform: translate3d(-50%, -50%, 0);
47 | transform: translate3d(-50%, -50%, 0); }
48 | .spop--center .spop {
49 | -webkit-transform-origin: 50% 0;
50 | -ms-transform-origin: 50% 0;
51 | transform-origin: 50% 0; }
52 |
53 | .spop--bottom-left {
54 | bottom: 0;
55 | left: 0; }
56 | .spop--bottom-left .spop {
57 | -webkit-transform-origin: 0 100%;
58 | -ms-transform-origin: 0 100%;
59 | transform-origin: 0 100%; }
60 |
61 | .spop--bottom-center {
62 | bottom: 0;
63 | left: 50%;
64 | -webkit-transform: translateX(-50%);
65 | -ms-transform: translateX(-50%);
66 | transform: translateX(-50%); }
67 | .spop--bottom-center .spop {
68 | -webkit-transform-origin: 50% 100%;
69 | -ms-transform-origin: 50% 100%;
70 | transform-origin: 50% 100%; }
71 |
72 | .spop--bottom-right {
73 | bottom: 0;
74 | right: 0; }
75 | .spop--bottom-right .spop {
76 | -webkit-transform-origin: 100% 100%;
77 | -ms-transform-origin: 100% 100%;
78 | transform-origin: 100% 100%; }
79 |
80 | @media screen and (max-width: 30em) {
81 | .spop--top-left,
82 | .spop--top-center,
83 | .spop--top-right,
84 | .spop--bottom-left,
85 | .spop--bottom-center,
86 | .spop--bottom-right {
87 | top: auto;
88 | bottom: 0;
89 | left: 0;
90 | right: 0;
91 | margin-left: 0;
92 | -webkit-transform: translateX(0);
93 | -ms-transform: translateX(0);
94 | transform: translateX(0); }
95 | .spop--top-left .spop,
96 | .spop--top-center .spop,
97 | .spop--top-right .spop,
98 | .spop--bottom-left .spop,
99 | .spop--bottom-center .spop,
100 | .spop--bottom-right .spop {
101 | -webkit-transform-origin: 50% 100%;
102 | -ms-transform-origin: 50% 100%;
103 | transform-origin: 50% 100%; }
104 | .spop {
105 | border-bottom: 1px solid rgba(0, 0, 0, 0.15); } }
106 |
107 | .spop {
108 | position: relative;
109 | min-height: 56px;
110 | line-height: 1.25;
111 | font-size: 14px;
112 | -webkit-transform: translateZ(0);
113 | transform: translateZ(0); }
114 | @media screen and (min-width: 30em) {
115 | .spop {
116 | border-radius: 2px;
117 | width: 320px;
118 | margin: 0.7em; } }
119 |
120 | .spop--info,
121 | .spop--error,
122 | .spop--warning,
123 | .spop--success {
124 | color: #fff;
125 | background-color: #454A56; }
126 |
127 | @-webkit-keyframes spopIn {
128 | 0% {
129 | -webkit-transform: scale(0.2, 0.2);
130 | transform: scale(0.2, 0.2); }
131 | 95% {
132 | -webkit-transform: scale(1.1, 1.1);
133 | transform: scale(1.1, 1.1); }
134 | 100% {
135 | -webkit-transform: scale(1, 1);
136 | transform: scale(1, 1); } }
137 |
138 | @keyframes spopIn {
139 | 0% {
140 | -webkit-transform: scale(0.2, 0.2);
141 | transform: scale(0.2, 0.2); }
142 | 95% {
143 | -webkit-transform: scale(1.1, 1.1);
144 | transform: scale(1.1, 1.1); }
145 | 100% {
146 | -webkit-transform: scale(1, 1);
147 | transform: scale(1, 1); } }
148 |
149 | @-webkit-keyframes spopOut {
150 | 0% {
151 | opacity: 1;
152 | -webkit-transform: scale(1, 1);
153 | transform: scale(1, 1); }
154 | 20% {
155 | -webkit-transform: scale(1.1, 1.1);
156 | transform: scale(1.1, 1.1); }
157 | 100% {
158 | opacity: 0;
159 | -webkit-transform: scale(0, 0);
160 | transform: scale(0, 0); } }
161 |
162 | @keyframes spopOut {
163 | 0% {
164 | opacity: 1;
165 | -webkit-transform: scale(1, 1);
166 | transform: scale(1, 1); }
167 | 20% {
168 | -webkit-transform: scale(1.1, 1.1);
169 | transform: scale(1.1, 1.1); }
170 | 100% {
171 | opacity: 0;
172 | -webkit-transform: scale(0, 0);
173 | transform: scale(0, 0); } }
174 |
175 | .spop--out {
176 | -webkit-animation: spopOut 0.4s ease-in-out;
177 | animation: spopOut 0.4s ease-in-out; }
178 |
179 | .spop--in {
180 | -webkit-animation: spopIn 0.4s ease-in-out;
181 | animation: spopIn 0.4s ease-in-out; }
182 |
183 | .spop-body {
184 | padding: 1.4em; }
185 | .spop-body p {
186 | margin: 0; }
187 | .spop-body a {
188 | color: #fff;
189 | text-decoration: underline; }
190 | .spop-body a:hover {
191 | color: rgba(255, 255, 255, 0.8);
192 | text-decoration: none; }
193 |
194 | .spop-title {
195 | margin-top: 0;
196 | margin-bottom: 0.25em;
197 | color: #fff; }
198 |
199 | .spop-close {
200 | position: absolute;
201 | right: 0;
202 | top: 0;
203 | height: 32px;
204 | width: 32px;
205 | padding-top: 7px;
206 | padding-right: 7px;
207 | font-size: 22px;
208 | font-weight: bold;
209 | text-align: right;
210 | line-height: 0.6;
211 | color: #fff;
212 | opacity: 0.5; }
213 | .spop-close:hover {
214 | opacity: 0.7;
215 | cursor: pointer; }
216 |
217 | .spop-icon {
218 | position: absolute;
219 | top: 13px;
220 | left: 16px;
221 | width: 30px;
222 | height: 30px;
223 | border-radius: 50%;
224 | -webkit-animation: spopIn 0.4s 0.4s ease-in-out;
225 | animation: spopIn 0.4s 0.4s ease-in-out; }
226 | .spop-icon:after,
227 | .spop-icon:before {
228 | content: "";
229 | position: absolute;
230 | display: block; }
231 | .spop-icon + .spop-body {
232 | padding-left: 4.2em; }
233 |
234 | .spop-icon--error,
235 | .spop-icon--info {
236 | border: 2px solid #3a95ed; }
237 | .spop-icon--error:before,
238 | .spop-icon--info:before {
239 | top: 5px;
240 | left: 11px;
241 | width: 4px;
242 | height: 4px;
243 | background-color: #3a95ed; }
244 | .spop-icon--error:after,
245 | .spop-icon--info:after {
246 | top: 12px;
247 | left: 11px;
248 | width: 4px;
249 | height: 9px;
250 | background-color: #3a95ed; }
251 |
252 | .spop-icon--error {
253 | border-color: #ff5656; }
254 | .spop-icon--error:before {
255 | top: 16px;
256 | background-color: #ff5656; }
257 | .spop-icon--error:after {
258 | top: 5px;
259 | background-color: #ff5656; }
260 |
261 | .spop-icon--success {
262 | border: 2px solid #2ecc54; }
263 | .spop-icon--success:before {
264 | top: 7px;
265 | left: 7px;
266 | width: 13px;
267 | height: 8px;
268 | border-bottom: 3px solid #2ecc54;
269 | border-left: 3px solid #2ecc54;
270 | -webkit-transform: rotate(-45deg);
271 | -ms-transform: rotate(-45deg);
272 | transform: rotate(-45deg); }
273 |
274 | .spop-icon--warning {
275 | border: 2px solid #fcd000; }
276 | .spop-icon--warning:before {
277 | top: 7px;
278 | left: 7px;
279 | width: 0;
280 | height: 0;
281 | border-style: solid;
282 | border-color: transparent transparent #fcd000 transparent;
283 | border-width: 0 6px 10px 6px; }
284 |
--------------------------------------------------------------------------------
/dist/spop.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * smallPop 0.1.2 | https://github.com/silvio-r/spop
3 | * Copyright (c) 2015 Sílvio Rosa @silvior_
4 | * MIT license
5 | */
6 |
7 | ;(function() {
8 | 'use strict';
9 |
10 | var animationTime = 390;
11 | var options, defaults, container, icon, layout, popStyle, positions, close;
12 |
13 | var SmallPop = function(template, style) {
14 |
15 | this.defaults = {
16 | template : null,
17 | style : 'info',
18 | autoclose : false,
19 | position : 'top-right',
20 | icon : true,
21 | group : false,
22 | onOpen : false,
23 | onClose : false
24 | };
25 |
26 | defaults = extend(this.defaults, spop.defaults);
27 |
28 | if ( typeof template === 'string' || typeof style === 'string' ) {
29 | options = { template: template, style: style || defaults.style};
30 | }
31 | else if (typeof template === 'object') {
32 | options = template;
33 | }
34 | else {
35 | console.error('Invalid arguments.');
36 | return false;
37 | }
38 |
39 | this.opt = extend( defaults, options);
40 |
41 | if ($('spop--' + this.opt.group)) {
42 |
43 | this.remove($('spop--' + this.opt.group));
44 | }
45 |
46 | this.open();
47 | };
48 |
49 | SmallPop.prototype.create = function(template) {
50 |
51 | container = $(this.getPosition('spop--', this.opt.position));
52 |
53 | icon = (!this.opt.icon) ? '' : '';
55 |
56 | layout ='
×
' +
57 | icon +
58 | '' +
59 | template +
60 | '
';
61 |
62 | if (!container) {
63 |
64 | this.popContainer = document.createElement('div');
65 |
66 | this.popContainer.setAttribute('class', 'spop-container ' +
67 | this.getPosition('spop--', this.opt.position));
68 |
69 | this.popContainer.setAttribute('id', this.getPosition('spop--', this.opt.position));
70 |
71 | document.body.appendChild(this.popContainer);
72 |
73 | container = $(this.getPosition('spop--', this.opt.position));
74 | }
75 |
76 | this.pop = document.createElement('div');
77 |
78 | this.pop.setAttribute('class', 'spop spop--out spop--in ' + this.getStyle('spop--', this.opt.style) );
79 |
80 | if (this.opt.group && typeof this.opt.group === 'string') {
81 | this.pop.setAttribute('id', 'spop--' + this.opt.group);
82 | }
83 |
84 |
85 | this.pop.setAttribute('role', 'alert');
86 |
87 | this.pop.innerHTML = layout;
88 |
89 | container.appendChild(this.pop);
90 | };
91 |
92 | SmallPop.prototype.getStyle = function(sufix, arg) {
93 |
94 | popStyle = {
95 | 'success': 'success',
96 | 'error' : 'error',
97 | 'warning': 'warning'
98 | };
99 | return sufix + (popStyle[arg] || 'info');
100 | };
101 |
102 | SmallPop.prototype.getPosition = function(sufix, position) {
103 |
104 | positions = {
105 | 'top-left' : 'top-left',
106 | 'top-center' : 'top-center',
107 | 'top-right' : 'top-right',
108 | 'bottom-left' : 'bottom-left',
109 | 'bottom-center': 'bottom-center',
110 | 'bottom-right' : 'bottom-right'
111 | };
112 | return sufix + (positions[position] || 'top-right');
113 | };
114 |
115 | SmallPop.prototype.open = function() {
116 |
117 | this.create(this.opt.template);
118 |
119 | if (this.opt.onOpen) { this.opt.onOpen();}
120 |
121 | this.close();
122 | };
123 |
124 | SmallPop.prototype.close = function () {
125 |
126 | if (this.opt.autoclose && typeof this.opt.autoclose === 'number') {
127 |
128 | this.autocloseTimer = setTimeout( this.remove.bind(this, this.pop), this.opt.autoclose);
129 | }
130 |
131 | this.pop.addEventListener('click', this.addListeners.bind(this) , false);
132 | };
133 |
134 | SmallPop.prototype.addListeners = function(event) {
135 |
136 | close = event.target.getAttribute('data-spop');
137 |
138 | if (close === 'close') {
139 |
140 | if (this.autocloseTimer) { clearTimeout(this.autocloseTimer);}
141 |
142 | this.remove(this.pop);
143 | }
144 | };
145 |
146 | SmallPop.prototype.remove = function(elm) {
147 |
148 | if (this.opt.onClose) { this.opt.onClose();}
149 |
150 | removeClass(elm, 'spop--in');
151 |
152 | setTimeout( function () {
153 |
154 | if(document.body.contains(elm)) {
155 | elm.parentNode.removeChild(elm);
156 | }
157 |
158 | }, animationTime);
159 | };
160 |
161 |
162 | // Helpers
163 |
164 | function $(el, con) {
165 | return typeof el === 'string'? (con || document).getElementById(el) : el || null;
166 | }
167 |
168 | function removeClass(el, className) {
169 | if (el.classList) {
170 | el.classList.remove(className);
171 | }
172 | else {
173 | el.className = el.className.replace(new RegExp('(^|\\b)' +
174 | className.split(' ').join('|') +
175 | '(\\b|$)', 'gi'), ' ');
176 | }
177 | }
178 |
179 | function extend(obj, src) {
180 |
181 | for (var key in src) {
182 | if (src.hasOwnProperty(key)) obj[key] = src[key];
183 | }
184 |
185 | return obj;
186 | }
187 |
188 | window.spop = function (template, style) {
189 | if ( !template || !window.addEventListener ) { return false;}
190 |
191 | return new SmallPop(template, style);
192 | };
193 |
194 | spop.defaults = {};
195 | }());
196 |
--------------------------------------------------------------------------------
/dist/spop.min.css:
--------------------------------------------------------------------------------
1 | @charset "UTF-8";/*!
2 | * smallPop 0.1.2 | https://github.com/silvio-r/spop
3 | * Copyright (c) 2015 Sílvio Rosa @silvior_
4 | * MIT license
5 | */.spop-container{z-index:2000;position:fixed}.spop-container,.spop-container *,.spop-container :after,.spop-container :before{box-sizing:border-box}.spop--top-left{top:0;left:0}.spop--top-left .spop{-webkit-transform-origin:0 0;-ms-transform-origin:0 0;transform-origin:0 0}.spop--top-center{top:0;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%)}.spop--top-center .spop{-webkit-transform-origin:50% 0;-ms-transform-origin:50% 0;transform-origin:50% 0}.spop--top-right{top:0;right:0}.spop--top-right .spop{-webkit-transform-origin:100% 0;-ms-transform-origin:100% 0;transform-origin:100% 0}.spop--center{top:50%;left:50%;-webkit-transform:translate3d(-50%,-50%,0);transform:translate3d(-50%,-50%,0)}.spop--center .spop{-webkit-transform-origin:50% 0;-ms-transform-origin:50% 0;transform-origin:50% 0}.spop--bottom-left{bottom:0;left:0}.spop--bottom-left .spop{-webkit-transform-origin:0 100%;-ms-transform-origin:0 100%;transform-origin:0 100%}.spop--bottom-center{bottom:0;left:50%;-webkit-transform:translateX(-50%);-ms-transform:translateX(-50%);transform:translateX(-50%)}.spop--bottom-center .spop{-webkit-transform-origin:50% 100%;-ms-transform-origin:50% 100%;transform-origin:50% 100%}.spop--bottom-right{bottom:0;right:0}.spop--bottom-right .spop{-webkit-transform-origin:100% 100%;-ms-transform-origin:100% 100%;transform-origin:100% 100%}@media screen and (max-width:30em){.spop--bottom-center,.spop--bottom-left,.spop--bottom-right,.spop--top-center,.spop--top-left,.spop--top-right{top:auto;bottom:0;left:0;right:0;margin-left:0;-webkit-transform:translateX(0);-ms-transform:translateX(0);transform:translateX(0)}.spop--bottom-center .spop,.spop--bottom-left .spop,.spop--bottom-right .spop,.spop--top-center .spop,.spop--top-left .spop,.spop--top-right .spop{-webkit-transform-origin:50% 100%;-ms-transform-origin:50% 100%;transform-origin:50% 100%}.spop{border-bottom:1px solid rgba(0,0,0,.15)}}.spop{position:relative;min-height:56px;line-height:1.25;font-size:14px;-webkit-transform:translateZ(0);transform:translateZ(0)}@media screen and (min-width:30em){.spop{border-radius:2px;width:320px;margin:.7em}}.spop--error,.spop--info,.spop--success,.spop--warning{color:#fff;background-color:#454A56}@-webkit-keyframes spopIn{0%{-webkit-transform:scale(.2,.2);transform:scale(.2,.2)}95%{-webkit-transform:scale(1.1,1.1);transform:scale(1.1,1.1)}100%{-webkit-transform:scale(1,1);transform:scale(1,1)}}@keyframes spopIn{0%{-webkit-transform:scale(.2,.2);transform:scale(.2,.2)}95%{-webkit-transform:scale(1.1,1.1);transform:scale(1.1,1.1)}100%{-webkit-transform:scale(1,1);transform:scale(1,1)}}@-webkit-keyframes spopOut{0%{opacity:1;-webkit-transform:scale(1,1);transform:scale(1,1)}20%{-webkit-transform:scale(1.1,1.1);transform:scale(1.1,1.1)}100%{opacity:0;-webkit-transform:scale(0,0);transform:scale(0,0)}}@keyframes spopOut{0%{opacity:1;-webkit-transform:scale(1,1);transform:scale(1,1)}20%{-webkit-transform:scale(1.1,1.1);transform:scale(1.1,1.1)}100%{opacity:0;-webkit-transform:scale(0,0);transform:scale(0,0)}}.spop--out{-webkit-animation:spopOut .4s ease-in-out;animation:spopOut .4s ease-in-out}.spop--in{-webkit-animation:spopIn .4s ease-in-out;animation:spopIn .4s ease-in-out}.spop-body{padding:1.4em}.spop-body p{margin:0}.spop-body a{color:#fff;text-decoration:underline}.spop-body a:hover{color:rgba(255,255,255,.8);text-decoration:none}.spop-title{margin-top:0;margin-bottom:.25em;color:#fff}.spop-close{position:absolute;right:0;top:0;height:32px;width:32px;padding-top:7px;padding-right:7px;font-size:22px;font-weight:700;text-align:right;line-height:.6;color:#fff;opacity:.5}.spop-close:hover{opacity:.7;cursor:pointer}.spop-icon{position:absolute;top:13px;left:16px;width:30px;height:30px;border-radius:50%;-webkit-animation:spopIn .4s .4s ease-in-out;animation:spopIn .4s .4s ease-in-out}.spop-icon:after,.spop-icon:before{content:"";position:absolute;display:block}.spop-icon+.spop-body{padding-left:4.2em}.spop-icon--error,.spop-icon--info{border:2px solid #3a95ed}.spop-icon--error:before,.spop-icon--info:before{top:5px;left:11px;width:4px;height:4px;background-color:#3a95ed}.spop-icon--error:after,.spop-icon--info:after{top:12px;left:11px;width:4px;height:9px;background-color:#3a95ed}.spop-icon--error{border-color:#ff5656}.spop-icon--error:before{top:16px;background-color:#ff5656}.spop-icon--error:after{top:5px;background-color:#ff5656}.spop-icon--success{border:2px solid #2ecc54}.spop-icon--success:before{top:7px;left:7px;width:13px;height:8px;border-bottom:3px solid #2ecc54;border-left:3px solid #2ecc54;-webkit-transform:rotate(-45deg);-ms-transform:rotate(-45deg);transform:rotate(-45deg)}.spop-icon--warning{border:2px solid #fcd000}.spop-icon--warning:before{top:7px;left:7px;width:0;height:0;border-style:solid;border-color:transparent transparent #fcd000;border-width:0 6px 10px}
--------------------------------------------------------------------------------
/dist/spop.min.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * smallPop 0.1.2 | https://github.com/silvio-r/spop
3 | * Copyright (c) 2015 Sílvio Rosa @silvior_
4 | * MIT license
5 | */
6 | !function(){"use strict";function t(t,o){return"string"==typeof t?(o||document).getElementById(t):t||null}function o(t,o){t.classList?t.classList.remove(o):t.className=t.className.replace(new RegExp("(^|\\b)"+o.split(" ").join("|")+"(\\b|$)","gi")," ")}function e(t,o){for(var e in o)o.hasOwnProperty(e)&&(t[e]=o[e]);return t}var s,i,p,n,r,c,l,h,a=390,u=function(o,p){if(this.defaults={template:null,style:"info",autoclose:!1,position:"top-right",icon:!0,group:!1,onOpen:!1,onClose:!1},i=e(this.defaults,spop.defaults),"string"==typeof o||"string"==typeof p)s={template:o,style:p||i.style};else{if("object"!=typeof o)return console.error("Invalid arguments."),!1;s=o}this.opt=e(i,s),t("spop--"+this.opt.group)&&this.remove(t("spop--"+this.opt.group)),this.open()};u.prototype.create=function(o){p=t(this.getPosition("spop--",this.opt.position)),n=this.opt.icon?'':"",r='×
'+n+''+o+"
",p||(this.popContainer=document.createElement("div"),this.popContainer.setAttribute("class","spop-container "+this.getPosition("spop--",this.opt.position)),this.popContainer.setAttribute("id",this.getPosition("spop--",this.opt.position)),document.body.appendChild(this.popContainer),p=t(this.getPosition("spop--",this.opt.position))),this.pop=document.createElement("div"),this.pop.setAttribute("class","spop spop--out spop--in "+this.getStyle("spop--",this.opt.style)),this.opt.group&&"string"==typeof this.opt.group&&this.pop.setAttribute("id","spop--"+this.opt.group),this.pop.setAttribute("role","alert"),this.pop.innerHTML=r,p.appendChild(this.pop)},u.prototype.getStyle=function(t,o){return c={success:"success",error:"error",warning:"warning"},t+(c[o]||"info")},u.prototype.getPosition=function(t,o){return l={"top-left":"top-left","top-center":"top-center","top-right":"top-right","bottom-left":"bottom-left","bottom-center":"bottom-center","bottom-right":"bottom-right"},t+(l[o]||"top-right")},u.prototype.open=function(){this.create(this.opt.template),this.opt.onOpen&&this.opt.onOpen(),this.close()},u.prototype.close=function(){this.opt.autoclose&&"number"==typeof this.opt.autoclose&&(this.autocloseTimer=setTimeout(this.remove.bind(this,this.pop),this.opt.autoclose)),this.pop.addEventListener("click",this.addListeners.bind(this),!1)},u.prototype.addListeners=function(t){h=t.target.getAttribute("data-spop"),"close"===h&&(this.autocloseTimer&&clearTimeout(this.autocloseTimer),this.remove(this.pop))},u.prototype.remove=function(t){this.opt.onClose&&this.opt.onClose(),o(t,"spop--in"),setTimeout(function(){document.body.contains(t)&&t.parentNode.removeChild(t)},a)},window.spop=function(t,o){return t&&window.addEventListener?new u(t,o):!1},spop.defaults={}}();
--------------------------------------------------------------------------------
/dist/spop.scss:
--------------------------------------------------------------------------------
1 | /*!
2 | * smallPop 0.1.2 | https://github.com/silvio-r/spop
3 | * Copyright (c) 2015 Sílvio Rosa @silvior_
4 | * MIT license
5 | */
6 |
7 | $spop-bg-color: #454A56 !default;
8 | $spop-color: #fff !default;
9 |
10 | $spop-info-bg: $spop-bg-color !default;
11 | $spop-info-color: #3a95ed !default;
12 |
13 | $spop-error-bg: $spop-bg-color !default;
14 | $spop-error-color: #ff5656 !default;
15 |
16 | $spop-success-bg: $spop-bg-color !default;
17 | $spop-success-color: #2ecc54 !default;
18 |
19 | $spop-warning-bg: $spop-bg-color !default;
20 | $spop-warning-color: #fcd000 !default;
21 |
22 | $spop-title-color: #fff !default;
23 | $spop-link-color: $spop-title-color !default;
24 |
25 | $spop-width: 320px !default;
26 | $spop-font-size-base: 14px;
27 | $spop-space: 0.7em !default;
28 |
29 | $spop-animation-duration: 0.4s !default;
30 |
31 | $use-box-shadow: false !default;
32 | $box-shadow: 0 0 6px 2px rgba( #000, 0.25) !default;
33 |
34 | $use-border-radius: true !default;
35 | $border-radius: 2px !default;
36 |
37 | $use-icon: true;
38 |
39 | .spop-container {
40 | z-index: 2000;
41 | position: fixed;
42 |
43 | &,
44 | *,
45 | *:after,
46 | *:before { box-sizing: border-box;}
47 | }
48 |
49 | .spop--top-left {
50 | top: 0;
51 | left: 0;
52 | .spop { transform-origin: 0 0;}
53 | }
54 | .spop--top-center {
55 | top: 0;
56 | left: 50%;
57 | transform: translateX(-50%);
58 | .spop { transform-origin: 50% 0;}
59 | }
60 | .spop--top-right {
61 | top: 0;
62 | right: 0;
63 | .spop { transform-origin: 100% 0;}
64 | }
65 |
66 |
67 | .spop--center {
68 | top: 50%;
69 | left: 50%;
70 | transform: translate3d(-50%, -50%, 0);
71 | .spop { transform-origin: 50% 0;}
72 | }
73 |
74 |
75 | .spop--bottom-left {
76 | bottom: 0;
77 | left: 0;
78 | .spop {transform-origin: 0 100%;}
79 | }
80 | .spop--bottom-center {
81 | bottom: 0;
82 | left: 50%;
83 | transform: translateX(-50%);
84 | .spop { transform-origin: 50% 100%;}
85 | }
86 | .spop--bottom-right {
87 | bottom: 0;
88 | right: 0;
89 | .spop { transform-origin: 100% 100%;}
90 | }
91 |
92 |
93 | @media screen and (max-width:30em) {
94 | .spop--top-left,
95 | .spop--top-center,
96 | .spop--top-right,
97 | .spop--bottom-left,
98 | .spop--bottom-center,
99 | .spop--bottom-right {
100 | top: auto;
101 | bottom: 0;
102 | left: 0;
103 | right: 0;
104 | margin-left: 0;
105 | transform: translateX(0);
106 | .spop { transform-origin: 50% 100%;}
107 | }
108 |
109 | .spop { border-bottom: 1px solid rgba(#000,0.15);}
110 | }
111 |
112 | .spop {
113 | position: relative;
114 | min-height: 56px;
115 | line-height: 1.25;
116 | font-size: $spop-font-size-base;
117 | transform: translateZ(0);
118 |
119 |
120 | @if $use-box-shadow == true {
121 | box-shadow: $box-shadow;
122 | }
123 |
124 | @media screen and (min-width:30em) {
125 | @if $use-border-radius == true {
126 | border-radius: $border-radius;
127 | }
128 |
129 | width: $spop-width;
130 | margin: $spop-space;
131 | }
132 | }
133 |
134 | .spop--info,
135 | .spop--error,
136 | .spop--warning,
137 | .spop--success { color: $spop-color; background-color: $spop-bg-color;}
138 |
139 | @keyframes spopIn {
140 | 0% { transform: scale(0.2,0.2);}
141 | 95% { transform: scale(1.1,1.1);}
142 | 100% { transform: scale(1,1);}
143 | }
144 | @keyframes spopOut {
145 | 0% { opacity: 1; transform: scale(1,1);}
146 | 20% { transform: scale(1.1,1.1);}
147 | 100% { opacity: 0; transform: scale(0,0);}
148 | }
149 |
150 | .spop--out {
151 | animation: spopOut $spop-animation-duration ease-in-out;
152 | }
153 |
154 | .spop--in {
155 | animation: spopIn $spop-animation-duration ease-in-out;
156 | }
157 |
158 | .spop-body {
159 | padding: ($spop-space * 2);
160 | p { margin: 0;}
161 |
162 | a {
163 | color: $spop-link-color;
164 | text-decoration: underline;
165 |
166 | &:hover {
167 | color: rgba($spop-link-color, 0.8);
168 | text-decoration: none;
169 | }
170 | }
171 | }
172 |
173 | .spop-title {
174 | margin-top: 0;
175 | margin-bottom: 0.25em;
176 | color: $spop-title-color;
177 | }
178 |
179 | .spop-close {
180 | position: absolute;
181 | right: 0;
182 | top: 0;
183 | height: 32px;
184 | width: 32px;
185 | padding-top: 7px;
186 | padding-right: 7px;
187 | font-size: 22px;
188 | font-weight: bold;
189 | text-align: right;
190 | line-height: 0.6;
191 | color: $spop-color;
192 | opacity: 0.5;
193 |
194 | &:hover {
195 | opacity: 0.7;
196 | cursor: pointer;
197 | }
198 | }
199 |
200 | @if $use-icon == true {
201 | .spop-icon {
202 | position: absolute;
203 | top: 13px;
204 | left: 16px;
205 | width: 30px;
206 | height: 30px;
207 | border-radius: 50%;
208 | animation: spopIn $spop-animation-duration $spop-animation-duration ease-in-out;
209 | &:after,
210 | &:before {
211 | content:"";
212 | position: absolute;
213 | display: block;
214 | }
215 |
216 | & + .spop-body { padding-left: ($spop-space * 6);}
217 | }
218 |
219 | .spop-icon--error,
220 | .spop-icon--info {
221 | border: 2px solid $spop-info-color;
222 | &:before {
223 | top: 5px;
224 | left: 11px;
225 | width: 4px;
226 | height: 4px;
227 | background-color:$spop-info-color;
228 | }
229 | &:after {
230 | top: 12px;
231 | left: 11px;
232 | width: 4px;
233 | height: 9px;
234 | background-color:$spop-info-color;
235 | }
236 | }
237 |
238 | .spop-icon--error {
239 | border-color: $spop-error-color;
240 | &:before {
241 | top: 16px;
242 | background-color:$spop-error-color;
243 | }
244 | &:after {
245 | top: 5px;
246 | background-color:$spop-error-color;
247 | }
248 | }
249 |
250 | .spop-icon--success {
251 | border: 2px solid $spop-success-color;
252 | &:before {
253 | top: 7px;
254 | left: 7px;
255 | width: 13px;
256 | height: 8px;
257 | border-bottom: 3px solid $spop-success-color;
258 | border-left: 3px solid $spop-success-color;
259 | transform: rotate(-45deg);
260 | }
261 | }
262 |
263 | .spop-icon--warning {
264 | border: 2px solid $spop-warning-color;
265 | &:before {
266 | top: 7px;
267 | left: 7px;
268 | width: 0;
269 | height: 0;
270 | border-style: solid;
271 | border-color: transparent transparent $spop-warning-color transparent;
272 | border-width: 0 6px 10px 6px;
273 | }
274 | }
275 | }
276 |
--------------------------------------------------------------------------------
/gulpfile.js:
--------------------------------------------------------------------------------
1 | 'use strict';
2 |
3 | var gulp = require('gulp');
4 | var $ = require('gulp-load-plugins')();
5 | var pac = require('./package.json');
6 |
7 | // SPOP
8 | gulp.task('default', function () {
9 | console.log('Be specific !');
10 | });
11 |
12 | gulp.task('clean', function () {
13 | return gulp.src([
14 | './dist/spop.min.js',
15 | './dist/spop.css',
16 | './dist/spop.min.css'
17 | ], { read: false })
18 | .pipe($.clean());
19 | });
20 |
21 | gulp.task('styles', function () {
22 | gulp.src('./dist/spop.scss')
23 | .pipe($.sass().on('error', $.sass.logError))
24 | .pipe($.autoprefixer('> 1%', 'ie 8'))
25 | .pipe(gulp.dest('./dist/'))
26 | .pipe($.rename({suffix: '.min'}))
27 | .pipe($.cssmin())
28 | .pipe(gulp.dest('./dist/'))
29 | .pipe($.livereload());
30 | });
31 |
32 | gulp.task('scripts', function() {
33 | return gulp.src('./dist/spop.js')
34 | .pipe($.uglify({preserveComments:'some'}))
35 | .pipe($.rename({suffix: '.min'}))
36 | .pipe(gulp.dest('./dist/'))
37 | .pipe($.livereload());
38 | });
39 |
40 | gulp.task('watch', [ 'clean', 'styles', 'scripts'], function () {
41 | $.livereload.listen();
42 |
43 | gulp.watch([
44 | './dist/spop.min.js',
45 | './dist/spop.min.css'
46 | ]).on('change', $.livereload.changed);
47 |
48 | gulp.watch('./dist/spop.js', ['scripts']);
49 | gulp.watch('./dist/spop.scss', ['styles']);
50 | });
51 |
52 |
53 |
54 | // DOCS
55 | gulp.task('cleanDocs', function () {
56 | return gulp.src([
57 | './src/styles.min.css',
58 | './src/scripts.min.js',
59 | './index.html'
60 | ], { read: false })
61 | .pipe($.clean());
62 | });
63 |
64 | gulp.task('stylesDocs', function () {
65 | gulp.src('./src/styles.scss')
66 | .pipe($.sass({sourceComments:true }).on('error', $.sass.logError))
67 | .pipe($.autoprefixer('> 1%', 'ie 9'))
68 | .pipe($.cssmin())
69 | .pipe($.rename({suffix: '.min'}))
70 | .pipe(gulp.dest('./src/'))
71 | .pipe($.livereload());
72 | });
73 |
74 | gulp.task('scriptsDocs', function() {
75 | return gulp.src('./src/scripts.js')
76 | .pipe($.uglify())
77 | .pipe($.rename({suffix: '.min'}))
78 | .pipe(gulp.dest('./src/'))
79 | .pipe($.livereload());
80 | });
81 |
82 | gulp.task('html', function () {
83 | var LOCALS = {
84 | title: pac.name,
85 | description: pac.description,
86 | version: pac.version
87 | };
88 |
89 | gulp.src('./src/index.jade')
90 | .pipe($.jade({
91 | pretty: true,
92 | locals: LOCALS
93 | }))
94 | .pipe(gulp.dest('./'))
95 | .pipe($.livereload());
96 | });
97 |
98 |
99 | gulp.task('watchDocs', [ 'cleanDocs', 'stylesDocs', 'scriptsDocs', 'html'], function () {
100 | $.livereload.listen();
101 |
102 | gulp.watch([
103 | './*.html',
104 | './src/scripts.min.js',
105 | './src/styles.min.css'
106 | ]).on('change', $.livereload.changed);
107 |
108 | gulp.watch(['./src/index.jade', './package.json'], ['html']);
109 | gulp.watch('./src/scripts.js', ['scriptsDocs']);
110 | gulp.watch('./src/*.scss', ['stylesDocs']);
111 | });
112 |
113 |
114 | // ALL
115 | gulp.task('watchAll', ['watch', 'watchDocs']);
116 |
117 |
--------------------------------------------------------------------------------
/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | SmallPop, small pop up javascript plugin
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
21 |
22 |
23 |
24 |
25 |
29 |
30 |
31 |
32 |
Basic
33 |
34 |
Tip: to remove all SmallPop's click the title.
35 |
Include spop.js
and spop.css
in your page,
36 |
37 |
40 |
41 |
49 |
50 |
51 |
52 |
Position
53 |
54 |
SmallPox has six differents positions:
55 |
56 |
57 |
In mobile (max-width:30em), all go down.
58 |
59 |
62 |
63 |
64 |
65 |
66 |
Autoclose
67 |
68 |
Autoclose, to... close... automatically... Woohoo never done before
Autoclose
69 |
70 |
73 |
74 |
75 |
76 |
77 |
Groups
78 |
79 |
There can only be one SmallPop from each group
GroupNo groupGroup
80 |
81 |
84 |
85 |
86 |
87 |
88 |
Callbacks
89 |
90 |
Do what you need onOpen and onClose
Callbacks
91 |
92 |
95 |
96 |
97 |
98 |
99 |
Event
100 |
101 |
In your template you can call the close event, just add data-spop="close"
Launch
102 |
103 |
106 |
107 |
118 |
119 |
120 |
121 |
122 |
Options
123 |
124 |
125 |
126 |
127 |
130 |
131 |
138 |
Go top
139 |
140 |
141 |
142 |
143 |
144 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "SmallPop",
3 | "version": "0.1.3",
4 | "description": "A lightweight small pop up widget with no dependencies",
5 | "author": "Sílvio Rosa",
6 | "main": "./dist/spop.js",
7 | "homepage": "http://silvio-r.github.io/spop/",
8 | "repository": "https://github.com/silvio-r/spop",
9 | "bugs": {
10 | "url": "https://github.com/silvio-r/spop/issues"
11 | },
12 | "license": "MIT",
13 | "keywords": [
14 | "smalpop",
15 | "spop",
16 | "spop.js",
17 | "pop up",
18 | "alert",
19 | "toast",
20 | "notification",
21 | "toast notification",
22 | "javascript plugin"
23 | ],
24 | "devDependencies": {
25 | "gulp": "3.9.0",
26 | "gulp-rename": "1.2.2",
27 | "gulp-load-plugins": "1.0.0-rc.1",
28 | "gulp-uglify": "1.2.0",
29 | "gulp-clean": "0.3.1",
30 | "gulp-cssmin": "0.1.7",
31 | "gulp-autoprefixer": "2.3.1",
32 | "gulp-sass": "2.0.1",
33 | "gulp-livereload": "2.1.1",
34 | "gulp-jade": "1.1.0"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/readme.md:
--------------------------------------------------------------------------------
1 | # SmallPop
2 |
3 | A lightweight small pop up widget with no dependencies, create notifications easily with this javascript plugin.
Playground in [Codepen](http://codepen.io/silvio-r/pen/jWmWXy).
4 |
5 | ## Basic
6 |
7 | Include spop.js and spop.css in your page.
8 |
9 | ```html
10 |
11 |
12 |
13 | ```
14 |
15 | and call it:
16 |
17 | ```javascript
18 | spop('Default SmallPop');
19 |
20 | spop('Success
I´m a success SmallPop', 'success');
21 |
22 | spop('Warning pop', 'warning');
23 |
24 | spop('Error Here!', 'error');
25 | ```
26 |
27 |
28 | ## Position
29 |
30 | SmallPox has six differents positions: top-left, top-center, top-right, bottom-left, bottom-center and bottom-right
31 |
32 | ```javascript
33 | // top left example
34 | spop({
35 | template: 'Position top left',
36 | position : 'top-left',
37 | style: 'success'
38 | });
39 | ```
40 |
41 | In *mobile* (max-width:30em), all go down.
42 |
43 |
44 | ## Autoclose
45 |
46 | Autoclose, to... close... automatically...
47 |
48 | ```javascript
49 | spop({
50 | template: '3 seconds autoclose',
51 | autoclose: 3000
52 | });
53 | ```
54 |
55 |
56 | ## Groups
57 |
58 | There can only be one SmallPop visible from each group.
59 |
60 | ```javascript
61 | spop({
62 | template: 'All fields are required!',
63 | group: 'submit-satus',
64 | style: 'error'
65 | });
66 |
67 | spop({
68 | template: 'Your information has been submitted',
69 | group: 'submit-satus',
70 | style: 'success'
71 | autoclose: 2000
72 | });
73 | ```
74 |
75 | ## Callbacks
76 |
77 | Do what you need onOpen and onClose
78 |
79 | ```javascript
80 | spop({
81 | template: 'Please, close me.',
82 | onOpen: function () {
83 | document.body.style.background = "#fff";
84 | },
85 | onClose: function() {
86 | document.body.style.background = "";
87 | spop({
88 | template: 'Thank you!',
89 | style: 'success',
90 | autoclose: 2000
91 | });
92 | }
93 | });
94 | ```
95 |
96 |
97 | ## Event
98 |
99 | In your template you can call the close event, just add data-spop="close".
100 |
101 | ```javascript
102 | spop('Got to defaults');
103 | ```
104 |
105 |
106 | ## Options
107 |
108 | ```javascript
109 | spop({
110 | template : null,// string required. Without it nothing happens!
111 | style : 'info',// success, warning or error
112 | autoclose : false,// miliseconds
113 | position : 'top-right',// top-left top-center bottom-left bottom-center bottom-right
114 | icon : true,// or false
115 | group : false,// string, add a id reference
116 | onOpen : function() { },
117 | onClose : function() { }
118 | });
119 | ```
120 |
121 |
122 | ### Browser support
123 | Chrome, Firefox, IE 11-10-9 (9 no animations), Android Browser, Chrome for Android, Safari, iOS Safari
124 |
125 | ### License
126 |
127 | MIT License
128 |
129 | ----
130 |
131 | Created by Sílvio Rosa • Follow me on [twitter](https://twitter.com/silvior_) for updates.
132 |
--------------------------------------------------------------------------------
/src/_normalize.scss:
--------------------------------------------------------------------------------
1 | /*! normalize.css v3.0.2 | MIT License | git.io/normalize */
2 |
3 | /**
4 | * 1. Set default font family to sans-serif.
5 | * 2. Prevent iOS text size adjust after orientation change, without disabling
6 | * user zoom.
7 | */
8 |
9 | html {
10 | font-family: sans-serif; /* 1 */
11 | -ms-text-size-adjust: 100%; /* 2 */
12 | -webkit-text-size-adjust: 100%; /* 2 */
13 | }
14 |
15 | /**
16 | * Remove default margin.
17 | */
18 |
19 | body {
20 | margin: 0;
21 | }
22 |
23 | /* HTML5 display definitions
24 | ========================================================================== */
25 |
26 | /**
27 | * Correct `block` display not defined for any HTML5 element in IE 8/9.
28 | * Correct `block` display not defined for `details` or `summary` in IE 10/11
29 | * and Firefox.
30 | * Correct `block` display not defined for `main` in IE 11.
31 | */
32 |
33 | article,
34 | aside,
35 | details,
36 | figcaption,
37 | figure,
38 | footer,
39 | header,
40 | hgroup,
41 | main,
42 | menu,
43 | nav,
44 | section,
45 | summary {
46 | display: block;
47 | }
48 |
49 | /**
50 | * 1. Correct `inline-block` display not defined in IE 8/9.
51 | * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
52 | */
53 |
54 | audio,
55 | canvas,
56 | progress,
57 | video {
58 | display: inline-block; /* 1 */
59 | vertical-align: baseline; /* 2 */
60 | }
61 |
62 | /**
63 | * Prevent modern browsers from displaying `audio` without controls.
64 | * Remove excess height in iOS 5 devices.
65 | */
66 |
67 | audio:not([controls]) {
68 | display: none;
69 | height: 0;
70 | }
71 |
72 | /**
73 | * Address `[hidden]` styling not present in IE 8/9/10.
74 | * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
75 | */
76 |
77 | [hidden],
78 | template {
79 | display: none;
80 | }
81 |
82 | /* Links
83 | ========================================================================== */
84 |
85 | /**
86 | * Remove the gray background color from active links in IE 10.
87 | */
88 |
89 | a {
90 | background-color: transparent;
91 | }
92 |
93 | /**
94 | * Improve readability when focused and also mouse hovered in all browsers.
95 | */
96 |
97 | a:active,
98 | a:hover {
99 | outline: 0;
100 | }
101 |
102 | /* Text-level semantics
103 | ========================================================================== */
104 |
105 | /**
106 | * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
107 | */
108 |
109 | abbr[title] {
110 | border-bottom: 1px dotted;
111 | }
112 |
113 | /**
114 | * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
115 | */
116 |
117 | b,
118 | strong {
119 | font-weight: bold;
120 | }
121 |
122 | /**
123 | * Address styling not present in Safari and Chrome.
124 | */
125 |
126 | dfn {
127 | font-style: italic;
128 | }
129 |
130 | /**
131 | * Address variable `h1` font-size and margin within `section` and `article`
132 | * contexts in Firefox 4+, Safari, and Chrome.
133 | */
134 |
135 | h1 {
136 | font-size: 2em;
137 | margin: 0.67em 0;
138 | }
139 |
140 | /**
141 | * Address styling not present in IE 8/9.
142 | */
143 |
144 | mark {
145 | background: #ff0;
146 | color: #000;
147 | }
148 |
149 | /**
150 | * Address inconsistent and variable font size in all browsers.
151 | */
152 |
153 | small {
154 | font-size: 80%;
155 | }
156 |
157 | /**
158 | * Prevent `sub` and `sup` affecting `line-height` in all browsers.
159 | */
160 |
161 | sub,
162 | sup {
163 | font-size: 75%;
164 | line-height: 0;
165 | position: relative;
166 | vertical-align: baseline;
167 | }
168 |
169 | sup {
170 | top: -0.5em;
171 | }
172 |
173 | sub {
174 | bottom: -0.25em;
175 | }
176 |
177 | /* Embedded content
178 | ========================================================================== */
179 |
180 | /**
181 | * Remove border when inside `a` element in IE 8/9/10.
182 | */
183 |
184 | img {
185 | border: 0;
186 | }
187 |
188 | /**
189 | * Correct overflow not hidden in IE 9/10/11.
190 | */
191 |
192 | svg:not(:root) {
193 | overflow: hidden;
194 | }
195 |
196 | /* Grouping content
197 | ========================================================================== */
198 |
199 | /**
200 | * Address margin not present in IE 8/9 and Safari.
201 | */
202 |
203 | figure {
204 | margin: 1em 40px;
205 | }
206 |
207 | /**
208 | * Address differences between Firefox and other browsers.
209 | */
210 |
211 | hr {
212 | -moz-box-sizing: content-box;
213 | box-sizing: content-box;
214 | height: 0;
215 | }
216 |
217 | /**
218 | * Contain overflow in all browsers.
219 | */
220 |
221 | pre {
222 | overflow: auto;
223 | }
224 |
225 | /**
226 | * Address odd `em`-unit font size rendering in all browsers.
227 | */
228 |
229 | code,
230 | kbd,
231 | pre,
232 | samp {
233 | font-family: monospace, monospace;
234 | font-size: 1em;
235 | }
236 |
237 | /* Forms
238 | ========================================================================== */
239 |
240 | /**
241 | * Known limitation: by default, Chrome and Safari on OS X allow very limited
242 | * styling of `select`, unless a `border` property is set.
243 | */
244 |
245 | /**
246 | * 1. Correct color not being inherited.
247 | * Known issue: affects color of disabled elements.
248 | * 2. Correct font properties not being inherited.
249 | * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
250 | */
251 |
252 | button,
253 | input,
254 | optgroup,
255 | select,
256 | textarea {
257 | color: inherit; /* 1 */
258 | font: inherit; /* 2 */
259 | margin: 0; /* 3 */
260 | }
261 |
262 | /**
263 | * Address `overflow` set to `hidden` in IE 8/9/10/11.
264 | */
265 |
266 | button {
267 | overflow: visible;
268 | }
269 |
270 | /**
271 | * Address inconsistent `text-transform` inheritance for `button` and `select`.
272 | * All other form control elements do not inherit `text-transform` values.
273 | * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
274 | * Correct `select` style inheritance in Firefox.
275 | */
276 |
277 | button,
278 | select {
279 | text-transform: none;
280 | }
281 |
282 | /**
283 | * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
284 | * and `video` controls.
285 | * 2. Correct inability to style clickable `input` types in iOS.
286 | * 3. Improve usability and consistency of cursor style between image-type
287 | * `input` and others.
288 | */
289 |
290 | button,
291 | html input[type="button"], /* 1 */
292 | input[type="reset"],
293 | input[type="submit"] {
294 | -webkit-appearance: button; /* 2 */
295 | cursor: pointer; /* 3 */
296 | }
297 |
298 | /**
299 | * Re-set default cursor for disabled elements.
300 | */
301 |
302 | button[disabled],
303 | html input[disabled] {
304 | cursor: default;
305 | }
306 |
307 | /**
308 | * Remove inner padding and border in Firefox 4+.
309 | */
310 |
311 | button::-moz-focus-inner,
312 | input::-moz-focus-inner {
313 | border: 0;
314 | padding: 0;
315 | }
316 |
317 | /**
318 | * Address Firefox 4+ setting `line-height` on `input` using `!important` in
319 | * the UA stylesheet.
320 | */
321 |
322 | input {
323 | line-height: normal;
324 | }
325 |
326 | /**
327 | * It's recommended that you don't attempt to style these elements.
328 | * Firefox's implementation doesn't respect box-sizing, padding, or width.
329 | *
330 | * 1. Address box sizing set to `content-box` in IE 8/9/10.
331 | * 2. Remove excess padding in IE 8/9/10.
332 | */
333 |
334 | input[type="checkbox"],
335 | input[type="radio"] {
336 | box-sizing: border-box; /* 1 */
337 | padding: 0; /* 2 */
338 | }
339 |
340 | /**
341 | * Fix the cursor style for Chrome's increment/decrement buttons. For certain
342 | * `font-size` values of the `input`, it causes the cursor style of the
343 | * decrement button to change from `default` to `text`.
344 | */
345 |
346 | input[type="number"]::-webkit-inner-spin-button,
347 | input[type="number"]::-webkit-outer-spin-button {
348 | height: auto;
349 | }
350 |
351 | /**
352 | * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
353 | * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
354 | * (include `-moz` to future-proof).
355 | */
356 |
357 | input[type="search"] {
358 | -webkit-appearance: textfield; /* 1 */
359 | -moz-box-sizing: content-box;
360 | -webkit-box-sizing: content-box; /* 2 */
361 | box-sizing: content-box;
362 | }
363 |
364 | /**
365 | * Remove inner padding and search cancel button in Safari and Chrome on OS X.
366 | * Safari (but not Chrome) clips the cancel button when the search input has
367 | * padding (and `textfield` appearance).
368 | */
369 |
370 | input[type="search"]::-webkit-search-cancel-button,
371 | input[type="search"]::-webkit-search-decoration {
372 | -webkit-appearance: none;
373 | }
374 |
375 | /**
376 | * Define consistent border, margin, and padding.
377 | */
378 |
379 | fieldset {
380 | border: 1px solid #c0c0c0;
381 | margin: 0 2px;
382 | padding: 0.35em 0.625em 0.75em;
383 | }
384 |
385 | /**
386 | * 1. Correct `color` not being inherited in IE 8/9/10/11.
387 | * 2. Remove padding so people aren't caught out if they zero out fieldsets.
388 | */
389 |
390 | legend {
391 | border: 0; /* 1 */
392 | padding: 0; /* 2 */
393 | }
394 |
395 | /**
396 | * Remove default vertical scrollbar in IE 8/9/10/11.
397 | */
398 |
399 | textarea {
400 | overflow: auto;
401 | }
402 |
403 | /**
404 | * Don't inherit the `font-weight` (applied by a rule above).
405 | * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
406 | */
407 |
408 | optgroup {
409 | font-weight: bold;
410 | }
411 |
412 | /* Tables
413 | ========================================================================== */
414 |
415 | /**
416 | * Remove most spacing between table cells.
417 | */
418 |
419 | table {
420 | border-collapse: collapse;
421 | border-spacing: 0;
422 | }
423 |
424 | td,
425 | th {
426 | padding: 0;
427 | }
428 |
--------------------------------------------------------------------------------
/src/_prism.scss:
--------------------------------------------------------------------------------
1 | /*! http://prismjs.com/download.html?themes=prism-okaidia&languages=markup+css+clike+javascript+scss */
2 | /**
3 | * okaidia theme for JavaScript, CSS and HTML
4 | * Loosely based on Monokai textmate theme by http://www.monokai.nl/
5 | * @author ocodia
6 | */
7 |
8 | code[class*="language-"],
9 | pre[class*="language-"] {
10 | color: #f8f8f2;
11 | text-shadow: 0 1px rgba(0, 0, 0, 0.3);
12 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
13 | direction: ltr;
14 | text-align: left;
15 | // white-space: pre;
16 | white-space: pre-wrap;
17 | word-spacing: normal;
18 | word-wrap: normal;
19 | word-break: normal;
20 | line-height: 1.5;
21 |
22 | -moz-tab-size: 4;
23 | -o-tab-size: 4;
24 | tab-size: 4;
25 |
26 | -webkit-hyphens: none;
27 | -moz-hyphens: none;
28 | -ms-hyphens: none;
29 | hyphens: none;
30 | }
31 |
32 | // Code blocks
33 | pre[class*="language-"] {
34 | padding: 1em;
35 | margin: 0;
36 | overflow: auto;
37 | border-radius: 0;
38 | border: none;
39 | // margin-left: -30px;
40 | // margin-right: -30px;
41 |
42 | // @media (min-width: 768px) {
43 | // margin-left: 0;
44 | // border-top-left-radius: 3px;
45 | // border-bottom-left-radius: 3px;
46 |
47 | // &.pre-full {
48 | // margin-left: -30px;
49 | // border-radius: 0;
50 | // }
51 | // }
52 | }
53 |
54 | // :not(pre) > code[class*="language-"],
55 | // pre[class*="language-"] {
56 | // background: #272822;
57 | // }
58 |
59 | // Inline code
60 | :not(pre) > code[class*="language-"] {
61 | padding: .1em;
62 | // border-radius: .3em;
63 | }
64 |
65 | .token.comment,
66 | .token.prolog,
67 | .token.doctype,
68 | .token.cdata {
69 | color: slategray;
70 | }
71 |
72 | .token.punctuation {
73 | color: #f8f8f2;
74 | }
75 |
76 | .namespace {
77 | opacity: .7;
78 | }
79 |
80 | .token.property,
81 | .token.tag,
82 | .token.constant,
83 | .token.symbol,
84 | .token.deleted {
85 | color: #f92672;
86 | }
87 |
88 | .token.boolean,
89 | .token.number {
90 | color: #ae81ff;
91 | }
92 |
93 | .token.selector,
94 | .token.attr-name,
95 | .token.string,
96 | .token.char,
97 | .token.builtin,
98 | .token.inserted {
99 | color: #a6e22e;
100 | }
101 |
102 | .token.operator,
103 | .token.entity,
104 | .token.url,
105 | .language-css .token.string,
106 | .style .token.string,
107 | .token.variable {
108 | color: #f8f8f2;
109 | }
110 |
111 | .token.atrule,
112 | .token.attr-value,
113 | .token.function {
114 | color: #e6db74;
115 | }
116 |
117 | .token.keyword {
118 | color: #66d9ef;
119 | }
120 |
121 | .token.regex,
122 | .token.important {
123 | color: #fd971f;
124 | }
125 |
126 | .token.important,
127 | .token.bold {
128 | font-weight: bold;
129 | }
130 | .token.italic {
131 | font-style: italic;
132 | }
133 |
134 | .token.entity {
135 | cursor: help;
136 | }
137 |
138 |
--------------------------------------------------------------------------------
/src/_variables.scss:
--------------------------------------------------------------------------------
1 |
2 |
3 | $gray-dark: #555;
4 | $gray: #ddd;
5 | $gray-light: #eee;
6 | $gray-lighter: #f7f7f7;
7 |
8 | $color: #454A56;
9 | $color-light: #5c83b0;
10 | $content-bg: #f7f7f7;
11 |
12 | $gutter: 2rem;
13 |
14 | $h1: 2.5rem;
15 | $h2: 1.8rem;
16 | $h3: 1.3rem;
17 | $h4: 1.15rem;
18 |
19 | $lh: 1.47em;
20 |
21 | @mixin mediaBP() {
22 | @media (min-width: 57.88em) {
23 | @content;
24 | }
25 | }
26 |
27 | @mixin mediaXS() {
28 | @media (min-width: 30em) {
29 | @content;
30 | }
31 | }
32 |
33 | @mixin clearfix() {
34 | &:after {
35 | content: " ";
36 | display: block;
37 | clear: both;
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/silvio-r/spop/5684749948c9a6204e13c93540f4fb35572a676b/src/favicon.ico
--------------------------------------------------------------------------------
/src/index.jade:
--------------------------------------------------------------------------------
1 |
2 | html(lang="en")
3 | head
4 | meta(charset="utf-8")
5 | title #{locals.title}, small pop up javascript plugin
6 | meta(name="description" content="#{locals.description}, create notifications easily with this javascript plugin")
7 | meta(name="viewport" content="width=device-width, initial-scale=1")
8 | link(href="http://fonts.googleapis.com/css?family=Roboto:300,400,500" rel="stylesheet")
9 | link(href="dist/spop.min.css" rel="stylesheet")
10 | link(href="src/styles.min.css" rel="stylesheet")
11 | link(href="src/favicon.ico" rel="icon")
12 |
13 | script(async src="https://www.googletagmanager.com/gtag/js?id=G-N8DGG9J61Z")
14 | script.
15 | window.dataLayer = window.dataLayer || [];
16 | function gtag(){dataLayer.push(arguments);}
17 | gtag('js', new Date());
18 | gtag('config', 'G-N8DGG9J61Z');
19 |
20 | body#body
21 | .container
22 | nav.menu
23 | a(href="#demo-basic") Basic
24 | a(href="#demo-position") Position
25 | a(href="#demo-autoclose") Autoclose
26 | a(href="#demo-groups") Groups
27 | a(href="#demo-callbacks") Callbacks
28 | a(href="#demo-event") Event
29 | a(href="#demo-defaults") Defaults
30 | a(href="#demo-options") Options
31 |
32 | header.header
33 | h1.header-title #{locals.title}
34 | p.header-text.h3
35 | | #{locals.description},
36 | br
37 | | create notifications easily with this javascript plugin.
38 | a.btn(href='https://github.com/silvio-r/spop/archive/#{locals.version}.zip') Download #{locals.version}
39 | a.btn(href='https://github.com/silvio-r/spop') View code
40 |
41 | section#demo-basic.section
42 | .text-main
43 | .titles
44 | h2.title Basic
45 |
46 | p Tip: to remove all SmallPop's click the title.
47 |
48 | p Include spop.js
and spop.css
in your page,
49 |
50 | .text-code
51 | pre
52 | code.language-markup#code-markup
53 |
54 | section.section
55 | .text-main
56 | p and call it:
57 | a.btn.btn-block#btn-default-pop Default pop
58 | a.btn.btn-block#btn-success-pop Success pop
59 | a.btn.btn-block#btn-warning-pop Warning pop
60 | a.btn.btn-block#btn-error-pop Error pop
61 |
62 | .text-code
63 | pre
64 | code.language-javascript#code-basic
65 |
66 | section.section#demo-position
67 | .text-main
68 | .titles
69 | h2.title Position
70 |
71 | p SmallPox has six differents positions:
72 |
73 | .btn-group
74 | a.btn#btn-top-left Top left
75 | a.btn#btn-top-center Top center
76 | a.btn#btn-top-right Top right
77 |
78 | .btn-group
79 | a.btn#btn-bottom-left Bottom left
80 | a.btn#btn-bottom-center Bottom center
81 | a.btn#btn-bottom-right Bottom right
82 |
83 | p In mobile (max-width:30em), all go down.
84 |
85 | .text-code
86 | pre
87 | code.language-javascript#code-position
88 |
89 | section.section#demo-autoclose
90 | .text-main
91 | .titles
92 | h2.title Autoclose
93 |
94 | p Autoclose, to... close... automatically... Woohoo never done before
95 | a.btn.btn-block#btn-autoclose-pop Autoclose
96 |
97 | .text-code
98 | pre
99 | code.language-javascript#code-autoclose-pop
100 |
101 | section.section#demo-groups
102 | .text-main
103 | .titles
104 | h2.title Groups
105 |
106 | p There can only be one SmallPop from each group
107 | a.btn.btn-block#btn-groups-1 Group
108 | a.btn.btn-block#btn-groups No group
109 | a.btn.btn-block#btn-groups-2 Group
110 |
111 | .text-code
112 | pre
113 | code.language-javascript#code-groups
114 |
115 | section.section#demo-callbacks
116 | .text-main
117 | .titles
118 | h2.title Callbacks
119 |
120 | p Do what you need onOpen and onClose
121 | a.btn.btn-block#btn-callbacks Callbacks
122 |
123 | .text-code
124 | pre
125 | code.language-javascript#code-callbacks
126 |
127 | section.section#demo-event
128 | .text-main
129 | .titles
130 | h2.title Event
131 |
132 | p In your template you can call the close event, just add data-spop="close"
133 | a.btn.btn-block#btn-event Launch
134 |
135 | .text-code
136 | pre
137 | code.language-javascript#code-event
138 |
139 | section.section#demo-defaults
140 | .text-main
141 | .titles
142 | h2.title Change Defaults
143 |
144 | p Change the default options of all SmallPop's
145 | a.btn.btn-block#btn-defaults Changed all defaults
146 | a.btn.btn-block#btn-defaults-reset Restore defaults
147 |
148 | .text-code
149 | pre
150 | code.language-javascript#code-defaults
151 |
152 | section.section-full#demo-options
153 | .section
154 | .text-main-full
155 | .titles
156 | h2.title Options
157 | .text-code
158 |
159 | .text-code-full
160 | pre
161 | code.language-javascript#code-options
162 |
163 |
164 |
165 | footer.footer
166 | p
167 | span.h3 Browser support:
168 | br
169 | | Chrome, Firefox, IE 11-10-9 (9 no animations),
170 | | Android Browser, Chrome for Android, Safari, iOS Safari
171 |
172 | p.footer-menu
173 | a(href="https://github.com/silvio-r/spop/archive/#{locals.version}.zip") Download
174 | a(href="https://github.com/silvio-r/spop") Code
175 | a(href="https://github.com/silvio-r/spop/issues") Issues/Bugs
176 | a(href="http://codepen.io/silvio-r/pen/jWmWXy") Codepen playground
177 |
178 |
179 | p
180 | small Created by Sílvio Rosa • Follow me on
181 | a(href="https://twitter.com/silvior_") twitter
182 | | for updates.
183 |
184 | a.btn.btn-go-top(href="#body") Go top
185 |
186 | script(src="src/prism.js")
187 | script(src="dist/spop.min.js")
188 | script(src="src/scripts.min.js")
189 |
--------------------------------------------------------------------------------
/src/prism.js:
--------------------------------------------------------------------------------
1 | /* http://prismjs.com/download.html?themes=prism&languages=markup+css+clike+javascript+scss */
2 | self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{};var Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var s="";for(var o in i.attributes)s+=o+'="'+(i.attributes[o]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+s+">"+i.content+""+i.tag+">"},!self.document)return self.addEventListener?(self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),self.close()},!1),self.Prism):self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);;
3 | Prism.languages.markup={comment://,prolog:/<\?.+?\?>/,doctype://,cdata://i,tag:{pattern:/<\/?[^\s>\/]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/=|>|"/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))});;
4 | Prism.languages.css={comment:/\/\*[\w\W]*?\*\//,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*\{))/i,inside:{punctuation:/[;:]/}},url:/url\((?:(["'])(\\\n|\\?.)*?\1|.*?)\)/i,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/,string:/("|')(\\\n|\\?.)*?\1/,property:/(\b|\B)[\w-]+(?=\s*:)/i,important:/\B!important\b/i,punctuation:/[\{\};:]/,"function":/[-a-z0-9]+(?=\()/i},Prism.languages.markup&&(Prism.languages.insertBefore("markup","tag",{style:{pattern:/