Commit 6b4c3088bc8f2fc00c1b86b004f0d200d6c1369b
1 parent
dd3e537c
Fixed problems with TriangleIconDown in jQueryPlugin-sample.
Fixed jquery.pnotify.js (events detached on hide) both in jQueryPlugin-sample and in notify component.
Showing
1 changed file
with
729 additions
and
721 deletions
... | ... | @@ -8,9 +8,9 @@ |
8 | 8 | */ |
9 | 9 | |
10 | 10 | (function($) { |
11 | - var history_handle_top, timer; | |
12 | - var body; | |
13 | - var jwindow; | |
11 | + var history_handle_top, timer; | |
12 | + var body; | |
13 | + var jwindow; | |
14 | 14 | |
15 | 15 | function $14(element, options) { |
16 | 16 | var attrFn = { |
... | ... | @@ -27,733 +27,741 @@ |
27 | 27 | for (var key in options) { |
28 | 28 | if (jQuery.isFunction(options[key])) { |
29 | 29 | o.bind(key, options[key]); |
30 | - } else if(key in attrFn) { | |
30 | + } else if (key in attrFn) { | |
31 | 31 | o[key](options[key]); |
32 | 32 | } else { |
33 | 33 | o.attr(key, options[key]); |
34 | 34 | } |
35 | - } | |
36 | - return o; | |
35 | + } | |
36 | + return o; | |
37 | 37 | } |
38 | - $.extend({ | |
39 | - pnotify_remove_all: function () { | |
40 | - var body_data = body.data("pnotify"); | |
41 | - /* POA: Added null-check */ | |
42 | - if (body_data && body_data.length) { | |
43 | - $.each(body_data, function(){ | |
44 | - if (this.pnotify_remove) | |
45 | - this.pnotify_remove(); | |
46 | - }); | |
47 | - } | |
48 | - }, | |
49 | - pnotify_position_all: function () { | |
50 | - if (timer) | |
51 | - clearTimeout(timer); | |
52 | - timer = null; | |
53 | - var body_data = body.data("pnotify"); | |
54 | - if (!body_data || !body_data.length) | |
55 | - return; | |
56 | - $.each(body_data, function(){ | |
57 | - var s = this.opts.pnotify_stack; | |
58 | - if (!s) return; | |
59 | - if (!s.nextpos1) | |
60 | - s.nextpos1 = s.firstpos1; | |
61 | - if (!s.nextpos2) | |
62 | - s.nextpos2 = s.firstpos2; | |
63 | - if (!s.addpos2) | |
64 | - s.addpos2 = 0; | |
65 | - if (this.css("display") != "none") { | |
66 | - var curpos1, curpos2; | |
67 | - var animate = {}; | |
68 | - // Calculate the current pos1 value. | |
69 | - var csspos1; | |
70 | - switch (s.dir1) { | |
71 | - case "down": | |
72 | - csspos1 = "top"; | |
73 | - break; | |
74 | - case "up": | |
75 | - csspos1 = "bottom"; | |
76 | - break; | |
77 | - case "left": | |
78 | - csspos1 = "right"; | |
79 | - break; | |
80 | - case "right": | |
81 | - csspos1 = "left"; | |
82 | - break; | |
83 | - } | |
84 | - curpos1 = parseInt(this.css(csspos1)); | |
85 | - if (isNaN(curpos1)) | |
86 | - curpos1 = 0; | |
87 | - // Remember the first pos1, so the first visible notice goes there. | |
88 | - if (typeof s.firstpos1 == "undefined") { | |
89 | - s.firstpos1 = curpos1; | |
90 | - s.nextpos1 = s.firstpos1; | |
91 | - } | |
92 | - // Calculate the current pos2 value. | |
93 | - var csspos2; | |
94 | - switch (s.dir2) { | |
95 | - case "down": | |
96 | - csspos2 = "top"; | |
97 | - break; | |
98 | - case "up": | |
99 | - csspos2 = "bottom"; | |
100 | - break; | |
101 | - case "left": | |
102 | - csspos2 = "right"; | |
103 | - break; | |
104 | - case "right": | |
105 | - csspos2 = "left"; | |
106 | - break; | |
107 | - } | |
108 | - curpos2 = parseInt(this.css(csspos2)); | |
109 | - if (isNaN(curpos2)) | |
110 | - curpos2 = 0; | |
111 | - // Remember the first pos2, so the first visible notice goes there. | |
112 | - if (typeof s.firstpos2 == "undefined") { | |
113 | - s.firstpos2 = curpos2; | |
114 | - s.nextpos2 = s.firstpos2; | |
115 | - } | |
116 | - // Check that it's not beyond the viewport edge. | |
117 | - if ((s.dir1 == "down" && s.nextpos1 + this.height() > jwindow.height()) || | |
118 | - (s.dir1 == "up" && s.nextpos1 + this.height() > jwindow.height()) || | |
119 | - (s.dir1 == "left" && s.nextpos1 + this.width() > jwindow.width()) || | |
120 | - (s.dir1 == "right" && s.nextpos1 + this.width() > jwindow.width()) ) { | |
121 | - // If it is, it needs to go back to the first pos1, and over on pos2. | |
122 | - s.nextpos1 = s.firstpos1; | |
123 | - s.nextpos2 += s.addpos2 + 10; | |
124 | - s.addpos2 = 0; | |
125 | - } | |
126 | - // Animate if we're moving on dir2. | |
127 | - if (s.animation && s.nextpos2 < curpos2) { | |
128 | - switch (s.dir2) { | |
129 | - case "down": | |
130 | - animate.top = s.nextpos2+"px"; | |
131 | - break; | |
132 | - case "up": | |
133 | - animate.bottom = s.nextpos2+"px"; | |
134 | - break; | |
135 | - case "left": | |
136 | - animate.right = s.nextpos2+"px"; | |
137 | - break; | |
138 | - case "right": | |
139 | - animate.left = s.nextpos2+"px"; | |
140 | - break; | |
141 | - } | |
142 | - } else | |
143 | - this.css(csspos2, s.nextpos2+"px"); | |
144 | - // Keep track of the widest/tallest notice in the column/row, so we can push the next column/row. | |
145 | - switch (s.dir2) { | |
146 | - case "down": | |
147 | - case "up": | |
148 | - if (this.outerHeight(true) > s.addpos2) | |
149 | - s.addpos2 = this.height(); | |
150 | - break; | |
151 | - case "left": | |
152 | - case "right": | |
153 | - if (this.outerWidth(true) > s.addpos2) | |
154 | - s.addpos2 = this.width(); | |
155 | - break; | |
156 | - } | |
157 | - // Move the notice on dir1. | |
158 | - if (s.nextpos1) { | |
159 | - // Animate if we're moving toward the first pos. | |
160 | - if (s.animation && (curpos1 > s.nextpos1 || animate.top || animate.bottom || animate.right || animate.left)) { | |
161 | - switch (s.dir1) { | |
162 | - case "down": | |
163 | - animate.top = s.nextpos1+"px"; | |
164 | - break; | |
165 | - case "up": | |
166 | - animate.bottom = s.nextpos1+"px"; | |
167 | - break; | |
168 | - case "left": | |
169 | - animate.right = s.nextpos1+"px"; | |
170 | - break; | |
171 | - case "right": | |
172 | - animate.left = s.nextpos1+"px"; | |
173 | - break; | |
174 | - } | |
175 | - } else | |
176 | - this.css(csspos1, s.nextpos1+"px"); | |
177 | - } | |
178 | - if (animate.top || animate.bottom || animate.right || animate.left) | |
179 | - this.animate(animate, {duration: 500, queue: false}); | |
180 | - // Calculate the next dir1 position. | |
181 | - switch (s.dir1) { | |
182 | - case "down": | |
183 | - case "up": | |
184 | - s.nextpos1 += this.height() + 10; | |
185 | - break; | |
186 | - case "left": | |
187 | - case "right": | |
188 | - s.nextpos1 += this.width() + 10; | |
189 | - break; | |
190 | - } | |
191 | - } | |
192 | - }); | |
193 | - // Reset the next position data. | |
194 | - $.each(body_data, function(){ | |
195 | - var s = this.opts.pnotify_stack; | |
196 | - if (!s) return; | |
197 | - s.nextpos1 = s.firstpos1; | |
198 | - s.nextpos2 = s.firstpos2; | |
199 | - s.addpos2 = 0; | |
200 | - s.animation = true; | |
201 | - }); | |
202 | - }, | |
203 | - pnotify: function(options) { | |
204 | - if (!body) | |
205 | - body = $("body"); | |
206 | - if (!jwindow) | |
207 | - jwindow = $(window); | |
208 | - | |
209 | - var animating; | |
210 | - | |
211 | - // Build main options. | |
212 | - var opts; | |
213 | - if (typeof options != "object") { | |
214 | - opts = $.extend({}, $.pnotify.defaults); | |
215 | - opts.pnotify_text = options; | |
216 | - } else { | |
217 | - opts = $.extend({}, $.pnotify.defaults, options); | |
38 | + | |
39 | + $.extend({ | |
40 | + pnotify_remove_all: function () { | |
41 | + var body_data = body.data("pnotify"); | |
42 | + /* POA: Added null-check */ | |
43 | + if (body_data && body_data.length) { | |
44 | + $.each(body_data, function() { | |
45 | + if (this.pnotify_remove) | |
46 | + this.pnotify_remove(); | |
47 | + }); | |
48 | + } | |
49 | + }, | |
50 | + pnotify_position_all: function () { | |
51 | + if (timer) | |
52 | + clearTimeout(timer); | |
53 | + timer = null; | |
54 | + var body_data = body.data("pnotify"); | |
55 | + if (!body_data || !body_data.length) | |
56 | + return; | |
57 | + $.each(body_data, function() { | |
58 | + var s = this.opts.pnotify_stack; | |
59 | + if (!s) return; | |
60 | + if (!s.nextpos1) | |
61 | + s.nextpos1 = s.firstpos1; | |
62 | + if (!s.nextpos2) | |
63 | + s.nextpos2 = s.firstpos2; | |
64 | + if (!s.addpos2) | |
65 | + s.addpos2 = 0; | |
66 | + if (this.css("display") != "none") { | |
67 | + var curpos1, curpos2; | |
68 | + var animate = {}; | |
69 | + // Calculate the current pos1 value. | |
70 | + var csspos1; | |
71 | + switch (s.dir1) { | |
72 | + case "down": | |
73 | + csspos1 = "top"; | |
74 | + break; | |
75 | + case "up": | |
76 | + csspos1 = "bottom"; | |
77 | + break; | |
78 | + case "left": | |
79 | + csspos1 = "right"; | |
80 | + break; | |
81 | + case "right": | |
82 | + csspos1 = "left"; | |
83 | + break; | |
84 | + } | |
85 | + curpos1 = parseInt(this.css(csspos1)); | |
86 | + if (isNaN(curpos1)) | |
87 | + curpos1 = 0; | |
88 | + // Remember the first pos1, so the first visible notice goes there. | |
89 | + if (typeof s.firstpos1 == "undefined") { | |
90 | + s.firstpos1 = curpos1; | |
91 | + s.nextpos1 = s.firstpos1; | |
92 | + } | |
93 | + // Calculate the current pos2 value. | |
94 | + var csspos2; | |
95 | + switch (s.dir2) { | |
96 | + case "down": | |
97 | + csspos2 = "top"; | |
98 | + break; | |
99 | + case "up": | |
100 | + csspos2 = "bottom"; | |
101 | + break; | |
102 | + case "left": | |
103 | + csspos2 = "right"; | |
104 | + break; | |
105 | + case "right": | |
106 | + csspos2 = "left"; | |
107 | + break; | |
108 | + } | |
109 | + curpos2 = parseInt(this.css(csspos2)); | |
110 | + if (isNaN(curpos2)) | |
111 | + curpos2 = 0; | |
112 | + // Remember the first pos2, so the first visible notice goes there. | |
113 | + if (typeof s.firstpos2 == "undefined") { | |
114 | + s.firstpos2 = curpos2; | |
115 | + s.nextpos2 = s.firstpos2; | |
116 | + } | |
117 | + // Check that it's not beyond the viewport edge. | |
118 | + if ((s.dir1 == "down" && s.nextpos1 + this.height() > jwindow.height()) || | |
119 | + (s.dir1 == "up" && s.nextpos1 + this.height() > jwindow.height()) || | |
120 | + (s.dir1 == "left" && s.nextpos1 + this.width() > jwindow.width()) || | |
121 | + (s.dir1 == "right" && s.nextpos1 + this.width() > jwindow.width())) { | |
122 | + // If it is, it needs to go back to the first pos1, and over on pos2. | |
123 | + s.nextpos1 = s.firstpos1; | |
124 | + s.nextpos2 += s.addpos2 + 10; | |
125 | + s.addpos2 = 0; | |
126 | + } | |
127 | + // Animate if we're moving on dir2. | |
128 | + if (s.animation && s.nextpos2 < curpos2) { | |
129 | + switch (s.dir2) { | |
130 | + case "down": | |
131 | + animate.top = s.nextpos2 + "px"; | |
132 | + break; | |
133 | + case "up": | |
134 | + animate.bottom = s.nextpos2 + "px"; | |
135 | + break; | |
136 | + case "left": | |
137 | + animate.right = s.nextpos2 + "px"; | |
138 | + break; | |
139 | + case "right": | |
140 | + animate.left = s.nextpos2 + "px"; | |
141 | + break; | |
142 | + } | |
143 | + } else | |
144 | + this.css(csspos2, s.nextpos2 + "px"); | |
145 | + // Keep track of the widest/tallest notice in the column/row, so we can push the next column/row. | |
146 | + switch (s.dir2) { | |
147 | + case "down": | |
148 | + case "up": | |
149 | + if (this.outerHeight(true) > s.addpos2) | |
150 | + s.addpos2 = this.height(); | |
151 | + break; | |
152 | + case "left": | |
153 | + case "right": | |
154 | + if (this.outerWidth(true) > s.addpos2) | |
155 | + s.addpos2 = this.width(); | |
156 | + break; | |
157 | + } | |
158 | + // Move the notice on dir1. | |
159 | + if (s.nextpos1) { | |
160 | + // Animate if we're moving toward the first pos. | |
161 | + if (s.animation && (curpos1 > s.nextpos1 || animate.top || animate.bottom || animate.right || animate.left)) { | |
162 | + switch (s.dir1) { | |
163 | + case "down": | |
164 | + animate.top = s.nextpos1 + "px"; | |
165 | + break; | |
166 | + case "up": | |
167 | + animate.bottom = s.nextpos1 + "px"; | |
168 | + break; | |
169 | + case "left": | |
170 | + animate.right = s.nextpos1 + "px"; | |
171 | + break; | |
172 | + case "right": | |
173 | + animate.left = s.nextpos1 + "px"; | |
174 | + break; | |
175 | + } | |
176 | + } else | |
177 | + this.css(csspos1, s.nextpos1 + "px"); | |
178 | + } | |
179 | + if (animate.top || animate.bottom || animate.right || animate.left) | |
180 | + this.animate(animate, {duration: 500, queue: false}); | |
181 | + // Calculate the next dir1 position. | |
182 | + switch (s.dir1) { | |
183 | + case "down": | |
184 | + case "up": | |
185 | + s.nextpos1 += this.height() + 10; | |
186 | + break; | |
187 | + case "left": | |
188 | + case "right": | |
189 | + s.nextpos1 += this.width() + 10; | |
190 | + break; | |
191 | + } | |
192 | + } | |
193 | + }); | |
194 | + // Reset the next position data. | |
195 | + $.each(body_data, function() { | |
196 | + var s = this.opts.pnotify_stack; | |
197 | + if (!s) return; | |
198 | + s.nextpos1 = s.firstpos1; | |
199 | + s.nextpos2 = s.firstpos2; | |
200 | + s.addpos2 = 0; | |
201 | + s.animation = true; | |
202 | + }); | |
203 | + }, | |
204 | + pnotify: function(options) { | |
205 | + if (!body) | |
206 | + body = $("body"); | |
207 | + if (!jwindow) | |
208 | + jwindow = $(window); | |
209 | + | |
210 | + var animating; | |
211 | + | |
212 | + // Build main options. | |
213 | + var opts; | |
214 | + if (typeof options != "object") { | |
215 | + opts = $.extend({}, $.pnotify.defaults); | |
216 | + opts.pnotify_text = options; | |
217 | + } else { | |
218 | + opts = $.extend({}, $.pnotify.defaults, options); | |
218 | 219 | if (opts['pnotify_animation'] instanceof Object) { |
219 | 220 | opts['pnotify_animation'] = $.extend({ |
220 | 221 | effect_in:$.pnotify.defaults.pnotify_animation, |
221 | 222 | effect_out:$.pnotify.defaults.pnotify_animation |
222 | 223 | }, opts['pnotify_animation']); |
223 | 224 | } |
224 | - } | |
225 | - | |
226 | - if (opts.pnotify_before_init) { | |
227 | - if (opts.pnotify_before_init(opts) === false) | |
228 | - return null; | |
229 | - } | |
230 | - | |
231 | - // This keeps track of the last element the mouse was over, so | |
232 | - // mouseleave, mouseenter, etc can be called. | |
233 | - var nonblock_last_elem; | |
234 | - // This is used to pass events through the notice if it is non-blocking. | |
235 | - var nonblock_pass = function(e, e_name){ | |
236 | - pnotify.css("display", "none"); | |
237 | - var element_below = document.elementFromPoint(e.clientX, e.clientY); | |
238 | - pnotify.css("display", "block"); | |
239 | - var jelement_below = $(element_below); | |
240 | - var cursor_style = jelement_below.css("cursor"); | |
241 | - pnotify.css("cursor", cursor_style != "auto" ? cursor_style : "default"); | |
242 | - // If the element changed, call mouseenter, mouseleave, etc. | |
243 | - if (!nonblock_last_elem || nonblock_last_elem.get(0) != element_below) { | |
244 | - if (nonblock_last_elem) { | |
245 | - dom_event.call(nonblock_last_elem.get(0), "mouseleave", e.originalEvent); | |
246 | - dom_event.call(nonblock_last_elem.get(0), "mouseout", e.originalEvent); | |
247 | - } | |
248 | - dom_event.call(element_below, "mouseenter", e.originalEvent); | |
249 | - dom_event.call(element_below, "mouseover", e.originalEvent); | |
250 | - } | |
251 | - dom_event.call(element_below, e_name, e.originalEvent); | |
252 | - // Remember the latest element the mouse was over. | |
253 | - nonblock_last_elem = jelement_below; | |
254 | - }; | |
255 | - | |
256 | - // Create our widget. | |
257 | - // Stop animation, reset the removal timer, and show the close | |
258 | - // button when the user mouses over. | |
259 | - var pnotify = $14("<div />", { | |
260 | - "class": "rf-ny "+opts.pnotify_addclass, | |
261 | - "css": {"display": "none"}, | |
262 | - "mouseenter": function(e){ | |
263 | - if (opts.pnotify_nonblock) e.stopPropagation(); | |
264 | - if (opts.pnotify_mouse_reset && animating == "out") { | |
265 | - // If it's animating out, animate back in really quick. | |
266 | - pnotify.stop(true); | |
267 | - pnotify.css("height", "auto").animate({"width": opts.pnotify_width, "opacity": opts.pnotify_nonblock ? opts.pnotify_nonblock_opacity : opts.pnotify_opacity}, "fast"); | |
268 | - } else if (opts.pnotify_nonblock && animating != "out") { | |
269 | - // If it's non-blocking, animate to the other opacity. | |
270 | - pnotify.animate({"opacity": opts.pnotify_nonblock_opacity}, "fast"); | |
271 | - } | |
272 | - if (opts.pnotify_hide && opts.pnotify_mouse_reset) pnotify.pnotify_cancel_remove(); | |
273 | - if (opts.pnotify_closer && !opts.pnotify_nonblock) pnotify.closer.show(); | |
274 | - }, | |
275 | - "mouseleave": function(e){ | |
276 | - if (opts.pnotify_nonblock) e.stopPropagation(); | |
277 | - nonblock_last_elem = null; | |
278 | - pnotify.css("cursor", "auto"); | |
279 | - if (opts.pnotify_nonblock && animating != "out") | |
280 | - pnotify.animate({"opacity": opts.pnotify_opacity}, "fast"); | |
281 | - if (opts.pnotify_hide && opts.pnotify_mouse_reset) pnotify.pnotify_queue_remove(); | |
282 | - pnotify.closer.hide(); | |
283 | - $.pnotify_position_all(); | |
284 | - }, | |
285 | - "mouseover": function(e){ | |
286 | - if (opts.pnotify_nonblock) e.stopPropagation(); | |
287 | - }, | |
288 | - "mouseout": function(e){ | |
289 | - if (opts.pnotify_nonblock) e.stopPropagation(); | |
290 | - }, | |
291 | - "mousemove": function(e){ | |
292 | - if (opts.pnotify_nonblock) { | |
293 | - e.stopPropagation(); | |
294 | - nonblock_pass(e, "onmousemove"); | |
295 | - } | |
296 | - }, | |
297 | - "mousedown": function(e){ | |
298 | - if (opts.pnotify_nonblock) { | |
299 | - e.stopPropagation(); | |
300 | - e.preventDefault(); | |
301 | - nonblock_pass(e, "onmousedown"); | |
302 | - } | |
303 | - }, | |
304 | - "mouseup": function(e){ | |
305 | - if (opts.pnotify_nonblock) { | |
306 | - e.stopPropagation(); | |
307 | - e.preventDefault(); | |
308 | - nonblock_pass(e, "onmouseup"); | |
309 | - } | |
310 | - }, | |
311 | - "click": function(e){ | |
312 | - if (opts.pnotify_nonblock) { | |
313 | - e.stopPropagation(); | |
314 | - nonblock_pass(e, "onclick"); | |
315 | - } | |
316 | - }, | |
317 | - "dblclick": function(e){ | |
318 | - if (opts.pnotify_nonblock) { | |
319 | - e.stopPropagation(); | |
320 | - nonblock_pass(e, "ondblclick"); | |
321 | - } | |
322 | - } | |
323 | - }); | |
324 | - pnotify.opts = opts; | |
325 | - // Create a drop shadow. | |
326 | - if (opts.pnotify_shadow && !$.browser.msie) | |
327 | - pnotify.shadow_container = $14("<div />", {"class": "rf-ny-sh"}).prependTo(pnotify); | |
328 | - // Create a container for the notice contents. | |
329 | - pnotify.container = $14("<div />", {"class": "rf-ny-co"}) | |
330 | - .appendTo(pnotify); | |
331 | - | |
332 | - pnotify.pnotify_version = "1.0.0"; | |
333 | - | |
334 | - // This function is for updating the notice. | |
335 | - pnotify.pnotify = function(options) { | |
336 | - // Update the notice. | |
337 | - var old_opts = opts; | |
338 | - if (typeof options == "string") | |
339 | - opts.pnotify_text = options; | |
340 | - else | |
341 | - opts = $.extend({}, opts, options); | |
342 | - pnotify.opts = opts; | |
343 | - // Update the shadow. | |
344 | - if (opts.pnotify_shadow != old_opts.pnotify_shadow) { | |
345 | - if (opts.pnotify_shadow && !$.browser.msie) | |
346 | - pnotify.shadow_container = $14("<div />", {"class": "rf-ny-sh"}).prependTo(pnotify); | |
347 | - else | |
348 | - pnotify.children(".rf-ny-sh").remove(); | |
349 | - } | |
350 | - // Update the additional classes. | |
351 | - if (opts.pnotify_addclass === false) | |
352 | - pnotify.removeClass(old_opts.pnotify_addclass); | |
353 | - else if (opts.pnotify_addclass !== old_opts.pnotify_addclass) | |
354 | - pnotify.removeClass(old_opts.pnotify_addclass).addClass(opts.pnotify_addclass); | |
355 | - // Update the title. | |
356 | - if (opts.pnotify_title === false) | |
357 | - pnotify.title_container.hide("fast"); | |
358 | - else if (opts.pnotify_title !== old_opts.pnotify_title) | |
359 | - pnotify.title_container.html(opts.pnotify_title).show(200); | |
360 | - // Update the text. | |
361 | - if (opts.pnotify_text === false) { | |
362 | - pnotify.text_container.hide("fast"); | |
363 | - } else if (opts.pnotify_text !== old_opts.pnotify_text) { | |
364 | - if (opts.pnotify_insert_brs) | |
365 | - opts.pnotify_text = opts.pnotify_text.replace(/\n/g, "<br />"); | |
366 | - pnotify.text_container.html(opts.pnotify_text).show(200); | |
367 | - } | |
368 | - pnotify.pnotify_history = opts.pnotify_history; | |
369 | - // Change the notice type. | |
370 | - if (opts.pnotify_type != old_opts.pnotify_type) | |
371 | - pnotify.container.toggleClass("rf-ny-co rf-ny-co-hover"); | |
372 | - if ((opts.pnotify_notice_icon != old_opts.pnotify_notice_icon && opts.pnotify_type == "notice") || | |
373 | - (opts.pnotify_error_icon != old_opts.pnotify_error_icon && opts.pnotify_type == "error") || | |
374 | - (opts.pnotify_type != old_opts.pnotify_type)) { | |
375 | - // Remove any old icon. | |
376 | - pnotify.container.find("div.rf-ny-ic").remove(); | |
377 | -// if ((opts.pnotify_error_icon && opts.pnotify_type == "error") || (opts.pnotify_notice_icon)) { | |
378 | - // Build the new icon. | |
379 | - $14("<div />", {"class": "rf-ny-ic"}) | |
380 | - .append($14("<span />", {"class": opts.pnotify_type == "error" ? opts.pnotify_error_icon : opts.pnotify_notice_icon})) | |
381 | - .prependTo(pnotify.container); | |
382 | -// } | |
383 | - } | |
384 | - // Update the width. | |
385 | - if (opts.pnotify_width !== old_opts.pnotify_width) | |
386 | - pnotify.animate({width: opts.pnotify_width}); | |
387 | - // Update the minimum height. | |
388 | - if (opts.pnotify_min_height !== old_opts.pnotify_min_height) | |
389 | - pnotify.container.animate({minHeight: opts.pnotify_min_height}); | |
390 | - // Update the opacity. | |
391 | - if (opts.pnotify_opacity !== old_opts.pnotify_opacity) | |
392 | - pnotify.fadeTo(opts.pnotify_animate_speed, opts.pnotify_opacity); | |
393 | - if (!opts.pnotify_hide) | |
394 | - pnotify.pnotify_cancel_remove(); | |
395 | - else if (!old_opts.pnotify_hide) | |
396 | - pnotify.pnotify_queue_remove(); | |
397 | - pnotify.pnotify_queue_position(); | |
398 | - return pnotify; | |
399 | - }; | |
400 | - | |
401 | - // Queue the position function so it doesn't run repeatedly and use | |
402 | - // up resources. | |
403 | - pnotify.pnotify_queue_position = function() { | |
404 | - if (timer) | |
405 | - clearTimeout(timer); | |
406 | - timer = setTimeout($.pnotify_position_all, 10); | |
407 | - }; | |
408 | - | |
409 | - // Display the notice. | |
410 | - pnotify.pnotify_display = function() { | |
411 | - // If the notice is not in the DOM, append it. | |
412 | - if (!pnotify.parent().length) | |
413 | - pnotify.appendTo(body); | |
414 | - // Run callback. | |
415 | - if (opts.pnotify_before_open) { | |
416 | - if (opts.pnotify_before_open(pnotify) === false) | |
417 | - return; | |
418 | - } | |
419 | - pnotify.pnotify_queue_position(); | |
420 | - // First show it, then set its opacity, then hide it. | |
421 | - if (opts.pnotify_animation == "fade" || opts.pnotify_animation.effect_in == "fade") { | |
422 | - // If it's fading in, it should start at 0. | |
423 | - pnotify.show().fadeTo(0, 0).hide(); | |
424 | - } else { | |
425 | - // Or else it should be set to the opacity. | |
426 | - if (opts.pnotify_opacity != 1) | |
427 | - pnotify.show().fadeTo(0, opts.pnotify_opacity).hide(); | |
428 | - } | |
429 | - pnotify.animate_in(function(){ | |
430 | - if (opts.pnotify_after_open) | |
431 | - opts.pnotify_after_open(pnotify); | |
432 | - | |
433 | - pnotify.pnotify_queue_position(); | |
434 | - | |
435 | - // Now set it to hide. | |
436 | - if (opts.pnotify_hide) | |
437 | - pnotify.pnotify_queue_remove(); | |
438 | - }); | |
439 | - }; | |
440 | - | |
441 | - // Remove the notice. | |
442 | - pnotify.pnotify_remove = function() { | |
443 | - if (pnotify.timer) { | |
444 | - window.clearTimeout(pnotify.timer); | |
445 | - pnotify.timer = null; | |
446 | - } | |
447 | - // Run callback. | |
448 | - if (opts.pnotify_before_close) { | |
449 | - if (opts.pnotify_before_close(pnotify) === false) | |
450 | - return; | |
451 | - } | |
452 | - pnotify.animate_out(function(){ | |
453 | - if (opts.pnotify_after_close) { | |
454 | - if (opts.pnotify_after_close(pnotify) === false) | |
455 | - return; | |
456 | - } | |
457 | - pnotify.pnotify_queue_position(); | |
458 | - // If we're supposed to remove the notice from the DOM, do it. | |
459 | - if (opts.pnotify_remove) | |
460 | - pnotify.remove(); | |
461 | - }); | |
462 | - }; | |
463 | - | |
464 | - // Animate the notice in. | |
465 | - pnotify.animate_in = function(callback){ | |
466 | - // Declare that the notice is animating in. (Or has completed animating in.) | |
467 | - animating = "in"; | |
468 | - var animation; | |
469 | - if (typeof opts.pnotify_animation.effect_in != "undefined") | |
470 | - animation = opts.pnotify_animation.effect_in; | |
471 | - else | |
472 | - animation = opts.pnotify_animation; | |
473 | - if (animation == "none") { | |
474 | - pnotify.show(); | |
475 | - callback(); | |
476 | - } else if (animation == "show") | |
477 | - pnotify.show(opts.pnotify_animate_speed, callback); | |
478 | - else if (animation == "fade") | |
479 | - pnotify.show().fadeTo(opts.pnotify_animate_speed, opts.pnotify_opacity, callback); | |
480 | - else if (animation == "slide") | |
481 | - pnotify.slideDown(opts.pnotify_animate_speed, callback); | |
482 | - else if (typeof animation == "function") | |
483 | - animation("in", callback, pnotify); | |
484 | - else if (pnotify.effect) | |
485 | - pnotify.effect(animation, {}, opts.pnotify_animate_speed, callback); | |
486 | - }; | |
487 | - | |
488 | - // Animate the notice out. | |
489 | - pnotify.animate_out = function(callback){ | |
490 | - // Declare that the notice is animating out. (Or has completed animating out.) | |
491 | - animating = "out"; | |
492 | - var animation; | |
493 | - if (typeof opts.pnotify_animation.effect_out != "undefined") | |
494 | - animation = opts.pnotify_animation.effect_out; | |
495 | - else | |
496 | - animation = opts.pnotify_animation; | |
497 | - if (animation == "none") { | |
498 | - pnotify.hide(); | |
499 | - callback(); | |
500 | - } else if (animation == "show") | |
501 | - pnotify.hide(opts.pnotify_animate_speed, callback); | |
502 | - else if (animation == "fade") | |
503 | - pnotify.fadeOut(opts.pnotify_animate_speed, callback); | |
504 | - else if (animation == "slide") | |
505 | - pnotify.slideUp(opts.pnotify_animate_speed, callback); | |
506 | - else if (typeof animation == "function") | |
507 | - animation("out", callback, pnotify); | |
508 | - else if (pnotify.effect) | |
509 | - pnotify.effect(animation, {}, opts.pnotify_animate_speed, callback); | |
510 | - }; | |
511 | - | |
512 | - // Cancel any pending removal timer. | |
513 | - pnotify.pnotify_cancel_remove = function() { | |
514 | - if (pnotify.timer) | |
515 | - window.clearTimeout(pnotify.timer); | |
516 | - }; | |
517 | - | |
518 | - // Queue a removal timer. | |
519 | - pnotify.pnotify_queue_remove = function() { | |
520 | - // Cancel any current removal timer. | |
521 | - pnotify.pnotify_cancel_remove(); | |
522 | - pnotify.timer = window.setTimeout(function(){ | |
523 | - pnotify.pnotify_remove(); | |
524 | - }, (isNaN(opts.pnotify_delay) ? 0 : opts.pnotify_delay)); | |
525 | - }; | |
526 | - | |
527 | - // Provide a button to close the notice. | |
528 | - pnotify.closer = $14("<div />", { | |
529 | - "class": "rf-ny-cl", | |
530 | - "css": {"cursor": "pointer", "display": "none"}, | |
531 | - "click": function(){ | |
532 | - pnotify.pnotify_remove(); | |
533 | - pnotify.closer.hide(); | |
534 | - } | |
535 | - }) | |
536 | - .append($14("<span />", {"class": "rf-ny-cl-ic"})) | |
537 | - .appendTo(pnotify.container); | |
538 | - | |
539 | - // Add the appropriate icon. | |
540 | -// if ((opts.pnotify_error_icon && opts.pnotify_type == "error") || (opts.pnotify_notice_icon)) { | |
541 | - $14("<div />", {"class": "rf-ny-ic"}) | |
542 | - .append($14("<span />", {"class": opts.pnotify_type == "error" ? opts.pnotify_error_icon : opts.pnotify_notice_icon})) | |
543 | - .appendTo(pnotify.container); | |
544 | -// } | |
545 | - | |
546 | - // Add a title. | |
547 | - pnotify.title_container = $14("<div />", { | |
548 | - "class": "rf-ny-tl", | |
549 | - "html": opts.pnotify_title | |
550 | - }) | |
551 | - .appendTo(pnotify.container); | |
552 | - if (opts.pnotify_title === false) | |
553 | - pnotify.title_container.hide(); | |
554 | - | |
555 | - // Replace new lines with HTML line breaks. | |
556 | - if (opts.pnotify_insert_brs && typeof opts.pnotify_text == "string") | |
557 | - opts.pnotify_text = opts.pnotify_text.replace(/\n/g, "<br />"); | |
558 | - // Add text. | |
559 | - pnotify.text_container = $14("<div />", { | |
560 | - "class": "rf-ny-te", | |
561 | - "html": opts.pnotify_text | |
562 | - }) | |
563 | - .appendTo(pnotify.container); | |
564 | - if (opts.pnotify_text === false) | |
565 | - pnotify.text_container.hide(); | |
566 | - | |
567 | - // Set width and min height. | |
568 | - if (typeof opts.pnotify_width == "string") | |
569 | - pnotify.css("width", opts.pnotify_width); | |
570 | - if (typeof opts.pnotify_min_height == "string") | |
571 | - pnotify.container.css("min-height", opts.pnotify_min_height); | |
572 | - | |
573 | - // The history variable controls whether the notice gets redisplayed | |
574 | - // by the history pull down. | |
575 | - pnotify.pnotify_history = opts.pnotify_history; | |
576 | - | |
577 | - // Add the notice to the notice array. | |
578 | - var body_data = body.data("pnotify"); | |
579 | - if (body_data == null || typeof body_data != "object") | |
580 | - body_data = []; | |
581 | - if (opts.pnotify_stack.push == "top") | |
582 | - body_data = $.merge([pnotify], body_data); | |
583 | - else | |
584 | - body_data = $.merge(body_data, [pnotify]); | |
585 | - body.data("pnotify", body_data); | |
586 | - | |
587 | - // Run callback. | |
588 | - if (opts.pnotify_after_init) | |
589 | - opts.pnotify_after_init(pnotify); | |
590 | - | |
591 | - if (opts.pnotify_history) { | |
592 | - // If there isn't a history pull down, create one. | |
593 | - var body_history = body.data("pnotify_history"); | |
594 | - if (typeof body_history == "undefined") { | |
595 | - body_history = $14("<div />", { | |
596 | - "class": "rf-ny-hc", | |
597 | - "mouseleave": function(){ | |
598 | - body_history.animate({top: "-"+history_handle_top+"px"}, {duration: 100, queue: false}); | |
599 | - } | |
600 | - }) | |
601 | - .append($14("<div />", {"class": "rf-ny-hh", "text": "Redisplay"})) | |
602 | - .append($14("<button />", { | |
603 | - "class": "rf-ny-ha", | |
604 | - "text": "All", | |
605 | -// "mouseenter": function(){ | |
606 | -// $(this).addClass("ui-state-hover"); | |
607 | -// }, | |
608 | -// "mouseleave": function(){ | |
609 | -// $(this).removeClass("ui-state-hover"); | |
610 | -// }, | |
611 | - "click": function(){ | |
612 | - // Display all notices. (Disregarding non-history notices.) | |
613 | - $.each(body.data("pnotify"), function(){ | |
614 | - if (this.pnotify_history && this.pnotify_display) | |
615 | - this.pnotify_display(); | |
616 | - }); | |
617 | - return false; | |
618 | - } | |
619 | - })) | |
620 | - .append($14("<button />", { | |
621 | - "class": "rf-ny-hl", | |
622 | - "text": "Last", | |
623 | -// "mouseenter": function(){ | |
624 | -// $(this).addClass("ui-state-hover"); | |
625 | -// }, | |
626 | -// "mouseleave": function(){ | |
627 | -// $(this).removeClass("ui-state-hover"); | |
628 | -// }, | |
629 | - "click": function(){ | |
630 | - // Look up the last history notice, and display it. | |
631 | - var i = 1; | |
632 | - var body_data = body.data("pnotify"); | |
633 | - while (!body_data[body_data.length - i] || !body_data[body_data.length - i].pnotify_history || body_data[body_data.length - i].is(":visible")) { | |
634 | - if (body_data.length - i === 0) | |
635 | - return false; | |
636 | - i++; | |
637 | - } | |
638 | - var n = body_data[body_data.length - i]; | |
639 | - if (n.pnotify_display) | |
640 | - n.pnotify_display(); | |
641 | - return false; | |
642 | - } | |
643 | - })) | |
644 | - .appendTo(body); | |
645 | - | |
646 | - // Make a handle so the user can pull down the history pull down. | |
647 | - var handle = $14("<span />", { | |
648 | - "class": "rf-ny-hp", | |
649 | - "mouseenter": function(){ | |
650 | - body_history.animate({top: "0"}, {duration: 100, queue: false}); | |
651 | - } | |
652 | - }) | |
653 | - .appendTo(body_history); | |
654 | - | |
655 | - // Get the top of the handle. | |
656 | - history_handle_top = handle.offset().top + 2; | |
657 | - // Hide the history pull down up to the top of the handle. | |
658 | - body_history.css({top: "-"+history_handle_top+"px"}); | |
659 | - // Save the history pull down. | |
660 | - body.data("pnotify_history", body_history); | |
661 | - } | |
662 | - } | |
663 | - | |
664 | - // Mark the stack so it won't animate the new notice. | |
665 | - opts.pnotify_stack.animation = false; | |
666 | - | |
667 | - // Display the notice. | |
668 | - pnotify.pnotify_display(); | |
669 | - | |
670 | - return pnotify; | |
671 | - } | |
672 | - }); | |
673 | - | |
674 | - // Some useful regexes. | |
675 | - var re_on = /^on/; | |
676 | - var re_mouse_events = /^(dbl)?click$|^mouse(move|down|up|over|out|enter|leave)$|^contextmenu$/; | |
677 | - var re_ui_events = /^(focus|blur|select|change|reset)$|^key(press|down|up)$/; | |
678 | - var re_html_events = /^(scroll|resize|(un)?load|abort|error)$/; | |
679 | - // Fire a DOM event. | |
680 | - var dom_event = function(e, orig_e){ | |
681 | - var event_object; | |
682 | - e = e.toLowerCase(); | |
683 | - if (document.createEvent && this.dispatchEvent) { | |
684 | - // FireFox, Opera, Safari, Chrome | |
685 | - e = e.replace(re_on, ''); | |
686 | - if (e.match(re_mouse_events)) { | |
687 | - // This allows the click event to fire on the notice. There is | |
688 | - // probably a much better way to do it. | |
689 | - $(this).offset(); | |
690 | - event_object = document.createEvent("MouseEvents"); | |
691 | - event_object.initMouseEvent( | |
692 | - e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail, | |
693 | - orig_e.screenX, orig_e.screenY, orig_e.clientX, orig_e.clientY, | |
694 | - orig_e.ctrlKey, orig_e.altKey, orig_e.shiftKey, orig_e.metaKey, orig_e.button, orig_e.relatedTarget | |
695 | - ); | |
696 | - } else if (e.match(re_ui_events)) { | |
697 | - event_object = document.createEvent("UIEvents"); | |
698 | - event_object.initUIEvent(e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail); | |
699 | - } else if (e.match(re_html_events)) { | |
700 | - event_object = document.createEvent("HTMLEvents"); | |
701 | - event_object.initEvent(e, orig_e.bubbles, orig_e.cancelable); | |
702 | - } | |
703 | - if (!event_object) return; | |
704 | - this.dispatchEvent(event_object); | |
705 | - } else { | |
706 | - // Internet Explorer | |
707 | - if (!e.match(re_on)) e = "on"+e; | |
708 | - event_object = document.createEventObject(orig_e); | |
709 | - this.fireEvent(e, event_object); | |
710 | - } | |
711 | - }; | |
712 | - | |
713 | - $.pnotify.defaults = { | |
714 | - // The notice's title. | |
715 | - pnotify_title: false, | |
716 | - // The notice's text. | |
717 | - pnotify_text: false, | |
718 | - // Additional classes to be added to the notice. (For custom styling.) | |
719 | - pnotify_addclass: "", | |
720 | - // Create a non-blocking notice. It lets the user click elements underneath it. | |
721 | - pnotify_nonblock: false, | |
722 | - // The opacity of the notice (if it's non-blocking) when the mouse is over it. | |
723 | - pnotify_nonblock_opacity: .2, | |
724 | - // Display a pull down menu to redisplay previous notices, and place the notice in the history. | |
725 | - pnotify_history: true, | |
726 | - // Width of the notice. | |
727 | - pnotify_width: "300px", | |
728 | - // Minimum height of the notice. It will expand to fit content. | |
729 | - pnotify_min_height: "16px", | |
730 | - // Type of the notice. "notice" or "error". | |
731 | - pnotify_type: "notice", | |
732 | - // The icon class to use if type is notice. | |
733 | - pnotify_notice_icon: "", | |
734 | - // The icon class to use if type is error. | |
735 | - pnotify_error_icon: "", | |
736 | - // The animation to use when displaying and hiding the notice. "none", "show", "fade", and "slide" are built in to jQuery. Others require jQuery UI. Use an object with effect_in and effect_out to use different effects. | |
737 | - pnotify_animation: "fade", | |
738 | - // Speed at which the notice animates in and out. "slow", "def" or "normal", "fast" or number of milliseconds. | |
739 | - pnotify_animate_speed: "slow", | |
740 | - // Opacity of the notice. | |
741 | - pnotify_opacity: 1, | |
742 | - // Display a drop shadow. | |
743 | - pnotify_shadow: false, | |
744 | - // Provide a button for the user to manually close the notice. | |
745 | - pnotify_closer: true, | |
746 | - // After a delay, remove the notice. | |
747 | - pnotify_hide: true, | |
748 | - // Delay in milliseconds before the notice is removed. | |
749 | - pnotify_delay: 8000, | |
750 | - // Reset the hide timer if the mouse moves over the notice. | |
751 | - pnotify_mouse_reset: true, | |
752 | - // Remove the notice's elements from the DOM after it is removed. | |
753 | - pnotify_remove: true, | |
754 | - // Change new lines to br tags. | |
755 | - pnotify_insert_brs: true, | |
756 | - // The stack on which the notices will be placed. Also controls the direction the notices stack. | |
757 | - pnotify_stack: {"dir1": "down", "dir2": "left", "push": "bottom"} | |
758 | - }; | |
225 | + } | |
226 | + | |
227 | + if (opts.pnotify_before_init) { | |
228 | + if (opts.pnotify_before_init(opts) === false) | |
229 | + return null; | |
230 | + } | |
231 | + | |
232 | + // This keeps track of the last element the mouse was over, so | |
233 | + // mouseleave, mouseenter, etc can be called. | |
234 | + var nonblock_last_elem; | |
235 | + // This is used to pass events through the notice if it is non-blocking. | |
236 | + var nonblock_pass = function(e, e_name) { | |
237 | + pnotify.css("display", "none"); | |
238 | + var element_below = document.elementFromPoint(e.clientX, e.clientY); | |
239 | + pnotify.css("display", "block"); | |
240 | + var jelement_below = $(element_below); | |
241 | + var cursor_style = jelement_below.css("cursor"); | |
242 | + pnotify.css("cursor", cursor_style != "auto" ? cursor_style : "default"); | |
243 | + // If the element changed, call mouseenter, mouseleave, etc. | |
244 | + if (!nonblock_last_elem || nonblock_last_elem.get(0) != element_below) { | |
245 | + if (nonblock_last_elem) { | |
246 | + dom_event.call(nonblock_last_elem.get(0), "mouseleave", e.originalEvent); | |
247 | + dom_event.call(nonblock_last_elem.get(0), "mouseout", e.originalEvent); | |
248 | + } | |
249 | + dom_event.call(element_below, "mouseenter", e.originalEvent); | |
250 | + dom_event.call(element_below, "mouseover", e.originalEvent); | |
251 | + } | |
252 | + dom_event.call(element_below, e_name, e.originalEvent); | |
253 | + // Remember the latest element the mouse was over. | |
254 | + nonblock_last_elem = jelement_below; | |
255 | + }; | |
256 | + | |
257 | + // Create our widget. | |
258 | + // Stop animation, reset the removal timer, and show the close | |
259 | + // button when the user mouses over. | |
260 | + var pnotify = $14("<div />", { | |
261 | + "class": "rf-ny " + opts.pnotify_addclass, | |
262 | + "css": {"display": "none"}, | |
263 | + "mouseenter": function(e) { | |
264 | + if (opts.pnotify_nonblock) e.stopPropagation(); | |
265 | + if (opts.pnotify_mouse_reset && animating == "out") { | |
266 | + // If it's animating out, animate back in really quick. | |
267 | + pnotify.stop(true); | |
268 | + pnotify.css("height", "auto").animate({"width": opts.pnotify_width, "opacity": opts.pnotify_nonblock ? opts.pnotify_nonblock_opacity : opts.pnotify_opacity}, "fast"); | |
269 | + } else if (opts.pnotify_nonblock && animating != "out") { | |
270 | + // If it's non-blocking, animate to the other opacity. | |
271 | + pnotify.animate({"opacity": opts.pnotify_nonblock_opacity}, "fast"); | |
272 | + } | |
273 | + if (opts.pnotify_hide && opts.pnotify_mouse_reset) pnotify.pnotify_cancel_remove(); | |
274 | + if (opts.pnotify_closer && !opts.pnotify_nonblock) pnotify.closer.show(); | |
275 | + }, | |
276 | + "mouseleave": function(e) { | |
277 | + if (opts.pnotify_nonblock) e.stopPropagation(); | |
278 | + nonblock_last_elem = null; | |
279 | + pnotify.css("cursor", "auto"); | |
280 | + if (opts.pnotify_nonblock && animating != "out") | |
281 | + pnotify.animate({"opacity": opts.pnotify_opacity}, "fast"); | |
282 | + if (opts.pnotify_hide && opts.pnotify_mouse_reset) pnotify.pnotify_queue_remove(); | |
283 | + pnotify.closer.hide(); | |
284 | + $.pnotify_position_all(); | |
285 | + }, | |
286 | + "mouseover": function(e) { | |
287 | + if (opts.pnotify_nonblock) e.stopPropagation(); | |
288 | + }, | |
289 | + "mouseout": function(e) { | |
290 | + if (opts.pnotify_nonblock) e.stopPropagation(); | |
291 | + }, | |
292 | + "mousemove": function(e) { | |
293 | + if (opts.pnotify_nonblock) { | |
294 | + e.stopPropagation(); | |
295 | + nonblock_pass(e, "onmousemove"); | |
296 | + } | |
297 | + }, | |
298 | + "mousedown": function(e) { | |
299 | + if (opts.pnotify_nonblock) { | |
300 | + e.stopPropagation(); | |
301 | + e.preventDefault(); | |
302 | + nonblock_pass(e, "onmousedown"); | |
303 | + } | |
304 | + }, | |
305 | + "mouseup": function(e) { | |
306 | + if (opts.pnotify_nonblock) { | |
307 | + e.stopPropagation(); | |
308 | + e.preventDefault(); | |
309 | + nonblock_pass(e, "onmouseup"); | |
310 | + } | |
311 | + }, | |
312 | + "click": function(e) { | |
313 | + if (opts.pnotify_nonblock) { | |
314 | + e.stopPropagation(); | |
315 | + nonblock_pass(e, "onclick"); | |
316 | + } | |
317 | + }, | |
318 | + "dblclick": function(e) { | |
319 | + if (opts.pnotify_nonblock) { | |
320 | + e.stopPropagation(); | |
321 | + nonblock_pass(e, "ondblclick"); | |
322 | + } | |
323 | + } | |
324 | + }); | |
325 | + pnotify.opts = opts; | |
326 | + // Create a drop shadow. | |
327 | + if (opts.pnotify_shadow && !$.browser.msie) | |
328 | + pnotify.shadow_container = $14("<div />", {"class": "rf-ny-sh"}).prependTo(pnotify); | |
329 | + // Create a container for the notice contents. | |
330 | + pnotify.container = $14("<div />", {"class": "rf-ny-co"}) | |
331 | + .appendTo(pnotify); | |
332 | + | |
333 | + pnotify.pnotify_version = "1.0.0"; | |
334 | + | |
335 | + // This function is for updating the notice. | |
336 | + pnotify.pnotify = function(options) { | |
337 | + // Update the notice. | |
338 | + var old_opts = opts; | |
339 | + if (typeof options == "string") | |
340 | + opts.pnotify_text = options; | |
341 | + else | |
342 | + opts = $.extend({}, opts, options); | |
343 | + pnotify.opts = opts; | |
344 | + // Update the shadow. | |
345 | + if (opts.pnotify_shadow != old_opts.pnotify_shadow) { | |
346 | + if (opts.pnotify_shadow && !$.browser.msie) | |
347 | + pnotify.shadow_container = $14("<div />", {"class": "rf-ny-sh"}).prependTo(pnotify); | |
348 | + else | |
349 | + pnotify.children(".rf-ny-sh").remove(); | |
350 | + } | |
351 | + // Update the additional classes. | |
352 | + if (opts.pnotify_addclass === false) | |
353 | + pnotify.removeClass(old_opts.pnotify_addclass); | |
354 | + else if (opts.pnotify_addclass !== old_opts.pnotify_addclass) | |
355 | + pnotify.removeClass(old_opts.pnotify_addclass).addClass(opts.pnotify_addclass); | |
356 | + // Update the title. | |
357 | + if (opts.pnotify_title === false) | |
358 | + pnotify.title_container.hide("fast"); | |
359 | + else if (opts.pnotify_title !== old_opts.pnotify_title) | |
360 | + pnotify.title_container.html(opts.pnotify_title).show(200); | |
361 | + // Update the text. | |
362 | + if (opts.pnotify_text === false) { | |
363 | + pnotify.text_container.hide("fast"); | |
364 | + } else if (opts.pnotify_text !== old_opts.pnotify_text) { | |
365 | + if (opts.pnotify_insert_brs) | |
366 | + opts.pnotify_text = opts.pnotify_text.replace(/\n/g, "<br />"); | |
367 | + pnotify.text_container.html(opts.pnotify_text).show(200); | |
368 | + } | |
369 | + pnotify.pnotify_history = opts.pnotify_history; | |
370 | + // Change the notice type. | |
371 | + if (opts.pnotify_type != old_opts.pnotify_type) | |
372 | + pnotify.container.toggleClass("rf-ny-co rf-ny-co-hover"); | |
373 | + if ((opts.pnotify_notice_icon != old_opts.pnotify_notice_icon && opts.pnotify_type == "notice") || | |
374 | + (opts.pnotify_error_icon != old_opts.pnotify_error_icon && opts.pnotify_type == "error") || | |
375 | + (opts.pnotify_type != old_opts.pnotify_type)) { | |
376 | + // Remove any old icon. | |
377 | + pnotify.container.find("div.rf-ny-ic").remove(); | |
378 | + // if ((opts.pnotify_error_icon && opts.pnotify_type == "error") || (opts.pnotify_notice_icon)) { | |
379 | + // Build the new icon. | |
380 | + $14("<div />", {"class": "rf-ny-ic"}) | |
381 | + .append($14("<span />", {"class": opts.pnotify_type == "error" ? opts.pnotify_error_icon : opts.pnotify_notice_icon})) | |
382 | + .prependTo(pnotify.container); | |
383 | + // } | |
384 | + } | |
385 | + // Update the width. | |
386 | + if (opts.pnotify_width !== old_opts.pnotify_width) | |
387 | + pnotify.animate({width: opts.pnotify_width}); | |
388 | + // Update the minimum height. | |
389 | + if (opts.pnotify_min_height !== old_opts.pnotify_min_height) | |
390 | + pnotify.container.animate({minHeight: opts.pnotify_min_height}); | |
391 | + // Update the opacity. | |
392 | + if (opts.pnotify_opacity !== old_opts.pnotify_opacity) | |
393 | + pnotify.fadeTo(opts.pnotify_animate_speed, opts.pnotify_opacity); | |
394 | + if (!opts.pnotify_hide) | |
395 | + pnotify.pnotify_cancel_remove(); | |
396 | + else if (!old_opts.pnotify_hide) | |
397 | + pnotify.pnotify_queue_remove(); | |
398 | + pnotify.pnotify_queue_position(); | |
399 | + return pnotify; | |
400 | + }; | |
401 | + | |
402 | + // Queue the position function so it doesn't run repeatedly and use | |
403 | + // up resources. | |
404 | + pnotify.pnotify_queue_position = function() { | |
405 | + if (timer) | |
406 | + clearTimeout(timer); | |
407 | + timer = setTimeout($.pnotify_position_all, 10); | |
408 | + }; | |
409 | + | |
410 | + // Display the notice. | |
411 | + pnotify.pnotify_display = function() { | |
412 | + // If the notice is not in the DOM, append it. | |
413 | + if (!pnotify.parent().length) | |
414 | + pnotify.appendTo(body); | |
415 | + // Run callback. | |
416 | + if (opts.pnotify_before_open) { | |
417 | + if (opts.pnotify_before_open(pnotify) === false) | |
418 | + return; | |
419 | + } | |
420 | + pnotify.pnotify_queue_position(); | |
421 | + // First show it, then set its opacity, then hide it. | |
422 | + if (opts.pnotify_animation == "fade" || opts.pnotify_animation.effect_in == "fade") { | |
423 | + // If it's fading in, it should start at 0. | |
424 | + pnotify.show().fadeTo(0, 0).hide(); | |
425 | + } else { | |
426 | + // Or else it should be set to the opacity. | |
427 | + if (opts.pnotify_opacity != 1) | |
428 | + pnotify.show().fadeTo(0, opts.pnotify_opacity).hide(); | |
429 | + } | |
430 | + pnotify.animate_in(function() { | |
431 | + if (opts.pnotify_after_open) | |
432 | + opts.pnotify_after_open(pnotify); | |
433 | + | |
434 | + pnotify.pnotify_queue_position(); | |
435 | + | |
436 | + // Now set it to hide. | |
437 | + if (opts.pnotify_hide) | |
438 | + pnotify.pnotify_queue_remove(); | |
439 | + }); | |
440 | + }; | |
441 | + | |
442 | + // Remove the notice. | |
443 | + pnotify.pnotify_remove = function() { | |
444 | + if (pnotify.timer) { | |
445 | + window.clearTimeout(pnotify.timer); | |
446 | + pnotify.timer = null; | |
447 | + } | |
448 | + // Run callback. | |
449 | + if (opts.pnotify_before_close) { | |
450 | + if (opts.pnotify_before_close(pnotify) === false) | |
451 | + return; | |
452 | + } | |
453 | + pnotify.animate_out(function() { | |
454 | + if (opts.pnotify_after_close) { | |
455 | + if (opts.pnotify_after_close(pnotify) === false) | |
456 | + return; | |
457 | + } | |
458 | + pnotify.pnotify_queue_position(); | |
459 | + // If we're supposed to remove the notice from the DOM, do it. | |
460 | + if (opts.pnotify_remove) { | |
461 | + if (opts.pnotify_history) { | |
462 | + if (pnotify[0].parentNode != null) { | |
463 | + pnotify[0].parentNode.removeChild(pnotify[0]); | |
464 | + } | |
465 | + } else { | |
466 | + pnotify.remove(); | |
467 | + } | |
468 | + } | |
469 | + }); | |
470 | + }; | |
471 | + | |
472 | + // Animate the notice in. | |
473 | + pnotify.animate_in = function(callback) { | |
474 | + // Declare that the notice is animating in. (Or has completed animating in.) | |
475 | + animating = "in"; | |
476 | + var animation; | |
477 | + if (typeof opts.pnotify_animation.effect_in != "undefined") | |
478 | + animation = opts.pnotify_animation.effect_in; | |
479 | + else | |
480 | + animation = opts.pnotify_animation; | |
481 | + if (animation == "none") { | |
482 | + pnotify.show(); | |
483 | + callback(); | |
484 | + } else if (animation == "show") | |
485 | + pnotify.show(opts.pnotify_animate_speed, callback); | |
486 | + else if (animation == "fade") | |
487 | + pnotify.show().fadeTo(opts.pnotify_animate_speed, opts.pnotify_opacity, callback); | |
488 | + else if (animation == "slide") | |
489 | + pnotify.slideDown(opts.pnotify_animate_speed, callback); | |
490 | + else if (typeof animation == "function") | |
491 | + animation("in", callback, pnotify); | |
492 | + else if (pnotify.effect) | |
493 | + pnotify.effect(animation, {}, opts.pnotify_animate_speed, callback); | |
494 | + }; | |
495 | + | |
496 | + // Animate the notice out. | |
497 | + pnotify.animate_out = function(callback) { | |
498 | + // Declare that the notice is animating out. (Or has completed animating out.) | |
499 | + animating = "out"; | |
500 | + var animation; | |
501 | + if (typeof opts.pnotify_animation.effect_out != "undefined") | |
502 | + animation = opts.pnotify_animation.effect_out; | |
503 | + else | |
504 | + animation = opts.pnotify_animation; | |
505 | + if (animation == "none") { | |
506 | + pnotify.hide(); | |
507 | + callback(); | |
508 | + } else if (animation == "show") | |
509 | + pnotify.hide(opts.pnotify_animate_speed, callback); | |
510 | + else if (animation == "fade") | |
511 | + pnotify.fadeOut(opts.pnotify_animate_speed, callback); | |
512 | + else if (animation == "slide") | |
513 | + pnotify.slideUp(opts.pnotify_animate_speed, callback); | |
514 | + else if (typeof animation == "function") | |
515 | + animation("out", callback, pnotify); | |
516 | + else if (pnotify.effect) | |
517 | + pnotify.effect(animation, {}, opts.pnotify_animate_speed, callback); | |
518 | + }; | |
519 | + | |
520 | + // Cancel any pending removal timer. | |
521 | + pnotify.pnotify_cancel_remove = function() { | |
522 | + if (pnotify.timer) | |
523 | + window.clearTimeout(pnotify.timer); | |
524 | + }; | |
525 | + | |
526 | + // Queue a removal timer. | |
527 | + pnotify.pnotify_queue_remove = function() { | |
528 | + // Cancel any current removal timer. | |
529 | + pnotify.pnotify_cancel_remove(); | |
530 | + pnotify.timer = window.setTimeout(function() { | |
531 | + pnotify.pnotify_remove(); | |
532 | + }, (isNaN(opts.pnotify_delay) ? 0 : opts.pnotify_delay)); | |
533 | + }; | |
534 | + | |
535 | + // Provide a button to close the notice. | |
536 | + pnotify.closer = $14("<div />", { | |
537 | + "class": "rf-ny-cl", | |
538 | + "css": {"cursor": "pointer", "display": "none"}, | |
539 | + "click": function() { | |
540 | + pnotify.pnotify_remove(); | |
541 | + pnotify.closer.hide(); | |
542 | + } | |
543 | + }) | |
544 | + .append($14("<span />", {"class": "rf-ny-cl-ic"})) | |
545 | + .appendTo(pnotify.container); | |
546 | + | |
547 | + // Add the appropriate icon. | |
548 | + // if ((opts.pnotify_error_icon && opts.pnotify_type == "error") || (opts.pnotify_notice_icon)) { | |
549 | + $14("<div />", {"class": "rf-ny-ic"}) | |
550 | + .append($14("<span />", {"class": opts.pnotify_type == "error" ? opts.pnotify_error_icon : opts.pnotify_notice_icon})) | |
551 | + .appendTo(pnotify.container); | |
552 | + // } | |
553 | + | |
554 | + // Add a title. | |
555 | + pnotify.title_container = $14("<div />", { | |
556 | + "class": "rf-ny-tl", | |
557 | + "html": opts.pnotify_title | |
558 | + }) | |
559 | + .appendTo(pnotify.container); | |
560 | + if (opts.pnotify_title === false) | |
561 | + pnotify.title_container.hide(); | |
562 | + | |
563 | + // Replace new lines with HTML line breaks. | |
564 | + if (opts.pnotify_insert_brs && typeof opts.pnotify_text == "string") | |
565 | + opts.pnotify_text = opts.pnotify_text.replace(/\n/g, "<br />"); | |
566 | + // Add text. | |
567 | + pnotify.text_container = $14("<div />", { | |
568 | + "class": "rf-ny-te", | |
569 | + "html": opts.pnotify_text | |
570 | + }) | |
571 | + .appendTo(pnotify.container); | |
572 | + if (opts.pnotify_text === false) | |
573 | + pnotify.text_container.hide(); | |
574 | + | |
575 | + // Set width and min height. | |
576 | + if (typeof opts.pnotify_width == "string") | |
577 | + pnotify.css("width", opts.pnotify_width); | |
578 | + if (typeof opts.pnotify_min_height == "string") | |
579 | + pnotify.container.css("min-height", opts.pnotify_min_height); | |
580 | + | |
581 | + // The history variable controls whether the notice gets redisplayed | |
582 | + // by the history pull down. | |
583 | + pnotify.pnotify_history = opts.pnotify_history; | |
584 | + | |
585 | + // Add the notice to the notice array. | |
586 | + var body_data = body.data("pnotify"); | |
587 | + if (body_data == null || typeof body_data != "object") | |
588 | + body_data = []; | |
589 | + if (opts.pnotify_stack.push == "top") | |
590 | + body_data = $.merge([pnotify], body_data); | |
591 | + else | |
592 | + body_data = $.merge(body_data, [pnotify]); | |
593 | + body.data("pnotify", body_data); | |
594 | + | |
595 | + // Run callback. | |
596 | + if (opts.pnotify_after_init) | |
597 | + opts.pnotify_after_init(pnotify); | |
598 | + | |
599 | + if (opts.pnotify_history) { | |
600 | + // If there isn't a history pull down, create one. | |
601 | + var body_history = body.data("pnotify_history"); | |
602 | + if (typeof body_history == "undefined") { | |
603 | + body_history = $14("<div />", { | |
604 | + "class": "rf-ny-hc", | |
605 | + "mouseleave": function() { | |
606 | + body_history.animate({top: "-" + history_handle_top + "px"}, {duration: 100, queue: false}); | |
607 | + } | |
608 | + }) | |
609 | + .append($14("<div />", {"class": "rf-ny-hh", "text": "Redisplay"})) | |
610 | + .append($14("<button />", { | |
611 | + "class": "rf-ny-ha", | |
612 | + "text": "All", | |
613 | + // "mouseenter": function(){ | |
614 | + // $(this).addClass("ui-state-hover"); | |
615 | + // }, | |
616 | + // "mouseleave": function(){ | |
617 | + // $(this).removeClass("ui-state-hover"); | |
618 | + // }, | |
619 | + "click": function() { | |
620 | + // Display all notices. (Disregarding non-history notices.) | |
621 | + $.each(body.data("pnotify"), function() { | |
622 | + if (this.pnotify_history && this.pnotify_display) | |
623 | + this.pnotify_display(); | |
624 | + }); | |
625 | + return false; | |
626 | + } | |
627 | + })) | |
628 | + .append($14("<button />", { | |
629 | + "class": "rf-ny-hl", | |
630 | + "text": "Last", | |
631 | + // "mouseenter": function(){ | |
632 | + // $(this).addClass("ui-state-hover"); | |
633 | + // }, | |
634 | + // "mouseleave": function(){ | |
635 | + // $(this).removeClass("ui-state-hover"); | |
636 | + // }, | |
637 | + "click": function() { | |
638 | + // Look up the last history notice, and display it. | |
639 | + var i = 1; | |
640 | + var body_data = body.data("pnotify"); | |
641 | + while (!body_data[body_data.length - i] || !body_data[body_data.length - i].pnotify_history || body_data[body_data.length - i].is(":visible")) { | |
642 | + if (body_data.length - i === 0) | |
643 | + return false; | |
644 | + i++; | |
645 | + } | |
646 | + var n = body_data[body_data.length - i]; | |
647 | + if (n.pnotify_display) | |
648 | + n.pnotify_display(); | |
649 | + return false; | |
650 | + } | |
651 | + })) | |
652 | + .appendTo(body); | |
653 | + | |
654 | + // Make a handle so the user can pull down the history pull down. | |
655 | + var handle = $14("<span />", { | |
656 | + "class": "rf-ny-hp", | |
657 | + "mouseenter": function() { | |
658 | + body_history.animate({top: "0"}, {duration: 100, queue: false}); | |
659 | + } | |
660 | + }) | |
661 | + .appendTo(body_history); | |
662 | + | |
663 | + // Get the top of the handle. | |
664 | + history_handle_top = handle.offset().top + 2; | |
665 | + // Hide the history pull down up to the top of the handle. | |
666 | + body_history.css({top: "-" + history_handle_top + "px"}); | |
667 | + // Save the history pull down. | |
668 | + body.data("pnotify_history", body_history); | |
669 | + } | |
670 | + } | |
671 | + | |
672 | + // Mark the stack so it won't animate the new notice. | |
673 | + opts.pnotify_stack.animation = false; | |
674 | + | |
675 | + // Display the notice. | |
676 | + pnotify.pnotify_display(); | |
677 | + | |
678 | + return pnotify; | |
679 | + } | |
680 | + }); | |
681 | + | |
682 | + // Some useful regexes. | |
683 | + var re_on = /^on/; | |
684 | + var re_mouse_events = /^(dbl)?click$|^mouse(move|down|up|over|out|enter|leave)$|^contextmenu$/; | |
685 | + var re_ui_events = /^(focus|blur|select|change|reset)$|^key(press|down|up)$/; | |
686 | + var re_html_events = /^(scroll|resize|(un)?load|abort|error)$/; | |
687 | + // Fire a DOM event. | |
688 | + var dom_event = function(e, orig_e) { | |
689 | + var event_object; | |
690 | + e = e.toLowerCase(); | |
691 | + if (document.createEvent && this.dispatchEvent) { | |
692 | + // FireFox, Opera, Safari, Chrome | |
693 | + e = e.replace(re_on, ''); | |
694 | + if (e.match(re_mouse_events)) { | |
695 | + // This allows the click event to fire on the notice. There is | |
696 | + // probably a much better way to do it. | |
697 | + $(this).offset(); | |
698 | + event_object = document.createEvent("MouseEvents"); | |
699 | + event_object.initMouseEvent( | |
700 | + e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail, | |
701 | + orig_e.screenX, orig_e.screenY, orig_e.clientX, orig_e.clientY, | |
702 | + orig_e.ctrlKey, orig_e.altKey, orig_e.shiftKey, orig_e.metaKey, orig_e.button, orig_e.relatedTarget | |
703 | + ); | |
704 | + } else if (e.match(re_ui_events)) { | |
705 | + event_object = document.createEvent("UIEvents"); | |
706 | + event_object.initUIEvent(e, orig_e.bubbles, orig_e.cancelable, orig_e.view, orig_e.detail); | |
707 | + } else if (e.match(re_html_events)) { | |
708 | + event_object = document.createEvent("HTMLEvents"); | |
709 | + event_object.initEvent(e, orig_e.bubbles, orig_e.cancelable); | |
710 | + } | |
711 | + if (!event_object) return; | |
712 | + this.dispatchEvent(event_object); | |
713 | + } else { | |
714 | + // Internet Explorer | |
715 | + if (!e.match(re_on)) e = "on" + e; | |
716 | + event_object = document.createEventObject(orig_e); | |
717 | + this.fireEvent(e, event_object); | |
718 | + } | |
719 | + }; | |
720 | + | |
721 | + $.pnotify.defaults = { | |
722 | + // The notice's title. | |
723 | + pnotify_title: false, | |
724 | + // The notice's text. | |
725 | + pnotify_text: false, | |
726 | + // Additional classes to be added to the notice. (For custom styling.) | |
727 | + pnotify_addclass: "", | |
728 | + // Create a non-blocking notice. It lets the user click elements underneath it. | |
729 | + pnotify_nonblock: false, | |
730 | + // The opacity of the notice (if it's non-blocking) when the mouse is over it. | |
731 | + pnotify_nonblock_opacity: .2, | |
732 | + // Display a pull down menu to redisplay previous notices, and place the notice in the history. | |
733 | + pnotify_history: true, | |
734 | + // Width of the notice. | |
735 | + pnotify_width: "300px", | |
736 | + // Minimum height of the notice. It will expand to fit content. | |
737 | + pnotify_min_height: "16px", | |
738 | + // Type of the notice. "notice" or "error". | |
739 | + pnotify_type: "notice", | |
740 | + // The icon class to use if type is notice. | |
741 | + pnotify_notice_icon: "", | |
742 | + // The icon class to use if type is error. | |
743 | + pnotify_error_icon: "", | |
744 | + // The animation to use when displaying and hiding the notice. "none", "show", "fade", and "slide" are built in to jQuery. Others require jQuery UI. Use an object with effect_in and effect_out to use different effects. | |
745 | + pnotify_animation: "fade", | |
746 | + // Speed at which the notice animates in and out. "slow", "def" or "normal", "fast" or number of milliseconds. | |
747 | + pnotify_animate_speed: "slow", | |
748 | + // Opacity of the notice. | |
749 | + pnotify_opacity: 1, | |
750 | + // Display a drop shadow. | |
751 | + pnotify_shadow: false, | |
752 | + // Provide a button for the user to manually close the notice. | |
753 | + pnotify_closer: true, | |
754 | + // After a delay, remove the notice. | |
755 | + pnotify_hide: true, | |
756 | + // Delay in milliseconds before the notice is removed. | |
757 | + pnotify_delay: 8000, | |
758 | + // Reset the hide timer if the mouse moves over the notice. | |
759 | + pnotify_mouse_reset: true, | |
760 | + // Remove the notice's elements from the DOM after it is removed. | |
761 | + pnotify_remove: true, | |
762 | + // Change new lines to br tags. | |
763 | + pnotify_insert_brs: true, | |
764 | + // The stack on which the notices will be placed. Also controls the direction the notices stack. | |
765 | + pnotify_stack: {"dir1": "down", "dir2": "left", "push": "bottom"} | |
766 | + }; | |
759 | 767 | })(jQuery); |
\ No newline at end of file | ... | ... |
Please
register
or
login
to post a comment