OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 * The model class for audio player. | 6 * The model class for audio player. |
7 * @constructor | 7 * @constructor |
8 */ | 8 */ |
9 function AudioPlayerModel() {} | 9 function AudioPlayerModel() {} |
10 | 10 |
11 AudioPlayerModel.prototype.initialize = function(callback) { | 11 AudioPlayerModel.prototype.initialize = function(callback) { |
12 'use strict'; | 12 'use strict'; |
13 | 13 |
14 /** | 14 /** |
15 * List of values to be stored into the model. | 15 * List of values to be stored into the model. |
16 * @type {!Object<*>} | 16 * @type {!Object<*>} |
17 * @const | 17 * @const |
18 */ | 18 */ |
19 var VALUES = | 19 var VALUES = |
20 /** | 20 /** |
21 * They will be used as properties of AudioPlayerModel. | 21 * They will be used as properties of AudioPlayerModel. |
22 * @lends {AudioPlayerModel.prototype} | 22 * @lends {AudioPlayerModel.prototype} |
23 */ | 23 */ |
24 { | 24 { |
25 shuffle: false, | 25 shuffle: false, |
26 repeat: false, | 26 repeat: false, |
27 volume: 100, | 27 volume: 100, |
28 expanded: false, | 28 expanded: false, |
29 volumeSliderShown: false | |
30 }; | 29 }; |
31 | 30 |
32 /** | 31 /** |
33 * Prefix of the stored values in the storage. | 32 * Prefix of the stored values in the storage. |
34 * @type {string} | 33 * @type {string} |
35 */ | 34 */ |
36 var STORAGE_PREFIX = 'audioplayer-'; | 35 var STORAGE_PREFIX = 'audioplayer-'; |
37 | 36 |
38 /** | 37 /** |
39 * Save the values in the model into the storage. | 38 * Save the values in the model into the storage. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 // Restores the values from the storage | 77 // Restores the values from the storage |
79 var target = this; | 78 var target = this; |
80 loadModel(target, function() { | 79 loadModel(target, function() { |
81 // Installs observer to watch changes of the values. | 80 // Installs observer to watch changes of the values. |
82 Object.observe(target, function(changes) { | 81 Object.observe(target, function(changes) { |
83 saveModel(target); | 82 saveModel(target); |
84 }); | 83 }); |
85 callback(); | 84 callback(); |
86 }); | 85 }); |
87 } | 86 } |
OLD | NEW |