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

Side by Side Diff: chrome/common/extensions/docs/examples/apps/calculator/app/view.js

Issue 11189028: Improve accessibility of Calculator default app. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 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
« no previous file with comments | « chrome/common/extensions/docs/examples/apps/calculator/app/style.css ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /** 1 /**
2 * Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 * Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 **/ 5 **/
6 6
7 function View(window, model) { 7 function View(window, model) {
8 var view = this; 8 var view = this;
9 var model = model; 9 var model = model;
10 var events = this.defineEvents_(); 10 var events = this.defineEvents_();
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 this.addEquation_(display, {operator: operation.operator}); 81 this.addEquation_(display, {operator: operation.operator});
82 } else if (!this.updateEquation_(display.lastElementChild, operation)) { 82 } else if (!this.updateEquation_(display.lastElementChild, operation)) {
83 this.addEquation_(display, operation); 83 this.addEquation_(display, operation);
84 } 84 }
85 } 85 }
86 86
87 /** @private */ 87 /** @private */
88 View.prototype.addEquation_ = function(display, values) { 88 View.prototype.addEquation_ = function(display, values) {
89 // The order of the equation children below makes them stack correctly. 89 // The order of the equation children below makes them stack correctly.
90 var equation = this.createDiv_(display, 'equation'); 90 var equation = this.createDiv_(display, 'equation');
91 equation.appendChild(this.createDiv_(display, 'operand')); 91 var operation = this.createDiv_(display, 'operation');
92 equation.appendChild(this.createDiv_(display, 'operator')); 92 operation.appendChild(this.createSpan_(display, 'operator'));
93 equation.appendChild(this.createDiv_(display, 'accumulator')); 93 operation.appendChild(this.createSpan_(display, 'operand'));
94 equation.appendChild(operation);
95 var accumulator = this.createDiv_(display, 'accumulator');
96 accumulator.setAttribute('aria-hidden', 'true');
97 equation.appendChild(accumulator);
94 this.updateEquation_(equation, values); 98 this.updateEquation_(equation, values);
95 display.appendChild(equation).scrollIntoView(); 99 display.appendChild(equation).scrollIntoView();
96 } 100 }
97 101
98 /** @private */ 102 /** @private */
99 View.prototype.updateEquation_ = function(equation, values) { 103 View.prototype.updateEquation_ = function(equation, values) {
100 // Equations which are "finalized" (which have an accumulator value) shouldn't 104 // Equations which are "finalized" (which have an accumulator value) shouldn't
101 // and won't be updated, and this method returns whether an update occurred. 105 // and won't be updated, and this method returns whether an update occurred.
102 var accumulator = equation && equation.querySelector('.accumulator'); 106 var accumulator = equation && equation.querySelector('.accumulator');
103 var operator = equation && equation.querySelector('.operator'); 107 var operator = equation && equation.querySelector('.operator');
(...skipping 14 matching lines...) Expand all
118 element.textContent = zero ? (value || '0') : (value || ''); 122 element.textContent = zero ? (value || '0') : (value || '');
119 } 123 }
120 } 124 }
121 125
122 /** @private */ 126 /** @private */
123 View.prototype.createDiv_ = function(display, classes) { 127 View.prototype.createDiv_ = function(display, classes) {
124 var div = display.ownerDocument.createElement('div'); 128 var div = display.ownerDocument.createElement('div');
125 div.setAttribute('class', classes); 129 div.setAttribute('class', classes);
126 return div; 130 return div;
127 } 131 }
132
133 /** @private */
134 View.prototype.createSpan_ = function(display, classes) {
135 var span = display.ownerDocument.createElement('span');
136 span.setAttribute('class', classes);
137 return span;
138 }
OLDNEW
« no previous file with comments | « chrome/common/extensions/docs/examples/apps/calculator/app/style.css ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698