Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: components/dom_distiller/core/javascript/dom_distiller_viewer.js

Issue 1125343004: Add a "Simplify Page" option to the print preview dialog (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for the failing tests Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This variable will be changed by iOS scripts. 5 // This variable will be changed by iOS scripts.
6 var distiller_on_ios = false; 6 var distiller_on_ios = false;
7 7
8 function addToPage(html) { 8 function addToPage(html) {
9 var div = document.createElement('div'); 9 var div = document.createElement('div');
10 div.innerHTML = html; 10 div.innerHTML = html;
11 document.getElementById('content').appendChild(div); 11 document.getElementById('content').appendChild(div);
12 fillYouTubePlaceholders(); 12 fillYouTubePlaceholders();
13
14 if (typeof navigate_on_initial_content_load !== 'undefined' &&
15 navigate_on_initial_content_load) {
16 navigate_on_initial_content_load = false;
17 setTimeout(function() {
18 window.location = window.location + "#loaded";
19 }, 0);
20 }
13 } 21 }
14 22
15 function fillYouTubePlaceholders() { 23 function fillYouTubePlaceholders() {
16 var placeholders = document.getElementsByClassName('embed-placeholder'); 24 var placeholders = document.getElementsByClassName('embed-placeholder');
17 for (var i = 0; i < placeholders.length; i++) { 25 for (var i = 0; i < placeholders.length; i++) {
18 if (!placeholders[i].hasAttribute('data-type') || 26 if (!placeholders[i].hasAttribute('data-type') ||
19 placeholders[i].getAttribute('data-type') != 'youtube' || 27 placeholders[i].getAttribute('data-type') != 'youtube' ||
20 !placeholders[i].hasAttribute('data-id')) { 28 !placeholders[i].hasAttribute('data-id')) {
21 continue; 29 continue;
22 } 30 }
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
124 // If the distiller is running on iOS, do not show the feedback form. This 132 // If the distiller is running on iOS, do not show the feedback form. This
125 // variable is set in distiller_viewer.cc before this function is run. 133 // variable is set in distiller_viewer.cc before this function is run.
126 if (distiller_on_ios) return; 134 if (distiller_on_ios) return;
127 135
128 document.getElementById('feedbackYes').innerText = yesText; 136 document.getElementById('feedbackYes').innerText = yesText;
129 document.getElementById('feedbackNo').innerText = noText; 137 document.getElementById('feedbackNo').innerText = noText;
130 document.getElementById('feedbackQuestion').innerText = questionText; 138 document.getElementById('feedbackQuestion').innerText = questionText;
131 139
132 document.getElementById('contentWrap').style.paddingBottom = '120px'; 140 document.getElementById('contentWrap').style.paddingBottom = '120px';
133 document.getElementById('feedbackContainer').style.display = 'block'; 141 document.getElementById('feedbackContainer').style.display = 'block';
142 var mediaQuery = window.matchMedia("print");
143 mediaQuery.addListener(function (query) {
144 if (query.matches) {
145 document.getElementById('contentWrap').style.paddingBottom = '0px';
146 document.getElementById('feedbackContainer').style.display = 'none';
147 } else {
148 document.getElementById('contentWrap').style.paddingBottom = '120px';
149 document.getElementById('feedbackContainer').style.display = 'block';
150 }
151 });
134 } 152 }
135 153
136 /** 154 /**
137 * Send feedback about this distilled article. 155 * Send feedback about this distilled article.
138 * @param good True if the feedback was positive, false if negative. 156 * @param good True if the feedback was positive, false if negative.
139 */ 157 */
140 function sendFeedback(good) { 158 function sendFeedback(good) {
141 var img = document.createElement('img'); 159 var img = document.createElement('img');
142 if (good) { 160 if (good) {
143 img.src = '/feedbackgood'; 161 img.src = '/feedbackgood';
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
375 shiftY: shiftY 393 shiftY: shiftY
376 }; 394 };
377 } 395 }
378 }; 396 };
379 }()); 397 }());
380 398
381 window.addEventListener('touchstart', pincher.handleTouchStart, false); 399 window.addEventListener('touchstart', pincher.handleTouchStart, false);
382 window.addEventListener('touchmove', pincher.handleTouchMove, false); 400 window.addEventListener('touchmove', pincher.handleTouchMove, false);
383 window.addEventListener('touchend', pincher.handleTouchEnd, false); 401 window.addEventListener('touchend', pincher.handleTouchEnd, false);
384 window.addEventListener('touchcancel', pincher.handleTouchCancel, false); 402 window.addEventListener('touchcancel', pincher.handleTouchCancel, false);
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698