1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Adds web/* and test/* for jshint target

This commit is contained in:
Yury Delendik 2013-02-04 12:01:19 -06:00
parent bf8b10c961
commit 81f8f92696
18 changed files with 53 additions and 25 deletions

View file

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals VBArray */
'use strict';
@ -85,9 +86,9 @@
return;
Object.create = function objectCreate(proto) {
var constructor = function objectCreateConstructor() {};
constructor.prototype = proto;
return new constructor();
function Constructor() {}
Constructor.prototype = proto;
return new Constructor();
};
})();
@ -334,7 +335,7 @@
function changeList(element, itemName, add, remove) {
var s = element.className || '';
var list = s.split(/\s+/g);
if (list[0] == '') list.shift();
if (list[0] === '') list.shift();
var index = list.indexOf(itemName);
if (index < 0 && add)
list.push(itemName);
@ -380,18 +381,18 @@
// Check console compatability
(function checkConsoleCompatibility() {
if (typeof console == 'undefined') {
console = {
if (!('console' in window)) {
window.console = {
log: function() {},
error: function() {}
};
} else if (!('bind' in console.log)) {
// native functions in IE9 might not have bind
console.log = (function(fn) {
return function(msg) { return fn(msg); }
return function(msg) { return fn(msg); };
})(console.log);
console.error = (function(fn) {
return function(msg) { return fn(msg); }
return function(msg) { return fn(msg); };
})(console.error);
}
})();

View file

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFJS */
'use strict';
@ -271,7 +272,7 @@ var Stepper = (function StepperClosure() {
else
self.breakPoints.splice(self.breakPoints.indexOf(x), 1);
StepperManager.saveBreakPoints(self.pageIndex, self.breakPoints);
}
};
})(i);
breakCell.appendChild(cbox);
@ -376,7 +377,7 @@ var Stats = (function Stats() {
wrapper.appendChild(title);
wrapper.appendChild(statsDiv);
stats.push({ pageNumber: pageNumber, div: wrapper });
stats.sort(function(a, b) { return a.pageNumber - b.pageNumber});
stats.sort(function(a, b) { return a.pageNumber - b.pageNumber; });
clear(this.panel);
for (var i = 0, ii = stats.length; i < ii; ++i)
this.panel.appendChild(stats[i].div);

View file

@ -14,6 +14,8 @@
*/
var FirefoxCom = (function FirefoxComClosure() {
'use strict';
return {
/**
* Creates an event that the extension is listening for and will

View file

@ -14,6 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/* globals PDFJS, PDFBug, FirefoxCom, Stats */
'use strict';
@ -64,7 +65,8 @@ function scrollIntoView(element, spot) {
// producing the error. See also animationStartedClosure.
var parent = element.offsetParent, offsetY = element.offsetTop;
if (!parent) {
error('offsetParent is not set -- cannot scroll');
console.error('offsetParent is not set -- cannot scroll');
return;
}
while (parent.clientHeight == parent.scrollHeight) {
offsetY += parent.offsetTop;
@ -2042,8 +2044,9 @@ var PageView = function pageView(container, pdfPage, id, scale,
};
this.draw = function pageviewDraw(callback) {
if (this.renderingState !== RenderingStates.INITIAL)
error('Must be in new state before drawing');
if (this.renderingState !== RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
}
this.renderingState = RenderingStates.RUNNING;
@ -2217,7 +2220,7 @@ var PageView = function pageView(container, pdfPage, id, scale,
console.error(error);
// Tell the printEngine that rendering this canvas/page has failed.
// This will make the print proces stop.
if ('abort' in object)
if ('abort' in obj)
obj.abort();
else
obj.done();
@ -2299,7 +2302,7 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
this.hasImage = false;
this.renderingState = RenderingStates.INITIAL;
this.resume = null;
}
};
function getPageDrawContext() {
var canvas = document.createElement('canvas');
@ -2329,8 +2332,9 @@ var ThumbnailView = function thumbnailView(container, pdfPage, id) {
};
this.draw = function thumbnailViewDraw(callback) {
if (this.renderingState !== RenderingStates.INITIAL)
error('Must be in new state before drawing');
if (this.renderingState !== RenderingStates.INITIAL) {
console.error('Must be in new state before drawing');
}
this.renderingState = RenderingStates.RUNNING;
if (this.hasImage) {
@ -3076,7 +3080,7 @@ window.addEventListener('hashchange', function webViewerHashchange(evt) {
window.addEventListener('change', function webViewerChange(evt) {
var files = evt.target.files;
if (!files || files.length == 0)
if (!files || files.length === 0)
return;
// Read the local file into a Uint8Array.
@ -3271,7 +3275,7 @@ window.addEventListener('keydown', function keydown(evt) {
curElement = curElement.parentNode;
}
if (cmd == 0) { // no control key pressed at all.
if (cmd === 0) { // no control key pressed at all.
switch (evt.keyCode) {
case 38: // up arrow
case 33: // pg up
@ -3279,12 +3283,14 @@ window.addEventListener('keydown', function keydown(evt) {
if (!PDFView.isFullscreen && PDFView.currentScaleValue !== 'page-fit') {
break;
}
// in fullscreen mode falls throw here
/* in fullscreen mode */
/* falls through */
case 37: // left arrow
// horizontal scrolling using arrow keys
if (PDFView.isHorizontalScrollbarEnabled) {
break;
}
/* falls through */
case 75: // 'k'
case 80: // 'p'
PDFView.page--;
@ -3296,12 +3302,13 @@ window.addEventListener('keydown', function keydown(evt) {
if (!PDFView.isFullscreen && PDFView.currentScaleValue !== 'page-fit') {
break;
}
// in fullscreen mode falls throw here
/* falls through */
case 39: // right arrow
// horizontal scrolling using arrow keys
if (PDFView.isHorizontalScrollbarEnabled) {
break;
}
/* falls through */
case 74: // 'j'
case 78: // 'n'
PDFView.page++;