Permalink
Browse files

Lint fixes

  • Loading branch information...
1 parent 476face commit 7cbae0d4029d70cbbd0ed0fa732f1c19c6971192 @timdream committed Apr 13, 2014
View
@@ -1,4 +1,5 @@
/assets/vars.js
+/assets/vars-sample.js
/assets/wordfreq
/assets/wordcloud2.js
/assets/go2
View
@@ -1,5 +1,8 @@
'use strict';
+/* global WordCloud, FilePanelView, WordFreq, WordFreqSync,
+ FACEBOOK_APP_ID, FB, FACEBOOK_APP_ID */
+
var WordCloudApp = function WordCloudApp() {
// Special code here to handle non-supported browser case.
if (!((window.WordFreq && window.WordFreq.isSupported) ||
@@ -29,12 +32,14 @@ var WordCloudApp = function WordCloudApp() {
this.logAction('WordCloudApp::isSupported::true');
this.isFullySupported = (function checkFullySupport() {
- if (!FilePanelView.prototype.isSupported)
+ if (!FilePanelView.prototype.isSupported) {
return false;
+ }
// Check for real canvas.toBlob() method.
- if (window.HTMLCanvasElement.prototype.toBlob)
+ if (window.HTMLCanvasElement.prototype.toBlob) {
return true;
+ }
// If not, see if we should shim it.
var hasBlobConstructor = window.Blob && (function tryBlob() {
@@ -219,8 +224,9 @@ WordCloudApp.prototype.pushUrlHash = function wca_pushUrlHash(hash) {
return true;
};
WordCloudApp.prototype.reset = function wca_reset() {
- if (!window.location.hash.substr(1))
+ if (!window.location.hash.substr(1)) {
return;
+ }
if (this.backToReset) {
// Go back
@@ -239,8 +245,9 @@ WordCloudApp.prototype.UI_STATE_ERROR_WITH_DASHBOARD = 5;
WordCloudApp.prototype.UI_STATE_SHARER_DIALOG = 6;
WordCloudApp.prototype.UI_STATE_ABOUT_DIALOG = 7;
WordCloudApp.prototype.switchUIState = function wca_switchUIState(state) {
- if (!this.UIStateViewMap[state])
+ if (!this.UIStateViewMap[state]) {
throw 'Undefined state ' + state;
+ }
if (document.activeElement &&
document.activeElement !== document.body) {
@@ -297,8 +304,9 @@ WordCloudApp.prototype.handleData = function wca_handleData(text, title) {
}
};
WordCloudApp.prototype.stopHandleData = function wca_stopHandleData() {
- if (!this.wordfreq)
+ if (!this.wordfreq) {
return;
+ }
// Stop any current WordFreq async operation,
// or the timer that would invoke WordFreqSync.
@@ -338,7 +346,7 @@ WordCloudApp.prototype.draw = function wca_draw() {
parsedHash[1].substr(0, 128));
};
WordCloudApp.prototype.getCanvasElement = function wcp_getCanvasElement() {
- return this.views['canvas'].canvasElement;
+ return this.views.canvas.canvasElement;
};
WordCloudApp.prototype.calculateWeightFactor =
function wca_calculateWeightFactor(vol) {
@@ -372,8 +380,9 @@ WordCloudApp.prototype.showSharer = function wca_showSharer() {
WordCloudApp.prototype.route = function wca_route() {
var hash = window.location.hash.substr(1);
- if (this.backToReset && !this.lastUrlHashChangePushedByScript)
+ if (this.backToReset && !this.lastUrlHashChangePushedByScript) {
this.backToReset = false;
+ }
this.lastUrlHashChangePushedByScript = false;
@@ -413,8 +422,9 @@ WordCloudApp.prototype.route = function wca_route() {
}
};
WordCloudApp.prototype.logAction = function wca_logAction(action, label, val) {
- if (!window._gaq)
+ if (!window._gaq) {
return;
+ }
var msgs = ['_trackEvent', 'Word Cloud'];
if (action !== undefined) {
@@ -469,14 +479,16 @@ WordCloudApp.prototype.uninit = function wca_uninit() {
var FacebookSDKLoader = function FacebookSDKLoader() {
- if (!FACEBOOK_APP_ID)
+ if (!FACEBOOK_APP_ID) {
throw 'No FACEBOOK_APP_ID defined.';
+ }
this.loaded = false;
};
FacebookSDKLoader.prototype.load = function fsl_load(callback) {
- if (this.loaded)
+ if (this.loaded) {
throw 'FacebookSDKLoader shouldn\'t be reused.';
+ }
this.loaded = true;
// If API is already available, run the callback synchronizely.
View
@@ -1,5 +1,7 @@
'use strict';
+/* global View, WordCloud, __ */
+
var CanvasView = function CanvasView(opts) {
this.load(opts, {
name: 'canvas',
@@ -20,8 +22,9 @@ var CanvasView = function CanvasView(opts) {
'webkitTransform',
'msTransform',
'oTransform'].some((function findTransformProperty(prop) {
- if (!(prop in style))
+ if (!(prop in style)) {
return false;
+ }
this.cssTransformProperty = prop;
return true;
@@ -67,8 +70,9 @@ CanvasView.prototype.beforeShow =
CanvasView.prototype.beforeHide = function cv_beforeShowHide(state, nextState) {
switch (nextState) {
case this.app.UI_STATE_SOURCE_DIALOG:
- if (state == this.app.UI_STATE_ABOUT_DIALOG)
+ if (state == this.app.UI_STATE_ABOUT_DIALOG) {
break;
+ }
this.drawIdleCloud();
break;
@@ -87,8 +91,9 @@ CanvasView.prototype.handleEvent = function cv_handleEvent(evt) {
break;
case 'wordclouddrawn':
- if (evt.detail.drawn)
+ if (evt.detail.drawn) {
break;
+ }
// Stop the draw.
evt.preventDefault();
@@ -157,8 +162,9 @@ CanvasView.prototype.drawIdleCloud = function cv_drawIdleCloud() {
var height = this.documentHeight;
// Only enable the rotation effect on non-touch capable browser.
- if (!('ontouchstart' in window))
+ if (!('ontouchstart' in window)) {
document.addEventListener('mousemove', this);
+ }
this.canvasElement.style[this.cssTransformProperty] = 'scale(1.2)';
@@ -1,5 +1,7 @@
'use strict';
+/* global View, _ */
+
var DashboardView = function DashboardView(opts) {
this.load(opts, {
name: 'dashboard',
@@ -17,17 +19,17 @@ DashboardView.prototype.beforeShow =
DashboardView.prototype.beforeHide =
function dv_beforeShowHide(state, nextState) {
var ctlBtns = this.element.querySelectorAll('[data-canvas-ctl]');
+ var i = ctlBtns.length;
+ var el;
if (nextState === this.app.UI_STATE_DASHBOARD) {
- var i = ctlBtns.length;
while (i--) {
- var el = ctlBtns[i];
+ el = ctlBtns[i];
el.className = el.className.replace(/ disabled/g, '');
}
} else {
- var i = ctlBtns.length;
while (i--) {
- var el = ctlBtns[i];
+ el = ctlBtns[i];
// We might add extra disabled here, but all of them will be removed,
// so don't worry.
el.className += ' disabled';
@@ -36,8 +38,9 @@ DashboardView.prototype.beforeHide =
};
DashboardView.prototype.handleEvent = function dv_handleEvent(evt) {
var el = evt.currentTarget;
- if (el.className.indexOf('disabled') !== -1)
+ if (el.className.indexOf('disabled') !== -1) {
return;
+ }
var app = this.app;
var action = el.getAttribute('data-action');
@@ -55,16 +58,18 @@ DashboardView.prototype.handleEvent = function dv_handleEvent(evt) {
case 'theme':
app.data.theme++;
- if (app.data.theme >= app.themes.length)
+ if (app.data.theme >= app.themes.length) {
app.data.theme = 0;
+ }
app.draw();
break;
case 'shape':
app.data.shape++;
- if (app.data.shape >= app.shapes.length)
+ if (app.data.shape >= app.shapes.length) {
app.data.shape = 0;
+ }
app.draw();
break;
@@ -80,8 +85,9 @@ DashboardView.prototype.handleEvent = function dv_handleEvent(evt) {
break;
case 'size-':
- if (app.data.weightFactor <= 0.1)
+ if (app.data.weightFactor <= 0.1) {
break;
+ }
app.data.weightFactor -= 0.1;
@@ -95,8 +101,9 @@ DashboardView.prototype.handleEvent = function dv_handleEvent(evt) {
break;
case 'gap-':
- if (app.data.gridSize <= 2)
+ if (app.data.gridSize <= 2) {
break;
+ }
app.data.gridSize--;
@@ -120,8 +127,9 @@ DashboardView.prototype.handleEvent = function dv_handleEvent(evt) {
'width=500,height=300,resizable=yes,menubar=yes');
var loadImage = function loadImage() {
win.removeEventListener('load', loadImage);
- if (win.detachEvent)
+ if (win.detachEvent) {
win.detachEvent('onload', loadImage);
+ }
var doc = win.document;
Oops, something went wrong.

0 comments on commit 7cbae0d

Please sign in to comment.