Permalink
Browse files

Bookmarklet stuff.

  • Loading branch information...
1 parent 29cb4a9 commit 318474507f875420c34e81a9d6b1efe0983ca9bb @davedash davedash committed Feb 22, 2012
View
3 apps/common/templates/common/bookmarklet.html
@@ -1,3 +1,2 @@
<a class="bookmarklet" href="javascript:void((function(){var%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','{{ settings.SITE_URL }}/media/js/bookmarklet.js?'+new Date());document.body.appendChild(e)})());">
- Submit an Issue
-</a>
+ {{ _('Submit an Issue') }}</a>
View
8 apps/feedback/templates/feedback/feedback-form.html
@@ -36,14 +36,6 @@
{% if type != 'idea' %}
<div>
- <label for="{{ type }}-with-url">
- <input id="{{ type }}-with-url" type="checkbox" name="add_url" />
- {% if type == 'happy' %}
- {{ _('Include the URL of a site that worked better.') }}
- {% elif type == 'sad' %}
- {{ _('Include the URL of the site with the problem.') }}
- {% endif %}
- </label>
<p>{{ form.url }}</p>
{{ form.url.errors }}
</div>
View
8 apps/feedback/templates/feedback/index.html
@@ -15,7 +15,7 @@
<h1>{{ _('Submit Your Feedback') }}</h1>
<p>{{ _('Your feedback helps us improve Firefox.') }}</p>
</header>
-
+
<section class="content">
<ul id="feedback-types-beta">
<li><a id="intro-happy" href="#happy"><span><strong></strong></span>{{ _('Firefox Made Me Happy') }}</a></li>
@@ -32,6 +32,12 @@
{% endtrans %}
</span>
</aside>
+ <aside>
+ {% trans %}
+ Drag this link to your bookmark bar to file more issues:
+ {% endtrans %}
+ {% include "common/bookmarklet.html" %}.
+ </aside>
<span class="fade"></span>
</article>
View
17 apps/feedback/views.py
@@ -60,6 +60,7 @@ def wrapped(request, *args, **kwargs):
@anonymous_csrf_exempt
def feedback(request, ua):
"""Page to receive feedback under happy/sad/idea categories"""
+ initial = dict(url=request.REQUEST.get('url'))
if request.method == 'POST':
typ = int(request.POST.get('_type'))
@@ -77,16 +78,17 @@ def feedback(request, ua):
url = reverse('thanks')
return http.HttpResponseRedirect(url)
+
else:
forms = {'happy': (form if typ == input.OPINION_PRAISE.id else
- PraiseForm(auto_id='happy-%s')),
+ PraiseForm(auto_id='happy-%s', initial=initial)),
'sad': (form if typ == input.OPINION_ISSUE.id else
- IssueForm(auto_id='sad-%s')),
+ IssueForm(auto_id='sad-%s', initial=initial)),
'idea': (form if typ == input.OPINION_IDEA.id else
IdeaForm(auto_id='idea-%s'))}
else:
- forms = {'happy': PraiseForm(auto_id='happy-%s'),
- 'sad': IssueForm(auto_id='sad-%s'),
+ forms = {'happy': PraiseForm(auto_id='happy-%s', initial=initial),
+ 'sad': IssueForm(auto_id='sad-%s', initial=initial),
'idea': IdeaForm(auto_id='idea-%s')}
template = 'feedback/%sindex.html' % (
@@ -133,13 +135,6 @@ def save_opinion_from_form(request, type, ua, form):
"""Given a (valid) form and feedback type, save it to the DB."""
locale = detect_language(request)
- # Remove URL if checkbox disabled or no URL submitted. Broken Website
- # report does not have the option to disable URL submission.
- if (type != input.OPINION_BROKEN.id and
- not (form.cleaned_data.get('add_url', False) and
- form.cleaned_data.get('url'))):
- form.cleaned_data['url'] = ''
-
if type not in input.OPINION_TYPES:
raise ValueError('Unknown type %s' % type)
View
12 media/css/feedback.css
@@ -466,7 +466,7 @@ footer form option {
#rate {
-
+
}
#rate table {
width: 100%;
@@ -776,4 +776,12 @@ html.js #sad-url {
.errorlist {
color: red;
-}
+}
+
+/* Bookmarklet button */
+a.bookmarklet {
+ border-radius: 9px;
+ background: #999;
+ color: #333;
+ padding: 5px;
+}
View
4 media/js/bookmarklet.js
@@ -0,0 +1,4 @@
+var w = window;
+var s = document.getElementsByTagName('script');
+var site = new RegExp("http.*//[^/]+/").exec(s[s.length - 1].src);
+w.location = site+"feedback?url="+encodeURIComponent(w.location)+"#sad";

0 comments on commit 3184745

Please sign in to comment.