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 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 this.draggedControl_.getOrientation(), | 362 this.draggedControl_.getOrientation(), |
363 this.draggedControl_.getPositionInPts()); | 363 this.draggedControl_.getPositionInPts()); |
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 * @param {!Event} event Contains element mouse moved from. |
372 * @private | 373 * @private |
373 */ | 374 */ |
374 onMouseOver_: function() { | 375 onMouseOver_: function(event) { |
375 var fromElement = event.fromElement; | 376 var fromElement = event.fromElement; |
376 while (fromElement != null) { | 377 while (fromElement != null) { |
377 if (fromElement == this.getElement()) { | 378 if (fromElement == this.getElement()) { |
378 return; | 379 return; |
379 } | 380 } |
380 fromElement = fromElement.parentElement; | 381 fromElement = fromElement.parentElement; |
381 } | 382 } |
382 if (this.marginsTypeTicketItem_.isCapabilityAvailable() && | 383 if (this.marginsTypeTicketItem_.isCapabilityAvailable() && |
383 this.marginsTypeTicketItem_.getValue() == | 384 this.marginsTypeTicketItem_.getValue() == |
384 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { | 385 print_preview.ticket_items.MarginsTypeValue.CUSTOM) { |
385 this.setIsMarginControlsVisible_(true); | 386 this.setIsMarginControlsVisible_(true); |
386 } | 387 } |
387 }, | 388 }, |
388 | 389 |
389 /** | 390 /** |
390 * Called when the mouse moves off of the component. Hides the margin | 391 * Called when the mouse moves off of the component. Hides the margin |
391 * controls. | 392 * controls. |
| 393 * @param {!Event} event Contains element mouse moved to. |
392 * @private | 394 * @private |
393 */ | 395 */ |
394 onMouseOut_: function(event) { | 396 onMouseOut_: function(event) { |
395 var toElement = event.toElement; | 397 var toElement = event.toElement; |
396 while (toElement != null) { | 398 while (toElement != null) { |
397 if (toElement == this.getElement()) { | 399 if (toElement == this.getElement()) { |
398 return; | 400 return; |
399 } | 401 } |
400 toElement = toElement.parentElement; | 402 toElement = toElement.parentElement; |
401 } | 403 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 } | 473 } |
472 } | 474 } |
473 } | 475 } |
474 }; | 476 }; |
475 | 477 |
476 // Export | 478 // Export |
477 return { | 479 return { |
478 MarginControlContainer: MarginControlContainer | 480 MarginControlContainer: MarginControlContainer |
479 }; | 481 }; |
480 }); | 482 }); |
OLD | NEW |