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

Side by Side Diff: chrome/browser/resources/print_preview/settings/advanced_settings/advanced_settings.js

Issue 399973004: Advanced printing destination settings modal dialog (non-functional yet, just the skeleton). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 cr.define('print_preview', function() {
6 'use strict';
7
8 /**
9 * Modal dialog for print destination's advanced settings.
10 * @param {!print_preview.Metrics} metrics Used to record usage statistics.
11 * @constructor
12 * @extends {print_preview.Component}
13 */
14 function AdvancedSettings(metrics) {
15 print_preview.Component.call(this);
16
17 /** @private {!print_preview.Metrics} */
18 this.metrics_ = metrics;
19
20 /** @private {!print_preview.SearchBox} */
21 this.searchBox_ = new print_preview.SearchBox(
22 localStrings.getString('advancedSettingsSearchBoxPlaceholder'));
23 this.addChild(this.searchBox_);
24
25 /** @private {print_preview.Destination} */
26 this.destination_ = null;
27 };
28
29 AdvancedSettings.prototype = {
30 __proto__: print_preview.Component.prototype,
31
32 /**
33 * @param {!print_preview.Destination} destination Destination to show
34 * advanced settings for.
35 */
36 showForDestination: function(destination) {
37 //assert(!this.destination_);
38 this.destination_ = destination;
39 this.getChildElement('.advanced-settings-title').textContent =
40 localStrings.getStringF('advancedSettingsDialogTitle',
41 this.destination_.displayName);
42 this.setIsVisible_(true);
43 },
44
45 /** @override */
46 enterDocument: function() {
47 print_preview.Component.prototype.enterDocument.call(this);
48
49 this.getElement().addEventListener('webkitTransitionEnd', function f(e) {
50 if (e.target != e.currentTarget || e.propertyName != 'opacity')
51 return;
52 if (e.target.classList.contains('transparent'))
53 setIsVisible(e.target, false);
54 });
55
56 this.tracker.add(
57 this.getChildElement('.page > .close-button'),
58 'click',
59 this.onCloseClick_.bind(this));
60 this.tracker.add(
61 this.getChildElement('#cancel-button'),
62 'click',
63 this.onCloseClick_.bind(this));
64
65 this.tracker.add(
66 this.searchBox_,
67 print_preview.SearchBox.EventType.SEARCH,
68 this.onSearch_.bind(this));
69
70 this.tracker.add(
71 this.getElement(), 'click', this.onOverlayClick_.bind(this));
72 this.tracker.add(
73 this.getChildElement('.page'),
74 'webkitAnimationEnd',
75 this.onAnimationEnd_.bind(this));
76
77 this.renderSettings_();
78 },
79
80 /** @override */
81 decorateInternal: function() {
82 this.searchBox_.render(this.getChildElement('.search-box-container'));
83 },
84
85 /**
86 * @return {boolean} Whether the component is visible.
87 * @private
88 */
89 getIsVisible_: function() {
90 return !this.getElement().classList.contains('transparent');
91 },
92
93 /**
94 * @param {boolean} isVisible Whether the component is visible.
95 * @private
96 */
97 setIsVisible_: function(isVisible) {
98 if (this.getIsVisible_() == isVisible)
99 return;
100 if (isVisible) {
101 setIsVisible(this.getElement(), true);
102 setTimeout(function(element) {
103 element.classList.remove('transparent');
104 }.bind(this, this.getElement()), 0);
105 this.searchBox_.focus();
106 } else {
107 this.getElement().classList.add('transparent');
108 this.searchBox_.setQuery('');
109 this.filterLists_(null);
110 this.destination_ = null;
111 }
112 },
113
114 /**
115 * @return {number} Height available for settings lists, in pixels.
116 * @private
117 */
118 getAvailableListsHeight_: function() {
119 var elStyle = window.getComputedStyle(this.getElement());
120 return this.getElement().offsetHeight -
121 parseInt(elStyle.getPropertyValue('padding-top')) -
122 parseInt(elStyle.getPropertyValue('padding-bottom')) -
123 this.getChildElement('.lists').offsetTop;
124 },
125
126 /**
127 * Filters displayed settings with the given query.
128 * @param {?string} query Query to filter settings by.
129 * @private
130 */
131 filterLists_: function(query) {
132 },
133
134 /**
135 * Resets the filter query.
136 * @private
137 */
138 resetSearch_: function() {
139 this.searchBox_.setQuery(null);
140 this.filterLists_(null);
141 },
142
143 /**
144 * Renders all of the available settings.
145 * @private
146 */
147 renderSettings_: function() {
148 },
149
150 /**
151 * Called when settings search query changes. Filters displayed settings
152 * with the given query.
153 * @param {Event} evt Contains search query.
154 * @private
155 */
156 onSearch_: function(evt) {
157 this.filterLists_(evt.query);
158 },
159
160 /**
161 * Called when the close button is clicked. Hides the search widget.
162 * @private
163 */
164 onCloseClick_: function() {
165 this.setIsVisible_(false);
166 this.resetSearch_();
167 },
168
169 /**
170 * Called when the overlay is clicked. Pulses the page.
171 * @param {Event} event Contains the element that was clicked.
172 * @private
173 */
174 onOverlayClick_: function(event) {
175 if (event.target == this.getElement())
176 this.getChildElement('.page').classList.add('pulse');
177 },
178
179 /**
180 * Called when an animation ends on the page.
181 * @private
182 */
183 onAnimationEnd_: function() {
184 this.getChildElement('.page').classList.remove('pulse');
185 }
186 };
187
188 // Export
189 return {
190 AdvancedSettings: AdvancedSettings
191 };
192 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698