Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
torbutton
Commits
4c9e8dc0
Commit
4c9e8dc0
authored
Oct 15, 2018
by
Arthur Edelstein
Browse files
Bug 23925: Donation banner for YE 2018 Campaign
Design by Antonela Debiasi
parent
9ad95c91
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/chrome/content/aboutTor/aboutTor-content.js
View file @
4c9e8dc0
...
...
@@ -24,7 +24,7 @@ let { bindPrefAndInit, show_torbrowser_manual } = Cu.import("resource://torbutto
var
AboutTorListener
=
{
kAboutTorLoadedMessage
:
"
AboutTor:Loaded
"
,
kAboutTorChromeDataMessage
:
"
AboutTor:ChromeData
"
,
kAboutTorHide
TorNews
Banner
:
"
AboutTor:Hide
TorNews
Banner
"
,
kAboutTorHide
Donation
Banner
:
"
AboutTor:Hide
Donation
Banner
"
,
get
isAboutTor
()
{
return
content
.
document
.
documentURI
.
toLowerCase
()
==
"
about:tor
"
;
...
...
@@ -61,20 +61,24 @@ var AboutTorListener = {
setupBannerClosing
:
function
()
{
let
that
=
this
;
let
closer
=
content
.
document
.
getElementById
(
"
tornews
-banner-closer
"
);
let
closer
=
content
.
document
.
getElementById
(
"
donation
-banner-closer
"
);
closer
.
addEventListener
(
"
click
"
,
function
()
{
sendAsyncMessage
(
that
.
kAboutTorHide
TorNews
Banner
);
sendAsyncMessage
(
that
.
kAboutTorHide
Donation
Banner
);
});
let
link
=
content
.
document
.
querySelector
(
"
#tornews-banner-message a
"
);
link
.
addEventListener
(
"
click
"
,
function
()
{
let
button
=
content
.
document
.
getElementById
(
"
donation-banner-button
"
);
button
.
addEventListener
(
"
click
"
,
function
()
{
// Wait until page unloads so we don't hide banner before that.
content
.
addEventListener
(
"
unload
"
,
function
()
{
sendAsyncMessage
(
that
.
kAboutTorHide
TorNews
Banner
);
sendAsyncMessage
(
that
.
kAboutTorHide
Donation
Banner
);
});
});
bindPrefAndInit
(
"
extensions.torbutton.tornews_banner_countdown
"
,
countdown
=>
content
.
document
.
body
.
setAttribute
(
"
show-tornews-banner
"
,
countdown
>
0
));
bindPrefAndInit
(
"
extensions.torbutton.donation_banner_countdown
"
,
countdown
=>
{
if
(
content
.
document
&&
content
.
document
.
body
)
{
content
.
document
.
body
.
setAttribute
(
"
show-donation-banner
"
,
countdown
>
0
);
}
});
},
onPageLoad
:
function
()
{
...
...
@@ -124,6 +128,14 @@ var AboutTorListener = {
content
.
document
.
getElementById
(
"
manualLink
"
).
href
=
"
https://tb-manual.torproject.org/
"
+
aLocale
;
// Don't use "Count Me In" phrase in non-en-US locales
if
(
!
aLocale
.
startsWith
(
"
en
"
))
{
let
button
=
content
.
document
.
getElementById
(
"
donation-banner-button
"
);
button
.
innerHTML
=
button
.
getAttribute
(
"
data-0
"
);
let
theURL
=
button
.
getAttribute
(
"
href
"
);
button
.
setAttribute
(
"
href
"
,
theURL
.
slice
(
0
,
-
2
));
}
// Display the Tor Browser product name and version.
try
{
const
kBrandBundle
=
"
chrome://branding/locale/brand.properties
"
;
...
...
src/chrome/content/aboutTor/aboutTor.xhtml
View file @
4c9e8dc0
...
...
@@ -31,21 +31,48 @@ window.addEventListener("pageshow", function() {
</script>
</head>
<body
dir=
"&locale.dir;"
>
<div
id=
"tornews-banner"
>
<div>
<!--EMPTY SPACER DIV-->
</div>
<div
id=
"tornews-banner-message"
>
<div
id=
"tornews-banner-icon"
></div>
<div>
&aboutTor.newsletter.tagline;
<a
href=
"https://newsletter.torproject.org"
>
&aboutTor.newsletter.link_text;
</a>
<div
id=
"donation-banner"
>
<div
id=
"donation-banner-image"
></div>
<div
id=
"donation-banner-lines"
>
<div
id=
"donation-banner-line1"
>
&aboutTor.donationBanner.line1;
</div>
<div
id=
"donation-banner-line2"
data-0=
"&aboutTor.donationBanner.line2a;"
data-1=
"&aboutTor.donationBanner.line2b;"
data-2=
"&aboutTor.donationBanner.line2c;"
data-3=
"&aboutTor.donationBanner.line2d;"
data-4=
"&aboutTor.donationBanner.line2e;"
data-5=
"&aboutTor.donationBanner.line2f;"
>
&aboutTor.donationBanner.line2a;
</div>
<div
id=
"donation-banner-line3"
>
&aboutTor.donationBanner.line3;
</div>
<a
id=
"donation-banner-button"
href=
"https://www.torproject.org/donate/donate-sin-tbd0-0"
type=
"button"
data-0=
"&aboutTor.donationBanner.buttonA;"
data-1=
"&aboutTor.donationBanner.buttonB;"
>
&aboutTor.donationBanner.buttonA;
</a>
</div>
<div
id=
"
tornews
-banner-closer"
>
×
</div>
<div
id=
"
donation
-banner-closer"
>
×
</div>
</div>
<script
type=
"text/javascript"
>
<!
[
CDATA
[
let
lineChoice
=
Math
.
floor
(
Math
.
random
()
*
6
);
let
line2
=
document
.
getElementById
(
"
donation-banner-line2
"
);
let
line2text
=
line2
.
getAttribute
(
`data-
${
lineChoice
}
`
);
let
line2pieces
=
line2text
.
split
(
"
"
);
let
line2end
=
'
<span>
'
+
line2pieces
.
pop
()
+
'
</span>
'
;
line2pieces
.
push
(
line2end
);
line2
.
innerHTML
=
line2pieces
.
join
(
"
"
);
let
buttonChoice
=
Math
.
floor
(
Math
.
random
()
*
2
);
let
button
=
document
.
getElementById
(
"
donation-banner-button
"
);
button
.
innerHTML
=
button
.
getAttribute
(
`data-
${
buttonChoice
}
`
);
button
.
setAttribute
(
"
href
"
,
`https://www.torproject.org/donate/donate-sin-tbd
${
lineChoice
}
-
${
buttonChoice
}
`
);
]]
>
</script>
<div
id=
"torstatus-version"
/>
<div
class=
"torcontent-container"
>
<div
id=
"torstatus-version"
/>
<div
id=
"torstatus"
class=
"top"
>
<div
id=
"torstatus-on-container"
class=
"hideIfTorOff torstatus-container"
>
<div
class=
"heading1"
>
&aboutTor.ready.label;
</div>
...
...
src/chrome/content/torbutton.js
View file @
4c9e8dc0
...
...
@@ -19,7 +19,7 @@ const k_tb_last_browser_version_pref = "extensions.torbutton.lastBrowserVersion"
const
k_tb_browser_update_needed_pref
=
"
extensions.torbutton.updateNeeded
"
;
const
k_tb_last_update_check_pref
=
"
extensions.torbutton.lastUpdateCheck
"
;
const
k_tb_tor_check_failed_topic
=
"
Torbutton:TorCheckFailed
"
;
const
k_tb_
tornews
_banner_countdown
=
"
extensions.torbutton.
tornews
_banner_countdown
"
;
const
k_tb_
donation
_banner_countdown
=
"
extensions.torbutton.
donation
_banner_countdown
"
;
var
m_tb_prefs
=
Services
.
prefs
;
...
...
@@ -233,10 +233,10 @@ function torbutton_init_toolbutton()
}
// Show the Sign Up for Tor News banner a finite number of times.
function
torbutton_
tornews
_banner_countdown
()
{
let
count
=
m_tb_prefs
.
getIntPref
(
k_tb_
tornews
_banner_countdown
,
0
);
function
torbutton_
donation
_banner_countdown
()
{
let
count
=
m_tb_prefs
.
getIntPref
(
k_tb_
donation
_banner_countdown
,
0
);
if
(
count
>
0
)
{
m_tb_prefs
.
setIntPref
(
k_tb_
tornews
_banner_countdown
,
count
-
1
);
m_tb_prefs
.
setIntPref
(
k_tb_
donation
_banner_countdown
,
count
-
1
);
}
}
...
...
@@ -348,10 +348,10 @@ function torbutton_init() {
// Add about:tor IPC message listener.
window
.
messageManager
.
addMessageListener
(
"
AboutTor:Loaded
"
,
torbutton_abouttor_message_handler
);
window
.
messageManager
.
addMessageListener
(
"
AboutTor:Hide
TorNews
Banner
"
,
window
.
messageManager
.
addMessageListener
(
"
AboutTor:Hide
Donation
Banner
"
,
torbutton_abouttor_message_handler
);
torbutton_
tornews
_banner_countdown
();
torbutton_
donation
_banner_countdown
();
setupPreferencesForMobile
();
...
...
@@ -431,9 +431,9 @@ var torbutton_abouttor_message_handler = {
aMessage
.
target
.
messageManager
.
sendAsyncMessage
(
"
AboutTor:ChromeData
"
,
this
.
chromeData
);
break
;
case
"
AboutTor:Hide
TorNews
Banner
"
:
torbutton_log
(
5
,
"
message AboutTor:Hide
TorNews
Banner received
"
);
m_tb_prefs
.
setIntPref
(
k_tb_
tornews
_banner_countdown
,
0
);
case
"
AboutTor:Hide
Donation
Banner
"
:
torbutton_log
(
5
,
"
message AboutTor:Hide
Donation
Banner received
"
);
m_tb_prefs
.
setIntPref
(
k_tb_
donation
_banner_countdown
,
0
);
break
;
}
},
...
...
src/chrome/skin/aboutTor.css
View file @
4c9e8dc0
...
...
@@ -272,74 +272,126 @@ body:not([showmanual]) .showForManual {
border-radius
:
50px
50px
0
0
;
}
/*
Tor News Signup
Banner
/*
Donation
Banner
* While this banner is present, we need to
* offset the elements normally at the top of
* the window.
*/
#
tornews
-banner
{
#
donation
-banner
{
display
:
flex
;
align-items
:
center
;
align-items
:
stretch
;
background-color
:
white
;
color
:
var
(
--abouttor-bg-toron-color
);
font-size
:
16px
;
height
:
6
0px
;
justify-content
:
space-between
;
height
:
20
0px
;
justify-content
:
center
;
left
:
0px
;
right
:
0px
;
top
:
0px
;
transform
:
translateY
(
-60px
);
position
:
absolute
;
transform
:
translateY
(
-200px
);
transition
:
transform
200ms
;
z-index
:
1
;
}
body
[
show-
tornews
-banner
=
"true"
]
#
tornews
-banner
{
body
[
show-
donation
-banner
=
"true"
]
#
donation
-banner
{
transform
:
translateY
(
0px
);
transition
:
transform
0ms
;
}
#tornews-banner-message
{
align-items
:
center
;
display
:
flex
;
justify-content
:
center
;
}
#tornews-banner-message
a
{
color
:
var
(
--abouttor-bg-toron-color
);
}
#tornews-banner-icon
{
background
:
url('chrome://torbutton/skin/newsletter_3x.png')
no-repeat
center
center
;
background-size
:
cover
;
height
:
32px
;
margin
:
0px
16px
;
width
:
32px
;
#donation-banner-image
{
background
:
url('chrome://torbutton/skin/donation_banner_image_3x.png')
no-repeat
center
center
;
background-size
:
contain
;
height
:
190px
;
margin
:
10px
10px
0px
0px
;
width
:
400px
;
}
#
tornews
-banner-closer
{
#
donation
-banner-closer
{
display
:
flex
;
align-items
:
center
;
font-size
:
20px
;
height
:
22px
;
justify-content
:
center
;
margin
:
4px
20px
;
margin
:
4px
;
padding
:
4px
;
position
:
absolute
;
offset-inline-end
:
0px
;
top
:
0px
;
width
:
22px
;
-moz-user-select
:
none
;
}
#
tornews
-banner-closer
:hover
{
#
donation
-banner-closer
:hover
{
background-color
:
gray
;
cursor
:
pointer
;
}
body
[
show-tornews-banner
=
"false"
]
#torstatus-version
,
body
[
show-tornews-banner
=
"false"
]
#onboarding-overlay-button
{
#donation-banner-lines
{
align-items
:
start
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
space-around
;
padding
:
20px
0px
;
}
#donation-banner-line1
{
font-size
:
11px
;
font-weight
:
bold
;
text-transform
:
uppercase
;
}
#donation-banner-line2
{
font-size
:
20px
;
font-weight
:
bold
;
}
#donation-banner-line2
span
{
background-color
:
#a9fef8
;
}
#donation-banner-line3
{
font-size
:
14px
;
}
#donation-banner-button
{
background-color
:
var
(
--abouttor-bg-toron-color
);
border-radius
:
3px
;
border
:
0px
;
color
:
white
;
font-size
:
14px
;
font-weight
:
bold
;
margin
:
10px
0px
;
padding
:
10px
24px
;
text-decoration
:
none
;
}
#donation-banner-button
:hover
{
background-color
:
#683d7d
;
cursor
:
pointer
;
}
body
[
show-donation-banner
=
"false"
]
.torcontent-container
,
body
[
show-donation-banner
=
"false"
]
.onion-pattern-container
,
body
[
show-donation-banner
=
"false"
]
#torstatus-version
,
body
[
show-donation-banner
=
"false"
]
#onboarding-overlay-button
{
transition
:
transform
200ms
;
}
body
[
show-
tornews
-banner
=
"true"
]
#
tor
status-version
,
body
[
show-
tornews
-banner
=
"true"
]
#
on
boarding-overlay-button
{
transform
:
translateY
(
6
0px
);
body
[
show-
donation
-banner
=
"true"
]
.
tor
content-container
,
body
[
show-
donation
-banner
=
"true"
]
.
on
ion-pattern-container
{
transform
:
translateY
(
8
0px
);
transition
:
transform
0ms
;
}
body
[
show-donation-banner
=
"true"
]
.onion-pattern-container
{
position
:
fixed
;
}
body
[
show-donation-banner
=
"true"
]
#torstatus-version
,
body
[
show-donation-banner
=
"true"
]
#onboarding-overlay-button
{
transform
:
translateY
(
200px
);
transition
:
transform
0ms
;
position
:
absolute
;
}
src/chrome/skin/donation_banner_image_3x.png
0 → 100644
View file @
4c9e8dc0
70.2 KB
src/chrome/skin/newsletter_3x.png
deleted
100644 → 0
View file @
9ad95c91
6.58 KB
src/defaults/preferences/preferences.js
View file @
4c9e8dc0
...
...
@@ -6,7 +6,7 @@ pref("extensions.torbutton.logmethod",1); // 0=stdout, 1=errorconsole, 2=debuglo
pref
(
"
extensions.torbutton.display_circuit
"
,
true
);
pref
(
"
extensions.torbutton@torproject.org.description
"
,
"
chrome://torbutton/locale/torbutton.properties
"
);
pref
(
"
extensions.torbutton.updateNeeded
"
,
false
);
pref
(
"
extensions.torbutton.
tornews
_banner_countdown
"
,
4
);
pref
(
"
extensions.torbutton.
donation
_banner_countdown
"
,
12
);
// Tor check and proxy prefs
pref
(
"
extensions.torbutton.test_enabled
"
,
true
);
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment