fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-02-22 03:54 pm

[dw-free] Inbox should not open links in new windows

[commit: http://hg.dwscoalition.org/dw-free/rev/f887a5ae273c]

http://bugs.dwscoalition.org/show_bug.cgi?id=1668

Don't force links to open in a new window when clicking through an inbox
notification (which simultaneously marks that inbox notification as read)

Patch by [personal profile] yvi.

Files modified:
  • htdocs/js/esn_inbox.js
--------------------------------------------------------------------------------
diff -r 69491bac723d -r f887a5ae273c htdocs/js/esn_inbox.js
--- a/htdocs/js/esn_inbox.js	Tue Feb 22 23:47:12 2011 +0800
+++ b/htdocs/js/esn_inbox.js	Tue Feb 22 23:54:25 2011 +0800
@@ -186,8 +186,7 @@ ESN_Inbox.markLinkedItemRead = function 
     Event.stop(evt);
     var row = DOM.getFirstAncestorByClassName(evt.target, "InboxItem_Row");
     var qid = row.getAttribute("lj_qid");
-    ESN_Inbox.updateItems('mark_read', evt, folder, qid);
-    window.open(evt.target.href);
+    ESN_Inbox.updateItems('mark_read', evt, folder, qid, '', '', function() { window.location=evt.target.href });
     return false;
 };
 
@@ -245,7 +244,7 @@ ESN_Inbox.bookmark = function (evt, fold
 }
 
 // do an ajax action on the currently selected items
-ESN_Inbox.updateItems = function (action, evt, folder, qid, cur_folder, itemid) {
+ESN_Inbox.updateItems = function (action, evt, folder, qid, cur_folder, itemid, successfunction) {
     if (!ESN_Inbox.hourglass) {
         var coords = DOM.getAbsoluteCursorPosition(evt);
         ESN_Inbox.hourglass = new Hourglass();
@@ -268,7 +267,7 @@ ESN_Inbox.updateItems = function (action
         "data": HTTPReq.formEncoded(postData),
         "method": "POST",
         "onError": ESN_Inbox.reqError,
-        "onData": function(info) { ESN_Inbox.finishedUpdate(info, folder) }
+        "onData": function(info) { ESN_Inbox.finishedUpdate(info, folder, successfunction) }
     };
 
     opts.url = Site.currentJournal ? "/" + Site.currentJournal + "/__rpc_esn_inbox" : "/__rpc_esn_inbox";
@@ -286,7 +285,7 @@ ESN_Inbox.reqError = function (error) {
 };
 
 // successfully completed request
-ESN_Inbox.finishedUpdate = function (info, folder) {
+ESN_Inbox.finishedUpdate = function (info, folder, successfunction) {
     if (ESN_Inbox.hourglass) {
         ESN_Inbox.hourglass.hide();
         ESN_Inbox.hourglass = null;
@@ -300,6 +299,10 @@ ESN_Inbox.finishedUpdate = function (inf
     }
 
     if (! info || ! info.success || ! defined(info.items)) return;
+
+    if ( successfunction ) {
+        successfunction();
+    }
 
     var unread_count = 0;
     var usermsg_recvd_count = 0;
--------------------------------------------------------------------------------