OLD | NEW |
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 Loading... |
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 Loading... |
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 } |
OLD | NEW |