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

Side by Side Diff: static/js/main.js

Issue 29596595: Issue 5912 - Hide/Show Content based on selected browser on help.eyeo.com article pages (Closed) Base URL: https://hg.adblockplus.org/help.eyeo.com
Patch Set: Created Nov. 3, 2017, 10:23 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
OLDNEW
1 (function() 1 (function()
2 { 2 {
3 document.addEventListener("DOMContentLoaded", function() 3 document.addEventListener("DOMContentLoaded", function()
4 { 4 {
5 5
6 /************************************************************************** 6 /**************************************************************************
7 * General 7 * General
8 **************************************************************************/ 8 **************************************************************************/
9 9
10 // Change html class name from "no-js" to "js" 10 // Change html class name from "no-js" to "js"
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
299 { 299 {
300 var autodetected = document 300 var autodetected = document
301 .getElementById('browser-select-autodetected') 301 .getElementById('browser-select-autodetected')
302 .innerHTML; 302 .innerHTML;
303 selectedOption += "<span class='muted'>(" + autodetected + ")</span>"; 303 selectedOption += "<span class='muted'>(" + autodetected + ")</span>";
304 } 304 }
305 305
306 this.select 306 this.select
307 .querySelector(".custom-select-selected") 307 .querySelector(".custom-select-selected")
308 .innerHTML = selectedOption; 308 .innerHTML = selectedOption;
309
310 this.checkBrowserContent(browser);
309 }; 311 };
310 312
313 BrowserSelect.prototype.checkBrowserContent = function(browser)
juliandoucette 2017/11/06 15:56:05 NIT: I don't think that this method name is descri
ire 2017/11/08 07:46:59 I think you're right. Since the method was essent
314 {
315 var browserContent = document.querySelector(".platform-" + browser);
316 if (browserContent) return;
317
318 var section = document.createElement("section");
juliandoucette 2017/11/06 15:56:05 TOL: This could be done with fewer lines of code e
ire 2017/11/08 07:46:59 I think it does matter where the unsupported messa
319 section.classList.add("platform-" + browser);
320 section.innerHTML = document
321 .getElementById("no-content-for-platform-message")
322 .innerHTML;
323
324 document
juliandoucette 2017/11/06 10:45:00 Why insert this instead of adding a class to the b
ire 2017/11/06 14:27:20 I think it makes sense semantically this way. Beca
325 .querySelector(".article-body")
326 .insertAdjacentElement('afterbegin', section);
327 }
328
311 BrowserSelect.prototype._onClickOrKeyDown = function(event) 329 BrowserSelect.prototype._onClickOrKeyDown = function(event)
312 { 330 {
313 if (!event.target.classList.contains("custom-select-option")) return; 331 if (!event.target.classList.contains("custom-select-option")) return;
314 332
315 var IS_ENTER_KEY = event.key == "Enter" || event.keyCode == 13; 333 var IS_ENTER_KEY = event.key == "Enter" || event.keyCode == 13;
316 if (event.keyCode && !IS_ENTER_KEY) return; 334 if (event.keyCode && !IS_ENTER_KEY) return;
317 335
318 localStorage.removeItem(this.BROWSER_AUTODETECTED_STORAGE_KEY); 336 localStorage.removeItem(this.BROWSER_AUTODETECTED_STORAGE_KEY);
319 337
320 // Uncheck previously checked option 338 // Uncheck previously checked option
321 this.select 339 this.select
322 .querySelector("[aria-checked='true']") 340 .querySelector("[aria-checked='true']")
323 .setAttribute("aria-checked", "false"); 341 .setAttribute("aria-checked", "false");
324 342
325 this.selectOption(event.target.getAttribute("data-value")); 343 this.selectOption(event.target.getAttribute("data-value"));
326 344
327 this.close(); 345 this.close();
328 }; 346 };
329 347
330 var browserSelect = document.getElementById("browser-select"); 348 var browserSelect = document.getElementById("browser-select");
331 if (browserSelect) 349 if (browserSelect)
332 { 350 {
333 new BrowserSelect(browserSelect); 351 new BrowserSelect(browserSelect);
334 } 352 }
335 353
336 }, false); 354 }, false);
337 }()); 355 }());
OLDNEW
« globals/browsers.py ('K') | « globals/browsers.py ('k') | static/scss/base/_variables.scss » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld