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

Side by Side Diff: chrome/browser/resources/shared/js/cr/ui/menu_item.js

Issue 3517004: Revert 60997 - o Add user customizable launch type for apps by adding options... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 cr.define('cr.ui', function() { 5 cr.define('cr.ui', function() {
6 const Command = cr.ui.Command; 6 const Command = cr.ui.Command;
7 7
8 /** 8 /**
9 * Creates a new menu item element. 9 * Creates a new menu item element.
10 * @param {Object=} opt_propertyBag Optional properties. 10 * @param {Object=} opt_propertyBag Optional properties.
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 */ 45 */
46 command_: null, 46 command_: null,
47 get command() { 47 get command() {
48 return this.command_; 48 return this.command_;
49 }, 49 },
50 set command(command) { 50 set command(command) {
51 if (this.command_) { 51 if (this.command_) {
52 this.command_.removeEventListener('labelChange', this); 52 this.command_.removeEventListener('labelChange', this);
53 this.command_.removeEventListener('disabledChange', this); 53 this.command_.removeEventListener('disabledChange', this);
54 this.command_.removeEventListener('hiddenChange', this); 54 this.command_.removeEventListener('hiddenChange', this);
55 this.command_.removeEventListener('checkedChange', this);
56 } 55 }
57 56
58 if (typeof command == 'string' && command[0] == '#') { 57 if (typeof command == 'string' && command[0] == '#') {
59 command = this.ownerDocument.getElementById(command.slice(1)); 58 command = this.ownerDocument.getElementById(command.slice(1));
60 cr.ui.decorate(command, Command); 59 cr.ui.decorate(command, Command);
61 } 60 }
62 61
63 this.command_ = command; 62 this.command_ = command;
64 if (command) { 63 if (command) {
65 if (command.id) 64 if (command.id)
66 this.setAttribute('command', '#' + command.id); 65 this.setAttribute('command', '#' + command.id);
67 66
68 this.label = command.label; 67 this.label = command.label;
69 this.disabled = command.disabled; 68 this.disabled = command.disabled;
70 this.hidden = command.hidden; 69 this.hidden = command.hidden;
71 70
72 this.command_.addEventListener('labelChange', this); 71 this.command_.addEventListener('labelChange', this);
73 this.command_.addEventListener('disabledChange', this); 72 this.command_.addEventListener('disabledChange', this);
74 this.command_.addEventListener('hiddenChange', this); 73 this.command_.addEventListener('hiddenChange', this);
75 this.command_.addEventListener('checkedChange', this);
76 } 74 }
77 }, 75 },
78 76
79 /** 77 /**
80 * The text label. 78 * The text label.
81 * @type {string} 79 * @type {string}
82 */ 80 */
83 get label() { 81 get label() {
84 return this.textContent; 82 return this.textContent;
85 }, 83 },
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 switch (e.type) { 117 switch (e.type) {
120 case 'disabledChange': 118 case 'disabledChange':
121 this.disabled = this.command.disabled; 119 this.disabled = this.command.disabled;
122 break; 120 break;
123 case 'hiddenChange': 121 case 'hiddenChange':
124 this.hidden = this.command.hidden; 122 this.hidden = this.command.hidden;
125 break; 123 break;
126 case 'labelChange': 124 case 'labelChange':
127 this.label = this.command.label; 125 this.label = this.command.label;
128 break; 126 break;
129 case 'checkedChange':
130 this.checked = this.command.checked;
131 break;
132 } 127 }
133 } 128 }
134 }; 129 };
135 130
136 /** 131 /**
137 * Whether the menu item is disabled or not. 132 * Whether the menu item is disabled or not.
138 * @type {boolean} 133 * @type {boolean}
139 */ 134 */
140 cr.defineProperty(MenuItem, 'disabled', cr.PropertyKind.BOOL_ATTR); 135 cr.defineProperty(MenuItem, 'disabled', cr.PropertyKind.BOOL_ATTR);
141 136
142 /** 137 /**
143 * Whether the menu item is hidden or not. 138 * Whether the menu item is hidden or not.
144 * @type {boolean} 139 * @type {boolean}
145 */ 140 */
146 cr.defineProperty(MenuItem, 'hidden', cr.PropertyKind.BOOL_ATTR); 141 cr.defineProperty(MenuItem, 'hidden', cr.PropertyKind.BOOL_ATTR);
147 142
148 /** 143 /**
149 * Whether the menu item is selected or not. 144 * Whether the menu item is selected or not.
150 * @type {boolean} 145 * @type {boolean}
151 */ 146 */
152 cr.defineProperty(MenuItem, 'selected', cr.PropertyKind.BOOL_ATTR); 147 cr.defineProperty(MenuItem, 'selected', cr.PropertyKind.BOOL_ATTR);
153 148
154 /**
155 * Whether the menu item is checked or not.
156 * @type {boolean}
157 */
158 cr.defineProperty(MenuItem, 'checked', cr.PropertyKind.BOOL_ATTR);
159
160 // Export 149 // Export
161 return { 150 return {
162 MenuItem: MenuItem 151 MenuItem: MenuItem
163 }; 152 };
164 }); 153 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/shared/js/cr/ui/command.js ('k') | tools/grit/grit/format/html_inline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698