Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: adblock-browser-head.html

Issue 4814987935612928: Issue 2213 - landing page for mobile beta launch (Closed)
Left Patch Set: Adjusted for IE8 after tests and addressed Thomas and Sebastian comments Created April 22, 2015, 3:19 p.m.
Right Patch Set: Make meta tags translatable Created April 29, 2015, 1:12 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « adblock-browser.html ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 <meta name="title" content="Adblock Browser Beta Launch" />
2 <meta property="og:title" content="Adblock Browser Beta Launch" />
3 <meta name="description" content="Want Adblock Browser for your smartphone or ta blet? Join the Adblock Browser for Android Beta Google+ community." />
4 <meta property="og:description" content="Want Adblock Browser for your smartphon e or tablet? Join the Adblock Browser for Android Beta Google+ community." />
5
6 <style type="text/css"> 1 <style type="text/css">
7 #content * 2 #content *
8 { 3 {
9 box-sizing: content-box; 4 box-sizing: content-box;
10 } 5 }
11 6
12 #content h1 7 #content h1
13 { 8 {
14 margin-bottom: 28px; 9 margin-bottom: 28px;
15 } 10 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
58 53
59 #subscribe-textbox 54 #subscribe-textbox
60 { 55 {
61 border: solid 1px #B5B4B0; 56 border: solid 1px #B5B4B0;
62 margin-right: 20px; 57 margin-right: 20px;
63 padding-left: 10px; 58 padding-left: 10px;
64 padding-right: 10px; 59 padding-right: 10px;
65 font-size: 16px; 60 font-size: 16px;
66 width: 276px; 61 width: 276px;
67 line-height: 44px; 62 line-height: 44px;
68 height: 44px; 63 height: 44px; /* IE 8 */
Thomas Greiner 2015/04/23 10:47:11 You don't need to explicitly specify the height if
saroyanm 2015/04/23 13:07:59 It's hack for IE8 unfortunately without specifying
Thomas Greiner 2015/04/23 13:38:00 As mentioned in an earlier comment, please add com
69 } 64 }
70 65
71 #subscribe-textbox.placeholder 66 #subscribe-textbox.placeholder
72 { 67 {
73 color: #B5B4B0; 68 color: #B5B4B0;
74 } 69 }
75 70
76 #subscribe-button 71 #subscribe-button
77 { 72 {
78 border: solid 1px #357EBD; 73 border: solid 1px #357EBD;
(...skipping 21 matching lines...) Expand all
100 border-radius: 5px; 95 border-radius: 5px;
101 padding: 5px; 96 padding: 5px;
102 margin-top: 30px; 97 margin-top: 30px;
103 } 98 }
104 99
105 html[lang="fr"] .disclaimer.lang-fr 100 html[lang="fr"] .disclaimer.lang-fr
106 { 101 {
107 display: block; 102 display: block;
108 } 103 }
109 104
110 #subscribe-form .empty-label, #subscribe-form .sucess-label, 105 #subscribe-form .sucess-label, #response-error,
111 #response-error, #subscribe-form .invalid-label, #email-placeholder, 106 #subscribe-form .invalid-label, #subscribe-form.success input,
112 #subscribe-form.success input, #subscribe-form.success button 107 #subscribe-form.success button
113 { 108 {
114 display: none; 109 display: none;
115 } 110 }
116 111
117 #subscribe-form .empty-label,
118 #subscribe-form .invalid-label 112 #subscribe-form .invalid-label
119 { 113 {
120 margin-top: 30px; 114 margin-top: 30px;
121 } 115 }
122 116
123 #subscribe-form.success .sucess-label, 117 #subscribe-form.success .sucess-label,
124 #subscribe-form.empty .empty-label,
125 #subscribe-form.invalid .invalid-label, 118 #subscribe-form.invalid .invalid-label,
126 #subscribe-form.error #response-error 119 #subscribe-form.error #response-error
127 { 120 {
128 display: block; 121 display: block;
129 } 122 }
130 </style> 123 </style>
131 124
132 <script type="text/javascript"><!-- 125 <script type="text/javascript">
Thomas Greiner 2015/04/23 10:47:11 It looks like `<!--` and `-->` are special excepti
saroyanm 2015/04/23 13:07:59 Done.
126 //<![CDATA[
133 function addListener(obj, type, listener, useCapture) 127 function addListener(obj, type, listener, useCapture)
134 { 128 {
135 if ("addEventListener" in obj) 129 if ("addEventListener" in obj)
136 { 130 {
137 obj.addEventListener(type, function(ev) 131 obj.addEventListener(type, function(ev)
138 { 132 {
139 ev.preventDefault(); 133 if (listener(ev) === false)
Thomas Greiner 2015/04/23 10:47:11 The default behavior is not to prevent the default
saroyanm 2015/04/23 13:07:59 Done.
140 listener(ev); 134 ev.preventDefault();
141 }, useCapture); 135 }, useCapture);
142 } 136 }
143 else 137 else
144 { 138 {
139 // IE 8
145 if (type == "DOMContentLoaded") 140 if (type == "DOMContentLoaded")
146 type = "readystatechange"; 141 type = "readystatechange";
147 142
148 // XMLHttpRequest missing attachEvent method In IE 8 143 type = "on" + type;
149 if (obj instanceof XMLHttpRequest && type == "load") 144 if ("attachEvent" in obj)
Thomas Greiner 2015/04/23 10:47:11 It's more useful if you'd make this more generic:
saroyanm 2015/04/23 13:07:59 Done.
150 { 145 {
151 obj.onreadystatechange = listener; 146 obj.attachEvent(type, function()
152 return; 147 {
148 if (document.readyState == "complete" && listener(event) === false)
149 event.returnValue = false;
150 });
153 } 151 }
154 obj.attachEvent("on" + type, function() 152 else
155 { 153 {
156 if (document.readyState == "complete") 154 obj[type] = listener;
157 { 155 }
158 event.returnValue = false;
Thomas Greiner 2015/04/23 10:47:11 The default return value is `true` so let's only s
saroyanm 2015/04/23 13:07:59 Done.
159 listener(event);
160 }
161 });
162 } 156 }
163 } 157 }
164 158
165 function addPlaceholder(textbox) 159 function addPlaceholder(textbox)
166 { 160 {
167 textbox.setAttribute("class", "placeholder"); 161 textbox.setAttribute("class", "placeholder");
168 textbox.value = getPlaceholderText(); 162 textbox.value = getPlaceholderText();
169 } 163 }
170 164
171 function getPlaceholderText() 165 function getPlaceholderText()
172 { 166 {
173 var text = "innerText" in document.body ? "innerText" : "textContent"; 167 return document.getElementById("subscribe-textbox").getAttribute("placeholder" );
174 return document.getElementById("email-placeholder")[text];
175 } 168 }
176 169
177 function contentLoad() 170 function contentLoad()
178 { 171 {
179 var emailTextbox = document.getElementById("subscribe-textbox"); 172 var emailTextbox = document.getElementById("subscribe-textbox");
180 173
181 // textbox placeholder implementation for browsers 174 // IE9 + Safari iOS
182 // that don't support placeholder attribute
183 if (!("placeholder" in document.createElement("input")) 175 if (!("placeholder" in document.createElement("input"))
184 && !emailTextbox.value) 176 && !emailTextbox.value)
185 { 177 {
186 addPlaceholder(emailTextbox); 178 addPlaceholder(emailTextbox);
187 addListener(emailTextbox, "focus", function() 179 addListener(emailTextbox, "focus", function()
188 { 180 {
189 if (emailTextbox.value == getPlaceholderText()) 181 if (emailTextbox.value == getPlaceholderText())
190 { 182 {
191 emailTextbox.value = ""; 183 emailTextbox.value = "";
192 emailTextbox.setAttribute("class", ""); 184 emailTextbox.setAttribute("class", "");
193 } 185 }
194 }, false); 186 }, false);
195 187
196 addListener(emailTextbox, "blur", function() 188 addListener(emailTextbox, "blur", function()
197 { 189 {
198 if (!emailTextbox.value) 190 if (!emailTextbox.value)
199 addPlaceholder(emailTextbox); 191 addPlaceholder(emailTextbox);
200 }, false); 192 }, false);
201 } 193 }
202 194
203 addListener(document.getElementById("subscribe-form"), "submit", function() 195 addListener(document.getElementById("subscribe-form"), "submit", function()
204 { 196 {
205 var formElement = document.getElementById("subscribe-form"); 197 var formElement = document.getElementById("subscribe-form");
206 if (!emailTextbox.value || emailTextbox.value == getPlaceholderText()) 198 if (!window.XMLHttpRequest)
207 { 199 {
208 formElement.setAttribute("class", "empty"); 200 formElement.submit();
209 return; 201 return false;
210 } 202 }
211 203
212 // Simple email validation for browsers 204 var pathArray = window.location.pathname.split("/");
213 // that don't support input of type email
214 var input = document.createElement("input");
215 input.setAttribute("type", "email");
216 if (input.type !== "email"
217 && !(/(.+)@(.+){2,}\.(.+){2,}/.test(emailTextbox.value)))
218 {
219 formElement.setAttribute("class", "invalid");
220 return;
221 }
222
223 if (!window.XMLHttpRequest)
224 {
225 formElement.submit();
226 return;
227 }
228
229 var params = emailTextbox.name + "=" + encodeURIComponent(emailTextbox.value ); 205 var params = emailTextbox.name + "=" + encodeURIComponent(emailTextbox.value );
206 params += "&lang=" + pathArray[1];
230 var request = new XMLHttpRequest(); 207 var request = new XMLHttpRequest();
231 request.open("POST", formElement.action, true); 208 request.open("POST", formElement.action, true);
232 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded" ); 209 request.setRequestHeader("Content-Type", "application/x-www-form-urlencoded" );
233 request.setRequestHeader("Content-length", params.length); 210 addListener(request, "readystatechange", function()
234 addListener(request, "load", function() 211 {
235 { 212 if (request.readyState == 4)
236 if (request.status >= 200 && request.status < 300)
237 { 213 {
238 formElement.setAttribute("class", "success"); 214 if (request.status >= 200 && request.status < 300)
239 } 215 {
240 else 216 formElement.setAttribute("class", "success");
241 { 217 }
242 var text = "innerText" in document.body ? "innerText" : "textContent"; 218 else if (request.status == 400)
Thomas Greiner 2015/04/23 10:47:11 The variable name is implying that this is a text
saroyanm 2015/04/23 13:07:59 Done.
243 document.getElementById("response-error")[text] = request.statusText; 219 {
244 formElement.setAttribute("class", "error"); 220 formElement.setAttribute("class", "invalid");
221 }
222 else
223 {
224 var errorWrapper = document.getElementById("response-error");
225 if ("textContent" in errorWrapper)
226 errorWrapper.textContent = request.statusText;
227 else // IE8
228 errorWrapper.innerText = request.statusText;
229
230 formElement.setAttribute("class", "error");
231 }
245 } 232 }
246 }, false); 233 }, false);
247 request.send(params); 234 request.send(params);
235 return false;
248 }, false); 236 }, false);
249 } 237 }
250 addListener(document, "DOMContentLoaded", contentLoad, false); 238 addListener(document, "DOMContentLoaded", contentLoad, false);
251 --></script> 239 //]]>
240 </script>
LEFTRIGHT

Powered by Google App Engine
This is Rietveld