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

Side by Side Diff: Source/devtools/front_end/ui/UIUtils.js

Issue 1171893005: DevTools: unify theming for checkbox components. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 1314 matching lines...) Expand 10 before | Expand all | Expand 10 after
1325 this.radioElement.checked = true; 1325 this.radioElement.checked = true;
1326 this.radioElement.dispatchEvent(new Event("change")); 1326 this.radioElement.dispatchEvent(new Event("change"));
1327 } 1327 }
1328 1328
1329 registerCustomElement("label", "dt-checkbox", { 1329 registerCustomElement("label", "dt-checkbox", {
1330 /** 1330 /**
1331 * @this {Element} 1331 * @this {Element}
1332 */ 1332 */
1333 createdCallback: function() 1333 createdCallback: function()
1334 { 1334 {
1335 var root = WebInspector.createShadowRootWithCoreStyles(this); 1335 this._root = WebInspector.createShadowRootWithCoreStyles(this);
1336 root.appendChild(WebInspector.Widget.createStyleElement("ui/checkbox TextLabel.css")); 1336 this._root.appendChild(WebInspector.Widget.createStyleElement("ui/ch eckboxTextLabel.css"));
1337 var checkboxElement = createElementWithClass("input", "dt-checkbox-b utton"); 1337 var checkboxElement = createElementWithClass("input", "dt-checkbox-b utton");
1338 checkboxElement.type = "checkbox"; 1338 checkboxElement.type = "checkbox";
1339 root.appendChild(checkboxElement); 1339 this._root.appendChild(checkboxElement);
1340 this.checkboxElement = checkboxElement; 1340 this.checkboxElement = checkboxElement;
1341 1341
1342 this.addEventListener("click", toggleCheckbox.bind(this)); 1342 this.addEventListener("click", toggleCheckbox.bind(this));
1343 1343
1344 /** 1344 /**
1345 * @param {!Event} event 1345 * @param {!Event} event
1346 * @this {Node} 1346 * @this {Node}
1347 */ 1347 */
1348 function toggleCheckbox(event) 1348 function toggleCheckbox(event)
1349 { 1349 {
1350 if (event.target !== checkboxElement && event.target !== this) 1350 if (event.target !== checkboxElement && event.target !== this)
1351 checkboxElement.click(); 1351 checkboxElement.click();
1352 } 1352 }
1353 1353
1354 root.createChild("content"); 1354 this._root.createChild("content");
1355 }, 1355 },
1356 1356
1357 /** 1357 /**
1358 * @param {string} color 1358 * @param {string} color
1359 * @this {Element} 1359 * @this {Element}
1360 */ 1360 */
1361 set backgroundColor(color) 1361 set backgroundColor(color)
1362 { 1362 {
1363 this.checkboxElement.classList.add("dt-checkbox-colored"); 1363 this.checkboxElement.classList.add("dt-checkbox-themed");
1364 this.checkboxElement.style.backgroundColor = color; 1364 this.checkboxElement.style.backgroundColor = color;
1365 }, 1365 },
1366 1366
1367 /** 1367 /**
1368 * @param {string} color 1368 * @param {string} color
1369 * @this {Element} 1369 * @this {Element}
1370 */ 1370 */
1371 set checkColor(color)
1372 {
1373 this.checkboxElement.classList.add("dt-checkbox-themed");
1374 var stylesheet = createElement("style");
1375 stylesheet.textContent = "input.dt-checkbox-themed:checked:after { b ackground-color: " + color + "}";
1376 this._root.appendChild(stylesheet);
dgozman 2015/06/09 15:42:59 Should we remove previous one, if any?
1377 },
1378
1379 /**
1380 * @param {string} color
1381 * @this {Element}
1382 */
1371 set borderColor(color) 1383 set borderColor(color)
1372 { 1384 {
1373 this.checkboxElement.classList.add("dt-checkbox-colored"); 1385 this.checkboxElement.classList.add("dt-checkbox-themed");
1374 this.checkboxElement.style.borderColor = color; 1386 this.checkboxElement.style.borderColor = color;
1375 }, 1387 },
1376 1388
1377 __proto__: HTMLLabelElement.prototype 1389 __proto__: HTMLLabelElement.prototype
1378 }); 1390 });
1379 1391
1380 registerCustomElement("label", "dt-icon-label", { 1392 registerCustomElement("label", "dt-icon-label", {
1381 /** 1393 /**
1382 * @this {Element} 1394 * @this {Element}
1383 */ 1395 */
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1471 // Due to the nature of regex, |items| array has matched elements on its even indexes. 1483 // Due to the nature of regex, |items| array has matched elements on its even indexes.
1472 var items = text.replace(regex, "\0$1\0").split("\0"); 1484 var items = text.replace(regex, "\0$1\0").split("\0");
1473 for (var i = 0; i < items.length; ++i) { 1485 for (var i = 0; i < items.length; ++i) {
1474 var processedNode = i % 2 ? processor(items[i]) : this._runProcessor (processorIndex + 1, items[i]); 1486 var processedNode = i % 2 ? processor(items[i]) : this._runProcessor (processorIndex + 1, items[i]);
1475 container.appendChild(processedNode); 1487 container.appendChild(processedNode);
1476 } 1488 }
1477 1489
1478 return container; 1490 return container;
1479 } 1491 }
1480 } 1492 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/emulation/responsiveDesignView.css ('k') | Source/devtools/front_end/ui/checkboxTextLabel.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698