@kunalnagarco/jquery-peek-a-bar 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Kunal Nagar
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.
package/README.md ADDED
@@ -0,0 +1,161 @@
1
+ # @kunalnagarco/jquery-peek-a-bar
2
+
3
+ <!-- [![npm version](https://img.shields.io/npm/v/jquery-peek-a-bar.svg)](https://www.npmjs.com/package/jquery-peek-a-bar) -->
4
+
5
+ A jQuery plugin for a notification bar with customization options.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ npm install @kunalnagarco/jquery-peek-a-bar --save
11
+ ```
12
+
13
+ ## Options
14
+
15
+ ### html
16
+
17
+ Use custom HTML as bar text.
18
+
19
+ Type: `String`
20
+ Default: `Your Message Here`
21
+
22
+ ### autohide
23
+
24
+ Autohide the bar after it is shown.
25
+
26
+ Type: `Boolean`
27
+ Default: `false`
28
+
29
+ ### delay
30
+
31
+ Time (in ms) before the bar is hidden if `autohide` is `true`.
32
+
33
+ Type: `Number`
34
+ Default: `3000`
35
+
36
+ ### padding
37
+
38
+ Add some padding to the bar.
39
+
40
+ Type: `String`
41
+ Default: `1em`
42
+
43
+ ### backgroundColor
44
+
45
+ Add a custom background color to the bar.
46
+
47
+ Type: `String`
48
+ Default: `rgb(195, 195, 195)`
49
+
50
+ ### animation
51
+
52
+ The way in which the bar reveals itself.
53
+
54
+ Type: `Object`
55
+ Example:
56
+
57
+ ```
58
+ animation: {
59
+ type: 'slide/fade',
60
+ duration: 'slow/3000(in ms)'
61
+ }
62
+ ```
63
+
64
+ ### cssClass
65
+
66
+ Assign a Custom CSS class to the bar.
67
+
68
+ Type: `String`
69
+ Default: `empty`
70
+
71
+ ### opacity
72
+
73
+ Change bar opacity.
74
+
75
+ Type: `Number`
76
+ Default: `1`
77
+
78
+ ### position
79
+
80
+ Where should the bar be revealed? Top or bottom of the page?
81
+
82
+ Type: `String`
83
+ Default: `top`
84
+ Values: `top | bottom`
85
+
86
+ ### closeOnClick
87
+
88
+ Close the bar by clicking on it.
89
+
90
+ Type: `Boolean`
91
+ Default: `false`
92
+
93
+ ## Event Methods
94
+
95
+ ### onShow
96
+
97
+ Called after the bar is shown.
98
+
99
+ ### onHide
100
+
101
+ Called after the bar is hidden.
102
+
103
+ ## Instance Methods
104
+
105
+ ### bar.show()
106
+
107
+ Show the bar.
108
+
109
+ ### bar.hide()
110
+
111
+ Hide the bar.
112
+
113
+ ## Example
114
+
115
+ Please check out the complete example below:
116
+
117
+ ```
118
+ // Create a bar
119
+ var bar = $.peekABar({
120
+ html: 'Custom Message',
121
+ delay: 2000,
122
+ autohide: true,
123
+ padding: '2em',
124
+ backgroundColor: 'rgb(195, 195, 195)',
125
+ animation: {
126
+ type: 'fade',
127
+ duration: '2000'
128
+ },
129
+ opacity: '0.8',
130
+ cssClass: 'custom-class',
131
+ position: 'bottom',
132
+ closeOnClick: true
133
+ onShow: function() {
134
+ console.log('called after bar is shown');
135
+ },
136
+ onHide: function() {
137
+ console.log('called after bar is hidden');
138
+ }
139
+ });
140
+
141
+ // Show the bar
142
+ bar.show();
143
+
144
+ // Hide the bar
145
+ bar.hide();
146
+
147
+ // Show the bar with custom HTML
148
+ // This call will override the HTML
149
+ // set in any previous definitions.
150
+ bar.show({
151
+ html: 'Overrides all, puny human.'
152
+ });
153
+ ```
154
+
155
+ ## Support
156
+
157
+ For any issues/queries, please open a new [Github Issue](https://github.com/kunalnagarco/jquery.peekABar/issues).
158
+
159
+ ## Share
160
+
161
+ If you like the plugin, please share it with your friends!
@@ -0,0 +1,7 @@
1
+ .peek-a-bar {
2
+ margin: 0;
3
+ position: fixed;
4
+ width: 100%;
5
+ left: 0;
6
+ right: 0;
7
+ text-align: center; }
@@ -0,0 +1,2 @@
1
+ .peek-a-bar{margin:0;position:fixed;width:100%;left:0;right:0;text-align:center}
2
+ /*# sourceMappingURL=jquery.peekabar.min.css.map */
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["dist/css/jquery.peekabar.css"],"names":[],"mappings":"AAAA,YACE,OAAQ,EACR,SAAU,MACV,MAAO,KACP,KAAM,EACN,MAAO,EACP,WAAY"}
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * @license
5
+ * @kunalnagarco/jquery-peek-a-bar <https://kunalnagarco.github.io/jquery.peekABar>
6
+ * Copyright 2019 Kunal Nagar
7
+ * Available under MIT license
8
+ */
9
+ (function ($) {
10
+ 'use strict';
11
+
12
+ $.peekABar = function (options) {
13
+ var _this = this;
14
+ var that = this,
15
+ rand = parseInt(Math.random() * 100000000, 0);
16
+ this.bar = {};
17
+ this.settings = {};
18
+ var defaults = {
19
+ html: 'Your Message Here',
20
+ delay: 3000,
21
+ autohide: false,
22
+ padding: '1em',
23
+ backgroundColor: 'rgb(195, 195, 195)',
24
+ animation: {
25
+ type: 'slide',
26
+ duration: 'slow'
27
+ },
28
+ cssClass: null,
29
+ opacity: '1',
30
+ position: 'top',
31
+ closeOnClick: false,
32
+ onShow: function onShow() {},
33
+ onHide: function onHide() {}
34
+ };
35
+ var init = function init() {
36
+ that.settings = $.extend({}, defaults, options);
37
+ _create();
38
+ _applyCustomSettings();
39
+ };
40
+ this.show = function (args) {
41
+ if (args !== undefined) {
42
+ if (args.html) {
43
+ _this.bar.html(args.html);
44
+ }
45
+ }
46
+ switch (_this.settings.animation.type) {
47
+ case 'slide':
48
+ _this.bar.slideDown(that.settings.animation.duration);
49
+ break;
50
+ case 'fade':
51
+ _this.bar.fadeIn(that.settings.animation.duration);
52
+ break;
53
+ }
54
+ if (_this.settings.autohide) {
55
+ setTimeout(function () {
56
+ that.hide();
57
+ }, _this.settings.delay);
58
+ }
59
+ _this.settings.onShow.call(_this, args);
60
+ };
61
+ this.hide = function () {
62
+ switch (_this.settings.animation.type) {
63
+ case 'slide':
64
+ _this.bar.slideUp(that.settings.animation.duration);
65
+ break;
66
+ case 'fade':
67
+ _this.bar.fadeOut(that.settings.animation.duration);
68
+ break;
69
+ }
70
+ _this.settings.onHide.call(_this);
71
+ };
72
+ var _create = function _create() {
73
+ that.bar = $('<div></div>').addClass('peek-a-bar').attr('id', '__peek_a_bar_' + rand);
74
+ $('html').append(that.bar);
75
+ that.bar.hide();
76
+ };
77
+ var _applyCustomSettings = function _applyCustomSettings() {
78
+ _applyHTML();
79
+ _applyAutohide();
80
+ _applyPadding();
81
+ _applyBackgroundColor();
82
+ _applyOpacity();
83
+ _applyCSSClass();
84
+ _applyPosition();
85
+ _applyCloseOnClick();
86
+ };
87
+ var _applyHTML = function _applyHTML() {
88
+ that.bar.html(that.settings.html);
89
+ };
90
+ var _applyAutohide = function _applyAutohide() {
91
+ if (that.settings.autohide) {
92
+ setTimeout(function () {
93
+ that.hide();
94
+ }, that.settings.delay);
95
+ }
96
+ };
97
+ var _applyPadding = function _applyPadding() {
98
+ that.bar.css('padding', that.settings.padding);
99
+ };
100
+ var _applyBackgroundColor = function _applyBackgroundColor() {
101
+ that.bar.css('background-color', that.settings.backgroundColor);
102
+ };
103
+ var _applyCSSClass = function _applyCSSClass() {
104
+ if (that.settings.cssClass !== null) {
105
+ that.bar.addClass(that.settings.cssClass);
106
+ }
107
+ };
108
+ var _applyOpacity = function _applyOpacity() {
109
+ that.bar.css('opacity', that.settings.opacity);
110
+ };
111
+ var _applyPosition = function _applyPosition() {
112
+ switch (that.settings.position) {
113
+ case 'top':
114
+ that.bar.css('top', 0);
115
+ break;
116
+ case 'bottom':
117
+ that.bar.css('bottom', 0);
118
+ break;
119
+ default:
120
+ that.bar.css('top', 0);
121
+ }
122
+ };
123
+ var _applyCloseOnClick = function _applyCloseOnClick() {
124
+ if (that.settings.closeOnClick) {
125
+ that.bar.click(function () {
126
+ that.hide();
127
+ });
128
+ }
129
+ };
130
+ init();
131
+ return this;
132
+ };
133
+ })(jQuery);
@@ -0,0 +1,2 @@
1
+ "use strict";!function(f){f.peekABar=function(t){var s=this,i=this,n=parseInt(1e8*Math.random(),0),a=(this.bar={},{html:"Your Message Here",delay:3e3,autohide:!(this.settings={}),padding:"1em",backgroundColor:"rgb(195, 195, 195)",animation:{type:"slide",duration:"slow"},cssClass:null,opacity:"1",position:"top",closeOnClick:!1,onShow:function(){},onHide:function(){}}),e=(this.show=function(t){switch(void 0!==t&&t.html&&s.bar.html(t.html),s.settings.animation.type){case"slide":s.bar.slideDown(i.settings.animation.duration);break;case"fade":s.bar.fadeIn(i.settings.animation.duration)}s.settings.autohide&&setTimeout(function(){i.hide()},s.settings.delay),s.settings.onShow.call(s,t)},this.hide=function(){switch(s.settings.animation.type){case"slide":s.bar.slideUp(i.settings.animation.duration);break;case"fade":s.bar.fadeOut(i.settings.animation.duration)}s.settings.onHide.call(s)},function(){i.bar=f("<div></div>").addClass("peek-a-bar").attr("id","__peek_a_bar_"+n),f("html").append(i.bar),i.bar.hide()}),o=function(){c(),d(),r(),u(),b(),l(),g(),h()},c=function(){i.bar.html(i.settings.html)},d=function(){i.settings.autohide&&setTimeout(function(){i.hide()},i.settings.delay)},r=function(){i.bar.css("padding",i.settings.padding)},u=function(){i.bar.css("background-color",i.settings.backgroundColor)},l=function(){null!==i.settings.cssClass&&i.bar.addClass(i.settings.cssClass)},b=function(){i.bar.css("opacity",i.settings.opacity)},g=function(){switch(i.settings.position){case"top":i.bar.css("top",0);break;case"bottom":i.bar.css("bottom",0);break;default:i.bar.css("top",0)}},h=function(){i.settings.closeOnClick&&i.bar.click(function(){i.hide()})};return i.settings=f.extend({},a,t),e(),o(),this}}(jQuery);
2
+ //# sourceMappingURL=jquery.peekabar.min.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jquery.peekabar.min.js","sources":["jquery.peekabar.js"],"names":["$","peekABar","options","_this","this","that","rand","parseInt","Math","random","defaults","bar","html","delay","autohide","settings","padding","backgroundColor","animation","type","duration","cssClass","opacity","position","closeOnClick","onShow","onHide","_create","show","args","undefined","slideDown","fadeIn","setTimeout","hide","call","slideUp","fadeOut","addClass","attr","append","_applyCustomSettings","_applyHTML","_applyAutohide","_applyPadding","_applyBackgroundColor","_applyOpacity","_applyCSSClass","_applyPosition","_applyCloseOnClick","css","click","extend","jQuery"],"mappings":"AAAA,aAQA,CAAA,SAAWA,GAGTA,EAAEC,SAAW,SAAUC,GACrB,IAAIC,EAAQC,KACRC,EAAOD,KACTE,EAAOC,SAAyB,IAAhBC,KAAKC,OAAO,EAAe,CAAC,EAG1CC,GAFJN,KAAKO,IAAM,GAEI,CACbC,KAAM,oBACNC,MAAO,IACPC,SAAU,EAJZV,KAAKW,SAAW,IAKdC,QAAS,MACTC,gBAAiB,qBACjBC,UAAW,CACTC,KAAM,QACNC,SAAU,MACZ,EACAC,SAAU,KACVC,QAAS,IACTC,SAAU,MACVC,aAAc,CAAA,EACdC,OAAQ,aACRC,OAAQ,YACV,GAsCIC,GAhCJvB,KAAKwB,KAAO,SA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O,CAC/C,EACI6B,EAAwB,WAC1BxC,EAAKM,IAAIuC,IAAI,mBAAoB7C,EAAKU,SAASE,eAAe,CAChE,EACI8B,EAAiB,WACY,OAA3B1C,EAAKU,SAASM,UAChBhB,EAAKM,IAAI2B,SAASjC,EAAKU,SAASM,QAAQ,CAE5C,EACIyB,EAAgB,WAClBzC,EAAKM,IAAIuC,IAAI,UAAW7C,EAAKU,SAASO,OAAO,CAC/C,EACI0B,EAAiB,WACnB,OAAQ3C,EAAKU,SAASQ,UACpB,IAAK,MACHlB,EAAKM,IAAIuC,IAAI,MAAO,CAAC,EACrB,MACF,IAAK,SACH7C,EAAKM,IAAIuC,IAAI,SAAU,CAAC,EACxB,MACF,QACE7C,EAAKM,IAAIuC,IAAI,MAAO,CAAC,CACzB,CACF,EACID,EAAqB,WACnB5C,EAAKU,SAASS,cAChBnB,EAAKM,IAAIwC,MAAM,WACb9C,EAAK6B,KAAK,CACZ,CAAC,CAEL,EAEA,OA/FE7B,EAAKU,SAAWf,EAAEoD,OAAO,GAAI1C,EAAUR,CAAO,EAC9CyB,EAAQ,EACRc,EAAqB,EA6FhBrC,IACT,CACD,EAAEiD,MAAM"}
package/package.json ADDED
@@ -0,0 +1,50 @@
1
+ {
2
+ "name": "@kunalnagarco/jquery-peek-a-bar",
3
+ "version": "4.0.0",
4
+ "description": "A jQuery plugin for a notification bar with a lot of customization options.",
5
+ "main": "dist/js/jquery.peekabar.js",
6
+ "files": [
7
+ "dist"
8
+ ],
9
+ "scripts": {
10
+ "prebuild": "rm -rf build",
11
+ "build": "grunt build",
12
+ "release": "semantic-release"
13
+ },
14
+ "author": "Kunal Nagar <knlnagar@gmail.com>",
15
+ "license": "MIT",
16
+ "devDependencies": {
17
+ "@babel/core": "7.24.7",
18
+ "@babel/preset-env": "7.24.7",
19
+ "@semantic-release/changelog": "6.0.3",
20
+ "@semantic-release/commit-analyzer": "13.0.0",
21
+ "@semantic-release/git": "10.0.1",
22
+ "@semantic-release/github": "10.0.6",
23
+ "@semantic-release/npm": "12.0.1",
24
+ "@semantic-release/release-notes-generator": "14.0.1",
25
+ "conventional-changelog-conventionalcommits": "8.0.0",
26
+ "grunt": "1.6.1",
27
+ "grunt-babel": "8.0.0",
28
+ "grunt-contrib-copy": "1.0.0",
29
+ "grunt-contrib-cssmin": "5.0.0",
30
+ "grunt-contrib-uglify": "5.2.2",
31
+ "grunt-contrib-watch": "1.1.0",
32
+ "grunt-sass": "*",
33
+ "load-grunt-tasks": "5.1.0",
34
+ "node-sass": "9.0.0",
35
+ "prettier": "3.2.5",
36
+ "semantic-release": "24.0.0",
37
+ "time-grunt": "2.0.0"
38
+ },
39
+ "keywords": [
40
+ "jquery-plugin",
41
+ "ecosystem:jquery"
42
+ ],
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git://github.com/kunalnagarco/jquery.peekABar.git"
46
+ },
47
+ "publishConfig": {
48
+ "access": "public"
49
+ }
50
+ }