Skip to content

Commit c8e6358

Browse files
committed
Lots of small tweaks to pass jshint.
1 parent c2d38fe commit c8e6358

24 files changed

Lines changed: 240 additions & 1048 deletions

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ Updates:
184184
* The Particle Emitter now remembers the frames given to it and resets it when a new particle is emitted.
185185
* Game.focusLoss and focusGain methods and onBlur and onFocus Signals added, allowing for more fine-grained control over game pause vs. focus loss.
186186
* Keyboard.removeKey method added (thanks qdrj, #550)
187+
* Key.event now stores the most recent DOM event that triggered it.
187188

188189

189190
Bug Fixes:

src/core/Game.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ Phaser.Game.prototype = {
615615
this.input.update();
616616
this.state.update();
617617
this.physics.update();
618-
this.particles.update();
618+
this.particles.update();
619619
this.plugins.update();
620620

621621
this.stage.postUpdate();

src/core/Group.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ Phaser.Group.prototype.preUpdate = function () {
916916
return false;
917917
}
918918

919-
var i = this.children.length;
919+
var i = this.children.length;
920920

921921
while (i--)
922922
{
@@ -1406,7 +1406,7 @@ Phaser.Group.prototype.removeBetween = function (startIndex, endIndex) {
14061406

14071407
this.removeChild(this.children[i]);
14081408

1409-
if (this.cursor === child)
1409+
if (this.cursor === this.children[i])
14101410
{
14111411
this.cursor = null;
14121412
}

src/core/Stage.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ Phaser.Stage = function (game, width, height) {
7676
* @property {number} _backgroundColor - Stage background color.
7777
* @private
7878
*/
79-
this._backgroundColor;
79+
this._backgroundColor = 0x000000;
8080

8181
if (game.config)
8282
{
@@ -261,19 +261,19 @@ Phaser.Stage.prototype.boot = function () {
261261
*/
262262
Phaser.Stage.prototype.checkVisibility = function () {
263263

264-
if (document.webkitHidden != undefined)
264+
if (document.webkitHidden !== undefined)
265265
{
266266
this._hiddenVar = 'webkitvisibilitychange';
267267
}
268-
else if (document.mozHidden != undefined)
268+
else if (document.mozHidden !== undefined)
269269
{
270270
this._hiddenVar = 'mozvisibilitychange';
271271
}
272-
else if (document.msHidden != undefined)
272+
else if (document.msHidden !== undefined)
273273
{
274274
this._hiddenVar = 'msvisibilitychange';
275275
}
276-
else if (document.hidden != undefined)
276+
else if (document.hidden !== undefined)
277277
{
278278
this._hiddenVar = 'visibilitychange';
279279
}

src/core/StateManager.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ Phaser.StateManager.prototype = {
141141
if (typeof this._pendingState === 'string')
142142
{
143143
// State was already added, so just start it
144-
// this.start(this._pendingState, false, false);
144+
this.start(this._pendingState, false, false);
145145
}
146146
else
147147
{

src/gameobjects/BitmapText.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ Object.defineProperty(Phaser.BitmapText.prototype, 'fontSize', {
357357

358358
set: function(value) {
359359

360-
value = parseInt(value);
360+
value = parseInt(value, 10);
361361

362362
if (value !== this._fontSize)
363363
{

src/gameobjects/GameObjectCreator.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ Phaser.GameObjectCreator.prototype = {
168168
* @param {object} style - The style object containing style attributes like font, font size , etc.
169169
* @return {Phaser.Text} The newly created text object.
170170
*/
171-
text: function (x, y, text, style, group) {
171+
text: function (x, y, text, style) {
172172

173173
return new Phaser.Text(this.game, x, y, text, style);
174174

@@ -189,7 +189,7 @@ Phaser.GameObjectCreator.prototype = {
189189
* @param {string|number} [upFrame] This is the frame or frameName that will be set when this button is in an up state. Give either a number to use a frame ID or a string for a frame name.
190190
* @return {Phaser.Button} The newly created button object.
191191
*/
192-
button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame, group) {
192+
button: function (x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame) {
193193

194194
return new Phaser.Button(this.game, x, y, key, callback, callbackContext, overFrame, outFrame, downFrame, upFrame);
195195

@@ -201,10 +201,9 @@ Phaser.GameObjectCreator.prototype = {
201201
* @method Phaser.GameObjectCreator#graphics
202202
* @param {number} x - X position of the new graphics object.
203203
* @param {number} y - Y position of the new graphics object.
204-
* @param {Phaser.Group} [group] - Optional Group to add the object to. If not specified it will be added to the World group.
205204
* @return {Phaser.Graphics} The newly created graphics object.
206205
*/
207-
graphics: function (x, y, group) {
206+
graphics: function (x, y) {
208207

209208
return new Phaser.Graphics(this.game, x, y);
210209

@@ -264,7 +263,7 @@ Phaser.GameObjectCreator.prototype = {
264263
* @param {number} [size] - The size the font will be rendered in, in pixels.
265264
* @return {Phaser.BitmapText} The newly created bitmapText object.
266265
*/
267-
bitmapText: function (x, y, font, text, size, group) {
266+
bitmapText: function (x, y, font, text, size) {
268267

269268
return new Phaser.BitmapText(this.game, x, y, font, text, size);
270269

@@ -326,7 +325,7 @@ Phaser.GameObjectCreator.prototype = {
326325
* @param {boolean} [addToCache=false] - Should this BitmapData be added to the Game.Cache? If so you can retrieve it with Cache.getBitmapData(key)
327326
* @return {Phaser.BitmapData} The newly created BitmapData object.
328327
*/
329-
bitmapData: function (width, height, addToCache) {
328+
bitmapData: function (width, height, key, addToCache) {
330329

331330
if (typeof addToCache === 'undefined') { addToCache = false; }
332331
if (typeof key === 'undefined' || key === '') { key = this.game.rnd.uuid(); }

src/gameobjects/GameObjectFactory.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,7 @@ Phaser.GameObjectFactory.prototype = {
377377
* @param {boolean} [addToCache=false] - Should this BitmapData be added to the Game.Cache? If so you can retrieve it with Cache.getBitmapData(key)
378378
* @return {Phaser.BitmapData} The newly created BitmapData object.
379379
*/
380-
bitmapData: function (width, height, addToCache) {
380+
bitmapData: function (width, height, key, addToCache) {
381381

382382
if (typeof addToCache === 'undefined') { addToCache = false; }
383383
if (typeof key === 'undefined' || key === '') { key = this.game.rnd.uuid(); }

src/gameobjects/RetroFont.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -267,7 +267,7 @@ Phaser.RetroFont.TEXT_SET11 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ.,\"-+!?()':;0123456789
267267
* @param {number} width - Width in pixels of this RetroFont. Set to zero to disable and re-enable automatic resizing.
268268
* @param {string} [lineAlignment='left'] - Align the text within this width. Set to RetroFont.ALIGN_LEFT (default), RetroFont.ALIGN_RIGHT or RetroFont.ALIGN_CENTER.
269269
*/
270-
Phaser.RetroFont.prototype.setFixedWidth = function (width, lineAlignment) {
270+
Phaser.RetroFont.prototype.setFixedWidth = function (width, lineAlignment) {
271271

272272
if (typeof lineAlignment === 'undefined') { lineAlignment = 'left'; }
273273

@@ -352,7 +352,7 @@ Phaser.RetroFont.prototype.resize = function (width, height) {
352352
* @method Phaser.RetroFont#buildRetroFontText
353353
* @memberof Phaser.RetroFont
354354
*/
355-
Phaser.RetroFont.prototype.buildRetroFontText = function () {
355+
Phaser.RetroFont.prototype.buildRetroFontText = function () {
356356

357357
var cx = 0;
358358
var cy = 0;
@@ -363,7 +363,7 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
363363

364364
if (this.fixedWidth > 0)
365365
{
366-
this.resize(fixedWidth, (lines.length * (this.characterHeight + this.customSpacingY)) - this.customSpacingY);
366+
this.resize(this.fixedWidth, (lines.length * (this.characterHeight + this.customSpacingY)) - this.customSpacingY);
367367
}
368368
else
369369
{
@@ -407,7 +407,7 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
407407
{
408408
if (this.fixedWidth > 0)
409409
{
410-
this.resize(fixedWidth, this.characterHeight);
410+
this.resize(this.fixedWidth, this.characterHeight);
411411
}
412412
else
413413
{
@@ -448,7 +448,7 @@ Phaser.RetroFont.prototype.buildRetroFontText = function () {
448448
* @param {number} y - The y coordinate.
449449
* @param {number} customSpacingX - Custom X spacing.
450450
*/
451-
Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
451+
Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
452452

453453
var p = new Phaser.Point();
454454

@@ -457,7 +457,7 @@ Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
457457
// If it's a space then there is no point copying, so leave a blank space
458458
if (line.charAt(c) == " ")
459459
{
460-
x += this.characterWidth + this.customSpacingX;
460+
x += this.characterWidth + customSpacingX;
461461
}
462462
else
463463
{
@@ -468,7 +468,7 @@ Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
468468
p.set(x, y);
469469
this.render(this.stamp, p, false);
470470

471-
x += this.characterWidth + this.customSpacingX;
471+
x += this.characterWidth + customSpacingX;
472472

473473
if (x > this.width)
474474
{
@@ -486,7 +486,7 @@ Phaser.RetroFont.prototype.pasteLine = function (line, x, y, customSpacingX) {
486486
* @memberof Phaser.RetroFont
487487
* @return {number} The length of the longest line of text.
488488
*/
489-
Phaser.RetroFont.prototype.getLongestLine = function () {
489+
Phaser.RetroFont.prototype.getLongestLine = function () {
490490

491491
var longestLine = 0;
492492

@@ -515,18 +515,18 @@ Phaser.RetroFont.prototype.getLongestLine = function () {
515515
* @param {boolean} [stripCR=true] - Should it strip carriage returns as well?
516516
* @return {string} A clean version of the string.
517517
*/
518-
Phaser.RetroFont.prototype.removeUnsupportedCharacters = function (stripCR) {
518+
Phaser.RetroFont.prototype.removeUnsupportedCharacters = function (stripCR) {
519519

520520
var newString = "";
521521

522522
for (var c = 0; c < this._text.length; c++)
523523
{
524-
var char = this._text[c];
525-
var code = char.charCodeAt(0);
524+
var aChar = this._text[c];
525+
var code = aChar.charCodeAt(0);
526526

527-
if (this.grabData[code] >= 0 || (!stripCR && char === "\n"))
527+
if (this.grabData[code] >= 0 || (!stripCR && aChar === "\n"))
528528
{
529-
newString = newString.concat(char);
529+
newString = newString.concat(aChar);
530530
}
531531
}
532532

src/gameobjects/Text.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Phaser.Text = function (game, x, y, text, style) {
2525
text = text || ' ';
2626
style = style || {};
2727

28-
if (text.length == 0)
28+
if (text.length === 0)
2929
{
3030
text = ' ';
3131
}
@@ -327,27 +327,36 @@ Phaser.Text.prototype.updateText = function () {
327327

328328
// word wrap
329329
// preserve original text
330-
if(this.style.wordWrap)outputText = this.runWordWrap(this.text);
330+
if (this.style.wordWrap)
331+
{
332+
outputText = this.runWordWrap(this.text);
333+
}
331334

332335
//split text into lines
333336
var lines = outputText.split(/(?:\r\n|\r|\n)/);
334337

335338
//calculate text width
336339
var lineWidths = [];
337340
var maxLineWidth = 0;
341+
338342
for (var i = 0; i < lines.length; i++)
339343
{
340344
var lineWidth = this.context.measureText(lines[i]).width;
341345
lineWidths[i] = lineWidth;
342346
maxLineWidth = Math.max(maxLineWidth, lineWidth);
343347
}
348+
344349
this.canvas.width = maxLineWidth + this.style.strokeThickness;
345350

346351
//calculate text height
347352
var lineHeight = this.determineFontHeight('font: ' + this.style.font + ';') + this.style.strokeThickness + this._lineSpacing + this.style.shadowOffsetY;
353+
348354
this.canvas.height = lineHeight * lines.length;
349355

350-
if(navigator.isCocoonJS) this.context.clearRect(0,0,this.canvas.width,this.canvas.height);
356+
if (navigator.isCocoonJS)
357+
{
358+
this.context.clearRect(0,0,this.canvas.width,this.canvas.height);
359+
}
351360

352361
//set canvas text styles
353362
this.context.fillStyle = this.style.fill;
@@ -520,7 +529,7 @@ Object.defineProperty(Phaser.Text.prototype, 'fontSize', {
520529

521530
set: function(value) {
522531

523-
value = parseInt(value);
532+
value = parseInt(value, 10);
524533

525534
if (value !== this._fontSize)
526535
{

0 commit comments

Comments
 (0)