Dim and disable the "submit a link" button when unable to submit.

This commit is contained in:
Max Goodman
2011-11-30 14:44:35 -08:00
parent dc5e74ea05
commit 7c328537d3
7 changed files with 38 additions and 11 deletions

View File

@@ -242,12 +242,19 @@ class Reddit(Templated):
no_ads_yet = False
if self.submit_box and (c.user_is_loggedin or not g.read_only_mode):
ps.append(SideBox(_('Submit a link'),
'/submit', 'submit',
sr_path = (isinstance(c.site,DefaultSR)
or not isinstance(c.site, FakeSubreddit)),
subtitles = [strings.submit_box_text],
show_cover = True))
kwargs = {
"title": _("Submit a link"),
"css_class": "submit",
"show_cover": True
}
if not c.user_is_loggedin or c.site.can_submit(c.user) or isinstance(c.site, FakeSubreddit):
kwargs["link"] = "/submit"
kwargs["sr_path"] = isinstance(c.site, DefaultSR) or not isinstance(c.site, FakeSubreddit),
kwargs["subtitles"] = [strings.submit_box_text]
else:
kwargs["disabled"] = True
kwargs["subtitles"] = [strings.submit_box_restricted_text]
ps.append(SideBox(**kwargs))
if self.create_reddit_box and c.user_is_loggedin:
delta = datetime.datetime.now(g.tz) - c.user._date
@@ -523,12 +530,13 @@ class SideBox(CachedTemplate):
"""
Generic sidebox used to generate the 'submit' and 'create a reddit' boxes.
"""
def __init__(self, title, link, css_class='', subtitles = [],
show_cover = False, nocname=False, sr_path = False):
def __init__(self, title, link=None, css_class='', subtitles = [],
show_cover = False, nocname=False, sr_path = False, disabled=False):
CachedTemplate.__init__(self, link = link, target = '_top',
title = title, css_class = css_class,
sr_path = sr_path, subtitles = subtitles,
show_cover = show_cover, nocname=nocname)
show_cover = show_cover, nocname=nocname,
disabled=disabled)
class PrefsPage(Reddit):

View File

@@ -124,6 +124,7 @@ string_dict = dict(
unknown_rule_type = _('unknown CSS rule type "%(ruletype)s"')
),
submit_box_text = _('to anything interesting: news article, blog entry, video, picture...'),
submit_box_restricted_text = _('submission in this subreddit is restricted to approved submitters.'),
permalink_title = _("%(author)s comments on %(title)s"),
link_info_title = _("%(title)s : %(site)s"),
banned_subreddit = _("""**this reddit has been banned**\n\nmost likely this was done automatically by our spam filtering program. the program is still learning, and may even have some bugs, so if you feel the ban was a mistake, please submit a link to our [request a reddit listing](%(link)s) and be sure to include the **exact name of the reddit**."""),

View File

@@ -448,6 +448,24 @@ ul.flat-vert {text-align: left;}
background-image: url(../gradient-nub-hover.png); /* SPRITE */
}
.disabled .morelink, .disabled .morelink:hover {
background-image: url(../gradient-button-gray.png); /* SPRITE stretch-x */
border-color: #dadada;
}
.disabled .morelink a {
cursor: default;
color: #aaa;
}
.disabled .morelink .nub, .disabled .morelink:hover .nub {
background-image: url(../gradient-nub-gray.png); /* SPRITE */
}
.sidebox.submit.disabled .spacer a {
opacity: .5;
}
/* raised box */
.raisedbox {

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 696 B

View File

@@ -22,7 +22,7 @@
<%namespace file="utils.html" import="plain_link"/>
<div class="sidebox ${thing.css_class}">
<div class="sidebox ${thing.css_class}${' disabled' if thing.disabled else ''}">
<div class="morelink">
${plain_link(thing.title, thing.link, _sr_path=thing.sr_path,
_class='login-required' if thing.show_cover else None, nocname=thing.nocname)}

View File

@@ -138,7 +138,7 @@ ${first_defined(kw[1:])}
kw['target'] = target
link = _a_buffered(link_text,
href=add_sr(path, sr_path=_sr_path, nocname=nocname),
href=path and add_sr(path, sr_path=_sr_path, nocname=nocname),
**kw)
%>