Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Side by Side Diff: chrome/browser/resources/print_preview/search/destination_search.js

Issue 2865633004: Fix all remaining print preview closure compiler errors (Closed)
Patch Set: Fix onkeydown function Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 13 matching lines...) Expand all
24 24
25 /** 25 /**
26 * Data store containing the destinations to search through. 26 * Data store containing the destinations to search through.
27 * @type {!print_preview.DestinationStore} 27 * @type {!print_preview.DestinationStore}
28 * @private 28 * @private
29 */ 29 */
30 this.destinationStore_ = destinationStore; 30 this.destinationStore_ = destinationStore;
31 31
32 /** 32 /**
33 * Data store holding printer sharing invitations. 33 * Data store holding printer sharing invitations.
34 * @type {!print_preview.DestinationStore} 34 * @type {!print_preview.InvitationStore}
35 * @private 35 * @private
36 */ 36 */
37 this.invitationStore_ = invitationStore; 37 this.invitationStore_ = invitationStore;
38 38
39 /** 39 /**
40 * Event target that contains information about the logged in user. 40 * Event target that contains information about the logged in user.
41 * @type {!print_preview.UserInfo} 41 * @type {!print_preview.UserInfo}
42 * @private 42 * @private
43 */ 43 */
44 this.userInfo_ = userInfo; 44 this.userInfo_ = userInfo;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 loadTimeData.getString('manage') : null); 108 loadTimeData.getString('manage') : null);
109 this.addChild(this.localList_); 109 this.addChild(this.localList_);
110 110
111 /** 111 /**
112 * Destination list containing cloud destinations. 112 * Destination list containing cloud destinations.
113 * @type {!print_preview.DestinationList} 113 * @type {!print_preview.DestinationList}
114 * @private 114 * @private
115 */ 115 */
116 this.cloudList_ = new print_preview.CloudDestinationList(this); 116 this.cloudList_ = new print_preview.CloudDestinationList(this);
117 this.addChild(this.cloudList_); 117 this.addChild(this.cloudList_);
118 }; 118 }
119 119
120 /** 120 /**
121 * Event types dispatched by the component. 121 * Event types dispatched by the component.
122 * @enum {string} 122 * @enum {string}
123 */ 123 */
124 DestinationSearch.EventType = { 124 DestinationSearch.EventType = {
125 // Dispatched when user requests to sign-in into another Google account. 125 // Dispatched when user requests to sign-in into another Google account.
126 ADD_ACCOUNT: 'print_preview.DestinationSearch.ADD_ACCOUNT', 126 ADD_ACCOUNT: 'print_preview.DestinationSearch.ADD_ACCOUNT',
127 127
128 // Dispatched when the user requests to manage their cloud destinations. 128 // Dispatched when the user requests to manage their cloud destinations.
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 this.showInvitation_(this.invitation_); 498 this.showInvitation_(this.invitation_);
499 } else { 499 } else {
500 this.invitation_ = null; 500 this.invitation_ = null;
501 } 501 }
502 setIsVisible( 502 setIsVisible(
503 this.getChildElement('.invitation-container'), !!this.invitation_); 503 this.getChildElement('.invitation-container'), !!this.invitation_);
504 this.reflowLists_(); 504 this.reflowLists_();
505 }, 505 },
506 506
507 /** 507 /**
508 * @param {!printe_preview.Invitation} invitation Invitation to show. 508 * @param {!print_preview.Invitation} invitation Invitation to show.
509 * @private 509 * @private
510 */ 510 */
511 showInvitation_: function(invitation) { 511 showInvitation_: function(invitation) {
512 var invitationText = ''; 512 var invitationText = '';
513 if (invitation.asGroupManager) { 513 if (invitation.asGroupManager) {
514 invitationText = loadTimeData.getStringF( 514 invitationText = loadTimeData.getStringF(
515 'groupPrinterSharingInviteText', 515 'groupPrinterSharingInviteText',
516 HTMLEscape(invitation.sender), 516 HTMLEscape(invitation.sender),
517 HTMLEscape(invitation.destination.displayName), 517 HTMLEscape(invitation.destination.displayName),
518 HTMLEscape(invitation.receiver)); 518 HTMLEscape(invitation.receiver));
(...skipping 29 matching lines...) Expand all
548 var option = document.createElement('option'); 548 var option = document.createElement('option');
549 option.text = account; 549 option.text = account;
550 option.value = account; 550 option.value = account;
551 accountSelectEl.add(option); 551 accountSelectEl.add(option);
552 }); 552 });
553 var option = document.createElement('option'); 553 var option = document.createElement('option');
554 option.text = loadTimeData.getString('addAccountTitle'); 554 option.text = loadTimeData.getString('addAccountTitle');
555 option.value = ''; 555 option.value = '';
556 accountSelectEl.add(option); 556 accountSelectEl.add(option);
557 557
558 accountSelectEl.selectedIndex = 558 accountSelectEl.selectedIndex = this.userInfo_.activeUser ?
559 this.userInfo_.users.indexOf(this.userInfo_.activeUser); 559 this.userInfo_.users.indexOf(this.userInfo_.activeUser) : -1;
560 } 560 }
561 561
562 setIsVisible(this.getChildElement('.user-info'), loggedIn); 562 setIsVisible(this.getChildElement('.user-info'), loggedIn);
563 setIsVisible(this.getChildElement('.cloud-list'), loggedIn); 563 setIsVisible(this.getChildElement('.cloud-list'), loggedIn);
564 setIsVisible(this.getChildElement('.cloudprint-promo'), !loggedIn); 564 setIsVisible(this.getChildElement('.cloudprint-promo'), !loggedIn);
565 this.updateInvitations_(); 565 this.updateInvitations_();
566 }, 566 },
567 567
568 /** 568 /**
569 * Called when a destination search should be executed. Filters the 569 * Called when a destination search should be executed. Filters the
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 * @param {!print_preview.Destination} destination The destination needs to 614 * @param {!print_preview.Destination} destination The destination needs to
615 * be setup. 615 * be setup.
616 * @private 616 * @private
617 */ 617 */
618 handleConfigureDestination_: function(destination) { 618 handleConfigureDestination_: function(destination) {
619 assert(destination.origin == print_preview.DestinationOrigin.CROS, 619 assert(destination.origin == print_preview.DestinationOrigin.CROS,
620 'Only local printer on Chrome OS requires setup.'); 620 'Only local printer on Chrome OS requires setup.');
621 this.destinationInConfiguring_ = destination; 621 this.destinationInConfiguring_ = destination;
622 this.destinationStore_.resolveCrosDestination(destination).then( 622 this.destinationStore_.resolveCrosDestination(destination).then(
623 /** 623 /**
624 * @param {!print_preview.PrinterSetupResponse} response. 624 * @param {!print_preview.PrinterSetupResponse} response
625 */ 625 */
626 function(response) { 626 function(response) {
627 this.destinationInConfiguring_ = null; 627 this.destinationInConfiguring_ = null;
628 this.localList_.getDestinationItem(destination.id) 628 this.localList_.getDestinationItem(destination.id)
629 .onConfigureResolved(response); 629 .onConfigureResolved(response);
630 }.bind(this), 630 }.bind(this),
631 function() { 631 function() {
632 this.destinationInConfiguring_ = null; 632 this.destinationInConfiguring_ = null;
633 this.localList_.getDestinationItem(destination.id) 633 this.localList_.getDestinationItem(destination.id)
634 .onConfigureResolved({printerId: destination.id, 634 .onConfigureResolved({printerId: destination.id,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 /** 670 /**
671 * @param {!print_preview.Destination} resolvedDestination 671 * @param {!print_preview.Destination} resolvedDestination
672 * Destination to which the provisional destination was 672 * Destination to which the provisional destination was
673 * resolved. 673 * resolved.
674 */ 674 */
675 function(resolvedDestination) { 675 function(resolvedDestination) {
676 this.handleOnDestinationSelect_(resolvedDestination); 676 this.handleOnDestinationSelect_(resolvedDestination);
677 }.bind(this)). 677 }.bind(this)).
678 catch( 678 catch(
679 function() { 679 function() {
680 console.log('Failed to resolve provisional destination: ' + 680 console.error('Failed to resolve provisional destination: ' +
681 destination.id); 681 destination.id);
682 }). 682 }).
683 then( 683 then(
684 function() { 684 function() {
685 this.removeChild(this.provisionalDestinationResolver_); 685 this.removeChild(
686 assert(this.provisionalDestinationResolver_));
686 this.provisionalDestinationResolver_ = null; 687 this.provisionalDestinationResolver_ = null;
687 688
688 // Restore focus to the previosly focused element if it's 689 // Restore focus to the previosly focused element if it's
689 // still shown in the search. 690 // still shown in the search.
690 if (lastFocusedElement && 691 if (lastFocusedElement &&
691 this.getIsVisible() && 692 this.getIsVisible() &&
692 getIsVisible(lastFocusedElement) && 693 getIsVisible(lastFocusedElement) &&
693 this.getElement().contains(lastFocusedElement)) { 694 this.getElement().contains(lastFocusedElement)) {
694 lastFocusedElement.focus(); 695 lastFocusedElement.focus();
695 } 696 }
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
807 808
808 /** 809 /**
809 * Called when the printer sharing invitation Accept/Reject button is 810 * Called when the printer sharing invitation Accept/Reject button is
810 * clicked. 811 * clicked.
811 * @private 812 * @private
812 */ 813 */
813 onInvitationProcessButtonClick_: function(accept) { 814 onInvitationProcessButtonClick_: function(accept) {
814 this.metrics_.record(accept ? 815 this.metrics_.record(accept ?
815 print_preview.Metrics.DestinationSearchBucket.INVITATION_ACCEPTED : 816 print_preview.Metrics.DestinationSearchBucket.INVITATION_ACCEPTED :
816 print_preview.Metrics.DestinationSearchBucket.INVITATION_REJECTED); 817 print_preview.Metrics.DestinationSearchBucket.INVITATION_REJECTED);
817 this.invitationStore_.processInvitation(this.invitation_, accept); 818 this.invitationStore_.processInvitation(assert(this.invitation_), accept);
818 this.updateInvitations_(); 819 this.updateInvitations_();
819 }, 820 },
820 821
821 /** 822 /**
822 * Called when the close button on the cloud print promo is clicked. Hides 823 * Called when the close button on the cloud print promo is clicked. Hides
823 * the promo. 824 * the promo.
824 * @private 825 * @private
825 */ 826 */
826 onCloudprintPromoCloseButtonClick_: function() { 827 onCloudprintPromoCloseButtonClick_: function() {
827 setIsVisible(this.getChildElement('.cloudprint-promo'), false); 828 setIsVisible(this.getChildElement('.cloudprint-promo'), false);
828 this.reflowLists_(); 829 this.reflowLists_();
829 }, 830 },
830 831
831 /** 832 /**
832 * Called when the window is resized. Reflows layout of destination lists. 833 * Called when the window is resized. Reflows layout of destination lists.
833 * @private 834 * @private
834 */ 835 */
835 onWindowResize_: function() { 836 onWindowResize_: function() {
836 this.reflowLists_(); 837 this.reflowLists_();
837 } 838 }
838 }; 839 };
839 840
840 // Export 841 // Export
841 return { 842 return {
842 DestinationSearch: DestinationSearch 843 DestinationSearch: DestinationSearch
843 }; 844 };
844 }); 845 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698