Index: js/tribune.ajax.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tribune/js/tribune.ajax.js,v retrieving revision 1.20.2.8 diff -u -r1.20.2.8 tribune.ajax.js --- js/tribune.ajax.js 11 Apr 2009 20:22:25 -0000 1.20.2.8 +++ js/tribune.ajax.js 14 Jul 2009 22:18:47 -0000 @@ -38,8 +38,8 @@ Drupal.tribune.tribunes[tribune_id].palmipede.get(0).focus(); } - $(document).mousemove(Drupal.tribune.resetNotification); - $(window).focus(Drupal.tribune.resetNotification); + $(document).mousemove(function() {Drupal.tribune.resetNotification(tribune_id);}); + $(window).focus(function() {Drupal.tribune.resetNotification(tribune_id);}); Drupal.settings.tribune.tribunes[tribune_id].after_reload = [function(nodes) {Drupal.tribune.setOnHovers(nodes, tribune_id)}, function(nodes) {Drupal.tribune.setNotification(nodes, tribune_id)}]; })(tribune_id); @@ -47,10 +47,32 @@ tribune_id = null; } -Drupal.tribune.resetNotification = function() { +Drupal.tribune.setNotificationFavicon = function(url, tribune_id) { + // browsers only take into account *new* favicons + // so just removing the last one doesn't restore the previous favicon + // you have to remove the previous one too, and append it again to head + + if (!Drupal.settings.tribune.tribunes[tribune_id].discreet_notification) { + var oldlink = $('link#tribune-notification-favicon'); + if (url) { + var newlink = $(''); + newlink.attr('rel', 'shortcut icon'); + newlink.attr('type', 'image/x-icon'); + newlink.attr('href', url); + newlink.attr('id', 'tribune-notification-favicon'); + $('head').append(newlink); + } + oldlink.remove(); + + $('link[rel=shortcut icon]').remove().appendTo($('head')); + } +} + +Drupal.tribune.resetNotification = function(tribune_id) { if (Drupal.tribune.notification) { document.title = Drupal.tribune.notification_original_title; Drupal.tribune.notification = false; + Drupal.tribune.setNotificationFavicon(null, tribune_id); } } @@ -60,10 +82,12 @@ if ($(this).hasClass("tribune-answer")) { document.title = "# " + Drupal.tribune.notification_original_title; Drupal.tribune.notification = true; + Drupal.tribune.setNotificationFavicon(Drupal.settings.tribune.tribunes[tribune_id].path.favicons.answer, tribune_id); return; } else if (!Drupal.tribune.notification) { document.title = "* " + document.title; Drupal.tribune.notification = true; + Drupal.tribune.setNotificationFavicon(Drupal.settings.tribune.tribunes[tribune_id].path.favicons.new_post, tribune_id); } } }); Index: tribune.admin.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tribune/tribune.admin.inc,v retrieving revision 1.6.2.5 diff -u -r1.6.2.5 tribune.admin.inc --- tribune.admin.inc 20 Jun 2009 11:48:36 -0000 1.6.2.5 +++ tribune.admin.inc 14 Jul 2009 22:20:04 -0000 @@ -108,6 +108,13 @@ '#default_value' => variable_get('tribune_pager', FALSE), '#description' => t('Show a pager on the main page.'), ); + + $form['tribune_discreet_notification'] = array( + '#type' => 'checkbox', + '#title' => t('Discreet notification of new posts'), + '#default_value' => variable_get('tribune_discreet_notification', FALSE), + '#description' => t('Show a discreet notification for new posts. In any case when a new post arrives, a "*" is prepended to the tab title, or a "#" when the new post is an answer. If left unchecked, the favicon will also be changed for more visibility.'), + ); $form['tribune_antispam'] = array( '#type' => 'checkbox', Index: tribune.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/tribune/tribune.module,v retrieving revision 1.159.2.22 diff -u -r1.159.2.22 tribune.module --- tribune.module 19 Jun 2009 22:02:51 -0000 1.159.2.22 +++ tribune.module 14 Jul 2009 22:23:39 -0000 @@ -392,6 +392,7 @@ $message_order = $node->tribune_settings['posts_order'] ? 'top_to_bottom' : 'bottom_to_top'; $shortcuts = $node->tribune_settings['shortcuts']; $last_load_time = time(); + $discreet_notification = variable_get("tribune_discreet_notification", FALSE); $tribune_id = "tribune-". $node->nid; @@ -405,6 +406,7 @@ "idle_delay" => $idle_delay, "last_load_time" => $last_load_time, "message_order" => $message_order, + "discreet_notification" => $discreet_notification, "shortcuts" => $shortcuts, "block" => FALSE, "path" => array( @@ -412,6 +414,10 @@ "json_post" => url("node/".$node->nid."/post-json"), "json_posts" => url("node/".$node->nid."/newposts-json"), "filters" => url("node/".$node->nid."/filter"), + "favicons" => array( + "answer" => base_path() . drupal_get_path('module', 'tribune') .'/images/answer1.ico', + "new_post" => base_path() . drupal_get_path('module', 'tribune') .'/images/newpost1.ico', + ), ), ), ), @@ -711,6 +717,7 @@ $message_order = $node->tribune_settings['posts_order'] ? 'top_to_bottom' : 'bottom_to_top'; $shortcuts = $node->tribune_settings['shortcuts']; $last_load_time = time(); + $discreet_notification = variable_get("tribune_discreet_notification", FALSE); $tribune_id = 'tribune-block-'. $node->nid; @@ -724,6 +731,7 @@ "idle_delay" => $idle_delay, "last_load_time" => $last_load_time, "message_order" => $message_order, + "discreet_notification" => $discreet_notification, "shortcuts" => $shortcuts, "block" => TRUE, "path" => array( @@ -731,6 +739,10 @@ "json_post" => url("node/". $node->nid ."/post-json"), "json_posts" => url("node/". $node->nid ."/newposts-json"), "filters" => url("node/". $node->nid ."/filter"), + "favicons" => array( + "answer" => base_path() . drupal_get_path('module', 'tribune') .'/images/answer1.ico', + "new_post" => base_path() . drupal_get_path('module', 'tribune') .'/images/newpost1.ico', + ), ), ), ),