Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I added a link parameter to people can make Gritter notifications be clickable to navigate #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions css/jquery.gritter.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
font-size: 11px;
font-family:verdana;
}
.gritter-link div {
color: #eee;
}
.hover .gritter-item {
background-position:right -40px;
}
Expand Down
14 changes: 9 additions & 5 deletions js/jquery.gritter.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
class_name: '', // could be set to 'gritter-light' to use white notifications
fade_in_speed: 'medium', // how fast notifications fade in
fade_out_speed: 1000, // how fast the notices fade out
time: 6000 // hang on the screen for...
time: 6000, // hang on the screen for...
link: '' //click me to go to go somewhere...
}

/**
Expand Down Expand Up @@ -73,14 +74,15 @@
fade_in_speed: '',
fade_out_speed: '',
time: '',
link: '',

// Private - no touchy the private parts
_custom_timer: 0,
_item_count: 0,
_is_setup: 0,
_tpl_close: '<div class="gritter-close"></div>',
_tpl_title: '<span class="gritter-title">[[title]]</span>',
_tpl_item: '<div id="gritter-item-[[number]]" class="gritter-item-wrapper [[item_class]]" style="display:none"><div class="gritter-top"></div><div class="gritter-item">[[close]][[image]]<div class="[[class_name]]">[[title]]<p>[[text]]</p></div><div style="clear:both"></div></div><div class="gritter-bottom"></div></div>',
_tpl_item: '<div id="gritter-item-[[number]]" class="gritter-item-wrapper [[item_class]]" style="display:none"><div class="gritter-top"></div><div class="gritter-item">[[close]]<a [[link]] class="gritter-link">[[image]]<div class="[[class_name]]">[[title]]<p>[[text]]</p></div></a><div style="clear:both"></div></div><div class="gritter-bottom"></div></div>',
_tpl_wrap: '<div id="gritter-notice-wrapper"></div>',

/**
Expand Down Expand Up @@ -112,6 +114,7 @@
item_class = params.class_name || $.gritter.options.class_name,
position = $.gritter.options.position,
time_alive = params.time || '';
link = params.link || '';

this._verifyWrapper();

Expand All @@ -133,7 +136,8 @@
}

var image_str = (image != '') ? '<img src="' + image + '" class="gritter-image" />' : '',
class_name = (image != '') ? 'gritter-with-image' : 'gritter-without-image';
class_name = (image != '') ? 'gritter-with-image' : 'gritter-without-image',
link_str = (link != '') ? 'href="' + link + '"' : '';

// String replacements on the template
if(title){
Expand All @@ -143,8 +147,8 @@
}

tmp = this._str_replace(
['[[title]]', '[[text]]', '[[close]]', '[[image]]', '[[number]]', '[[class_name]]', '[[item_class]]'],
[title, text, this._tpl_close, image_str, this._item_count, class_name, item_class], tmp
['[[title]]', '[[text]]', '[[close]]', '[[image]]', '[[number]]', '[[class_name]]', '[[item_class]]', '[[link]]'],
[title, text, this._tpl_close, image_str, this._item_count, class_name, item_class, link_str], tmp
);

// If it's false, don't show another gritter message
Expand Down