Skip to content

Commit 7f63ff1

Browse files
author
Erik Mellum
committed
Adds better javascript
1 parent f72b507 commit 7f63ff1

File tree

8 files changed

+71
-10
lines changed

8 files changed

+71
-10
lines changed

coffee/script.coffee

+9-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,9 @@
1-
$ ->
2-
$('h1').append('Hello')
1+
$list = $('#list')
2+
$('#add').click ->
3+
$li = $('<li class="animate">')
4+
$list.append $li
5+
$li.html 'test'
6+
return
7+
$('#remove').click ->
8+
$('#list li:last').remove()
9+
return

css/style.css

+10
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,12 @@
11
.test {
2+
color: red; }
3+
4+
.animate {
5+
transition-property: transform, color;
6+
transition-timing: ease-out;
7+
transition-duration: .3s;
8+
color: red; }
9+
10+
.animation:active {
11+
transform: scale(1.02);
212
color: blue; }

dist/all.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
alert("Hello");
1+
var $list;
2+
3+
$list = $('#list');
4+
5+
$('#add').click(function() {
6+
var $li;
7+
$li = $('<li class="animate">');
8+
$list.append($li);
9+
$li.html('test');
10+
});
11+
12+
$('#remove').click(function() {
13+
$('#list li:last').remove();
14+
});

dist/all.min.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gulpfile.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ gulp.task('sass', function() {
2929
gulp.task('coffee', function() {
3030
gulp.src('coffee/*.coffee')
3131
.pipe(coffee({bare: true}))
32-
.on('error', gutil.log)
33-
.pipe(gulp.dest('scripts'));
32+
.pipe(gulp.dest('js'));
3433
});
3534

3635
// Concatenate & Minify JS
@@ -47,12 +46,13 @@ gulp.task('scripts', function() {
4746
// Watch Files For Changes
4847
gulp.task('watch', function() {
4948
livereload.listen();
49+
gulp.watch('coffee/*.coffee', ['coffee']);
5050
gulp.watch('js/*.js', ['lint', 'scripts']);
51-
gulp.watch('scss/*.scss', ['sass']);
5251
gulp.watch('*.html', function(e){
5352
livereload.changed(e.path);
5453
});
54+
gulp.watch('scss/*.scss', ['sass']);
5555
});
5656

5757
// Default Task
58-
gulp.task('default', ['lint', 'sass', 'scripts', 'watch']);
58+
gulp.task('default', ['lint', 'sass', 'coffee', 'scripts', 'watch']);

index.html

+7-1
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,15 @@
44
<title>Bootstrap 101 Template</title>
55
<meta name="viewport" content="width=device-width, initial-scale=1.0">
66
<link rel="stylesheet" type="text/css" href="css/style.css">
7+
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.0.2/jquery.min.js"></script>
78
</head>
89
<body>
910
<h1 class="test">Hello, world!</h1>
10-
<script src="js/script.js"></script>
11+
<ul id="list">
12+
<li class='animate'>test</li>
13+
</ul>
14+
<input type="button" value="add" id="add">
15+
<input type="button" value="remove" id="remove">
16+
<script src="dist/all.min.js"></script>
1117
</body>
1218
</html>

js/script.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,14 @@
1-
alert("Hello");
1+
var $list;
2+
3+
$list = $('#list');
4+
5+
$('#add').click(function() {
6+
var $li;
7+
$li = $('<li class="animate">');
8+
$list.append($li);
9+
$li.html('test');
10+
});
11+
12+
$('#remove').click(function() {
13+
$('#list li:last').remove();
14+
});

scss/style.scss

+12
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
.test{
2+
color: red;
3+
}
4+
5+
.animate{
6+
transition-property: transform, color;
7+
transition-timing: ease-out;
8+
transition-duration: .3s;
9+
color: red;
10+
}
11+
12+
.animation:active{
13+
transform: scale(1.02);
214
color: blue;
315
}

0 commit comments

Comments
 (0)