Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

removing JQUERY, lost fade in and slow scrolling effects though #21

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
156 changes: 67 additions & 89 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

module.exports = function (grunt) {
module.exports = function(grunt){

// Load grunt tasks automatically
require('load-grunt-tasks')(grunt);
Expand All @@ -14,6 +14,16 @@ module.exports = function (grunt) {

// Project configuration.
grunt.initConfig({
sass: {
options: {
sourceMap: true
},
dist: {
files: {
'./dist/angular-tour.css': './src/tour/**/*.scss'
}
}
},
yeoman: yeomanConfig,
pkg: grunt.file.readJSON('package.json'),
modules: [],//to be filled in by buildmodules task
Expand All @@ -23,12 +33,12 @@ module.exports = function (grunt) {
tplmodules: 'angular.module("<%= pkg.name %>.tpls", [<%= tplModules %>]);',
all: 'angular.module("<%= pkg.name %>", ["<%= pkg.name %>.tpls", <%= srcModules %>]);',
banner: '/**\n' +
' * <%= pkg.description %>\n' +
' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * @link <%= pkg.homepage %>\n' +
' * @author <%= pkg.author.name %>\n' +
' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
' */\n\n'
' * <%= pkg.description %>\n' +
' * @version v<%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %>\n' +
' * @link <%= pkg.homepage %>\n' +
' * @author <%= pkg.author.name %>\n' +
' * @license MIT License, http://www.opensource.org/licenses/MIT\n' +
' */\n\n'
},

// Watches files for changes and runs tasks based on the changed files
Expand All @@ -44,9 +54,9 @@ module.exports = function (grunt) {
files: ['<%= yeoman.src %>/**/*.spec.js'],
tasks: ['karma']
},
compass: {
sass:{
files: ['<%= yeoman.src %>/**/*.{scss,sass}'],
tasks: ['compass:server', 'autoprefixer']
tasks: ['sass', 'autoprefixer']
},
gruntfile: {
files: ['Gruntfile.js']
Expand Down Expand Up @@ -131,26 +141,6 @@ module.exports = function (grunt) {
}
},

// Compiles Sass to CSS and generates necessary files if requested
compass: {
options: {
sassDir: '<%= yeoman.src %>',
cssDir: '.tmp/styles',
relativeAssets: false,
assetCacheBuster: false
},
server: {
options: {
debugInfo: true
}
},
dist: {
options: {
noLineComments: true
}
}
},

// Make sure code styles are up to par and there are no obvious mistakes
jshint: {
options: {
Expand Down Expand Up @@ -187,7 +177,7 @@ module.exports = function (grunt) {
// Replace all 'use strict' statements in the code with a single one at the top
banner: '(function(window, document, undefined) {\n\'use strict\';\n<%= meta.modules %>\n',
footer: '\n})(window, document);\n',
process: function(src, filepath) {
process: function(src, filepath){
return src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
}
},
Expand All @@ -203,7 +193,7 @@ module.exports = function (grunt) {
// Replace all 'use strict' statements in the code with a single one at the top
banner: '(function(window, document, undefined) {\n\'use strict\';\n<%= meta.all %>\n<%= meta.tplmodules %>\n',
footer: '\n})(window, document);\n',
process: function(src, filepath) {
process: function(src, filepath){
return src.replace(/(^|\n)[ \t]*('use strict'|"use strict");?\s*/g, '$1');
}
},
Expand Down Expand Up @@ -296,7 +286,7 @@ module.exports = function (grunt) {
module: null, // no bundle module for all the html2js templates
base: 'src'
},
src: [ 'src/**/*.tpl.html' ],
src: ['src/**/*.tpl.html'],
dest: '<%= yeoman.dist %>/<%= pkg.name %>-tpls.js'
}
},
Expand All @@ -321,23 +311,6 @@ module.exports = function (grunt) {
src: ['src/**/*.tpl.html']
}
},

// Run some tasks in parallel to speed up the build process
concurrent: {
server: [
'compass:server',
'copy:styles'
]
},

copy: {
styles: {
expand: true,
src: '<%= yeoman.src %>/**/*.css',
dest: '.tmp/'
}
},

processhtml: {
dist: {
files: {
Expand Down Expand Up @@ -372,91 +345,96 @@ module.exports = function (grunt) {

//findModule: Adds a given module to config
var foundModules = {};
function findModule(name) {
if (foundModules[name]) { return; }

function findModule(name){
if(foundModules[name]){
return;
}
foundModules[name] = true;

function enquote(str) {
function enquote(str){
return '"' + str + '"';
}

function removeroot(str) {
function removeroot(str){
return str.slice(str.indexOf('/') + 1, str.length);
}

var module = {
name: name,
moduleName: enquote(grunt.config('moduleprefix')+name),
srcFiles: grunt.file.expand(['src/'+name+'/*.js','!src/'+name+'/*.spec.js']),
tplFiles: grunt.file.expand('src/'+name+'/*.tpl.html'),
tplModules: grunt.file.expand('src/'+name+'/*.tpl.html').map(removeroot).map(enquote),
moduleName: enquote(grunt.config('moduleprefix') + name),
srcFiles: grunt.file.expand(['src/' + name + '/*.js', '!src/' + name + '/*.spec.js']),
tplFiles: grunt.file.expand('src/' + name + '/*.tpl.html'),
tplModules: grunt.file.expand('src/' + name + '/*.tpl.html').map(removeroot).map(enquote),
dependencies: dependenciesForModule(name)
};
module.dependencies.forEach(findModule);
grunt.config('modules', grunt.config('modules').concat(module));
}

function dependenciesForModule(name) {
function dependenciesForModule(name){
var deps = [];
grunt.file.expand(['src/'+name+'/*.js','!src/'+name+'/*.spec.js'])
.map(grunt.file.read)
.forEach(function(contents) {
//Strategy: find where module is declared,
//and from there get everything inside the [] and split them by comma
var moduleDeclIndex = contents.indexOf('angular.module(');
var depArrayStart = contents.indexOf('[', moduleDeclIndex);
var depArrayEnd = contents.indexOf(']', depArrayStart);
var dependencies = contents.substring(depArrayStart + 1, depArrayEnd);
dependencies.split(',').forEach(function(dep) {
if (dep.indexOf(grunt.config('moduleprefix')) > -1) {
var depName = dep.trim().replace( grunt.config('moduleprefix'),'').replace(/['"]/g,'');
if (deps.indexOf(depName) < 0) {
deps.push(depName);
//Get dependencies for this new dependency
deps = deps.concat(dependenciesForModule(depName));
grunt.file.expand(['src/' + name + '/*.js', '!src/' + name + '/*.spec.js'])
.map(grunt.file.read)
.forEach(function(contents){
//Strategy: find where module is declared,
//and from there get everything inside the [] and split them by comma
var moduleDeclIndex = contents.indexOf('angular.module(');
var depArrayStart = contents.indexOf('[', moduleDeclIndex);
var depArrayEnd = contents.indexOf(']', depArrayStart);
var dependencies = contents.substring(depArrayStart + 1, depArrayEnd);
dependencies.split(',').forEach(function(dep){
if(dep.indexOf(grunt.config('moduleprefix')) > -1){
var depName = dep.trim().replace(grunt.config('moduleprefix'), '').replace(/['"]/g, '');
if(deps.indexOf(depName) < 0){
deps.push(depName);
//Get dependencies for this new dependency
deps = deps.concat(dependenciesForModule(depName));
}
}
}
});
});
});
return deps;
}

grunt.registerTask('buildmodules', function() {
grunt.registerTask('buildmodules', function(){
var _ = grunt.util._;

//Build all modules
grunt.file.expand({
filter: 'isDirectory',
cwd: '.'
}, 'src/*').forEach(function(dir) {
}, 'src/*').forEach(function(dir){
findModule(dir.split('/')[1]);
});

var modules = grunt.config('modules');
grunt.config('srcModules', _.pluck(modules, 'moduleName'));
grunt.config('tplModules', _.pluck(modules, 'tplModules').filter(function(tpls) { return tpls.length > 0;} ));
grunt.config('tplModules', _.pluck(modules, 'tplModules').filter(function(tpls){
return tpls.length > 0;
}));
});

grunt.registerMultiTask('optionaltasks', 'Run task only if source files exists', function() {
grunt.registerMultiTask('optionaltasks', 'Run task only if source files exists', function(){
var options = this.options({
tasks: []
});

var filesExist = false;
this.files.forEach(function(f) {
var src = f.src.filter(function(filepath) {
if (!grunt.file.exists(filepath)) {
this.files.forEach(function(f){
var src = f.src.filter(function(filepath){
if(!grunt.file.exists(filepath)){
return false;
} else {
}else{
filesExist = true;
return true;
}
});
});

if(filesExist) {
if(filesExist){
console.log('true');
options.tasks.forEach(function(task) {
options.tasks.forEach(function(task){
grunt.task.run(task);
});
}
Expand All @@ -470,7 +448,7 @@ module.exports = function (grunt) {

grunt.registerTask('build', [
'clean:dist',
'compass:dist',
'sass:dist',
'autoprefixer',
'buildmodules',
'optionaltasks:css',
Expand All @@ -482,10 +460,10 @@ module.exports = function (grunt) {
'processhtml'
]);

grunt.registerTask('serve', function (target) {
grunt.registerTask('serve', function(target){
grunt.task.run([
'clean:server',
'concurrent:server',
//'concurrent:server',
'autoprefixer',
'connect:livereload',
'watch'
Expand Down
3 changes: 1 addition & 2 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@
"package.json"
],
"dependencies": {
"angular": "~1.2.x",
"jquery": "~2.0.3"
"angular": "~1.4.x"
},
"devDependencies": {
"angular-mocks": "~1.x",
Expand Down
7 changes: 2 additions & 5 deletions demo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@
<link href="//cdnjs.cloudflare.com/ajax/libs/rainbow/1.2.0/themes/github.css" rel='stylesheet' type='text/css'>
<link rel='stylesheet' href='demoapp.css' type='text/css'>

<!-- build:js lib/jquery/jquery.js -->
<script type="text/javascript" src="bower_components/jquery/jquery.js"></script>
<!-- /build -->
<!-- build:js lib/angular/angular.js -->
<script type="text/javascript" src="bower_components/angular/angular.js"></script>
<!-- /build -->
Expand Down Expand Up @@ -51,7 +48,7 @@
});
</script>
<!-- build:css angular-tour.css -->
<link rel="stylesheet" href="styles/tour/tour.css">
<link rel="stylesheet" href="/dist/angular-tour.css">
<!-- /build -->
</head>
<body ng-app="demoApp" ng-controller="DemoCtrl">
Expand Down Expand Up @@ -299,4 +296,4 @@
</div>
</tour>
</body>
</html>
</html>
Loading