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 * UI component used for setting custom print margins. | 9 * UI component used for setting custom print margins. |
10 * @param {!print_preview.DocumentInfo} documentInfo Document data model. | 10 * @param {!print_preview.DocumentInfo} documentInfo Document data model. |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 (-el.offsetTop) + 'px, ' + | 179 (-el.offsetTop) + 'px, ' + |
180 (clipSize.width - el.offsetLeft) + 'px, ' + | 180 (clipSize.width - el.offsetLeft) + 'px, ' + |
181 (clipSize.height - el.offsetTop) + 'px, ' + | 181 (clipSize.height - el.offsetTop) + 'px, ' + |
182 (-el.offsetLeft) + 'px)'; | 182 (-el.offsetLeft) + 'px)'; |
183 } | 183 } |
184 }, | 184 }, |
185 | 185 |
186 /** Shows the margin controls if the need to be shown. */ | 186 /** Shows the margin controls if the need to be shown. */ |
187 showMarginControlsIfNeeded: function() { | 187 showMarginControlsIfNeeded: function() { |
188 if (this.marginsTypeTicketItem_.getValue() == | 188 if (this.marginsTypeTicketItem_.getValue() == |
189 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 189 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
190 this.setIsMarginControlsVisible_(true); | 190 this.setIsMarginControlsVisible_(true); |
191 } | 191 } |
192 }, | 192 }, |
193 | 193 |
194 /** @override */ | 194 /** @override */ |
195 enterDocument: function() { | 195 enterDocument: function() { |
196 print_preview.Component.prototype.enterDocument.call(this); | 196 print_preview.Component.prototype.enterDocument.call(this); |
197 | 197 |
198 // We want to respond to mouse up events even beyond the component's | 198 // We want to respond to mouse up events even beyond the component's |
199 // element. | 199 // element. |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 onMouseOver_: function() { | 374 onMouseOver_: function() { |
375 var fromElement = event.fromElement; | 375 var fromElement = event.fromElement; |
376 while (fromElement != null) { | 376 while (fromElement != null) { |
377 if (fromElement == this.getElement()) { | 377 if (fromElement == this.getElement()) { |
378 return; | 378 return; |
379 } | 379 } |
380 fromElement = fromElement.parentElement; | 380 fromElement = fromElement.parentElement; |
381 } | 381 } |
382 if (this.marginsTypeTicketItem_.isCapabilityAvailable() && | 382 if (this.marginsTypeTicketItem_.isCapabilityAvailable() && |
383 this.marginsTypeTicketItem_.getValue() == | 383 this.marginsTypeTicketItem_.getValue() == |
384 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 384 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
385 this.setIsMarginControlsVisible_(true); | 385 this.setIsMarginControlsVisible_(true); |
386 } | 386 } |
387 }, | 387 }, |
388 | 388 |
389 /** | 389 /** |
390 * Called when the mouse moves off of the component. Hides the margin | 390 * Called when the mouse moves off of the component. Hides the margin |
391 * controls. | 391 * controls. |
392 * @private | 392 * @private |
393 */ | 393 */ |
394 onMouseOut_: function(event) { | 394 onMouseOut_: function(event) { |
(...skipping 27 matching lines...) Expand all Loading... |
422 var control = this.controls_[orientation]; | 422 var control = this.controls_[orientation]; |
423 control.setPageSize(this.documentInfo_.pageSize); | 423 control.setPageSize(this.documentInfo_.pageSize); |
424 control.setTextboxValue( | 424 control.setTextboxValue( |
425 this.serializeValueFromPts_(margins.get(orientation))); | 425 this.serializeValueFromPts_(margins.get(orientation))); |
426 control.setPositionInPts(margins.get(orientation)); | 426 control.setPositionInPts(margins.get(orientation)); |
427 control.setIsInError(false); | 427 control.setIsInError(false); |
428 control.setIsEnabled(true); | 428 control.setIsEnabled(true); |
429 } | 429 } |
430 this.updateClippingMask(this.clippingSize_); | 430 this.updateClippingMask(this.clippingSize_); |
431 if (this.marginsTypeTicketItem_.getValue() != | 431 if (this.marginsTypeTicketItem_.getValue() != |
432 print_preview.ticket_items.MarginsType.Value.CUSTOM) { | 432 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
433 this.setIsMarginControlsVisible_(false); | 433 this.setIsMarginControlsVisible_(false); |
434 } | 434 } |
435 }, | 435 }, |
436 | 436 |
437 /** | 437 /** |
438 * Called when the text in a textbox of a margin control changes or the | 438 * Called when the text in a textbox of a margin control changes or the |
439 * textbox loses focus. | 439 * textbox loses focus. |
440 * Updates the print ticket store. | 440 * Updates the print ticket store. |
441 * @param {!print_preview.MarginControl} control Updated control. | 441 * @param {!print_preview.MarginControl} control Updated control. |
442 * @private | 442 * @private |
(...skipping 28 matching lines...) Expand all Loading... |
471 } | 471 } |
472 } | 472 } |
473 } | 473 } |
474 }; | 474 }; |
475 | 475 |
476 // Export | 476 // Export |
477 return { | 477 return { |
478 MarginControlContainer: MarginControlContainer | 478 MarginControlContainer: MarginControlContainer |
479 }; | 479 }; |
480 }); | 480 }); |
OLD | NEW |