pnotify-rails 2.0.1.1 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (26) hide show
  1. checksums.yaml +4 -4
  2. data/lib/pnotify-rails/version.rb +1 -1
  3. data/vendor/assets/javascripts/pnotify/index.js +5 -1
  4. data/vendor/assets/javascripts/pnotify/pnotify.animate.js +108 -0
  5. data/vendor/assets/javascripts/pnotify/pnotify.buttons.js +165 -121
  6. data/vendor/assets/javascripts/pnotify/pnotify.callbacks.js +42 -40
  7. data/vendor/assets/javascripts/pnotify/pnotify.confirm.js +145 -139
  8. data/vendor/assets/javascripts/pnotify/pnotify.desktop.js +144 -133
  9. data/vendor/assets/javascripts/pnotify/pnotify.history.js +172 -171
  10. data/vendor/assets/javascripts/pnotify/pnotify.js +873 -0
  11. data/vendor/assets/javascripts/pnotify/pnotify.mobile.js +121 -0
  12. data/vendor/assets/javascripts/pnotify/pnotify.nonblock.js +144 -139
  13. data/vendor/assets/javascripts/pnotify/pnotify.reference.js +131 -116
  14. data/vendor/assets/javascripts/pnotify/pnotify.tooltip.js +15 -0
  15. data/vendor/assets/stylesheets/pnotify/index.css +5 -2
  16. data/vendor/assets/stylesheets/pnotify/pnotify.brighttheme.css +165 -0
  17. data/vendor/assets/stylesheets/pnotify/pnotify.buttons.css +2 -2
  18. data/vendor/assets/stylesheets/pnotify/pnotify.css +112 -0
  19. data/vendor/assets/stylesheets/pnotify/pnotify.history.css +22 -22
  20. data/vendor/assets/stylesheets/pnotify/pnotify.material.css +121 -0
  21. data/vendor/assets/stylesheets/pnotify/pnotify.mobile.css +46 -0
  22. data/vendor/assets/stylesheets/pnotify/pnotify.nonblock.css +7 -0
  23. metadata +12 -6
  24. data/vendor/assets/javascripts/pnotify/pnotify.core.js +0 -778
  25. data/vendor/assets/stylesheets/pnotify/pnotify.core.css +0 -56
  26. data/vendor/assets/stylesheets/pnotify/pnotify.picon.css +0 -11
@@ -1,152 +1,158 @@
1
1
  // Confirm
2
- // Uses AMD or browser globals for jQuery.
3
- (function (factory) {
2
+ (function (root, factory) {
4
3
  if (typeof define === 'function' && define.amd) {
5
4
  // AMD. Register as a module.
6
5
  define('pnotify.confirm', ['jquery', 'pnotify'], factory);
6
+ } else if (typeof exports === 'object' && typeof module !== 'undefined') {
7
+ // CommonJS
8
+ module.exports = factory(require('jquery'), require('./pnotify'));
7
9
  } else {
8
10
  // Browser globals
9
- factory(jQuery, PNotify);
11
+ factory(root.jQuery, root.PNotify);
10
12
  }
11
- }(function($, PNotify){
12
- PNotify.prototype.options.confirm = {
13
- // Make a confirmation box.
14
- confirm: false,
15
- // Make a prompt.
16
- prompt: false,
17
- // Classes to add to the input element of the prompt.
18
- prompt_class: "",
19
- // The default value of the prompt.
20
- prompt_default: "",
21
- // Whether the prompt should accept multiple lines of text.
22
- prompt_multi_line: false,
23
- // Where to align the buttons. (right, center, left, justify)
24
- align: "right",
25
- // The buttons to display, and their callbacks.
26
- buttons: [
27
- {
28
- text: "Ok",
29
- addClass: "",
30
- // Whether to trigger this button when the user hits enter in a single line prompt.
31
- promptTrigger: true,
32
- click: function(notice, value){
33
- notice.remove();
34
- notice.get().trigger("pnotify.confirm", [notice, value]);
35
- }
36
- },
37
- {
38
- text: "Cancel",
39
- addClass: "",
40
- click: function(notice){
41
- notice.remove();
42
- notice.get().trigger("pnotify.cancel", notice);
43
- }
44
- }
45
- ]
46
- };
47
- PNotify.prototype.modules.confirm = {
48
- // The div that contains the buttons.
49
- container: null,
50
- // The input element of a prompt.
51
- prompt: null,
13
+ }(this, function($, PNotify){
14
+ PNotify.prototype.options.confirm = {
15
+ // Make a confirmation box.
16
+ confirm: false,
17
+ // Make a prompt.
18
+ prompt: false,
19
+ // Classes to add to the input element of the prompt.
20
+ prompt_class: "",
21
+ // The default value of the prompt.
22
+ prompt_default: "",
23
+ // Whether the prompt should accept multiple lines of text.
24
+ prompt_multi_line: false,
25
+ // Where to align the buttons. (right, center, left, justify)
26
+ align: "right",
27
+ // The buttons to display, and their callbacks.
28
+ buttons: [
29
+ {
30
+ text: "Ok",
31
+ addClass: "",
32
+ // Whether to trigger this button when the user hits enter in a single line prompt.
33
+ promptTrigger: true,
34
+ click: function(notice, value){
35
+ notice.remove();
36
+ notice.get().trigger("pnotify.confirm", [notice, value]);
37
+ }
38
+ },
39
+ {
40
+ text: "Cancel",
41
+ addClass: "",
42
+ click: function(notice){
43
+ notice.remove();
44
+ notice.get().trigger("pnotify.cancel", notice);
45
+ }
46
+ }
47
+ ]
48
+ };
49
+ PNotify.prototype.modules.confirm = {
50
+ // The div that contains the buttons.
51
+ container: null,
52
+ // The input element of a prompt.
53
+ prompt: null,
52
54
 
53
- init: function(notice, options){
54
- this.container = $('<div style="margin-top:5px;clear:both;" />').css('text-align', options.align).appendTo(notice.container);
55
+ init: function(notice, options){
56
+ this.container = $('<div class="ui-pnotify-action-bar" style="margin-top:5px;clear:both;" />').css('text-align', options.align).appendTo(notice.container);
55
57
 
56
- if (options.confirm || options.prompt)
57
- this.makeDialog(notice, options);
58
- else
59
- this.container.hide();
60
- },
58
+ if (options.confirm || options.prompt)
59
+ this.makeDialog(notice, options);
60
+ else
61
+ this.container.hide();
62
+ },
61
63
 
62
- update: function(notice, options){
63
- if (options.confirm) {
64
- this.makeDialog(notice, options);
65
- this.container.show();
66
- } else {
67
- this.container.hide().empty();
68
- }
69
- },
64
+ update: function(notice, options){
65
+ if (options.confirm) {
66
+ this.makeDialog(notice, options);
67
+ this.container.show();
68
+ } else {
69
+ this.container.hide().empty();
70
+ }
71
+ },
70
72
 
71
- afterOpen: function(notice, options){
72
- if (options.prompt)
73
- this.prompt.focus();
74
- },
73
+ afterOpen: function(notice, options){
74
+ if (options.prompt)
75
+ this.prompt.focus();
76
+ },
75
77
 
76
- makeDialog: function(notice, options) {
77
- var already = false, that = this, btn, elem;
78
- this.container.empty();
79
- if (options.prompt) {
80
- this.prompt = $('<'+(options.prompt_multi_line ? 'textarea rows="5"' : 'input type="text"')+' style="margin-bottom:5px;clear:both;" />')
81
- .addClass(notice.styles.input+' '+options.prompt_class)
82
- .val(options.prompt_default)
83
- .appendTo(this.container);
84
- }
85
- for (var i in options.buttons) {
86
- btn = options.buttons[i];
87
- if (already)
88
- this.container.append(' ');
89
- else
90
- already = true;
91
- elem = $('<button type="button" />')
92
- .addClass(notice.styles.btn+' '+btn.addClass)
93
- .text(btn.text)
94
- .appendTo(this.container)
95
- .on("click", (function(btn){ return function(){
96
- if (typeof btn.click == "function") {
97
- btn.click(notice, options.prompt ? that.prompt.val() : null);
98
- }
99
- }})(btn));
100
- if (options.prompt && !options.prompt_multi_line && btn.promptTrigger)
101
- this.prompt.keypress((function(elem){ return function(e){
102
- if (e.keyCode == 13)
103
- elem.click();
104
- }})(elem));
105
- if (notice.styles.text) {
106
- elem.wrapInner('<span class="'+notice.styles.text+'"></span>');
107
- }
108
- if (notice.styles.btnhover) {
109
- elem.hover((function(elem){ return function(){
110
- elem.addClass(notice.styles.btnhover);
111
- }})(elem), (function(elem){ return function(){
112
- elem.removeClass(notice.styles.btnhover);
113
- }})(elem));
114
- }
115
- if (notice.styles.btnactive) {
116
- elem.on("mousedown", (function(elem){ return function(){
117
- elem.addClass(notice.styles.btnactive);
118
- }})(elem)).on("mouseup", (function(elem){ return function(){
119
- elem.removeClass(notice.styles.btnactive);
120
- }})(elem));
121
- }
122
- if (notice.styles.btnfocus) {
123
- elem.on("focus", (function(elem){ return function(){
124
- elem.addClass(notice.styles.btnfocus);
125
- }})(elem)).on("blur", (function(elem){ return function(){
126
- elem.removeClass(notice.styles.btnfocus);
127
- }})(elem));
128
- }
129
- }
130
- }
131
- };
132
- $.extend(PNotify.styling.jqueryui, {
133
- btn: "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only",
134
- btnhover: "ui-state-hover",
135
- btnactive: "ui-state-active",
136
- btnfocus: "ui-state-focus",
137
- input: "",
138
- text: "ui-button-text"
139
- });
140
- $.extend(PNotify.styling.bootstrap2, {
141
- btn: "btn",
142
- input: ""
143
- });
144
- $.extend(PNotify.styling.bootstrap3, {
145
- btn: "btn btn-default",
146
- input: "form-control"
147
- });
148
- $.extend(PNotify.styling.fontawesome, {
149
- btn: "btn btn-default",
150
- input: "form-control"
151
- });
78
+ makeDialog: function(notice, options) {
79
+ var already = false, that = this, btn, elem;
80
+ this.container.empty();
81
+ if (options.prompt) {
82
+ this.prompt = $('<'+(options.prompt_multi_line ? 'textarea rows="5"' : 'input type="text"')+' style="margin-bottom:5px;clear:both;" />')
83
+ .addClass((typeof notice.styles.input === "undefined" ? "" : notice.styles.input)+" "+(typeof options.prompt_class === "undefined" ? "" : options.prompt_class))
84
+ .val(options.prompt_default)
85
+ .appendTo(this.container);
86
+ }
87
+ var customButtons = (options.buttons[0] && options.buttons[0] !== PNotify.prototype.options.confirm.buttons[0]);
88
+ for (var i = 0; i < options.buttons.length; i++) {
89
+ if (options.buttons[i] === null || (customButtons && PNotify.prototype.options.confirm.buttons[i] && PNotify.prototype.options.confirm.buttons[i] === options.buttons[i])) {
90
+ continue;
91
+ }
92
+ btn = options.buttons[i];
93
+ if (already)
94
+ this.container.append(' ');
95
+ else
96
+ already = true;
97
+ elem = $('<button type="button" class="ui-pnotify-action-button" />')
98
+ .addClass((typeof notice.styles.btn === "undefined" ? "" : notice.styles.btn)+" "+(typeof btn.addClass === "undefined" ? "" : btn.addClass))
99
+ .text(btn.text)
100
+ .appendTo(this.container)
101
+ .on("click", (function(btn){ return function(){
102
+ if (typeof btn.click == "function") {
103
+ btn.click(notice, options.prompt ? that.prompt.val() : null);
104
+ }
105
+ }})(btn));
106
+ if (options.prompt && !options.prompt_multi_line && btn.promptTrigger)
107
+ this.prompt.keypress((function(elem){ return function(e){
108
+ if (e.keyCode == 13)
109
+ elem.click();
110
+ }})(elem));
111
+ if (notice.styles.text) {
112
+ elem.wrapInner('<span class="'+notice.styles.text+'"></span>');
113
+ }
114
+ if (notice.styles.btnhover) {
115
+ elem.hover((function(elem){ return function(){
116
+ elem.addClass(notice.styles.btnhover);
117
+ }})(elem), (function(elem){ return function(){
118
+ elem.removeClass(notice.styles.btnhover);
119
+ }})(elem));
120
+ }
121
+ if (notice.styles.btnactive) {
122
+ elem.on("mousedown", (function(elem){ return function(){
123
+ elem.addClass(notice.styles.btnactive);
124
+ }})(elem)).on("mouseup", (function(elem){ return function(){
125
+ elem.removeClass(notice.styles.btnactive);
126
+ }})(elem));
127
+ }
128
+ if (notice.styles.btnfocus) {
129
+ elem.on("focus", (function(elem){ return function(){
130
+ elem.addClass(notice.styles.btnfocus);
131
+ }})(elem)).on("blur", (function(elem){ return function(){
132
+ elem.removeClass(notice.styles.btnfocus);
133
+ }})(elem));
134
+ }
135
+ }
136
+ }
137
+ };
138
+ $.extend(PNotify.styling.jqueryui, {
139
+ btn: "ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only",
140
+ btnhover: "ui-state-hover",
141
+ btnactive: "ui-state-active",
142
+ btnfocus: "ui-state-focus",
143
+ input: "",
144
+ text: "ui-button-text"
145
+ });
146
+ $.extend(PNotify.styling.bootstrap2, {
147
+ btn: "btn",
148
+ input: ""
149
+ });
150
+ $.extend(PNotify.styling.bootstrap3, {
151
+ btn: "btn btn-default",
152
+ input: "form-control"
153
+ });
154
+ $.extend(PNotify.styling.fontawesome, {
155
+ btn: "btn btn-default",
156
+ input: "form-control"
157
+ });
152
158
  }));
@@ -1,143 +1,154 @@
1
1
  // Desktop
2
- // Uses AMD or browser globals for jQuery.
3
- (function (factory) {
2
+ (function (root, factory) {
4
3
  if (typeof define === 'function' && define.amd) {
5
4
  // AMD. Register as a module.
6
5
  define('pnotify.desktop', ['jquery', 'pnotify'], factory);
6
+ } else if (typeof exports === 'object' && typeof module !== 'undefined') {
7
+ // CommonJS
8
+ module.exports = factory(require('jquery'), require('./pnotify'));
7
9
  } else {
8
10
  // Browser globals
9
- factory(jQuery, PNotify);
11
+ factory(root.jQuery, root.PNotify);
10
12
  }
11
- }(function($, PNotify){
12
- var permission;
13
- var notify = function(title, options){
14
- // Memoize based on feature detection.
15
- if ("Notification" in window) {
16
- notify = function (title, options) {
17
- return new Notification(title, options);
18
- };
19
- } else if ("mozNotification" in navigator) {
20
- notify = function (title, options) {
21
- // Gecko < 22
22
- return navigator.mozNotification
23
- .createNotification(title, options.body, options.icon)
24
- .show();
25
- };
26
- } else if ("webkitNotifications" in window) {
27
- notify = function (title, options) {
28
- return window.webkitNotifications.createNotification(
29
- options.icon,
30
- title,
31
- options.body
32
- );
33
- };
34
- } else {
35
- notify = function (title, options) {
36
- return null;
37
- };
38
- }
39
- return notify(title, options);
40
- };
13
+ }(this, function($, PNotify){
14
+ var permission;
15
+ var notify = function(title, options){
16
+ // Memoize based on feature detection.
17
+ if ("Notification" in window) {
18
+ notify = function (title, options) {
19
+ return new Notification(title, options);
20
+ };
21
+ } else if ("mozNotification" in navigator) {
22
+ notify = function (title, options) {
23
+ // Gecko < 22
24
+ return navigator.mozNotification
25
+ .createNotification(title, options.body, options.icon)
26
+ .show();
27
+ };
28
+ } else if ("webkitNotifications" in window) {
29
+ notify = function (title, options) {
30
+ return window.webkitNotifications.createNotification(
31
+ options.icon,
32
+ title,
33
+ options.body
34
+ );
35
+ };
36
+ } else {
37
+ notify = function (title, options) {
38
+ return null;
39
+ };
40
+ }
41
+ return notify(title, options);
42
+ };
41
43
 
42
44
 
43
- PNotify.prototype.options.desktop = {
44
- // Display the notification as a desktop notification.
45
- desktop: false,
46
- // The URL of the icon to display. If false, no icon will show. If null, a default icon will show.
47
- icon: null,
48
- // Using a tag lets you update an existing notice, or keep from duplicating notices between tabs.
49
- // If you leave tag null, one will be generated, facilitating the "update" function.
50
- // see: http://www.w3.org/TR/notifications/#tags-example
51
- tag: null
52
- };
53
- PNotify.prototype.modules.desktop = {
54
- tag: null,
55
- icon: null,
56
- genNotice: function(notice, options){
57
- if (options.icon === null) {
58
- this.icon = "http://sciactive.com/pnotify/includes/desktop/"+notice.options.type+".png";
59
- } else if (options.icon === false) {
60
- this.icon = null;
61
- } else {
62
- this.icon = options.icon;
63
- }
64
- if (this.tag === null || options.tag !== null) {
65
- this.tag = options.tag === null ? "PNotify-"+Math.round(Math.random() * 1000000) : options.tag;
66
- }
67
- notice.desktop = notify(notice.options.title, {
68
- icon: this.icon,
69
- body: notice.options.text,
70
- tag: this.tag
71
- });
72
- if (!("close" in notice.desktop)) {
73
- notice.desktop.close = function(){
74
- notice.desktop.cancel();
75
- };
76
- }
77
- notice.desktop.onclick = function(){
78
- notice.elem.trigger("click");
79
- };
80
- notice.desktop.onclose = function(){
81
- if (notice.state !== "closing" && notice.state !== "closed") {
82
- notice.remove();
83
- }
84
- };
85
- },
86
- init: function(notice, options){
87
- if (!options.desktop)
88
- return;
89
- permission = PNotify.desktop.checkPermission();
90
- if (permission != 0)
91
- return;
92
- this.genNotice(notice, options);
93
- },
94
- update: function(notice, options, oldOpts){
95
- if (permission != 0 || !options.desktop)
96
- return;
97
- this.genNotice(notice, options);
98
- },
99
- beforeOpen: function(notice, options){
100
- if (permission != 0 || !options.desktop)
101
- return;
102
- notice.elem.css({'left': '-10000px', 'display': 'none'});
103
- },
104
- afterOpen: function(notice, options){
105
- if (permission != 0 || !options.desktop)
106
- return;
107
- notice.elem.css({'left': '-10000px', 'display': 'none'});
108
- if ("show" in notice.desktop) {
109
- notice.desktop.show();
110
- }
111
- },
112
- beforeClose: function(notice, options){
113
- if (permission != 0 || !options.desktop)
114
- return;
115
- notice.elem.css({'left': '-10000px', 'display': 'none'});
116
- },
117
- afterClose: function(notice, options){
118
- if (permission != 0 || !options.desktop)
119
- return;
120
- notice.elem.css({'left': '-10000px', 'display': 'none'});
121
- notice.desktop.close();
122
- }
123
- };
124
- PNotify.desktop = {
125
- permission: function(){
126
- if (typeof Notification !== "undefined" && "requestPermission" in Notification) {
127
- Notification.requestPermission();
128
- } else if ("webkitNotifications" in window) {
129
- window.webkitNotifications.requestPermission();
130
- }
131
- },
132
- checkPermission: function(){
133
- if (typeof Notification !== "undefined" && "permission" in Notification) {
134
- return (Notification.permission == "granted" ? 0 : 1);
135
- } else if ("webkitNotifications" in window) {
136
- return window.webkitNotifications.checkPermission();
137
- } else {
138
- return 1;
139
- }
140
- }
141
- };
142
- permission = PNotify.desktop.checkPermission();
45
+ PNotify.prototype.options.desktop = {
46
+ // Display the notification as a desktop notification.
47
+ desktop: false,
48
+ // If desktop notifications are not supported or allowed, fall back to a regular notice.
49
+ fallback: true,
50
+ // The URL of the icon to display. If false, no icon will show. If null, a default icon will show.
51
+ icon: null,
52
+ // Using a tag lets you update an existing notice, or keep from duplicating notices between tabs.
53
+ // If you leave tag null, one will be generated, facilitating the "update" function.
54
+ // see: http://www.w3.org/TR/notifications/#tags-example
55
+ tag: null
56
+ };
57
+ PNotify.prototype.modules.desktop = {
58
+ tag: null,
59
+ icon: null,
60
+ genNotice: function(notice, options){
61
+ if (options.icon === null) {
62
+ this.icon = "http://sciactive.com/pnotify/includes/desktop/"+notice.options.type+".png";
63
+ } else if (options.icon === false) {
64
+ this.icon = null;
65
+ } else {
66
+ this.icon = options.icon;
67
+ }
68
+ if (this.tag === null || options.tag !== null) {
69
+ this.tag = options.tag === null ? "PNotify-"+Math.round(Math.random() * 1000000) : options.tag;
70
+ }
71
+ notice.desktop = notify(notice.options.title, {
72
+ icon: this.icon,
73
+ body: options.text || notice.options.text,
74
+ tag: this.tag
75
+ });
76
+ if (!("close" in notice.desktop) && ("cancel" in notice.desktop)) {
77
+ notice.desktop.close = function(){
78
+ notice.desktop.cancel();
79
+ };
80
+ }
81
+ notice.desktop.onclick = function(){
82
+ notice.elem.trigger("click");
83
+ };
84
+ notice.desktop.onclose = function(){
85
+ if (notice.state !== "closing" && notice.state !== "closed") {
86
+ notice.remove();
87
+ }
88
+ };
89
+ },
90
+ init: function(notice, options){
91
+ if (!options.desktop)
92
+ return;
93
+ permission = PNotify.desktop.checkPermission();
94
+ if (permission !== 0) {
95
+ // Keep the notice from opening if fallback is false.
96
+ if (!options.fallback) {
97
+ notice.options.auto_display = false;
98
+ }
99
+ return;
100
+ }
101
+ this.genNotice(notice, options);
102
+ },
103
+ update: function(notice, options, oldOpts){
104
+ if ((permission !== 0 && options.fallback) || !options.desktop)
105
+ return;
106
+ this.genNotice(notice, options);
107
+ },
108
+ beforeOpen: function(notice, options){
109
+ if ((permission !== 0 && options.fallback) || !options.desktop)
110
+ return;
111
+ notice.elem.css({'left': '-10000px'}).removeClass('ui-pnotify-in');
112
+ },
113
+ afterOpen: function(notice, options){
114
+ if ((permission !== 0 && options.fallback) || !options.desktop)
115
+ return;
116
+ notice.elem.css({'left': '-10000px'}).removeClass('ui-pnotify-in');
117
+ if ("show" in notice.desktop) {
118
+ notice.desktop.show();
119
+ }
120
+ },
121
+ beforeClose: function(notice, options){
122
+ if ((permission !== 0 && options.fallback) || !options.desktop)
123
+ return;
124
+ notice.elem.css({'left': '-10000px'}).removeClass('ui-pnotify-in');
125
+ },
126
+ afterClose: function(notice, options){
127
+ if ((permission !== 0 && options.fallback) || !options.desktop)
128
+ return;
129
+ notice.elem.css({'left': '-10000px'}).removeClass('ui-pnotify-in');
130
+ if ("close" in notice.desktop) {
131
+ notice.desktop.close();
132
+ }
133
+ }
134
+ };
135
+ PNotify.desktop = {
136
+ permission: function(){
137
+ if (typeof Notification !== "undefined" && "requestPermission" in Notification) {
138
+ Notification.requestPermission();
139
+ } else if ("webkitNotifications" in window) {
140
+ window.webkitNotifications.requestPermission();
141
+ }
142
+ },
143
+ checkPermission: function(){
144
+ if (typeof Notification !== "undefined" && "permission" in Notification) {
145
+ return (Notification.permission === "granted" ? 0 : 1);
146
+ } else if ("webkitNotifications" in window) {
147
+ return window.webkitNotifications.checkPermission() == 0 ? 0 : 1;
148
+ } else {
149
+ return 1;
150
+ }
151
+ }
152
+ };
153
+ permission = PNotify.desktop.checkPermission();
143
154
  }));