| 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 // Checking for "chrome" availability allows this app code to be tested in | 7 // Checking for "chrome" availability allows this app code to be tested in |
| 8 // non-Chrome browsers, which is useful for example to test touch support with | 8 // non-Chrome browsers, which is useful for example to test touch support with |
| 9 // a non-Chrome touch device. | 9 // a non-Chrome touch device. |
| 10 // Checking for "chrome.shell" allows testing under app_shell, which does not | 10 // Checking for "chrome.shell" allows testing under app_shell, which does not |
| 11 // have chrome.app APIs. | 11 // have chrome.app APIs. |
| 12 // Checking for "chrome.app.runtime" availability allows testing in a regular | 12 // Checking for "chrome.app.runtime" availability allows testing in a regular |
| 13 // web page (like tests/manual.html). | 13 // web page (like tests/manual.html). |
| 14 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { | 14 if (typeof chrome !== 'undefined' && chrome.app && chrome.app.runtime) { |
| 15 // Compatibility for running under app_shell, which does not have app.window. | |
| 16 var createWindow = | |
| 17 chrome.shell ? chrome.shell.createWindow : chrome.app.window.create; | |
| 18 | |
| 19 var showCalculatorWindow = function () { | 15 var showCalculatorWindow = function () { |
| 20 createWindow('calculator.html', { | 16 chrome.app.window.create('calculator.html', { |
| 21 innerBounds: { | 17 innerBounds: { |
| 22 width: 243, minWidth: 243, maxWidth: 243, | 18 width: 243, minWidth: 243, maxWidth: 243, |
| 23 height: 380, minHeight: 380, maxHeight: 380 | 19 height: 380, minHeight: 380, maxHeight: 380 |
| 24 }, | 20 }, |
| 25 id: 'calculator' | 21 id: 'calculator' |
| 26 }, function(appWindow) { | 22 }, function(appWindow) { |
| 27 appWindow.contentWindow.onload = function() { | 23 appWindow.contentWindow.onload = function() { |
| 28 new Controller(new Model(9), new View(appWindow.contentWindow)); | 24 new Controller(new Model(9), new View(appWindow.contentWindow)); |
| 29 }; | 25 }; |
| 30 }); | 26 }); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 operand: this.getUpdatedValue_(before, after, 'operand', !before.operator) | 99 operand: this.getUpdatedValue_(before, after, 'operand', !before.operator) |
| 104 }); | 100 }); |
| 105 return !before.accumulator; | 101 return !before.accumulator; |
| 106 } | 102 } |
| 107 | 103 |
| 108 /** @private */ | 104 /** @private */ |
| 109 Controller.prototype.getUpdatedValue_ = function(before, after, key, zero) { | 105 Controller.prototype.getUpdatedValue_ = function(before, after, key, zero) { |
| 110 var value = (typeof after[key] !== 'undefined') ? after[key] : before[key]; | 106 var value = (typeof after[key] !== 'undefined') ? after[key] : before[key]; |
| 111 return zero ? (value || '0') : value; | 107 return zero ? (value || '0') : value; |
| 112 } | 108 } |
| OLD | NEW |