[dw-free] Add alt text to inbox
[commit: http://hg.dwscoalition.org/dw-free/rev/c8faec4b6245]
http://bugs.dwscoalition.org/show_bug.cgi?id=850
Alt text for images in the inbox.
Patch by
jadelennox.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=850
Alt text for images in the inbox.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- bin/upgrading/en.dat
- cgi-bin/LJ/Event/UserMessageRecvd.pm
- cgi-bin/LJ/Widget/InboxFolder.pm
- htdocs/inbox/index.bml
- htdocs/js/esn_inbox.js
-------------------------------------------------------------------------------- diff -r 1d40ae1aeb89 -r c8faec4b6245 bin/upgrading/en.dat --- a/bin/upgrading/en.dat Mon May 11 14:51:53 2009 +0000 +++ b/bin/upgrading/en.dat Mon May 11 16:29:02 2009 +0000 @@ -4167,6 +4167,14 @@ widget.inbox.menu.next_page.btn=Next Pag widget.inbox.menu.previous_page.btn=Previous Page +widget.inbox.notification.expanded=Collapse + +widget.inbox.notification.collapsed=Expand + +widget.inbox.notification.add_bookmark=Bookmark This + +widget.inbox.notification.rem_bookmark=Remove Bookmark + widget.inboxfolder.confirm.delete=Are you sure you want to delete one or more bookmarked items? widget.journaltitles.btn=Save diff -r 1d40ae1aeb89 -r c8faec4b6245 cgi-bin/LJ/Event/UserMessageRecvd.pm --- a/cgi-bin/LJ/Event/UserMessageRecvd.pm Mon May 11 14:51:53 2009 +0000 +++ b/cgi-bin/LJ/Event/UserMessageRecvd.pm Mon May 11 16:29:02 2009 +0000 @@ -201,16 +201,27 @@ sub display_pic { my ($msg, $u) = @_; my $pic; - if ($msg->userpic) { + + # Get the userpic object + if ( $msg->userpic ) { $pic = LJ::Userpic->new_from_keyword($u, $msg->userpic); } else { $pic = $u->userpic; } + # Get the image URL and the alternative text. Don't set + # alternative text if there isn't any userpic. + my ( $userpic_src, $userpic_alt ); + if ( $pic ) { + $userpic_src = $pic->url; + $userpic_alt = $pic->alttext; + } else { + $userpic_src = "$LJ::IMGPREFIX/nouserpic.png"; + $userpic_alt = ""; + } + my $ret; - $ret .= '<img src="'; - $ret .= $pic ? $pic->url : "$LJ::IMGPREFIX/nouserpic.png"; - $ret .= '" width="50" align="top" />'; + $ret .= '<img src="' . $userpic_src . '" alt="' . $userpic_alt . '" width="50" align="top" />'; return $ret; } diff -r 1d40ae1aeb89 -r c8faec4b6245 cgi-bin/LJ/Widget/InboxFolder.pm --- a/cgi-bin/LJ/Widget/InboxFolder.pm Mon May 11 14:51:53 2009 +0000 +++ b/cgi-bin/LJ/Widget/InboxFolder.pm Mon May 11 16:29:02 2009 +0000 @@ -133,10 +133,15 @@ sub render_body { }); # HTML for displaying bookmark flag - my $bookmark = $inbox->is_bookmark($qid) - ? "on" - : "off"; - $bookmark = "<a href='$LJ::SITEROOT/inbox/?page=$page&bookmark_$bookmark=$qid'><img src='$LJ::IMGPREFIX/flag_$bookmark.gif' width='16' height='18' class='InboxItem_Bookmark' border='0' /></a>"; + my ( $bookmark, $bookmark_alt ); + if ( $inbox->is_bookmark($qid) ) { + $bookmark = "on"; + $bookmark_alt = "<?_ml widget.inbox.notification.rem_bookmark _ml?>"; + } else { + $bookmark = "off"; + $bookmark_alt = "<?_ml widget.inbox.notification.add_bookmark _ml?>"; + } + $bookmark = "<a href='$LJ::SITEROOT/inbox/?page=$page&bookmark_$bookmark=$qid'><img src='$LJ::IMGPREFIX/flag_$bookmark.gif' width='16' height='18' class='InboxItem_Bookmark' border='0' alt='$bookmark_alt' /></a>"; my $when = LJ::ago_text(time() - $inbox_item->when_unixtime); my $contents = $inbox_item->as_html || ''; @@ -153,10 +158,19 @@ sub render_body { $expanded ||= $remote->prop('esn_inbox_default_expand'); $expanded = 0 if $inbox_item->read; - my $img = $expanded ? "expand.gif" : "collapse.gif"; + my ( $expand_img, $expand_alt ); + if ( $expanded ) { + $expand_img = "expand.gif"; + $expand_alt = "<?_ml widget.inbox.notification.expanded _ml?>"; + } else { + $expand_img = "collapse.gif"; + $expand_alt = "<?_ml widget.inbox.notification.collapsed _ml?>"; + } + my $expand_img = $expanded ? "expand.gif" : "collapse.gif"; + my $expand_img = $expanded ? "expand.gif" : "collapse.gif"; $expandbtn = qq { - <a href="$LJ::SITEROOT/inbox/?page=$page&expand=$qid"><img src="$LJ::IMGPREFIX/$img" class="InboxItem_Expand" border="0" /></a> + <a href="$LJ::SITEROOT/inbox/?page=$page&expand=$qid"><img src="$LJ::IMGPREFIX/$expand_img" class="InboxItem_Expand" border="0" alt="$expand_alt" /></a> }; my $display = $expanded ? "block" : "none"; diff -r 1d40ae1aeb89 -r c8faec4b6245 htdocs/inbox/index.bml --- a/htdocs/inbox/index.bml Mon May 11 14:51:53 2009 +0000 +++ b/htdocs/inbox/index.bml Mon May 11 16:29:02 2009 +0000 @@ -162,6 +162,15 @@ body<= </td></tr></table> }; + # send the i18n variables to the js page context + $body .= "<script type='text/javascript'>\n"; + $body .= "expanded = '$ML{'widget.inbox.notification.expanded'}';\n"; + $body .= "collapsed = '$ML{'widget.inbox.notification.collapsed'}';\n"; + $body .= "add_bookmark = '$ML{'widget.inbox.notification.add_bookmark'}';\n"; + $body .= "rem_bookmark = '$ML{'widget.inbox.notification.rem_bookmark'}';\n"; + $body .="</script>\n"; $body .= "</p>\n"; + + return $body; } _code?> diff -r 1d40ae1aeb89 -r c8faec4b6245 htdocs/js/esn_inbox.js --- a/htdocs/js/esn_inbox.js Mon May 11 14:51:53 2009 +0000 +++ b/htdocs/js/esn_inbox.js Mon May 11 16:29:02 2009 +0000 @@ -116,17 +116,21 @@ ESN_Inbox.toggleExpand = function (butto if (state == "expand") { contentContainer.style.display = "none"; button.src = Site.imgprefix + "/collapse.gif"; + button.alt = collapsed; } else { contentContainer.style.display = "block"; button.src = Site.imgprefix + "/expand.gif"; + button.alt = expanded; } } else { if (contentContainer.style.display == "none") { contentContainer.style.display = "block"; button.src = Site.imgprefix + "/expand.gif"; + button.alt = expanded; } else { contentContainer.style.display = "none"; button.src = Site.imgprefix + "/collapse.gif"; + button.alt = collapsed; } } return false; @@ -288,9 +292,15 @@ ESN_Inbox.finishedUpdate = function (inf var bookmarks = DOM.getElementsByClassName(rowElement, "InboxItem_Bookmark") || []; for (var i=0; i<bookmarks.length; i++) { - bookmarks[i].src = bookmarked ? Site.imgprefix + "/flag_on.gif" : - Site.imgprefix + "/flag_off.gif"; - ESN_Inbox.bookmarked[qid] = bookmarked ? true : false; + if ( bookmarked ) { + bookmarks[i].src = Site.imgprefix + "/flag_on.gif"; + bookmarks[i].alt = rem_bookmark; + ESN_Inbox.bookmarked[qid] = true; + } else { + bookmarks[i].src = Site.imgprefix + "/flag_off.gif"; + bookmarks[i].alt = add_bookmark; + ESN_Inbox.bookmarked[qid] = false; + } } if (deleted) { --------------------------------------------------------------------------------