Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 * Overrided metadata worker's path. | 6 * Overrided metadata worker's path. |
| 7 * @type {string} | 7 * @type {string} |
| 8 */ | 8 */ |
| 9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; | 9 ContentMetadataProvider.WORKER_SCRIPT = '/js/metadata_worker.js'; |
| 10 | 10 |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 343 } | 343 } |
| 344 }; | 344 }; |
| 345 | 345 |
| 346 /* Keep the below constants in sync with the CSS. */ | 346 /* Keep the below constants in sync with the CSS. */ |
| 347 | 347 |
| 348 /** | 348 /** |
| 349 * Window header size in pixels. | 349 * Window header size in pixels. |
| 350 * @type {number} | 350 * @type {number} |
| 351 * @const | 351 * @const |
| 352 */ | 352 */ |
| 353 AudioPlayer.HEADER_HEIGHT = 36; // 32px + border 4px | 353 AudioPlayer.HEADER_HEIGHT = 33; // 32px + border 1px |
| 354 | |
| 355 /** | |
| 356 * Top padding height of audio player in pixels. | |
| 357 * @type {number} | |
| 358 * @const | |
| 359 */ | |
| 360 AudioPlayer.TOP_PADDING_HEIGHT = 4; | |
| 354 | 361 |
| 355 /** | 362 /** |
| 356 * Track height in pixels. | 363 * Track height in pixels. |
| 357 * @type {number} | 364 * @type {number} |
| 358 * @const | 365 * @const |
| 359 */ | 366 */ |
| 360 AudioPlayer.TRACK_HEIGHT = 48; | 367 AudioPlayer.TRACK_HEIGHT = 48; |
| 361 | 368 |
| 369 | |
|
yawano
2016/01/13 10:24:02
nit: unnecessary blank line.
fukino
2016/01/14 02:25:18
Done.
| |
| 362 /** | 370 /** |
| 363 * Controls bar height in pixels. | 371 * Controls bar height in pixels. |
| 364 * @type {number} | 372 * @type {number} |
| 365 * @const | 373 * @const |
| 366 */ | 374 */ |
| 367 AudioPlayer.CONTROLS_HEIGHT = 96; | 375 AudioPlayer.CONTROLS_HEIGHT = 96; |
| 368 | 376 |
| 369 /** | 377 /** |
| 370 * Default number of items in the expanded mode. | 378 * Default number of items in the expanded mode. |
| 371 * @type {number} | 379 * @type {number} |
| 372 * @const | 380 * @const |
| 373 */ | 381 */ |
| 374 AudioPlayer.DEFAULT_EXPANDED_ITEMS = 5; | 382 AudioPlayer.DEFAULT_EXPANDED_ITEMS = 5; |
| 375 | 383 |
| 376 /** | 384 /** |
| 377 * Minimum size of the window in the expanded mode in pixels. | 385 * Minimum size of the window in the expanded mode in pixels. |
| 378 * @type {number} | 386 * @type {number} |
| 379 * @const | 387 * @const |
| 380 */ | 388 */ |
| 381 AudioPlayer.EXPANDED_MODE_MIN_HEIGHT = AudioPlayer.CONTROLS_HEIGHT + | 389 AudioPlayer.EXPANDED_MODE_MIN_HEIGHT = AudioPlayer.TOP_PADDING_HEIGHT + |
| 382 AudioPlayer.TRACK_HEIGHT * 2; | 390 AudioPlayer.TRACK_HEIGHT * 2 + |
| 391 AudioPlayer.CONTROLS_HEIGHT; | |
| 383 | 392 |
| 384 /** | 393 /** |
| 385 * Invoked when the 'expanded' property in the model is changed. | 394 * Invoked when the 'expanded' property in the model is changed. |
| 386 * @param {boolean} newValue New value. | 395 * @param {boolean} newValue New value. |
| 387 * @private | 396 * @private |
| 388 */ | 397 */ |
| 389 AudioPlayer.prototype.onExpandedChanged_ = function(newValue) { | 398 AudioPlayer.prototype.onExpandedChanged_ = function(newValue) { |
| 390 if (this.isExpanded_ !== null && | 399 if (this.isExpanded_ !== null && |
| 391 this.isExpanded_ === newValue) | 400 this.isExpanded_ === newValue) |
| 392 return; | 401 return; |
| 393 | 402 |
| 394 if (this.isExpanded_ && !newValue) | 403 if (this.isExpanded_ && !newValue) |
| 395 this.lastExpandedHeight_ = window.innerHeight; | 404 this.lastExpandedInnerHeight_ = window.innerHeight; |
| 396 | 405 |
| 397 if (this.isExpanded_ !== newValue) { | 406 if (this.isExpanded_ !== newValue) { |
| 398 this.isExpanded_ = newValue; | 407 this.isExpanded_ = newValue; |
| 399 this.syncHeight_(); | 408 this.syncHeight_(); |
| 400 | 409 |
| 401 // Saves new state. | 410 // Saves new state. |
| 402 window.appState.expanded = newValue; | 411 window.appState.expanded = newValue; |
| 403 util.saveAppState(); | 412 util.saveAppState(); |
| 404 } | 413 } |
| 405 }; | 414 }; |
| 406 | 415 |
| 407 /** | 416 /** |
| 408 * @private | 417 * @private |
| 409 */ | 418 */ |
| 410 AudioPlayer.prototype.syncHeight_ = function() { | 419 AudioPlayer.prototype.syncHeight_ = function() { |
| 411 var targetHeight; | 420 var targetInnerHeight; |
| 412 | 421 |
| 413 if (this.player_.expanded) { | 422 if (this.player_.expanded) { |
| 414 // Expanded. | 423 // Expanded. |
| 415 if (!this.lastExpandedHeight_ || | 424 if (!this.lastExpandedInnerHeight_ || |
| 416 this.lastExpandedHeight_ < AudioPlayer.EXPANDED_MODE_MIN_HEIGHT) { | 425 this.lastExpandedInnerHeight_ < AudioPlayer.EXPANDED_MODE_MIN_HEIGHT) { |
| 417 var expandedListHeight = | 426 var expandedListHeight = |
| 418 Math.min(this.entries_.length, AudioPlayer.DEFAULT_EXPANDED_ITEMS) * | 427 Math.min(this.entries_.length, AudioPlayer.DEFAULT_EXPANDED_ITEMS) * |
| 419 AudioPlayer.TRACK_HEIGHT; | 428 AudioPlayer.TRACK_HEIGHT; |
| 420 targetHeight = AudioPlayer.CONTROLS_HEIGHT + expandedListHeight; | 429 targetInnerHeight = AudioPlayer.TOP_PADDING_HEIGHT + |
| 421 this.lastExpandedHeight_ = targetHeight; | 430 expandedListHeight + |
| 431 AudioPlayer.CONTROLS_HEIGHT; | |
| 432 this.lastExpandedInnerHeight_ = targetInnerHeight; | |
| 422 } else { | 433 } else { |
| 423 targetHeight = this.lastExpandedHeight_; | 434 targetInnerHeight = this.lastExpandedInnerHeight_; |
| 424 } | 435 } |
| 425 } else { | 436 } else { |
| 426 // Not expanded. | 437 // Not expanded. |
| 427 targetHeight = AudioPlayer.CONTROLS_HEIGHT + AudioPlayer.TRACK_HEIGHT; | 438 targetInnerHeight = AudioPlayer.TOP_PADDING_HEIGHT + |
| 439 AudioPlayer.TRACK_HEIGHT + | |
| 440 AudioPlayer.CONTROLS_HEIGHT; | |
| 428 } | 441 } |
| 429 | 442 window.resizeTo(window.outerWidth, |
|
fukino
2016/01/13 08:20:21
Not related to the issue, but it should be outerWi
| |
| 430 window.resizeTo(window.innerWidth, targetHeight + AudioPlayer.HEADER_HEIGHT); | 443 AudioPlayer.HEADER_HEIGHT + targetInnerHeight); |
| 431 }; | 444 }; |
| 432 | 445 |
| 433 /** | 446 /** |
| 434 * Create a TrackInfo object encapsulating the information about one track. | 447 * Create a TrackInfo object encapsulating the information about one track. |
| 435 * | 448 * |
| 436 * @param {FileEntry} entry FileEntry to be retrieved the track info from. | 449 * @param {FileEntry} entry FileEntry to be retrieved the track info from. |
| 437 * @constructor | 450 * @constructor |
| 438 */ | 451 */ |
| 439 AudioPlayer.TrackInfo = function(entry) { | 452 AudioPlayer.TrackInfo = function(entry) { |
| 440 this.url = entry.toURL(); | 453 this.url = entry.toURL(); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 478 // TODO(yoshiki): Handle error in better way. | 491 // TODO(yoshiki): Handle error in better way. |
| 479 // TODO(yoshiki): implement artwork (metadata.thumbnail) | 492 // TODO(yoshiki): implement artwork (metadata.thumbnail) |
| 480 this.title = metadata.mediaTitle || this.getDefaultTitle(); | 493 this.title = metadata.mediaTitle || this.getDefaultTitle(); |
| 481 this.artist = error || metadata.mediaArtist || this.getDefaultArtist(); | 494 this.artist = error || metadata.mediaArtist || this.getDefaultArtist(); |
| 482 }; | 495 }; |
| 483 | 496 |
| 484 // Starts loading the audio player. | 497 // Starts loading the audio player. |
| 485 window.addEventListener('DOMContentLoaded', function(e) { | 498 window.addEventListener('DOMContentLoaded', function(e) { |
| 486 AudioPlayer.load(); | 499 AudioPlayer.load(); |
| 487 }); | 500 }); |
| OLD | NEW |