| 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 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 * @private | 101 * @private |
| 102 */ | 102 */ |
| 103 this.scaleTransform_ = 1; | 103 this.scaleTransform_ = 1; |
| 104 | 104 |
| 105 /** | 105 /** |
| 106 * Clipping size for clipping the margin controls. | 106 * Clipping size for clipping the margin controls. |
| 107 * @type {print_preview.Size} | 107 * @type {print_preview.Size} |
| 108 * @private | 108 * @private |
| 109 */ | 109 */ |
| 110 this.clippingSize_ = null; | 110 this.clippingSize_ = null; |
| 111 }; | 111 } |
| 112 | 112 |
| 113 /** | 113 /** |
| 114 * CSS classes used by the custom margins component. | 114 * CSS classes used by the custom margins component. |
| 115 * @enum {string} | 115 * @enum {string} |
| 116 * @private | 116 * @private |
| 117 */ | 117 */ |
| 118 MarginControlContainer.Classes_ = { | 118 MarginControlContainer.Classes_ = { |
| 119 DRAGGING_HORIZONTAL: 'margin-control-container-dragging-horizontal', | 119 DRAGGING_HORIZONTAL: 'margin-control-container-dragging-horizontal', |
| 120 DRAGGING_VERTICAL: 'margin-control-container-dragging-vertical' | 120 DRAGGING_VERTICAL: 'margin-control-container-dragging-vertical' |
| 121 }; | 121 }; |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 265 control.getOrientation()), | 265 control.getOrientation()), |
| 266 newPosInPts); | 266 newPosInPts); |
| 267 newPosInPts = Math.max(0, newPosInPts); | 267 newPosInPts = Math.max(0, newPosInPts); |
| 268 newPosInPts = Math.round(newPosInPts); | 268 newPosInPts = Math.round(newPosInPts); |
| 269 control.setPositionInPts(newPosInPts); | 269 control.setPositionInPts(newPosInPts); |
| 270 control.setTextboxValue(this.serializeValueFromPts_(newPosInPts)); | 270 control.setTextboxValue(this.serializeValueFromPts_(newPosInPts)); |
| 271 }, | 271 }, |
| 272 | 272 |
| 273 /** | 273 /** |
| 274 * @param {string} value Value to parse to points. E.g. '3.40"' or '200mm'. | 274 * @param {string} value Value to parse to points. E.g. '3.40"' or '200mm'. |
| 275 * @return {number} Value in points represented by the input value. | 275 * @return {?number} Value in points represented by the input value. |
| 276 * @private | 276 * @private |
| 277 */ | 277 */ |
| 278 parseValueToPts_: function(value) { | 278 parseValueToPts_: function(value) { |
| 279 // Removing whitespace anywhere in the string. | 279 // Removing whitespace anywhere in the string. |
| 280 value = value.replace(/\s*/g, ''); | 280 value = value.replace(/\s*/g, ''); |
| 281 if (value.length == 0) { | 281 if (value.length == 0) { |
| 282 return null; | 282 return null; |
| 283 } | 283 } |
| 284 var validationRegex = new RegExp('^(^-?)(\\d)+(\\' + | 284 var validationRegex = new RegExp('^(^-?)(\\d)+(\\' + |
| 285 this.measurementSystem_.thousandsDelimeter + '\\d{3})*(\\' + | 285 this.measurementSystem_.thousandsDelimeter + '\\d{3})*(\\' + |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 364 this.draggedControl_ = null; | 364 this.draggedControl_ = null; |
| 365 this.dragChangedCallback_(false); | 365 this.dragChangedCallback_(false); |
| 366 } | 366 } |
| 367 }, | 367 }, |
| 368 | 368 |
| 369 /** | 369 /** |
| 370 * Called when the mouse moves onto the component. Shows the margin | 370 * Called when the mouse moves onto the component. Shows the margin |
| 371 * controls. | 371 * controls. |
| 372 * @private | 372 * @private |
| 373 */ | 373 */ |
| 374 onMouseOver_: function() { | 374 onMouseOver_: function(event) { |
| 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.MarginsTypeValue.CUSTOM) { | 384 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after 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 |