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

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: Rebasing 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;
32
27 this.addEventListeners_(); 33 this.addEventListeners_();
28 } 34 }
29 35
30 cr.addSingletonGetter(PreviewArea); 36 cr.addSingletonGetter(PreviewArea);
31 37
32 PreviewArea.prototype = { 38 PreviewArea.prototype = {
33 /** 39 /**
34 * The width of the plugin area in pixels, excluding any visible scrollbars, 40 * The width of the plugin area in pixels, excluding any visible scrollbars,
35 * @type {number} 41 * @type {number}
36 */ 42 */
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 77
72 get pdfLoaded() { 78 get pdfLoaded() {
73 return this.pdfLoaded_; 79 return this.pdfLoaded_;
74 }, 80 },
75 81
76 set pdfLoaded(pdfLoaded) { 82 set pdfLoaded(pdfLoaded) {
77 this.pdfLoaded_ = pdfLoaded; 83 this.pdfLoaded_ = pdfLoaded;
78 }, 84 },
79 85
80 /** 86 /**
81 * @return {print_preview.Rect} A rectangle describing the postion of the 87 * Queries the plugin for the location of the most visible page and updates
82 * most visible page normalized with respect to the total height and width 88 * |this.pageLocationNormalized|.
83 * of the plugin.
84 */ 89 */
85 getPageLocationNormalized: function() { 90 update: function() {
91 if (!this.pdfLoaded_)
92 return;
86 var pluginLocation = 93 var pluginLocation =
87 this.pdfPlugin_.getPageLocationNormalized().split(';'); 94 this.pdfPlugin_.getPageLocationNormalized().split(';');
88 return new print_preview.Rect(parseFloat(pluginLocation[0]), 95 this.pageLocationNormalized = new print_preview.Rect(
89 parseFloat(pluginLocation[1]), 96 parseFloat(pluginLocation[0]),
90 parseFloat(pluginLocation[2]), 97 parseFloat(pluginLocation[1]),
91 parseFloat(pluginLocation[3])); 98 parseFloat(pluginLocation[2]),
99 parseFloat(pluginLocation[3]));
92 }, 100 },
93 101
94 /** 102 /**
95 * Resets the state variables of |this|. 103 * Resets the state variables of |this|.
96 */ 104 */
97 resetState: function() { 105 resetState: function() {
98 if (this.pdfPlugin_) { 106 if (this.pdfPlugin_) {
99 this.zoomLevel_ = this.pdfPlugin_.getZoomLevel(); 107 this.zoomLevel_ = this.pdfPlugin_.getZoomLevel();
100 this.pageOffset_ = { 108 this.pageOffset_ = {
101 x: this.pdfPlugin_.pageXOffset(), 109 x: this.pdfPlugin_.pageXOffset(),
(...skipping 26 matching lines...) Expand all
128 } else { 136 } else {
129 this.pdfPlugin_.fitToHeight(); 137 this.pdfPlugin_.fitToHeight();
130 } 138 }
131 } 139 }
132 }; 140 };
133 141
134 return { 142 return {
135 PreviewArea: PreviewArea, 143 PreviewArea: PreviewArea,
136 }; 144 };
137 }); 145 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/print_preview/margins_ui_pair.js ('k') | chrome/browser/resources/print_preview/print_preview.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698