Commit 8f15aafb authored by flackr@chromium.org's avatar flackr@chromium.org

Add icon-visibility attribute to cr.ui.Tree.

This adds an icon-visibility attribute to cr.ui.Tree. If 'hidden', no space is reserved beside .tree-item labels and icons are not displayed. 'all' => show folder icons beside all nodes. 'parent' => show folder icons beside expandable/parent nodes. Removes icons from certificate viewer.

BUG=101920
TEST=None


Review URL: http://codereview.chromium.org/8341081

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@108160 0039d316-1c4b-4281-b951-d872f2087c98
parent 8cdcca3a
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<link rel="stylesheet" href="chrome://resources/css/tabs.css"> <link rel="stylesheet" href="chrome://resources/css/tabs.css">
<link rel="stylesheet" href="chrome://resources/css/tree.css"> <link rel="stylesheet" href="chrome://resources/css/tree.css">
<script src="strings.js"></script> <script src="strings.js"></script>
<script src="chrome://resources/css/tree.css.js"></script>
<script src="chrome://resources/js/cr.js"></script> <script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/cr/ui.js"></script> <script src="chrome://resources/js/cr/ui.js"></script>
<script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script> <script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script>
...@@ -93,11 +94,13 @@ ...@@ -93,11 +94,13 @@
<!-- Details --> <!-- Details -->
<div id="hierarchy-section" class="vertical-box"> <div id="hierarchy-section" class="vertical-box">
<span class="title" i18n-content="hierarchy"></span> <span class="title" i18n-content="hierarchy"></span>
<div id="hierarchy" class="section-contents"></div> <tree id="hierarchy" class="section-contents"
icon-visibility='hidden'></tree>
</div> </div>
<div id="cert-fields-section" class="vertical-box"> <div id="cert-fields-section" class="vertical-box">
<span class="title" i18n-content="certFields"></span> <span class="title" i18n-content="certFields"></span>
<div id="cert-fields" class="section-contents"></div> <tree id="cert-fields" class="section-contents"
icon-visibility='hidden'></tree>
</div> </div>
<div id="cert-field-value-section" class="vertical-box"> <div id="cert-field-value-section" class="vertical-box">
<span class="title" i18n-content="certFieldVal"></span> <span class="title" i18n-content="certFieldVal"></span>
......
...@@ -22,11 +22,11 @@ ...@@ -22,11 +22,11 @@
<div id="info-banner" hidden></div> <div id="info-banner" hidden></div>
<p i18n-content="allowedCookies"></p> <p i18n-content="allowedCookies"></p>
<tree id="allowed-cookies" class="cookies-tree"></tree> <tree id="allowed-cookies" class="cookies-tree" icon-visibility="parent"></tree>
<button id="block-button" i18n-content="blockButton"></button> <button id="block-button" i18n-content="blockButton"></button>
<p i18n-content="blockedCookies"></p> <p i18n-content="blockedCookies"></p>
<tree id="blocked-cookies" class="cookies-tree"></tree> <tree id="blocked-cookies" class="cookies-tree" icon-visibility="parent"></tree>
<button id="allow-button" i18n-content="allowButton"></button> <button id="allow-button" i18n-content="allowButton"></button>
<button id="allow-this-session-button" <button id="allow-this-session-button"
i18n-content="allowThisSessionButton"></button> i18n-content="allowThisSessionButton"></button>
......
...@@ -35,26 +35,27 @@ ...@@ -35,26 +35,27 @@
<span i18n-content="personalCertsTabDescription"></span> <span i18n-content="personalCertsTabDescription"></span>
</td></tr> </td></tr>
<tr><td> <tr><td>
<tree id="personalCertsTab-tree" class="certificate-tree"></tree> <tree id="personalCertsTab-tree" class="certificate-tree"
icon-visibility="parent"></tree>
</td></tr> </td></tr>
<tr><td> <tr><td>
<button id="personalCertsTab-view" i18n-content="view_certificate" <button id="personalCertsTab-view" i18n-content="view_certificate"
disabled></button> disabled></button>
<!-- TODO(mattm): <!-- TODO(mattm):
<button id="personalCertsTab-backup-all" <button id="personalCertsTab-backup-all"
i18n-content="export_all_certificates" i18n-content="export_all_certificates"
disabled></button> disabled></button>
--> -->
<button id="personalCertsTab-import" i18n-content="import_certificate" <button id="personalCertsTab-import" i18n-content="import_certificate"
></button> ></button>
<if expr="pp_ifdef('chromeos')"> <if expr="pp_ifdef('chromeos')">
<button id="personalCertsTab-import-and-bind" <button id="personalCertsTab-import-and-bind"
i18n-content="importAndBindCertificate" disabled></button> i18n-content="importAndBindCertificate" disabled></button>
</if> </if>
<button id="personalCertsTab-backup" i18n-content="export_certificate" <button id="personalCertsTab-backup" i18n-content="export_certificate"
disabled></button> disabled></button>
<button id="personalCertsTab-delete" i18n-content="delete_certificate" <button id="personalCertsTab-delete" i18n-content="delete_certificate"
disabled></button> disabled></button>
</td></tr> </td></tr>
</table> </table>
</div> </div>
...@@ -64,21 +65,22 @@ ...@@ -64,21 +65,22 @@
<span i18n-content="serverCertsTabDescription"></span> <span i18n-content="serverCertsTabDescription"></span>
</td></tr> </td></tr>
<tr><td> <tr><td>
<tree id="serverCertsTab-tree" class="certificate-tree"></tree> <tree id="serverCertsTab-tree" class="certificate-tree"
icon-visibility="parent"></tree>
</td></tr> </td></tr>
<tr><td> <tr><td>
<button id="serverCertsTab-view" i18n-content="view_certificate" <button id="serverCertsTab-view" i18n-content="view_certificate"
disabled></button> disabled></button>
<!-- TODO(mattm): <!-- TODO(mattm):
<button id="serverCertsTab-edit" i18n-content="edit_certificate" <button id="serverCertsTab-edit" i18n-content="edit_certificate"
disabled></button> disabled></button>
--> -->
<button id="serverCertsTab-import" i18n-content="import_certificate" <button id="serverCertsTab-import" i18n-content="import_certificate"
></button> ></button>
<button id="serverCertsTab-export" i18n-content="export_certificate" <button id="serverCertsTab-export" i18n-content="export_certificate"
disabled></button> disabled></button>
<button id="serverCertsTab-delete" i18n-content="delete_certificate" <button id="serverCertsTab-delete" i18n-content="delete_certificate"
disabled></button> disabled></button>
</td></tr> </td></tr>
</table> </table>
</div> </div>
...@@ -88,19 +90,20 @@ ...@@ -88,19 +90,20 @@
<span i18n-content="caCertsTabDescription"></span> <span i18n-content="caCertsTabDescription"></span>
</td></tr> </td></tr>
<tr><td> <tr><td>
<tree id="caCertsTab-tree" class="certificate-tree"></tree> <tree id="caCertsTab-tree" class="certificate-tree"
icon-visibility="parent"></tree>
</td></tr> </td></tr>
<tr><td> <tr><td>
<button id="caCertsTab-view" i18n-content="view_certificate" <button id="caCertsTab-view" i18n-content="view_certificate"
disabled></button> disabled></button>
<button id="caCertsTab-edit" i18n-content="edit_certificate" <button id="caCertsTab-edit" i18n-content="edit_certificate"
disabled></button> disabled></button>
<button id="caCertsTab-import" i18n-content="import_certificate" <button id="caCertsTab-import" i18n-content="import_certificate"
></button> ></button>
<button id="caCertsTab-export" i18n-content="export_certificate" <button id="caCertsTab-export" i18n-content="export_certificate"
disabled></button> disabled></button>
<button id="caCertsTab-delete" i18n-content="delete_certificate" <button id="caCertsTab-delete" i18n-content="delete_certificate"
disabled></button> disabled></button>
</td></tr> </td></tr>
</table> </table>
</div> </div>
...@@ -110,15 +113,16 @@ ...@@ -110,15 +113,16 @@
<span i18n-content="unknownCertsTabDescription"></span> <span i18n-content="unknownCertsTabDescription"></span>
</td></tr> </td></tr>
<tr><td> <tr><td>
<tree id="otherCertsTab-tree" class="certificate-tree"></tree> <tree id="otherCertsTab-tree" class="certificate-tree"
icon-visibility="parent"></tree>
</td></tr> </td></tr>
<tr><td> <tr><td>
<button id="otherCertsTab-view" i18n-content="view_certificate" <button id="otherCertsTab-view" i18n-content="view_certificate"
disabled></button> disabled></button>
<button id="otherCertsTab-export" i18n-content="export_certificate" <button id="otherCertsTab-export" i18n-content="export_certificate"
disabled></button> disabled></button>
<button id="otherCertsTab-delete" i18n-content="delete_certificate" <button id="otherCertsTab-delete" i18n-content="delete_certificate"
disabled></button> disabled></button>
</td></tr> </td></tr>
</table> </table>
</div> </div>
......
...@@ -100,40 +100,55 @@ tree:focus .tree-row[selected] { ...@@ -100,40 +100,55 @@ tree:focus .tree-row[selected] {
.tree-label { .tree-label {
-webkit-padding-start: 20px; -webkit-padding-start: 20px;
background-image: url("../../../../../ui/resources/folder_closed.png");
background-position: 0 50%; background-position: 0 50%;
background-repeat: no-repeat; background-repeat: no-repeat;
white-space: pre; white-space: pre;
} }
/* We need to ensure that even empty labels take up space */ html[dir=rtl] .tree-label {
.tree-label:empty:after { background-position: 100% 50%;
content: " ";
white-space: pre;
} }
.tree-rename > .tree-row > .tree-label { html[dir=rtl] .tree-label,
-webkit-user-select: auto; html[dir=rtl] .tree-row[may-have-children] > .tree-label {
-webkit-user-modify: read-write-plaintext-only; background-image: url("../../../../../ui/resources/folder_closed_rtl.png");
background: white;
color: black;
outline: 1px solid black;
} }
html[dir=rtl] .tree-label { html[dir=rtl] .tree-item[expanded] > .tree-row > .tree-label {
background-position: 100% 50%; background-image: url("../../../../../ui/resources/folder_open_rtl.png");
}
tree[icon-visibility=hidden] .tree-label {
-webkit-padding-start: 0;
background-image: none !important;
}
tree[icon-visibility=parent] .tree-label,
tree[icon-visibility=parent] .tree-row[has-children=false] > .tree-label {
background-image: none;
}
.tree-label,
.tree-row[may-have-children] > .tree-label {
background-image: url("../../../../../ui/resources/folder_closed.png");
} }
.tree-item[expanded] > .tree-row > .tree-label { .tree-item[expanded] > .tree-row > .tree-label {
background-image: url("../../../../../ui/resources/folder_open.png"); background-image: url("../../../../../ui/resources/folder_open.png");
} }
html[dir='rtl'] .tree-label { /* We need to ensure that even empty labels take up space */
background-image: url("../../../../../ui/resources/folder_closed_rtl.png"); .tree-label:empty:after {
content: " ";
white-space: pre;
} }
html[dir='rtl'] .tree-item[expanded] > .tree-row > .tree-label { .tree-rename > .tree-row > .tree-label {
background-image: url("../../../../../ui/resources/folder_open_rtl.png"); -webkit-user-select: auto;
-webkit-user-modify: read-write-plaintext-only;
background: white;
color: black;
outline: 1px solid black;
} }
.tree-item[editing] input { .tree-item[editing] input {
......
...@@ -133,6 +133,16 @@ const cr = (function() { ...@@ -133,6 +133,16 @@ const cr = (function() {
target.dispatchEvent(e); target.dispatchEvent(e);
} }
/**
* Converts a camelCase javascript property name to a hyphenated-lower-case
* attribute name.
* @param {string} jsName The javascript camelCase property name.
* @return {string} The equivalent hyphenated-lower-case attribute name.
*/
function getAttributeName(jsName) {
return jsName.replace(/([A-Z])/g, '-$1').toLowerCase();
}
/** /**
* The kind of property to define in {@code defineProperty}. * The kind of property to define in {@code defineProperty}.
* @enum {number} * @enum {number}
...@@ -171,12 +181,14 @@ const cr = (function() { ...@@ -171,12 +181,14 @@ const cr = (function() {
return this[privateName]; return this[privateName];
}; };
case PropertyKind.ATTR: case PropertyKind.ATTR:
var attributeName = getAttributeName(name);
return function() { return function() {
return this.getAttribute(name); return this.getAttribute(attributeName);
}; };
case PropertyKind.BOOL_ATTR: case PropertyKind.BOOL_ATTR:
var attributeName = getAttributeName(name);
return function() { return function() {
return this.hasAttribute(name); return this.hasAttribute(attributeName);
}; };
} }
} }
...@@ -207,13 +219,14 @@ const cr = (function() { ...@@ -207,13 +219,14 @@ const cr = (function() {
}; };
case PropertyKind.ATTR: case PropertyKind.ATTR:
var attributeName = getAttributeName(name);
return function(value) { return function(value) {
var oldValue = this[name]; var oldValue = this[attributeName];
if (value !== oldValue) { if (value !== oldValue) {
if (value == undefined) if (value == undefined)
this.removeAttribute(name); this.removeAttribute(attributeName);
else else
this.setAttribute(name, value); this.setAttribute(attributeName, value);
if (opt_setHook) if (opt_setHook)
opt_setHook.call(this, value, oldValue); opt_setHook.call(this, value, oldValue);
dispatchPropertyChange(this, name, value, oldValue); dispatchPropertyChange(this, name, value, oldValue);
...@@ -221,13 +234,14 @@ const cr = (function() { ...@@ -221,13 +234,14 @@ const cr = (function() {
}; };
case PropertyKind.BOOL_ATTR: case PropertyKind.BOOL_ATTR:
var attributeName = getAttributeName(name);
return function(value) { return function(value) {
var oldValue = this[name]; var oldValue = this[attributeName];
if (value !== oldValue) { if (value !== oldValue) {
if (value) if (value)
this.setAttribute(name, name); this.setAttribute(attributeName, name);
else else
this.removeAttribute(name); this.removeAttribute(attributeName);
if (opt_setHook) if (opt_setHook)
opt_setHook.call(this, value, oldValue); opt_setHook.call(this, value, oldValue);
dispatchPropertyChange(this, name, value, oldValue); dispatchPropertyChange(this, name, value, oldValue);
......
...@@ -217,6 +217,16 @@ cr.define('cr.ui', function() { ...@@ -217,6 +217,16 @@ cr.define('cr.ui', function() {
} }
}; };
/**
* Determines the visibility of icons next to the treeItem labels. If set to
* 'hidden', no space is reserved for icons and no icons are displayed next
* to treeItem labels. If set to 'parent', folder icons will be displayed
* next to expandable parent nodes. If set to 'all' folder icons will be
* displayed next to all nodes. Icons can be set using the treeItem's icon
* property.
*/
cr.defineProperty(Tree, 'iconVisibility', cr.PropertyKind.ATTR);
/** /**
* This is used as a blueprint for new tree item elements. * This is used as a blueprint for new tree item elements.
* @type {!HTMLElement} * @type {!HTMLElement}
......
...@@ -8,7 +8,7 @@ item detail on the lower right. --> ...@@ -8,7 +8,7 @@ item detail on the lower right. -->
behavior when tree is too tall (currently it makes you scroll the behavior when tree is too tall (currently it makes you scroll the
entire page). --> entire page). -->
<div id="sync-node-tree-container"> <div id="sync-node-tree-container">
<tree id="sync-node-tree"></tree> <tree id="sync-node-tree" icon-visibility="parent"></tree>
</div> </div>
<div id="sync-node-splitter"></div> <div id="sync-node-splitter"></div>
<div id="sync-node-browser-container"> <div id="sync-node-browser-container">
......
...@@ -36,7 +36,6 @@ static const char kSubNodesId[] = "subnodes"; ...@@ -36,7 +36,6 @@ static const char kSubNodesId[] = "subnodes";
static const char kNameId[] = "name"; static const char kNameId[] = "name";
static const char kReadOnlyId[] = "readonly"; static const char kReadOnlyId[] = "readonly";
static const char kUntrustedId[] = "untrusted"; static const char kUntrustedId[] = "untrusted";
static const char kIconId[] = "icon";
static const char kSecurityDeviceId[] = "device"; static const char kSecurityDeviceId[] = "device";
static const char kErrorId[] = "error"; static const char kErrorId[] = "error";
...@@ -971,7 +970,6 @@ void CertificateManagerHandler::PopulateTree(const std::string& tab_name, ...@@ -971,7 +970,6 @@ void CertificateManagerHandler::PopulateTree(const std::string& tab_name,
kUntrustedId, kUntrustedId,
certificate_manager_model_->cert_db().IsUntrusted(cert)); certificate_manager_model_->cert_db().IsUntrusted(cert));
// TODO(mattm): Other columns. // TODO(mattm): Other columns.
cert_dict->SetString(kIconId, "none");
subnodes->Append(cert_dict); subnodes->Append(cert_dict);
} }
std::sort(subnodes->begin(), subnodes->end(), comparator); std::sort(subnodes->begin(), subnodes->end(), comparator);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment