Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(410)

Side by Side Diff: chrome/browser/resources/print_preview/preview_area.js

Issue 8233030: Print Preview: Making margin lines draggable. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Addresing comments Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 'strict'; 6 'strict';
7 7
8 /** 8 /**
9 * Creates a PreviewArea object. It represents the area where the preview 9 * Creates a PreviewArea object. It represents the area where the preview
10 * document is displayed. 10 * document is displayed.
11 * @constructor 11 * @constructor
12 */ 12 */
13 function PreviewArea() { 13 function PreviewArea() {
14 // The embedded pdf plugin object. 14 // The embedded pdf plugin object.
15 this.pdfPlugin_ = null; 15 this.pdfPlugin_ = null;
16 16
17 // True if the pdf document is loaded in the preview area. 17 // True if the pdf document is loaded in the preview area.
18 this.pdfLoaded_ = false; 18 this.pdfLoaded_ = false;
19 19
20 // Contains the zoom level just before a new preview is requested so the 20 // Contains the zoom level just before a new preview is requested so the
21 // same zoom level can be restored. 21 // same zoom level can be restored.
22 this.zoomLevel_ = null; 22 this.zoomLevel_ = null;
23 // @type {{x: number, y: number}} Contains the page offset values just 23 // @type {{x: number, y: number}} Contains the page offset values just
24 // before a new preview is requested so that the scroll amount can be 24 // before a new preview is requested so that the scroll amount can be
25 // restored later. 25 // restored later.
26 this.pageOffset_ = null; 26 this.pageOffset_ = null;
27
28 // @type {print_preview.Rect} A rectangle describing the postion of the
29 // most visible page normalized with respect to the total height and width
30 // of the plugin.
31 this.pageLocationNormalized = null;
27 } 32 }
28 33
29 cr.addSingletonGetter(PreviewArea); 34 cr.addSingletonGetter(PreviewArea);
30 35
31 PreviewArea.prototype = { 36 PreviewArea.prototype = {
32 /** 37 /**
33 * The width of the plugin area in pixels, excluding any visible scrollbars, 38 * The width of the plugin area in pixels, excluding any visible scrollbars,
34 * @type {number} 39 * @type {number}
35 */ 40 */
36 get width() { 41 get width() {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 75
71 get pdfLoaded() { 76 get pdfLoaded() {
72 return this.pdfLoaded_; 77 return this.pdfLoaded_;
73 }, 78 },
74 79
75 set pdfLoaded(pdfLoaded) { 80 set pdfLoaded(pdfLoaded) {
76 this.pdfLoaded_ = pdfLoaded; 81 this.pdfLoaded_ = pdfLoaded;
77 }, 82 },
78 83
79 /** 84 /**
80 * @return {print_preview.Rect} A rectangle describing the postion of the 85 * Queries the plugin for the location of the most visible page and updates
81 * most visible page normalized with respect to the total height and width 86 * |this.pageLocationNormalized|.
82 * of the plugin.
83 */ 87 */
84 getPageLocationNormalized: function() { 88 update: function() {
89 if (!this.pdfLoaded_)
90 return;
85 var pluginLocation = 91 var pluginLocation =
86 this.pdfPlugin_.getPageLocationNormalized().split(';'); 92 this.pdfPlugin_.getPageLocationNormalized().split(';');
87 return new print_preview.Rect(parseFloat(pluginLocation[0]), 93 this.pageLocationNormalized = new print_preview.Rect(
88 parseFloat(pluginLocation[1]), 94 parseFloat(pluginLocation[0]),
89 parseFloat(pluginLocation[2]), 95 parseFloat(pluginLocation[1]),
90 parseFloat(pluginLocation[3])); 96 parseFloat(pluginLocation[2]),
97 parseFloat(pluginLocation[3]));
91 }, 98 },
92 99
93 /** 100 /**
94 * Resets the state variables of |this|. 101 * Resets the state variables of |this|.
95 */ 102 */
96 resetState: function() { 103 resetState: function() {
97 if (this.pdfPlugin_) { 104 if (this.pdfPlugin_) {
98 this.zoomLevel_ = this.pdfPlugin_.getZoomLevel(); 105 this.zoomLevel_ = this.pdfPlugin_.getZoomLevel();
99 this.pageOffset_ = { 106 this.pageOffset_ = {
100 x: this.pdfPlugin_.pageXOffset(), 107 x: this.pdfPlugin_.pageXOffset(),
(...skipping 19 matching lines...) Expand all
120 onPDFLoaded_: function() { 127 onPDFLoaded_: function() {
121 this.pdfPlugin_ = $('pdf-viewer'); 128 this.pdfPlugin_ = $('pdf-viewer');
122 this.pdfLoaded_ = true; 129 this.pdfLoaded_ = true;
123 if (this.zoomLevel_ != null && this.pageOffset_ != null) { 130 if (this.zoomLevel_ != null && this.pageOffset_ != null) {
124 this.pdfPlugin_.setZoomLevel(this.zoomLevel_); 131 this.pdfPlugin_.setZoomLevel(this.zoomLevel_);
125 this.pdfPlugin_.setPageXOffset(this.pageOffset_.x); 132 this.pdfPlugin_.setPageXOffset(this.pageOffset_.x);
126 this.pdfPlugin_.setPageYOffset(this.pageOffset_.y); 133 this.pdfPlugin_.setPageYOffset(this.pageOffset_.y);
127 } else { 134 } else {
128 this.pdfPlugin_.fitToHeight(); 135 this.pdfPlugin_.fitToHeight();
129 } 136 }
137 this.update();
130 } 138 }
131 }; 139 };
132 140
133 return { 141 return {
134 PreviewArea: PreviewArea, 142 PreviewArea: PreviewArea,
135 }; 143 };
136 }); 144 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698