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

Unified Diff: chrome/browser/resources/downloads/downloads.js

Issue 668983004: Add <a is="action-link">, a web component extension of <a> for in-page actions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/resources/downloads/downloads.js
diff --git a/chrome/browser/resources/downloads/downloads.js b/chrome/browser/resources/downloads/downloads.js
index 75124aa47ab415e6fcd7675f7ce5306c2bccdac8..193e9f693d1ab70d36ca8c6997b1e255ab851e81 100644
--- a/chrome/browser/resources/downloads/downloads.js
+++ b/chrome/browser/resources/downloads/downloads.js
@@ -52,15 +52,13 @@ function showInlineBlock(node, isShow) {
/**
* Creates a link with a specified onclick handler and content.
* @param {function()} onclick The onclick handler.
- * @param {string} value The link text.
+ * @param {string=} opt_text The link text.
* @return {!Element} The created link element.
*/
-function createLink(onclick, value) {
- var link = document.createElement('a');
+function createActionLink(onclick, opt_text) {
+ var link = document.createElement('a', 'action-link');
link.onclick = onclick;
- link.href = '#';
- link.textContent = value;
- link.oncontextmenu = function() { return false; };
+ if (opt_text) link.textContent = opt_text;
return link;
}
@@ -330,7 +328,7 @@ function Download(download) {
this.nodeTitleArea_ = createElementWithClassName('div', 'title-area');
this.safe_.appendChild(this.nodeTitleArea_);
- this.nodeFileLink_ = createLink(this.openFile_.bind(this), '');
+ this.nodeFileLink_ = createActionLink(this.openFile_.bind(this));
this.nodeFileLink_.className = 'name';
this.nodeFileLink_.style.display = 'none';
this.nodeTitleArea_.appendChild(this.nodeFileLink_);
@@ -356,7 +354,7 @@ function Download(download) {
// We don't need 'show in folder' in chromium os. See download_ui.cc and
// http://code.google.com/p/chromium-os/issues/detail?id=916.
if (loadTimeData.valueExists('control_showinfolder')) {
- this.controlShow_ = createLink(this.show_.bind(this),
+ this.controlShow_ = createActionLink(this.show_.bind(this),
loadTimeData.getString('control_showinfolder'));
this.nodeControls_.appendChild(this.controlShow_);
} else {
@@ -369,17 +367,17 @@ function Download(download) {
this.nodeControls_.appendChild(this.controlRetry_);
// Pause/Resume are a toggle.
- this.controlPause_ = createLink(this.pause_.bind(this),
+ this.controlPause_ = createActionLink(this.pause_.bind(this),
loadTimeData.getString('control_pause'));
this.nodeControls_.appendChild(this.controlPause_);
- this.controlResume_ = createLink(this.resume_.bind(this),
+ this.controlResume_ = createActionLink(this.resume_.bind(this),
loadTimeData.getString('control_resume'));
this.nodeControls_.appendChild(this.controlResume_);
// Anchors <a> don't support the "disabled" property.
if (loadTimeData.getBoolean('allow_deleting_history')) {
- this.controlRemove_ = createLink(this.remove_.bind(this),
+ this.controlRemove_ = createActionLink(this.remove_.bind(this),
loadTimeData.getString('control_removefromlist'));
this.controlRemove_.classList.add('control-remove-link');
} else {
@@ -394,7 +392,7 @@ function Download(download) {
this.nodeControls_.appendChild(this.controlRemove_);
- this.controlCancel_ = createLink(this.cancel_.bind(this),
+ this.controlCancel_ = createActionLink(this.cancel_.bind(this),
loadTimeData.getString('control_cancel'));
this.nodeControls_.appendChild(this.controlCancel_);
@@ -414,11 +412,11 @@ function Download(download) {
// Buttons for the malicious case.
this.malwareNodeControls_ = createElementWithClassName('div', 'controls');
- this.malwareSave_ = createLink(
+ this.malwareSave_ = createActionLink(
this.saveDangerous_.bind(this),
loadTimeData.getString('danger_restore'));
this.malwareNodeControls_.appendChild(this.malwareSave_);
- this.malwareDiscard_ = createLink(
+ this.malwareDiscard_ = createActionLink(
this.discardDangerous_.bind(this),
loadTimeData.getString('control_removefromlist'));
this.malwareNodeControls_.appendChild(this.malwareDiscard_);
@@ -884,7 +882,8 @@ function load() {
var clearAllHolder = $('clear-all-holder');
var clearAllElement;
if (loadTimeData.getBoolean('allow_deleting_history')) {
- clearAllElement = createLink(clearAll, loadTimeData.getString('clear_all'));
+ clearAllElement = createActionLink(
+ clearAll, loadTimeData.getString('clear_all'));
clearAllElement.classList.add('clear-all-link');
clearAllHolder.classList.remove('disabled-link');
} else {
@@ -896,14 +895,10 @@ function load() {
clearAllHolder.hidden = true;
clearAllHolder.appendChild(clearAllElement);
- clearAllElement.oncontextmenu = function() { return false; };
- // TODO(jhawkins): Use a link-button here.
- var openDownloadsFolderLink = $('open-downloads-folder');
- openDownloadsFolderLink.onclick = function() {
+ $('open-downloads-folder').onclick = function() {
chrome.send('openDownloadsFolder');
};
- openDownloadsFolderLink.oncontextmenu = function() { return false; };
$('term').onsearch = function(e) {
setSearch($('term').value);
@@ -989,5 +984,3 @@ function tryDownloadUpdatedPeriodically() {
// Add handlers to HTML elements.
window.addEventListener('DOMContentLoaded', load);
-
-preventDefaultOnPoundLinkClicks(); // From util.js.
« no previous file with comments | « chrome/browser/resources/downloads/downloads.html ('k') | chrome/browser/resources/extensions/extension_error.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698