| 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 cr.define('print_preview', function() { | 5 cr.define('print_preview', function() { |
| 6 'use strict'; | 6 'use strict'; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * Component used for searching for a print destination. | 9 * Component used for searching for a print destination. |
| 10 * This is a modal dialog that allows the user to search and select a | 10 * This is a modal dialog that allows the user to search and select a |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 * @private | 64 * @private |
| 65 */ | 65 */ |
| 66 this.registerPromoShownMetricRecorded_ = false; | 66 this.registerPromoShownMetricRecorded_ = false; |
| 67 | 67 |
| 68 /** | 68 /** |
| 69 * Search box used to search through the destination lists. | 69 * Search box used to search through the destination lists. |
| 70 * @type {!print_preview.SearchBox} | 70 * @type {!print_preview.SearchBox} |
| 71 * @private | 71 * @private |
| 72 */ | 72 */ |
| 73 this.searchBox_ = new print_preview.SearchBox( | 73 this.searchBox_ = new print_preview.SearchBox( |
| 74 localStrings.getString('searchBoxPlaceholder')); | 74 loadTimeData.getString('searchBoxPlaceholder')); |
| 75 this.addChild(this.searchBox_); | 75 this.addChild(this.searchBox_); |
| 76 | 76 |
| 77 /** | 77 /** |
| 78 * Destination list containing recent destinations. | 78 * Destination list containing recent destinations. |
| 79 * @type {!print_preview.DestinationList} | 79 * @type {!print_preview.DestinationList} |
| 80 * @private | 80 * @private |
| 81 */ | 81 */ |
| 82 this.recentList_ = new print_preview.RecentDestinationList(this); | 82 this.recentList_ = new print_preview.RecentDestinationList(this); |
| 83 this.addChild(this.recentList_); | 83 this.addChild(this.recentList_); |
| 84 | 84 |
| 85 /** | 85 /** |
| 86 * Destination list containing local destinations. | 86 * Destination list containing local destinations. |
| 87 * @type {!print_preview.DestinationList} | 87 * @type {!print_preview.DestinationList} |
| 88 * @private | 88 * @private |
| 89 */ | 89 */ |
| 90 this.localList_ = new print_preview.DestinationList( | 90 this.localList_ = new print_preview.DestinationList( |
| 91 this, | 91 this, |
| 92 localStrings.getString('localDestinationsTitle'), | 92 loadTimeData.getString('localDestinationsTitle'), |
| 93 cr.isChromeOS ? null : localStrings.getString('manage')); | 93 cr.isChromeOS ? null : loadTimeData.getString('manage')); |
| 94 this.addChild(this.localList_); | 94 this.addChild(this.localList_); |
| 95 | 95 |
| 96 /** | 96 /** |
| 97 * Destination list containing cloud destinations. | 97 * Destination list containing cloud destinations. |
| 98 * @type {!print_preview.DestinationList} | 98 * @type {!print_preview.DestinationList} |
| 99 * @private | 99 * @private |
| 100 */ | 100 */ |
| 101 this.cloudList_ = new print_preview.CloudDestinationList(this); | 101 this.cloudList_ = new print_preview.CloudDestinationList(this); |
| 102 this.addChild(this.cloudList_); | 102 this.addChild(this.cloudList_); |
| 103 }; | 103 }; |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 // Render any destinations already in the store. | 271 // Render any destinations already in the store. |
| 272 this.renderDestinations_(); | 272 this.renderDestinations_(); |
| 273 }, | 273 }, |
| 274 | 274 |
| 275 /** @override */ | 275 /** @override */ |
| 276 decorateInternal: function() { | 276 decorateInternal: function() { |
| 277 this.searchBox_.render(this.getChildElement('.search-box-container')); | 277 this.searchBox_.render(this.getChildElement('.search-box-container')); |
| 278 this.recentList_.render(this.getChildElement('.recent-list')); | 278 this.recentList_.render(this.getChildElement('.recent-list')); |
| 279 this.localList_.render(this.getChildElement('.local-list')); | 279 this.localList_.render(this.getChildElement('.local-list')); |
| 280 this.cloudList_.render(this.getChildElement('.cloud-list')); | 280 this.cloudList_.render(this.getChildElement('.cloud-list')); |
| 281 this.getChildElement('.promo-text').innerHTML = localStrings.getStringF( | 281 this.getChildElement('.promo-text').innerHTML = loadTimeData.getStringF( |
| 282 'cloudPrintPromotion', | 282 'cloudPrintPromotion', |
| 283 '<span class="sign-in link-button">', | 283 '<span class="sign-in link-button">', |
| 284 '</span>'); | 284 '</span>'); |
| 285 this.getChildElement('.account-select-label').textContent = | 285 this.getChildElement('.account-select-label').textContent = |
| 286 localStrings.getString('accountSelectTitle'); | 286 loadTimeData.getString('accountSelectTitle'); |
| 287 }, | 287 }, |
| 288 | 288 |
| 289 /** | 289 /** |
| 290 * @return {number} Height available for destination lists, in pixels. | 290 * @return {number} Height available for destination lists, in pixels. |
| 291 * @private | 291 * @private |
| 292 */ | 292 */ |
| 293 getAvailableListsHeight_: function() { | 293 getAvailableListsHeight_: function() { |
| 294 var elStyle = window.getComputedStyle(this.getElement()); | 294 var elStyle = window.getComputedStyle(this.getElement()); |
| 295 return this.getElement().offsetHeight - | 295 return this.getElement().offsetHeight - |
| 296 parseInt(elStyle.getPropertyValue('padding-top')) - | 296 parseInt(elStyle.getPropertyValue('padding-top')) - |
| (...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 469 this.reflowLists_(); | 469 this.reflowLists_(); |
| 470 }, | 470 }, |
| 471 | 471 |
| 472 /** | 472 /** |
| 473 * @param {!printe_preview.Invitation} invitation Invitation to show. | 473 * @param {!printe_preview.Invitation} invitation Invitation to show. |
| 474 * @private | 474 * @private |
| 475 */ | 475 */ |
| 476 showInvitation_: function(invitation) { | 476 showInvitation_: function(invitation) { |
| 477 var invitationText = ''; | 477 var invitationText = ''; |
| 478 if (invitation.asGroupManager) { | 478 if (invitation.asGroupManager) { |
| 479 invitationText = localStrings.getStringF( | 479 invitationText = loadTimeData.getStringF( |
| 480 'groupPrinterSharingInviteText', | 480 'groupPrinterSharingInviteText', |
| 481 invitation.sender, | 481 invitation.sender, |
| 482 invitation.destination.displayName, | 482 invitation.destination.displayName, |
| 483 invitation.receiver); | 483 invitation.receiver); |
| 484 } else { | 484 } else { |
| 485 invitationText = localStrings.getStringF( | 485 invitationText = loadTimeData.getStringF( |
| 486 'printerSharingInviteText', | 486 'printerSharingInviteText', |
| 487 invitation.sender, | 487 invitation.sender, |
| 488 invitation.destination.displayName); | 488 invitation.destination.displayName); |
| 489 } | 489 } |
| 490 this.getChildElement('.invitation-text').innerHTML = invitationText; | 490 this.getChildElement('.invitation-text').innerHTML = invitationText; |
| 491 | 491 |
| 492 var acceptButton = this.getChildElement('.invitation-accept-button'); | 492 var acceptButton = this.getChildElement('.invitation-accept-button'); |
| 493 acceptButton.textContent = localStrings.getString( | 493 acceptButton.textContent = loadTimeData.getString( |
| 494 invitation.asGroupManager ? 'acceptForGroup' : 'accept'); | 494 invitation.asGroupManager ? 'acceptForGroup' : 'accept'); |
| 495 acceptButton.disabled = !!this.invitationStore_.invitationInProgress; | 495 acceptButton.disabled = !!this.invitationStore_.invitationInProgress; |
| 496 this.getChildElement('.invitation-reject-button').disabled = | 496 this.getChildElement('.invitation-reject-button').disabled = |
| 497 !!this.invitationStore_.invitationInProgress; | 497 !!this.invitationStore_.invitationInProgress; |
| 498 setIsVisible( | 498 setIsVisible( |
| 499 this.getChildElement('#invitation-process-throbber'), | 499 this.getChildElement('#invitation-process-throbber'), |
| 500 !!this.invitationStore_.invitationInProgress); | 500 !!this.invitationStore_.invitationInProgress); |
| 501 }, | 501 }, |
| 502 | 502 |
| 503 /** | 503 /** |
| 504 * Called when user's logged in accounts change. Updates the UI. | 504 * Called when user's logged in accounts change. Updates the UI. |
| 505 * @private | 505 * @private |
| 506 */ | 506 */ |
| 507 onUsersChanged_: function() { | 507 onUsersChanged_: function() { |
| 508 var loggedIn = this.userInfo_.loggedIn; | 508 var loggedIn = this.userInfo_.loggedIn; |
| 509 if (loggedIn) { | 509 if (loggedIn) { |
| 510 var accountSelectEl = this.getChildElement('.account-select'); | 510 var accountSelectEl = this.getChildElement('.account-select'); |
| 511 accountSelectEl.innerHTML = ''; | 511 accountSelectEl.innerHTML = ''; |
| 512 this.userInfo_.users.forEach(function(account) { | 512 this.userInfo_.users.forEach(function(account) { |
| 513 var option = document.createElement('option'); | 513 var option = document.createElement('option'); |
| 514 option.text = account; | 514 option.text = account; |
| 515 option.value = account; | 515 option.value = account; |
| 516 accountSelectEl.add(option); | 516 accountSelectEl.add(option); |
| 517 }); | 517 }); |
| 518 var option = document.createElement('option'); | 518 var option = document.createElement('option'); |
| 519 option.text = localStrings.getString('addAccountTitle'); | 519 option.text = loadTimeData.getString('addAccountTitle'); |
| 520 option.value = ''; | 520 option.value = ''; |
| 521 accountSelectEl.add(option); | 521 accountSelectEl.add(option); |
| 522 | 522 |
| 523 accountSelectEl.selectedIndex = | 523 accountSelectEl.selectedIndex = |
| 524 this.userInfo_.users.indexOf(this.userInfo_.activeUser); | 524 this.userInfo_.users.indexOf(this.userInfo_.activeUser); |
| 525 } | 525 } |
| 526 | 526 |
| 527 setIsVisible(this.getChildElement('.user-info'), loggedIn); | 527 setIsVisible(this.getChildElement('.user-info'), loggedIn); |
| 528 setIsVisible(this.getChildElement('.cloud-list'), loggedIn); | 528 setIsVisible(this.getChildElement('.cloud-list'), loggedIn); |
| 529 setIsVisible(this.getChildElement('.cloudprint-promo'), !loggedIn); | 529 setIsVisible(this.getChildElement('.cloudprint-promo'), !loggedIn); |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 681 onWindowResize_: function() { | 681 onWindowResize_: function() { |
| 682 this.reflowLists_(); | 682 this.reflowLists_(); |
| 683 } | 683 } |
| 684 }; | 684 }; |
| 685 | 685 |
| 686 // Export | 686 // Export |
| 687 return { | 687 return { |
| 688 DestinationSearch: DestinationSearch | 688 DestinationSearch: DestinationSearch |
| 689 }; | 689 }; |
| 690 }); | 690 }); |
| OLD | NEW |