Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
CombinedSearch: Add 'visited' state for search result links.
Browse files Browse the repository at this point in the history
Simplify the css a bit by making all links the same link color and adding a
purple link color for :visited and .visited links.  Also adds posts clicked on
from the new search results page to the 'Recently Viewed Links' widget.
  • Loading branch information
madbook committed Jun 10, 2015
1 parent 9c78287 commit 32db797
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 7 deletions.
4 changes: 3 additions & 1 deletion r2/r2/public/static/css/components/colors.less
Expand Up @@ -16,7 +16,9 @@
@color-green: #7CD344;
@color-teal: #25B79F;
@color-dark-teal: #008985;
@color-link-blue: #24A0ED;
@color-light-blue: #24A0ED;
@color-link-blue: #333df5;
@color-link-purple: #551a8b;
@color-periwinkle: #9494FF;
@color-white: #FFFFFF;
@color-off-white: #FCFCF7;
Expand Down
32 changes: 28 additions & 4 deletions r2/r2/public/static/css/search.less
@@ -1,12 +1,13 @@
@color-body: @color-text-grey;
@color-meta: @color-dark-grey;
@color-link: @color-alien-blue;
@color-link: darken(@color-alien-blue, 5%);
@color-link-visited: @color-link-purple;

@color-unsubscribe: darken(@color-warning-red, 10%);
@color-subscribe: darken(@color-green, 10%);
@color-subscribe-button-focus: @color-white;
@color-group-header-border: @color-pale-grey;

@color-title: darken(@color-link, 5%);
@color-subreddit: @color-meta;

@max-width: 750px;
Expand All @@ -31,11 +32,30 @@
.md-base-font-size(@search-font-base);
}

.search-result.visited {
.search-title,
.search-link {
&, > mark {
color: @color-link-visited;
}
}
}

.search-result {
margin-bottom: @margin-x-large * 1px;
margin-top: @margin-small * 1px;

a {
&, > mark {
color: @color-link;
}

&:visited,
&:visited > mark {
color: @color-link-visited;
}
}

&.has-thumbnail {
.display-flex();

Expand Down Expand Up @@ -76,8 +96,11 @@

.search-title {
font-size: @search-font-large * 1px;
color: @color-title;
margin-right: @margin-x-small * 1px;

> mark {
vertical-align: middle;
}
}

.search-subreddit-link {
Expand Down Expand Up @@ -149,7 +172,6 @@
white-space: nowrap;

.search-link {
color: @color-link;
margin-left: @margin-x-small * 1px;
}
}
Expand All @@ -158,6 +180,7 @@
background-color: transparent;
color: inherit;
font-weight: bold;
line-height: 1em;
}
}

Expand Down Expand Up @@ -192,6 +215,7 @@
}

.add, .remove {
color: @color-white;
text-align: center;
transform: scale(1, 1);
transition: all 0.15s;
Expand Down
8 changes: 8 additions & 0 deletions r2/r2/public/static/js/reddit.js
Expand Up @@ -1205,6 +1205,14 @@ $(function() {
.find('.search-title, .search-link, .search-subreddit-link, .search-result-body')
.highlight(query);

// add new search page links to the 'recently viewed' links...
$(".search-result-link").find("a.search-title, a.thumbnail").mousedown(function() {
var fullname = $(this).closest('[data-fullname]').data('fullname');
if (fullname) {
add_thing_id_to_cookie(fullname, "recentclicks2");
}
});

/* Select shortlink text on click */
$("#shortlink-text").click(function() {
$(this).select();
Expand Down
2 changes: 1 addition & 1 deletion r2/r2/templates/searchresultbase.html
Expand Up @@ -20,7 +20,7 @@
## reddit Inc. All Rights Reserved.
###############################################################################

<div class="${self.search_result_css_class()}">
<div class="${self.search_result_css_class()}" data-fullname="${thing.fullname}">
${self.search_result_content()}
</div>

Expand Down
3 changes: 2 additions & 1 deletion r2/r2/templates/searchresultlink.html
Expand Up @@ -38,8 +38,9 @@
<%
has_thumbnail_class = "has-thumbnail" if thing.thumbnail else ""
linkflair_classes = get_linkflair_css_classes(thing)
visited_class = 'visited' if thing.visited else ''
%>
${parent.search_result_css_class()} search-result-link ${has_thumbnail_class} ${linkflair_classes}
${parent.search_result_css_class()} search-result-link ${has_thumbnail_class} ${linkflair_classes} ${visited_class}
</%def>

<%def name="search_result_content()">
Expand Down

0 comments on commit 32db797

Please sign in to comment.