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.
- checksums.yaml +4 -4
- data/lib/pnotify-rails/version.rb +1 -1
- data/vendor/assets/javascripts/pnotify/index.js +5 -1
- data/vendor/assets/javascripts/pnotify/pnotify.animate.js +108 -0
- data/vendor/assets/javascripts/pnotify/pnotify.buttons.js +165 -121
- data/vendor/assets/javascripts/pnotify/pnotify.callbacks.js +42 -40
- data/vendor/assets/javascripts/pnotify/pnotify.confirm.js +145 -139
- data/vendor/assets/javascripts/pnotify/pnotify.desktop.js +144 -133
- data/vendor/assets/javascripts/pnotify/pnotify.history.js +172 -171
- data/vendor/assets/javascripts/pnotify/pnotify.js +873 -0
- data/vendor/assets/javascripts/pnotify/pnotify.mobile.js +121 -0
- data/vendor/assets/javascripts/pnotify/pnotify.nonblock.js +144 -139
- data/vendor/assets/javascripts/pnotify/pnotify.reference.js +131 -116
- data/vendor/assets/javascripts/pnotify/pnotify.tooltip.js +15 -0
- data/vendor/assets/stylesheets/pnotify/index.css +5 -2
- data/vendor/assets/stylesheets/pnotify/pnotify.brighttheme.css +165 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.buttons.css +2 -2
- data/vendor/assets/stylesheets/pnotify/pnotify.css +112 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.history.css +22 -22
- data/vendor/assets/stylesheets/pnotify/pnotify.material.css +121 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.mobile.css +46 -0
- data/vendor/assets/stylesheets/pnotify/pnotify.nonblock.css +7 -0
- metadata +12 -6
- data/vendor/assets/javascripts/pnotify/pnotify.core.js +0 -778
- data/vendor/assets/stylesheets/pnotify/pnotify.core.css +0 -56
- data/vendor/assets/stylesheets/pnotify/pnotify.picon.css +0 -11
@@ -1,152 +1,158 @@
|
|
1
1
|
// Confirm
|
2
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
54
|
-
|
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
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
58
|
+
if (options.confirm || options.prompt)
|
59
|
+
this.makeDialog(notice, options);
|
60
|
+
else
|
61
|
+
this.container.hide();
|
62
|
+
},
|
61
63
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
73
|
+
afterOpen: function(notice, options){
|
74
|
+
if (options.prompt)
|
75
|
+
this.prompt.focus();
|
76
|
+
},
|
75
77
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
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
|
-
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
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
|
}));
|