Skip to content

Commit

Permalink
Adding in jshint automation.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterdotjs committed Sep 6, 2014
1 parent facf8d3 commit 724aee2
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 25 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -0,0 +1 @@
node_modules/
25 changes: 20 additions & 5 deletions Gruntfile.js
Expand Up @@ -2,9 +2,6 @@ module.exports = function(grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
concat: {
options: {
separator: ';',
},
basic: {
src: [
'js/tracking.js',
Expand All @@ -26,6 +23,24 @@ module.exports = function(grunt) {
dest: 'public/<%= pkg.name %>_background.js'
}
},
jshint: {
beforeconcat: [
'js/tracking.js',
'js/resize.js',
'js/main_view.js',
'js/custom_view.js',
'js/options.js',
'js/layout.js',
'js/utility.js',
'js/display.js',
'js/main.js',
'js/background.js'
],
afterconcat: [
'public/<%= pkg.name %>.js',
'public/<%= pkg.name %>_background.js'
]
},
uglify: {
my_target: {
files: {
Expand All @@ -46,7 +61,7 @@ module.exports = function(grunt) {
}
});

['grunt-contrib-concat', 'grunt-contrib-uglify', 'grunt-contrib-less'].forEach(grunt.loadNpmTasks);
['grunt-contrib-concat', 'grunt-contrib-jshint', 'grunt-contrib-uglify', 'grunt-contrib-less'].forEach(grunt.loadNpmTasks);

grunt.registerTask('default', ['concat','uglify','less']);
grunt.registerTask('default', ['concat', 'jshint', 'uglify', 'less']);
};
2 changes: 1 addition & 1 deletion js/display.js
Expand Up @@ -122,7 +122,7 @@
return {
width: defaultWidth,
height: defaultHeight
}
};
}

function setDisplayHeight(scale,height){
Expand Down
5 changes: 3 additions & 2 deletions js/main_view.js
Expand Up @@ -88,9 +88,11 @@

var curVersion = localStorage.getItem('version') || '',
isOldVersion = (curVersion === '2.0');

var $body = $('body');

//user has never seen update
if(!localStorage.getItem('update-seen') || isOldVersion){
var $body = $('body');
$body.addClass('update');
if(isOldVersion){
localStorage.removeItem('update-seen');
Expand All @@ -102,7 +104,6 @@
}

if(localStorage.getItem('update-seen') && updateCount === resize.badgeLimit && !localStorage.getItem('promo-seen')){
var $body = $('body');
$body.addClass('promo');
resize.options.showPromoModal();
}
Expand Down
5 changes: 3 additions & 2 deletions js/tracking.js
Expand Up @@ -9,15 +9,16 @@ function sendTracking(category, label) {
if(!deferTracking && ga) {
ga('send','event', category, 'clicked', label || "na");
}
};
}

if(!deferTracking) {
// Standard Google Universal Analytics code
/* jshint ignore:start */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); // Note: https protocol here

/* jshint ignore:end */
ga('create', 'UA-34217520-2', 'auto');
ga('set', 'checkProtocolTask', function(){}); // Removes failing protocol check. @see: http://stackoverflow.com/a/22152353/1958200
ga('require', 'displayfeatures');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -5,6 +5,7 @@
"grunt": "~0.4.5",
"grunt-contrib-concat": "~0.5.0",
"grunt-contrib-uglify": "~0.5.1",
"grunt-contrib-less":"~0.11.4"
"grunt-contrib-less":"~0.11.4",
"grunt-contrib-jshint":"~0.10.0"
}
}
36 changes: 23 additions & 13 deletions public/tabResize.js
Expand Up @@ -9,20 +9,22 @@ function sendTracking(category, label) {
if(!deferTracking && ga) {
ga('send','event', category, 'clicked', label || "na");
}
};
}

if(!deferTracking) {
// Standard Google Universal Analytics code
/* jshint ignore:start */
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); // Note: https protocol here

/* jshint ignore:end */
ga('create', 'UA-34217520-2', 'auto');
ga('set', 'checkProtocolTask', function(){}); // Removes failing protocol check. @see: http://stackoverflow.com/a/22152353/1958200
ga('require', 'displayfeatures');
ga('send', 'pageview', '/index.html');
};/*
}
/*
* resize.js
* parent resize object, global variable and object initialization
*/
Expand Down Expand Up @@ -58,7 +60,8 @@ if(!deferTracking) {

window.resize = resize;

})();;/**
})();
/**
* main_view.js
* handles main view - bulk of resize functionality
*/
Expand Down Expand Up @@ -148,9 +151,11 @@ if(!deferTracking) {

var curVersion = localStorage.getItem('version') || '',
isOldVersion = (curVersion === '2.0');

var $body = $('body');

//user has never seen update
if(!localStorage.getItem('update-seen') || isOldVersion){
var $body = $('body');
$body.addClass('update');
if(isOldVersion){
localStorage.removeItem('update-seen');
Expand All @@ -162,7 +167,6 @@ if(!deferTracking) {
}

if(localStorage.getItem('update-seen') && updateCount === resize.badgeLimit && !localStorage.getItem('promo-seen')){
var $body = $('body');
$body.addClass('promo');
resize.options.showPromoModal();
}
Expand Down Expand Up @@ -264,7 +268,8 @@ if(!deferTracking) {

window.resize.main_view = main_view;

})();;/*
})();
/*
* custom_view.js
* handles custom view menu
*/
Expand Down Expand Up @@ -325,7 +330,8 @@ if(!deferTracking) {

window.resize.custom_view = custom_view;

})();;/*
})();
/*
* options.js
* handles resize options (single tab, undo resize, default config)
*/
Expand Down Expand Up @@ -546,7 +552,8 @@ if(!deferTracking) {

window.resize.options = options;

})();;/*
})();
/*
* layout.js
* adds/removes layout from popup
*/
Expand Down Expand Up @@ -718,7 +725,8 @@ if(!deferTracking) {

window.resize.layout = layout;

})();;/**
})();
/**
* utility.js
* general utility functions used for modal, canvas, etc.
*/
Expand Down Expand Up @@ -798,7 +806,8 @@ if(!deferTracking) {

window.resize.util = util;

})();;/*
})();
/*
* display.js
* handling display event handling and logic
*/
Expand Down Expand Up @@ -922,7 +931,7 @@ if(!deferTracking) {
return {
width: defaultWidth,
height: defaultHeight
}
};
}

function setDisplayHeight(scale,height){
Expand Down Expand Up @@ -975,7 +984,8 @@ if(!deferTracking) {
return $template;
}

})(window.jQuery);;/**
})(window.jQuery);
/**
* main.js
* initialization and event handlers
*/
Expand Down
2 changes: 1 addition & 1 deletion public/tabResize.min.js

Large diffs are not rendered by default.

0 comments on commit 724aee2

Please sign in to comment.