OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 * Creates a Margins object that holds four margin values. The units in which | 9 * Creates a Margins object that holds four margin values. The units in which |
10 * the values are expressed can be any numeric value. | 10 * the values are expressed can be any numeric value. |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 this.marginsUI.show(); | 284 this.marginsUI.show(); |
285 }, | 285 }, |
286 | 286 |
287 /** | 287 /** |
288 * Adds listeners to all margin related controls. | 288 * Adds listeners to all margin related controls. |
289 * @private | 289 * @private |
290 */ | 290 */ |
291 addEventListeners_: function() { | 291 addEventListeners_: function() { |
292 this.marginList_.onchange = this.onMarginsChanged_.bind(this); | 292 this.marginList_.onchange = this.onMarginsChanged_.bind(this); |
293 document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this)); | 293 document.addEventListener('PDFLoaded', this.onPDFLoaded_.bind(this)); |
| 294 document.addEventListener('PDFGenerationError', |
| 295 this.onPDFGenerationError_.bind(this)); |
294 }, | 296 }, |
295 | 297 |
296 /** | 298 /** |
| 299 * Executes when an 'PDFGenerationError' event occurs. |
| 300 * @private |
| 301 */ |
| 302 onPDFGenerationError_: function() { |
| 303 if (this.isCustomMarginsSelected()) { |
| 304 this.removeCustomMarginEventListeners_(); |
| 305 this.marginsUI.hide(); |
| 306 } |
| 307 }, |
| 308 |
| 309 /** |
297 * Executes whenever a "DragEvent" occurs. | 310 * Executes whenever a "DragEvent" occurs. |
298 * @param {cr.Event} e The event that triggered this listener. | 311 * @param {cr.Event} e The event that triggered this listener. |
299 */ | 312 */ |
300 onDragEvent_: function(e) { | 313 onDragEvent_: function(e) { |
301 var dragDeltaInPoints = this.convertDragDeltaToPoints_(e.dragDelta); | 314 var dragDeltaInPoints = this.convertDragDeltaToPoints_(e.dragDelta); |
302 this.marginsUI.lastClickedMarginsUIPair.updateWhileDragging( | 315 this.marginsUI.lastClickedMarginsUIPair.updateWhileDragging( |
303 dragDeltaInPoints, e.destinationPoint); | 316 dragDeltaInPoints, e.destinationPoint); |
304 }, | 317 }, |
305 | 318 |
306 /** | 319 /** |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
591 if (!previewModifiable) | 604 if (!previewModifiable) |
592 fadeOutElement(this.marginsOption_); | 605 fadeOutElement(this.marginsOption_); |
593 } | 606 } |
594 }; | 607 }; |
595 | 608 |
596 return { | 609 return { |
597 MarginSettings: MarginSettings, | 610 MarginSettings: MarginSettings, |
598 PageLayout: PageLayout, | 611 PageLayout: PageLayout, |
599 }; | 612 }; |
600 }); | 613 }); |
OLD | NEW |