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() {
*/
get colorMode() {
return this.bwRadioButton_.checked ?
this.printerColorModelForBlack_:
this.printerColorModelForBlack_ :
this.printerColorModelForColor_;
},
......
......@@ -50,14 +50,14 @@ cr.define('print_preview', function() {
* @return {boolean} true if the chosen layout mode has changed since last
* time the state was updated.
*/
hasChanged_ : function() {
hasChanged_: function() {
return this.isLandscape() != this.wasLandscape_;
},
/**
* Saves the currently selected layout mode. Used in |this.hasChanged_|.
*/
updateState : function() {
updateState: function() {
this.wasLandscape_ = this.isLandscape();
},
......
......@@ -169,7 +169,7 @@ cr.define('print_preview', function() {
* locale.
* @param {string} numberFormat Is the formatted version of a sample number,
* 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
* third_party/icu/public/i18n/unicode/ulocdata.h.
*/
......@@ -228,7 +228,7 @@ cr.define('print_preview', function() {
* |margin{Top|Bottom|Left|Right}| attributes are missing.
*/
setLastUsedMargins: function(lastUsedMarginsSettings) {
var lastUsedMarginsType = lastUsedMarginsSettings['marginsType']
var lastUsedMarginsType = lastUsedMarginsSettings['marginsType'];
this.forceMarginsUIOnPDFLoad_ =
lastUsedMarginsType == MarginSettings.MARGINS_VALUE_CUSTOM;
this.marginList_.selectedIndex =
......
......@@ -50,7 +50,7 @@ cr.define('print_preview', function() {
WITHIN_RANGE: 1,
TOO_BIG: 2,
NOT_A_NUMBER: 3
}
};
/**
* Checks whether |value| is within range [0, limit].
......
......@@ -79,7 +79,7 @@ cr.define('print_preview', function() {
/**
* Updates the state of the margins UI.
* @param {print_preview.Rect}
* @param {print_preview.Rect} marginsRectangle
* @param {Margins} marginValues
* @param {array} valueLimits
*/
......@@ -129,7 +129,7 @@ cr.define('print_preview', function() {
applyClippingMask_: function() {
var bottom = previewArea.height;
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() {
/**
* 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) {
if (e.button != 0)
......
......@@ -125,8 +125,8 @@ var customEvents = {
// 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',
}
UPDATE_SUMMARY: 'updateSummary'
};
/**
* Window onload handler, sets up the page and starts print preview by getting
......@@ -175,7 +175,6 @@ function onLoad() {
}
/**
* @param {string} initiatorTabTitle The title of the initiator tab.
* @param {object} initialSettings An object containing all the initial
* settings.
*/
......@@ -348,7 +347,7 @@ function reloadPrintersList() {
/**
* 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) {
useCloudPrint = true;
......@@ -476,7 +475,7 @@ function isExpectedPreviewResponse(previewResponseId) {
* @return {string} The name of the currently selected printer.
*/
function getSelectedPrinterName() {
var printerList = $('printer-list')
var printerList = $('printer-list');
var selectedPrinter = printerList.selectedIndex;
if (selectedPrinter < 0)
return '';
......@@ -611,7 +610,7 @@ function fileSelectionCompleted() {
/**
* 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
* the default printer is a cloud printer.
*/
......@@ -715,6 +714,8 @@ function createDestinationListOption(optionText, optionValue, isDefault,
* @param {string} optionValue specifies the option value.
* @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} isSeparator is true if the option serves just as a
* separator.
* @return {Object} The created option.
*/
function addDestinationListOption(optionText, optionValue, isDefault,
......@@ -736,6 +737,8 @@ function addDestinationListOption(optionText, optionValue, isDefault,
* @param {string} optionValue specifies the option value.
* @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} isSeparator is true if the option is a visual separator and
* needs to be disabled.
* @return {Object} The created option.
*/
function addDestinationListOptionAtPosition(position,
......@@ -877,8 +880,10 @@ function reloadPreviewPages(previewUid, previewResponseId) {
cr.dispatchSimpleEvent(document, customEvents.UPDATE_PRINT_BUTTON);
checkAndHideOverlayLayerIfValid();
var pageSet = pageSettings.previouslySelectedPages;
for (var i = 0; i < pageSet.length; i++)
$('pdf-viewer').loadPreviewPage(getPageSrcURL(previewUid, pageSet[i]-1), i);
for (var i = 0; i < pageSet.length; i++) {
$('pdf-viewer').loadPreviewPage(
getPageSrcURL(previewUid, pageSet[i] - 1), i);
}
hasPendingPreviewRequest = false;
isPrintReadyMetafileReady = true;
......@@ -928,7 +933,6 @@ function onDidPreviewPage(pageNumber, previewUid, previewResponseId) {
* Update the print preview when new preview data is available.
* Create the PDF plugin as needed.
* Called from PrintPreviewUI::PreviewDataIsAvailable().
* @param {boolean} modifiable If the preview is modifiable.
* @param {string} previewUid Preview unique identifier.
* @param {number} previewResponseId The preview request id that resulted in
* this response.
......@@ -1069,6 +1073,7 @@ function checkCompatiblePluginExists() {
/**
* Sets the default values and sends a request to regenerate preview data.
* Resets the margin options only if |resetMargins| is true.
* @param {boolean} resetMargins True if margin settings should be resetted.
*/
function setDefaultValuesAndRegeneratePreview(resetMargins) {
if (resetMargins)
......@@ -1093,7 +1098,7 @@ PrintSettings.prototype.save = function() {
this.deviceName = getSelectedPrinterName();
this.isLandscape = layoutSettings.isLandscape();
this.hasHeaderFooter = headerFooterSettings.hasHeaderFooter();
}
};
/**
* Updates the title of the print preview tab according to |initiatorTabTitle|.
......
......@@ -68,7 +68,7 @@ function fadeOutElement(el) {
var eventTracker = new EventTracker();
eventTracker.add(el, 'webkitTransitionEnd',
onFadeOutTransitionEnd.bind(el, animName, eventTracker),
false );
false);
el.classList.add('closing');
el.classList.remove('visible');
}
......@@ -76,8 +76,8 @@ function fadeOutElement(el) {
/**
* Executes when a fade out animation ends.
* @param {string} animationName The name of the animation to be removed.
* @param {EventTracker} The |EventTracker| object that was used for adding this
* listener.
* @param {EventTracker} eventTracker The |EventTracker| object that was used
* for adding this listener.
* @param {WebkitTransitionEvent} event The event that triggered this listener.
*/
function onFadeOutTransitionEnd(animationName, eventTracker, event) {
......@@ -90,8 +90,8 @@ function onFadeOutTransitionEnd(animationName, eventTracker, event) {
/**
* Executes when a fade in animation ends.
* @param{EventTracker} The |EventTracker| object that was used for adding this
* listener.
* @param {EventTracker} eventTracker The |EventTracker| object that was used
* for adding this listener.
* @param {WebkitAnimationEvent} event The event that triggered this listener.
*/
function onFadeInAnimationEnd(eventTracker, event) {
......
......@@ -88,12 +88,12 @@ cr.define('cloudprint', function() {
params = new Array;
}
if (lastXSRFToken.length != 0) {
params.push("xsrf=" + lastXSRFToken);
params.push('xsrf=' + lastXSRFToken);
}
if (params.length != 0) {
url = url + "?";
url = url + '?';
for (param in params) {
url = url + params[param] + "&";
url = url + params[param] + '&';
}
}
xhr.open(method, url, true);
......@@ -215,10 +215,10 @@ cr.define('cloudprint', function() {
printer.cloudPrintOptions.colorOption.type = cap.type;
for (var option in cap.options) {
var opt = cap.options[option];
if (opt.name == "Color") {
if (opt.name == 'Color') {
printer.cloudPrintOptions.colorOnOption = opt;
}
if (opt.name == "Grey_K") {
if (opt.name == 'Grey_K') {
printer.cloudPrintOptions.colorOffOption = opt;
}
if (opt.default) {
......@@ -323,7 +323,7 @@ cr.define('cloudprint', function() {
if (isCloudPrint(printer)) {
return JSON.stringify(printer.cloudPrintOptions);
} else {
return "";
return '';
}
}
......
......@@ -3,9 +3,9 @@
// 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.
* @return {boolean} True if |toTest| contains only digits. Leading and trailing
* whitespace is allowed.
*/
function isInteger(toTest) {
var numericExp = /^\s*[0-9]+\s*$/;
......@@ -25,7 +25,7 @@ function isPositiveInteger(value) {
/**
* Returns true if the contents of the two arrays are equal.
* @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.
*/
......@@ -33,7 +33,7 @@ function areArraysEqual(array1, array2) {
if (array1.length != array2.length)
return false;
for (var i = 0; i < array1.length; i++)
if(array1[i] != array2[i])
if (array1[i] != array2[i])
return false;
return true;
}
......@@ -41,18 +41,18 @@ function areArraysEqual(array1, array2) {
/**
* Removes duplicate elements from |inArray| and returns a new array.
* |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) {
var out = [];
if(inArray.length == 0)
if (inArray.length == 0)
return out;
out.push(inArray[0]);
for (var i = 1; i < inArray.length; ++i)
if(inArray[i] != inArray[i - 1])
if (inArray[i] != inArray[i - 1])
out.push(inArray[i]);
return out;
}
......@@ -75,6 +75,8 @@ function removeDuplicates(inArray) {
* Example: "34853253" 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.
*/
function isPageRangeTextValid(pageRangeText, totalPageCount) {
......@@ -112,8 +114,9 @@ function isPageRangeTextValid(pageRangeText, totalPageCount) {
* eliminated. If |pageRangeText| is not valid according to
* isPageRangeTextValid(), or |totalPageCount| is undefined an empty list is
* returned.
*
* @return {Array}
* @param {string} pageRangeText The text to be checked.
* @param {number} totalPageCount The total number of pages.
* @return {array} A list of all pages.
*/
function pageRangeTextToPageList(pageRangeText, totalPageCount) {
var pageList = [];
......@@ -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.
* @return {array} The contents of |pageList| in ascending order and without any
* duplicates. |pageList| is not affected.
*
* @return {Array}
*/
function pageListToPageSet(pageList) {
var pageSet = [];
if (pageList.length == 0)
return pageSet;
pageSet = pageList.slice(0);
pageSet.sort(function(a,b) { return a - b; });
pageSet.sort(function(a, b) { return a - b; });
pageSet = removeDuplicates(pageSet);
return pageSet;
}
......@@ -165,6 +167,8 @@ function pageListToPageSet(pageList) {
* Converts |pageSet| to page ranges. It squashes whenever possible.
* 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
* 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