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

Unified Diff: chrome/browser/resources/print_preview/print_preview.js

Issue 8357009: Print Preview Cleanup: Creating enum with all custom events used. (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/resources/print_preview/print_header.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/print_preview/print_preview.js
diff --git a/chrome/browser/resources/print_preview/print_preview.js b/chrome/browser/resources/print_preview/print_preview.js
index 135257e40e8d690d10a94ea80bf0ca080371ff51..38ca9ba73f4d624d802e5eec2b44ae067a29226d 100644
--- a/chrome/browser/resources/print_preview/print_preview.js
+++ b/chrome/browser/resources/print_preview/print_preview.js
@@ -103,6 +103,26 @@ const maxCloudPrinters = 10;
const MIN_REQUEST_ID = 0;
const MAX_REQUEST_ID = 32000;
+// Names of all the custom events used.
+var customEvents = {
+ // Fired when the mouse moves while a margin line is being dragged.
+ DRAG: 'Drag',
Evan Stade 2011/10/25 17:16:43 this needs a better name
dpapad 2011/10/25 18:35:32 Done.
+ // Fired when a mousedown event occurs on a margin line.
+ MARGINS_LINE_MOUSE_DOWN: 'marginsLineMouseDown',
+ // Fired when a new preview might be needed because of margin changes.
+ MARGINS_MAY_HAVE_CHANGED: 'marginsMayHaveChanged',
+ // Fired when a pdf generation related error occurs.
+ PDF_GENERATION_ERROR: 'PDFGenerationError',
+ // Fired once the first page of the pdf document is loaded in the plugin.
+ PDF_LOADED: 'PDFLoaded',
+ // Fired when the selected printer capabilities change.
+ PRINTER_CAPABILITIES_UPDATED: 'printerCapabilitiesUpdated',
+ // Fired when the print button needs to be updated.
+ UPDATE_PRINT_BUTTON: 'updatePrintButton',
+ // Fired when the print summary needs to be updated.
+ UPDATE_SUMMARY: 'updateSummary',
+}
+
/**
* Window onload handler, sets up the page and starts print preview by getting
* the printer list.
@@ -114,7 +134,8 @@ function onLoad() {
previewArea = print_preview.PreviewArea.getInstance();
printHeader = print_preview.PrintHeader.getInstance();
- document.addEventListener('PDFGenerationError', cancelPendingPrintRequest);
+ document.addEventListener(customEvents.PDF_GENERATION_ERROR,
+ cancelPendingPrintRequest);
if (!checkCompatiblePluginExists()) {
disableInputElementsInSidebar();
@@ -286,7 +307,7 @@ function doUpdateCloudPrinterCapabilities(printer) {
* @param {Object} settingInfo printer setting information.
*/
function updateWithPrinterCapabilities(settingInfo) {
- var customEvent = new cr.Event("printerCapabilitiesUpdated");
+ var customEvent = new cr.Event(customEvents.PRINTER_CAPABILITIES_UPDATED);
customEvent.printerCapabilities = settingInfo;
document.dispatchEvent(customEvent);
}
@@ -488,7 +509,7 @@ function loadSelectedPages() {
if (pageCount == 0 || currentPreviewUid == '')
return;
- cr.dispatchSimpleEvent(document, 'updateSummary');
+ cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY);
for (var i = 0; i < pageCount; i++)
onDidPreviewPage(pageSet[i] - 1, currentPreviewUid, lastPreviewRequestID);
}
@@ -733,7 +754,7 @@ function onPDFLoad() {
if (previewModifiable) {
setPluginPreviewPageCount();
}
- cr.dispatchSimpleEvent(document, 'PDFLoaded');
+ cr.dispatchSimpleEvent(document, customEvents.PDF_LOADED);
isFirstPageLoaded = true;
checkAndHideOverlayLayerIfValid();
sendPrintDocumentRequestIfNeeded();
@@ -761,7 +782,7 @@ function onDidGetPreviewPageCount(pageCount, isModifiable, previewResponseId) {
if (!previewModifiable && pageSettings.requestPrintPreviewIfNeeded())
return;
- cr.dispatchSimpleEvent(document, 'updateSummary');
+ cr.dispatchSimpleEvent(document, customEvents.UPDATE_SUMMARY);
}
/**
@@ -804,7 +825,7 @@ function reloadPreviewPages(previewUid, previewResponseId) {
if (!isExpectedPreviewResponse(previewResponseId))
return;
- cr.dispatchSimpleEvent(document, 'updatePrintButton');
+ cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON);
checkAndHideOverlayLayerIfValid();
var pageSet = pageSettings.previouslySelectedPages;
for (var i = 0; i < pageSet.length; i++)
@@ -875,7 +896,7 @@ function updatePrintPreview(previewUid, previewResponseId) {
createPDFPlugin(PRINT_READY_DATA_INDEX);
}
- cr.dispatchSimpleEvent(document, 'updatePrintButton');
+ cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON);
if (previewModifiable)
sendPrintDocumentRequestIfNeeded();
}
« no previous file with comments | « chrome/browser/resources/print_preview/print_header.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698