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 * Draggable control for setting a page margin. | 9 * Draggable control for setting a page margin. |
10 * @param {!print_preview.ticket_items.CustomMarginsOrientation} orientation | 10 * @param {!print_preview.ticket_items.CustomMarginsOrientation} orientation |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
92 * @private | 92 * @private |
93 */ | 93 */ |
94 this.isFocused_ = false; | 94 this.isFocused_ = false; |
95 | 95 |
96 /** | 96 /** |
97 * Whether the margin control is in an error state. | 97 * Whether the margin control is in an error state. |
98 * @type {boolean} | 98 * @type {boolean} |
99 * @private | 99 * @private |
100 */ | 100 */ |
101 this.isInError_ = false; | 101 this.isInError_ = false; |
102 }; | 102 } |
103 | 103 |
104 /** | 104 /** |
105 * Event types dispatched by the margin control. | 105 * Event types dispatched by the margin control. |
106 * @enum {string} | 106 * @enum {string} |
107 */ | 107 */ |
108 MarginControl.EventType = { | 108 MarginControl.EventType = { |
109 // Dispatched when the margin control starts dragging. | 109 // Dispatched when the margin control starts dragging. |
110 DRAG_START: 'print_preview.MarginControl.DRAG_START', | 110 DRAG_START: 'print_preview.MarginControl.DRAG_START', |
111 | 111 |
112 // Dispatched when the text in the margin control's textbox changes. | 112 // Dispatched when the text in the margin control's textbox changes. |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
320 | 320 |
321 /** @override */ | 321 /** @override */ |
322 enterDocument: function() { | 322 enterDocument: function() { |
323 print_preview.Component.prototype.enterDocument.call(this); | 323 print_preview.Component.prototype.enterDocument.call(this); |
324 this.tracker.add( | 324 this.tracker.add( |
325 this.getElement(), 'mousedown', this.onMouseDown_.bind(this)); | 325 this.getElement(), 'mousedown', this.onMouseDown_.bind(this)); |
326 this.tracker.add( | 326 this.tracker.add( |
327 this.getElement(), | 327 this.getElement(), |
328 'transitionend', | 328 'transitionend', |
329 this.onTransitionEnd_.bind(this)); | 329 this.onTransitionEnd_.bind(this)); |
330 this.tracker.add( | 330 if (this.textbox_) { |
dpapad
2017/05/08 20:40:10
The previous code assumed that this.textbox_ was a
rbpotter
2017/05/08 23:28:20
Done.
| |
331 this.textbox_, 'input', this.onTextboxInput_.bind(this)); | 331 this.tracker.add( |
332 this.tracker.add( | 332 this.textbox_, 'input', this.onTextboxInput_.bind(this)); |
333 this.textbox_, 'keydown', this.onTextboxKeyDown_.bind(this)); | 333 this.tracker.add( |
334 this.tracker.add( | 334 this.textbox_, 'keydown', this.onTextboxKeyDown_.bind(this)); |
335 this.textbox_, 'focus', this.setIsFocused_.bind(this, true)); | 335 this.tracker.add( |
336 this.tracker.add(this.textbox_, 'blur', this.onTexboxBlur_.bind(this)); | 336 this.textbox_, 'focus', this.setIsFocused_.bind(this, true)); |
337 this.tracker.add(this.textbox_, 'blur', this.onTexboxBlur_.bind(this)); | |
338 } | |
337 }, | 339 }, |
338 | 340 |
339 /** @override */ | 341 /** @override */ |
340 exitDocument: function() { | 342 exitDocument: function() { |
341 print_preview.Component.prototype.exitDocument.call(this); | 343 print_preview.Component.prototype.exitDocument.call(this); |
342 this.textbox_ = null; | 344 this.textbox_ = null; |
343 this.marginLineEl_ = null; | 345 this.marginLineEl_ = null; |
344 }, | 346 }, |
345 | 347 |
346 /** | 348 /** |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 this.setIsFocused_(false); | 447 this.setIsFocused_(false); |
446 cr.dispatchSimpleEvent(this, MarginControl.EventType.TEXT_CHANGE); | 448 cr.dispatchSimpleEvent(this, MarginControl.EventType.TEXT_CHANGE); |
447 } | 449 } |
448 }; | 450 }; |
449 | 451 |
450 // Export | 452 // Export |
451 return { | 453 return { |
452 MarginControl: MarginControl | 454 MarginControl: MarginControl |
453 }; | 455 }; |
454 }); | 456 }); |
OLD | NEW |