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

Side by Side Diff: chrome/browser/resources/file_manager/js/combobutton.js

Issue 10790100: [File Manager] Support HiDPI images in action picker and default action picker (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 5 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 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 /** 5 /**
6 * @fileoverview This implements a combobutton control. 6 * @fileoverview This implements a combobutton control.
7 */ 7 */
8 8
9 cr.define('cr.ui', function() { 9 cr.define('cr.ui', function() {
10 /** 10 /**
(...skipping 13 matching lines...) Expand all
24 /** 24 /**
25 * Truncates drop-down list. 25 * Truncates drop-down list.
26 */ 26 */
27 clear: function() { 27 clear: function() {
28 this.menu.clear(); 28 this.menu.clear();
29 this.multiple = false; 29 this.multiple = false;
30 }, 30 },
31 31
32 addDropDownItem: function(item) { 32 addDropDownItem: function(item) {
33 this.multiple = true; 33 this.multiple = true;
34 this.menu.addMenuItem(item).data = item; 34 var menuitem = this.menu.addMenuItem(item);
35 menuitem.data = item;
36 if (item.iconType) {
37 menuitem.style.backgroundImage = '';
38 menuitem.setAttribute('file-type-icon', item.iconType);
39 }
35 }, 40 },
36 41
37 /** 42 /**
38 * Adds separator to drop-down list. 43 * Adds separator to drop-down list.
39 */ 44 */
40 addSeparator: function() { 45 addSeparator: function() {
41 this.menu.addSeparator(); 46 this.menu.addSeparator();
42 }, 47 },
43 48
44 /** 49 /**
45 * Default item to fire on combobox click 50 * Default item to fire on combobox click
46 */ 51 */
47 get defaultItem() { 52 get defaultItem() {
48 return this.defaultItem_; 53 return this.defaultItem_;
49 }, 54 },
50 set defaultItem(defaultItem) { 55 set defaultItem(defaultItem) {
51 this.defaultItem_ = defaultItem; 56 this.defaultItem_ = defaultItem;
52 if (defaultItem.label) { 57
53 this.labelNode_.textContent = defaultItem.label; 58 this.actionNode_.textContent = defaultItem.label || '';
59
60 if (defaultItem.iconType) {
61 this.actionNode_.style.backgroundImage = '';
62 this.actionNode_.setAttribute('file-type-icon', defaultItem.iconType);
63 } else if (defaultItem.iconUrl) {
64 this.actionNode_.style.backgroundImage =
65 'url(' + defaultItem.iconUrl + ')';
54 } else { 66 } else {
55 this.labelNode_.textContent = ''; 67 this.actionNode_.style.backgroundImage = '';
56 }
57
58 if (defaultItem.iconUrl) {
59 this.iconNode_.src = defaultItem.iconUrl;
60 } else {
61 this.iconNode_.src = '';
62 } 68 }
63 }, 69 },
64 70
65 /** 71 /**
66 * Initializes the element. 72 * Initializes the element.
67 */ 73 */
68 decorate: function() { 74 decorate: function() {
69 cr.ui.MenuButton.prototype.decorate.call(this); 75 cr.ui.MenuButton.prototype.decorate.call(this);
70 76
71 this.classList.add('combobutton'); 77 this.classList.add('combobutton');
72 78
73 this.iconNode_ = this.ownerDocument.createElement('img'); 79 this.actionNode_ = this.ownerDocument.createElement('div');
74 this.appendChild(this.iconNode_); 80 this.actionNode_.classList.add('action');
75 81 this.appendChild(this.actionNode_);
76 this.labelNode_ = this.ownerDocument.createElement('span');
77 this.appendChild(this.labelNode_);
78 82
79 var triggerIcon = this.ownerDocument.createElement('span'); 83 var triggerIcon = this.ownerDocument.createElement('span');
80 triggerIcon.className = 'disclosureindicator'; 84 triggerIcon.className = 'disclosureindicator';
81 this.trigger_ = this.ownerDocument.createElement('div'); 85 this.trigger_ = this.ownerDocument.createElement('div');
86 this.trigger_.classList.add('trigger');
82 this.trigger_.appendChild(triggerIcon); 87 this.trigger_.appendChild(triggerIcon);
83 88
84 this.appendChild(this.trigger_); 89 this.appendChild(this.trigger_);
85 90
86 this.addEventListener('click', this.handleButtonClick_.bind(this)); 91 this.addEventListener('click', this.handleButtonClick_.bind(this));
87 92
88 this.trigger_.addEventListener('click', 93 this.trigger_.addEventListener('click',
89 this.handleTriggerClicked_.bind(this)); 94 this.handleTriggerClicked_.bind(this));
90 95
91 this.menu.addEventListener('activate', 96 this.menu.addEventListener('activate',
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 } 139 }
135 }; 140 };
136 141
137 cr.defineProperty(ComboButton, 'disabled', cr.PropertyKind.BOOL_ATTR); 142 cr.defineProperty(ComboButton, 'disabled', cr.PropertyKind.BOOL_ATTR);
138 cr.defineProperty(ComboButton, 'multiple', cr.PropertyKind.BOOL_ATTR); 143 cr.defineProperty(ComboButton, 'multiple', cr.PropertyKind.BOOL_ATTR);
139 144
140 return { 145 return {
141 ComboButton: ComboButton 146 ComboButton: ComboButton
142 }; 147 };
143 }); 148 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698