Commit 7e34fa53 authored by dpapad@chromium.org's avatar dpapad@chromium.org

Print Preview: Fixing code style issues reported by gjslint.

BUG=NONE
TEST=NONE


Review URL: http://codereview.chromium.org/8605001

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110985 0039d316-1c4b-4281-b951-d872f2087c98
parent c09a8fda
...@@ -46,7 +46,7 @@ cr.define('print_preview', function() { ...@@ -46,7 +46,7 @@ cr.define('print_preview', function() {
*/ */
get colorMode() { get colorMode() {
return this.bwRadioButton_.checked ? return this.bwRadioButton_.checked ?
this.printerColorModelForBlack_: this.printerColorModelForBlack_ :
this.printerColorModelForColor_; this.printerColorModelForColor_;
}, },
......
...@@ -50,14 +50,14 @@ cr.define('print_preview', function() { ...@@ -50,14 +50,14 @@ cr.define('print_preview', function() {
* @return {boolean} true if the chosen layout mode has changed since last * @return {boolean} true if the chosen layout mode has changed since last
* time the state was updated. * time the state was updated.
*/ */
hasChanged_ : function() { hasChanged_: function() {
return this.isLandscape() != this.wasLandscape_; return this.isLandscape() != this.wasLandscape_;
}, },
/** /**
* Saves the currently selected layout mode. Used in |this.hasChanged_|. * Saves the currently selected layout mode. Used in |this.hasChanged_|.
*/ */
updateState : function() { updateState: function() {
this.wasLandscape_ = this.isLandscape(); this.wasLandscape_ = this.isLandscape();
}, },
......
...@@ -169,7 +169,7 @@ cr.define('print_preview', function() { ...@@ -169,7 +169,7 @@ cr.define('print_preview', function() {
* locale. * locale.
* @param {string} numberFormat Is the formatted version of a sample number, * @param {string} numberFormat Is the formatted version of a sample number,
* sent from the backend. * sent from the backend.
* @oaram {number} measurementSystem 0 for SI (aka metric system), 1 for the * @param {number} measurementSystem 0 for SI (aka metric system), 1 for the
* system used in the US. Note: Mathces UMeasurementSystem enum in * system used in the US. Note: Mathces UMeasurementSystem enum in
* third_party/icu/public/i18n/unicode/ulocdata.h. * third_party/icu/public/i18n/unicode/ulocdata.h.
*/ */
...@@ -228,7 +228,7 @@ cr.define('print_preview', function() { ...@@ -228,7 +228,7 @@ cr.define('print_preview', function() {
* |margin{Top|Bottom|Left|Right}| attributes are missing. * |margin{Top|Bottom|Left|Right}| attributes are missing.
*/ */
setLastUsedMargins: function(lastUsedMarginsSettings) { setLastUsedMargins: function(lastUsedMarginsSettings) {
var lastUsedMarginsType = lastUsedMarginsSettings['marginsType'] var lastUsedMarginsType = lastUsedMarginsSettings['marginsType'];
this.forceMarginsUIOnPDFLoad_ = this.forceMarginsUIOnPDFLoad_ =
lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM; lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM;
this.marginList_.selectedIndex = this.marginList_.selectedIndex =
......
...@@ -50,7 +50,7 @@ cr.define('print_preview', function() { ...@@ -50,7 +50,7 @@ cr.define('print_preview', function() {
WITHIN_RANGE: 1, WITHIN_RANGE: 1,
TOO_BIG: 2, TOO_BIG: 2,
NOT_A_NUMBER: 3 NOT_A_NUMBER: 3
} };
/** /**
* Checks whether |value| is within range [0, limit]. * Checks whether |value| is within range [0, limit].
......
...@@ -79,7 +79,7 @@ cr.define('print_preview', function() { ...@@ -79,7 +79,7 @@ cr.define('print_preview', function() {
/** /**
* Updates the state of the margins UI. * Updates the state of the margins UI.
* @param {print_preview.Rect} * @param {print_preview.Rect} marginsRectangle
* @param {Margins} marginValues * @param {Margins} marginValues
* @param {array} valueLimits * @param {array} valueLimits
*/ */
...@@ -129,7 +129,7 @@ cr.define('print_preview', function() { ...@@ -129,7 +129,7 @@ cr.define('print_preview', function() {
applyClippingMask_: function() { applyClippingMask_: function() {
var bottom = previewArea.height; var bottom = previewArea.height;
var right = previewArea.width; var right = previewArea.width;
this.style.clip = "rect(0, " + right + "px, " + bottom + "px, 0)"; this.style.clip = 'rect(0, ' + right + 'px, ' + bottom + 'px, 0)';
}, },
/** /**
......
...@@ -165,7 +165,7 @@ cr.define('print_preview', function() { ...@@ -165,7 +165,7 @@ cr.define('print_preview', function() {
/** /**
* Executes whenever a mousedown event occurs on |this| or its child nodes. * Executes whenever a mousedown event occurs on |this| or its child nodes.
* @parameter {MouseEvent} e The event that occured. * @param {MouseEvent} e The event that occured.
*/ */
onMouseDown_: function(e) { onMouseDown_: function(e) {
if (e.button != 0) if (e.button != 0)
...@@ -193,7 +193,7 @@ cr.define('print_preview', function() { ...@@ -193,7 +193,7 @@ cr.define('print_preview', function() {
*/ */
moveTo: function(point) { moveTo: function(point) {
if (this.isTop_() || this.isBottom_()) if (this.isTop_() || this.isBottom_())
this.style.top = point.y - this.mousePointerOffset.y + 'px'; this.style.top = point.y - this.mousePointerOffset.y + 'px';
else else
this.style.left = point.x - this.mousePointerOffset.x + 'px'; this.style.left = point.x - this.mousePointerOffset.x + 'px';
}, },
......
...@@ -141,7 +141,7 @@ cr.define('print_preview', function() { ...@@ -141,7 +141,7 @@ cr.define('print_preview', function() {
numOfSheets *= copies; numOfSheets *= copies;
if (numOfSheets > 1) { if (numOfSheets > 1) {
summaryLabel = printToPDF ? pagesLabel : summaryLabel = printToPDF ? pagesLabel :
localStrings.getString('printPreviewSheetsLabelPlural'); localStrings.getString('printPreviewSheetsLabelPlural');
} }
......
...@@ -125,8 +125,8 @@ var customEvents = { ...@@ -125,8 +125,8 @@ var customEvents = {
// Fired when the print button needs to be updated. // Fired when the print button needs to be updated.
UPDATE_PRINT_BUTTON: 'updatePrintButton', UPDATE_PRINT_BUTTON: 'updatePrintButton',
// Fired when the print summary needs to be updated. // Fired when the print summary needs to be updated.
UPDATE_SUMMARY: 'updateSummary', UPDATE_SUMMARY: 'updateSummary'
} };
/** /**
* Window onload handler, sets up the page and starts print preview by getting * Window onload handler, sets up the page and starts print preview by getting
...@@ -175,7 +175,6 @@ function onLoad() { ...@@ -175,7 +175,6 @@ function onLoad() {
} }
/** /**
* @param {string} initiatorTabTitle The title of the initiator tab.
* @param {object} initialSettings An object containing all the initial * @param {object} initialSettings An object containing all the initial
* settings. * settings.
*/ */
...@@ -348,7 +347,7 @@ function reloadPrintersList() { ...@@ -348,7 +347,7 @@ function reloadPrintersList() {
/** /**
* Turn on the integration of Cloud Print. * Turn on the integration of Cloud Print.
* @param {string} cloudPrintUrl The URL to use for cloud print servers. * @param {string} cloudPrintURL The URL to use for cloud print servers.
*/ */
function setUseCloudPrint(cloudPrintURL) { function setUseCloudPrint(cloudPrintURL) {
useCloudPrint = true; useCloudPrint = true;
...@@ -476,7 +475,7 @@ function isExpectedPreviewResponse(previewResponseId) { ...@@ -476,7 +475,7 @@ function isExpectedPreviewResponse(previewResponseId) {
* @return {string} The name of the currently selected printer. * @return {string} The name of the currently selected printer.
*/ */
function getSelectedPrinterName() { function getSelectedPrinterName() {
var printerList = $('printer-list') var printerList = $('printer-list');
var selectedPrinter = printerList.selectedIndex; var selectedPrinter = printerList.selectedIndex;
if (selectedPrinter < 0) if (selectedPrinter < 0)
return ''; return '';
...@@ -611,7 +610,7 @@ function fileSelectionCompleted() { ...@@ -611,7 +610,7 @@ function fileSelectionCompleted() {
/** /**
* Set the default printer. If there is one, generate a print preview. * Set the default printer. If there is one, generate a print preview.
* @param {string} printer Name of the default printer. Empty if none. * @param {string} printerName Name of the default printer. Empty if none.
* @param {string} cloudPrintData Cloud print related data to restore if * @param {string} cloudPrintData Cloud print related data to restore if
* the default printer is a cloud printer. * the default printer is a cloud printer.
*/ */
...@@ -715,6 +714,8 @@ function createDestinationListOption(optionText, optionValue, isDefault, ...@@ -715,6 +714,8 @@ function createDestinationListOption(optionText, optionValue, isDefault,
* @param {string} optionValue specifies the option value. * @param {string} optionValue specifies the option value.
* @param {boolean} isDefault is true if the option needs to be selected. * @param {boolean} isDefault is true if the option needs to be selected.
* @param {boolean} isDisabled is true if the option needs to be disabled. * @param {boolean} isDisabled is true if the option needs to be disabled.
* @param {boolean} isSeparator is true if the option serves just as a
* separator.
* @return {Object} The created option. * @return {Object} The created option.
*/ */
function addDestinationListOption(optionText, optionValue, isDefault, function addDestinationListOption(optionText, optionValue, isDefault,
...@@ -736,6 +737,8 @@ function addDestinationListOption(optionText, optionValue, isDefault, ...@@ -736,6 +737,8 @@ function addDestinationListOption(optionText, optionValue, isDefault,
* @param {string} optionValue specifies the option value. * @param {string} optionValue specifies the option value.
* @param {boolean} isDefault is true if the option needs to be selected. * @param {boolean} isDefault is true if the option needs to be selected.
* @param {boolean} isDisabled is true if the option needs to be disabled. * @param {boolean} isDisabled is true if the option needs to be disabled.
* @param {boolean} isSeparator is true if the option is a visual separator and
* needs to be disabled.
* @return {Object} The created option. * @return {Object} The created option.
*/ */
function addDestinationListOptionAtPosition(position, function addDestinationListOptionAtPosition(position,
...@@ -877,8 +880,10 @@ function reloadPreviewPages(previewUid, previewResponseId) { ...@@ -877,8 +880,10 @@ function reloadPreviewPages(previewUid, previewResponseId) {
cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON); cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON);
checkAndHideOverlayLayerIfValid(); checkAndHideOverlayLayerIfValid();
var pageSet = pageSettings.previouslySelectedPages; var pageSet = pageSettings.previouslySelectedPages;
for (var i = 0; i < pageSet.length; i++) for (var i = 0; i < pageSet.length; i++) {
$('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i); $('pdf-viewer').loadPreviewPage(
getPageSrcURL(previewUid, pageSet[i] - 1), i);
}
hasPendingPreviewRequest = false; hasPendingPreviewRequest = false;
isPrintReadyMetafileReady = true; isPrintReadyMetafileReady = true;
...@@ -928,7 +933,6 @@ function onDidPreviewPage(pageNumber, previewUid, previewResponseId) { ...@@ -928,7 +933,6 @@ function onDidPreviewPage(pageNumber, previewUid, previewResponseId) {
* Update the print preview when new preview data is available. * Update the print preview when new preview data is available.
* Create the PDF plugin as needed. * Create the PDF plugin as needed.
* Called from PrintPreviewUI::PreviewDataIsAvailable(). * Called from PrintPreviewUI::PreviewDataIsAvailable().
* @param {boolean} modifiable If the preview is modifiable.
* @param {string} previewUid Preview unique identifier. * @param {string} previewUid Preview unique identifier.
* @param {number} previewResponseId The preview request id that resulted in * @param {number} previewResponseId The preview request id that resulted in
* this response. * this response.
...@@ -1069,6 +1073,7 @@ function checkCompatiblePluginExists() { ...@@ -1069,6 +1073,7 @@ function checkCompatiblePluginExists() {
/** /**
* Sets the default values and sends a request to regenerate preview data. * Sets the default values and sends a request to regenerate preview data.
* Resets the margin options only if |resetMargins| is true. * Resets the margin options only if |resetMargins| is true.
* @param {boolean} resetMargins True if margin settings should be resetted.
*/ */
function setDefaultValuesAndRegeneratePreview(resetMargins) { function setDefaultValuesAndRegeneratePreview(resetMargins) {
if (resetMargins) if (resetMargins)
...@@ -1093,7 +1098,7 @@ PrintSettings.prototype.save = function() { ...@@ -1093,7 +1098,7 @@ PrintSettings.prototype.save = function() {
this.deviceName = getSelectedPrinterName(); this.deviceName = getSelectedPrinterName();
this.isLandscape = layoutSettings.isLandscape(); this.isLandscape = layoutSettings.isLandscape();
this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter(); this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter();
} };
/** /**
* Updates the title of the print preview tab according to |initiatorTabTitle|. * Updates the title of the print preview tab according to |initiatorTabTitle|.
......
...@@ -26,7 +26,7 @@ function addAnimation(code) { ...@@ -26,7 +26,7 @@ function addAnimation(code) {
* @return {string} The css code for the fade in animation. * @return {string} The css code for the fade in animation.
*/ */
function getFadeInAnimationCode(targetHeight) { function getFadeInAnimationCode(targetHeight) {
return '0% { opacity: 0; height: 0; } ' + return '0% { opacity: 0; height: 0; } ' +
'80% { height: ' + (targetHeight + 4) + 'px; }' + '80% { height: ' + (targetHeight + 4) + 'px; }' +
'100% { opacity: 1; height: ' + targetHeight + 'px; }'; '100% { opacity: 1; height: ' + targetHeight + 'px; }';
} }
...@@ -68,7 +68,7 @@ function fadeOutElement(el) { ...@@ -68,7 +68,7 @@ function fadeOutElement(el) {
var eventTracker = new EventTracker(); var eventTracker = new EventTracker();
eventTracker.add(el, 'webkitTransitionEnd', eventTracker.add(el, 'webkitTransitionEnd',
onFadeOutTransitionEnd.bind(el, animName, eventTracker), onFadeOutTransitionEnd.bind(el, animName, eventTracker),
false ); false);
el.classList.add('closing'); el.classList.add('closing');
el.classList.remove('visible'); el.classList.remove('visible');
} }
...@@ -76,8 +76,8 @@ function fadeOutElement(el) { ...@@ -76,8 +76,8 @@ function fadeOutElement(el) {
/** /**
* Executes when a fade out animation ends. * Executes when a fade out animation ends.
* @param {string} animationName The name of the animation to be removed. * @param {string} animationName The name of the animation to be removed.
* @param {EventTracker} The |EventTracker| object that was used for adding this * @param {EventTracker} eventTracker The |EventTracker| object that was used
* listener. * for adding this listener.
* @param {WebkitTransitionEvent} event The event that triggered this listener. * @param {WebkitTransitionEvent} event The event that triggered this listener.
*/ */
function onFadeOutTransitionEnd(animationName, eventTracker, event) { function onFadeOutTransitionEnd(animationName, eventTracker, event) {
...@@ -90,8 +90,8 @@ function onFadeOutTransitionEnd(animationName, eventTracker, event) { ...@@ -90,8 +90,8 @@ function onFadeOutTransitionEnd(animationName, eventTracker, event) {
/** /**
* Executes when a fade in animation ends. * Executes when a fade in animation ends.
* @param{EventTracker} The |EventTracker| object that was used for adding this * @param {EventTracker} eventTracker The |EventTracker| object that was used
* listener. * for adding this listener.
* @param {WebkitAnimationEvent} event The event that triggered this listener. * @param {WebkitAnimationEvent} event The event that triggered this listener.
*/ */
function onFadeInAnimationEnd(eventTracker, event) { function onFadeInAnimationEnd(eventTracker, event) {
......
...@@ -88,12 +88,12 @@ cr.define('cloudprint', function() { ...@@ -88,12 +88,12 @@ cr.define('cloudprint', function() {
params = new Array; params = new Array;
} }
if (lastXSRFToken.length != 0) { if (lastXSRFToken.length != 0) {
params.push("xsrf=" + lastXSRFToken); params.push('xsrf=' + lastXSRFToken);
} }
if (params.length != 0) { if (params.length != 0) {
url = url + "?"; url = url + '?';
for (param in params) { for (param in params) {
url = url + params[param] + "&"; url = url + params[param] + '&';
} }
} }
xhr.open(method, url, true); xhr.open(method, url, true);
...@@ -215,10 +215,10 @@ cr.define('cloudprint', function() { ...@@ -215,10 +215,10 @@ cr.define('cloudprint', function() {
printer.cloudPrintOptions.colorOption.type = cap.type; printer.cloudPrintOptions.colorOption.type = cap.type;
for (var option in cap.options) { for (var option in cap.options) {
var opt = cap.options[option]; var opt = cap.options[option];
if (opt.name == "Color") { if (opt.name == 'Color') {
printer.cloudPrintOptions.colorOnOption = opt; printer.cloudPrintOptions.colorOnOption = opt;
} }
if (opt.name == "Grey_K") { if (opt.name == 'Grey_K') {
printer.cloudPrintOptions.colorOffOption = opt; printer.cloudPrintOptions.colorOffOption = opt;
} }
if (opt.default) { if (opt.default) {
...@@ -323,7 +323,7 @@ cr.define('cloudprint', function() { ...@@ -323,7 +323,7 @@ cr.define('cloudprint', function() {
if (isCloudPrint(printer)) { if (isCloudPrint(printer)) {
return JSON.stringify(printer.cloudPrintOptions); return JSON.stringify(printer.cloudPrintOptions);
} else { } else {
return ""; return '';
} }
} }
......
...@@ -3,9 +3,9 @@ ...@@ -3,9 +3,9 @@
// found in the LICENSE file. // found in the LICENSE file.
/** /**
* Returns true if |toTest| contains only digits. Leading and trailing
* whitespace is allowed.
* @param {string} toTest The string to be tested. * @param {string} toTest The string to be tested.
* @return {boolean} True if |toTest| contains only digits. Leading and trailing
* whitespace is allowed.
*/ */
function isInteger(toTest) { function isInteger(toTest) {
var numericExp = /^\s*[0-9]+\s*$/; var numericExp = /^\s*[0-9]+\s*$/;
...@@ -25,7 +25,7 @@ function isPositiveInteger(value) { ...@@ -25,7 +25,7 @@ function isPositiveInteger(value) {
/** /**
* Returns true if the contents of the two arrays are equal. * Returns true if the contents of the two arrays are equal.
* @param {Array} array1 The first array. * @param {Array} array1 The first array.
* @param {Array} array1 The second array. * @param {Array} array2 The second array.
* *
* @return {boolean} true if the arrays are equal. * @return {boolean} true if the arrays are equal.
*/ */
...@@ -33,7 +33,7 @@ function areArraysEqual(array1, array2) { ...@@ -33,7 +33,7 @@ function areArraysEqual(array1, array2) {
if (array1.length != array2.length) if (array1.length != array2.length)
return false; return false;
for (var i = 0; i < array1.length; i++) for (var i = 0; i < array1.length; i++)
if(array1[i] != array2[i]) if (array1[i] != array2[i])
return false; return false;
return true; return true;
} }
...@@ -41,18 +41,18 @@ function areArraysEqual(array1, array2) { ...@@ -41,18 +41,18 @@ function areArraysEqual(array1, array2) {
/** /**
* Removes duplicate elements from |inArray| and returns a new array. * Removes duplicate elements from |inArray| and returns a new array.
* |inArray| is not affected. It assumes that |inArray| is already sorted. * |inArray| is not affected. It assumes that |inArray| is already sorted.
* * @param {array} inArray The array to be processed.
* @param {Array} inArray The array to be processed. * @return {array} The array after processing.
*/ */
function removeDuplicates(inArray) { function removeDuplicates(inArray) {
var out = []; var out = [];
if(inArray.length == 0) if (inArray.length == 0)
return out; return out;
out.push(inArray[0]); out.push(inArray[0]);
for (var i = 1; i < inArray.length; ++i) for (var i = 1; i < inArray.length; ++i)
if(inArray[i] != inArray[i - 1]) if (inArray[i] != inArray[i - 1])
out.push(inArray[i]); out.push(inArray[i]);
return out; return out;
} }
...@@ -75,6 +75,8 @@ function removeDuplicates(inArray) { ...@@ -75,6 +75,8 @@ function removeDuplicates(inArray) {
* Example: "34853253" is valid. * Example: "34853253" is valid.
* Example: "1-4, 9, 3-6, 10, 11" is valid. * Example: "1-4, 9, 3-6, 10, 11" is valid.
* *
* @param {string} pageRangeText The text to be checked.
* @param {number} totalPageCount The total number of pages.
* @return {boolean} true if the |pageRangeText| is valid. * @return {boolean} true if the |pageRangeText| is valid.
*/ */
function isPageRangeTextValid(pageRangeText, totalPageCount) { function isPageRangeTextValid(pageRangeText, totalPageCount) {
...@@ -112,8 +114,9 @@ function isPageRangeTextValid(pageRangeText, totalPageCount) { ...@@ -112,8 +114,9 @@ function isPageRangeTextValid(pageRangeText, totalPageCount) {
* eliminated. If |pageRangeText| is not valid according to * eliminated. If |pageRangeText| is not valid according to
* isPageRangeTextValid(), or |totalPageCount| is undefined an empty list is * isPageRangeTextValid(), or |totalPageCount| is undefined an empty list is
* returned. * returned.
* * @param {string} pageRangeText The text to be checked.
* @return {Array} * @param {number} totalPageCount The total number of pages.
* @return {array} A list of all pages.
*/ */
function pageRangeTextToPageList(pageRangeText, totalPageCount) { function pageRangeTextToPageList(pageRangeText, totalPageCount) {
var pageList = []; var pageList = [];
...@@ -146,17 +149,16 @@ function pageRangeTextToPageList(pageRangeText, totalPageCount) { ...@@ -146,17 +149,16 @@ function pageRangeTextToPageList(pageRangeText, totalPageCount) {
} }
/** /**
* Returns the contents of |pageList| in ascending order and without any * @param {array} pageList The list to be processed.
* duplicates. |pageList| is not affected. * @return {array} The contents of |pageList| in ascending order and without any
* * duplicates. |pageList| is not affected.
* @return {Array}
*/ */
function pageListToPageSet(pageList) { function pageListToPageSet(pageList) {
var pageSet = []; var pageSet = [];
if (pageList.length == 0) if (pageList.length == 0)
return pageSet; return pageSet;
pageSet = pageList.slice(0); pageSet = pageList.slice(0);
pageSet.sort(function(a,b) { return a - b; }); pageSet.sort(function(a, b) { return a - b; });
pageSet = removeDuplicates(pageSet); pageSet = removeDuplicates(pageSet);
return pageSet; return pageSet;
} }
...@@ -165,6 +167,8 @@ function pageListToPageSet(pageList) { ...@@ -165,6 +167,8 @@ function pageListToPageSet(pageList) {
* Converts |pageSet| to page ranges. It squashes whenever possible. * Converts |pageSet| to page ranges. It squashes whenever possible.
* Example: '1-2,3,5-7' becomes 1-3,5-7. * Example: '1-2,3,5-7' becomes 1-3,5-7.
* *
* @param {array} pageSet The set of pages to be processed. Callers should
* ensure that no duplicates exist.
* @return {Array} an array of page range objects. A page range object has * @return {Array} an array of page range objects. A page range object has
* fields 'from' and 'to'. * fields 'from' and 'to'.
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment