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