1. myfreeweb
  2. jGrowl

Commits

myfreeweb  committed 777fa05

Added icon support

  • Participants
  • Parent commits c5b9d9e
  • Branches default

Comments (0)

Files changed (3)

File examples/simple.html

View file
 					$('#logs').append("<div><strong>#" + $(e).attr('id') + "</strong> <em>" + (new Date()).getTime() + "</em>: " + m + " (" + o.theme + ")</div>")
 				}				
 				
-				$.jGrowl("Hello world!");
-				$.jGrowl("This notification is always non-native.", { forceDefault: true, life: 1000 });
-				$.jGrowl("Sticky notification with a header", { header: 'A Header', sticky: true });
+				$.jGrowl("This notification is always non-native.", { forceDefault: true, life: 5000, icon: 'https://edge.launchpad.net/@@/product-logo' });
+				$.jGrowl("Sticky notification with a header", { header: 'A Header', sticky: true, icon: 'https://edge.launchpad.net/@@/product-logo' });
 			});
 		})(jQuery);
 

File jquery.jgrowl.css

View file
 	text-align: 			center;
 }
 
+/** Icon positioning **/
+div.icon {
+	float: left;
+}
+
 /** Hide jGrowl when printing **/
 @media print {
 	div.jGrowl {

File jquery.jgrowl.js

View file
  * - Move library settings to containers and allow them to be changed per container
  *
  * Changes in 1.2.3.4
- * - Native notifications used if present (via Fluid or Prism).
+ * - Native notifications used if present (via Fluid or Prism). 
  *
  * Changes in 1.2.3
  * - The callbacks no longer use the container as context, instead they use the actual notification
 	    forceDefault: false,
 	    pool: 0,
 	    header: '',
+	    icon: '',
 	    group: '',
 	    sticky: false,
 	    position: 'top-right', // Is this still needed?
 		if (window.fluid) {
 		    window.fluid.showGrowlNotification({ title: o.header,
 							 description: message,
+							 icon: o.icon,
 							 sticky: o.sticky
 						       });
 		} /** Or Prism **/
 		else if (window.platform.showNotification) {
-		    window.platform.showNotification(o.header, message, '');
+		    window.platform.showNotification(o.header, message, o.icon);
 		}
 		else { defaultNotify(); }
 	    }
 	    function defaultNotify () {
+		if (o.icon != '') {
+		    var icon = '<div class="icon"><img src="' + o.icon + '" alt="Icon" /></div>'
+		}
+		else { var icon = ''; }
 		var notification = $([
 		    '<div class="jGrowl-notification ui-state-highlight ui-corner-all', 
 		    (o.group) ? ' ' + o.group : '',
 		    '"><div class="close">', o.closeTemplate,
-		    '</div><div class="header">',
-		    o.header, '</div><div class="message">', message,
+		    '</div>' + icon + '<div class="header">', o.header,
+		    '</div><div class="message">', message,
 		    '</div></div>'].join(""))
 		    .data("jGrowl", o)
 		    .addClass(o.theme)