Skip to content

Commit 422cab0

Browse files
committed
Merge branch 'master' into gh-pages
Conflicts: LICENSE-MIT demo/bbq-fixed.html demo/bbq.html demo/index.html index.html jquery.smooth-scroll.js jquery.smooth-scroll.min.js lib/jquery/jquery.js readme.md src/jquery.smooth-scroll.js
2 parents 3662175 + 8cd0908 commit 422cab0

23 files changed

+1634
-321
lines changed

.editorconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
end_of_line = lf
7+
trim_trailing_whitespace = true
8+
insert_final_newline = true
9+
10+
[lib/jquery/**.js]
11+
indent_style = tab
12+
indent_size = 4
13+
14+
[lib/qunit/**.js]
15+
indent_style = tab
16+
indent_size = 4

.npmignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
demo
2+
node_modules
3+
lib
4+
bower.json
5+
smooth-scroll.jquery.json

Gruntfile.js

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
/*global module:false*/
2+
3+
module.exports = function(grunt) {
4+
5+
var marked = require('marked');
6+
var hl = require('node-syntaxhighlighter');
7+
8+
marked.setOptions({
9+
highlight: function(code, lang) {
10+
lang = lang || 'javascript';
11+
lang = hl.getLanguage(lang);
12+
13+
return hl.highlight(code, lang);
14+
},
15+
gfm: true
16+
});
17+
18+
// Project configuration.
19+
grunt.initConfig({
20+
pluginName: 'smooth-scroll',
21+
bower: './bower.json',
22+
pkg: grunt.file.readJSON('package.json'),
23+
meta: {
24+
banner: '/*!<%= "\\n" %>' +
25+
' * <%= pkg.title %> - v<%= pkg.version %> - ' +
26+
'<%= grunt.template.today("yyyy-mm-dd") + "\\n" %>' +
27+
'<%= pkg.homepage ? " * " + pkg.homepage + "\\n" : "" %>' +
28+
' * Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>' +
29+
'<%= "\\n" %>' +
30+
' * Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %>' +
31+
' (<%= _.pluck(pkg.licenses, "url").join(", ") %>)' +
32+
'<%= "\\n" %>' + ' */' +
33+
'<%= "\\n\\n" %>'
34+
},
35+
concat: {
36+
all: {
37+
src: ['src/jquery.<%= pluginName %>.js'],
38+
dest: 'jquery.<%= pluginName %>.js'
39+
},
40+
options: {
41+
stripBanners: true,
42+
banner: '<%= meta.banner %>',
43+
process: function(src) {
44+
var umdHead = grunt.file.read('lib/tmpl/umdhead.tpl'),
45+
umdFoot = grunt.file.read('lib/tmpl/umdfoot.tpl');
46+
47+
src = src
48+
.replace('(function($) {', umdHead)
49+
.replace('})(jQuery);', umdFoot);
50+
51+
return src;
52+
}
53+
}
54+
},
55+
uglify: {
56+
all: {
57+
files: {
58+
'jquery.<%= pluginName %>.min.js': ['<%= concat.all.dest %>']
59+
},
60+
options: {
61+
preserveComments: 'some'
62+
}
63+
}
64+
},
65+
watch: {
66+
scripts: {
67+
files: '<%= jshint.all %>',
68+
tasks: ['jshint:all']
69+
},
70+
docs: {
71+
files: ['readme.md', 'lib/tmpl/**/*.html'],
72+
tasks: ['docs']
73+
}
74+
75+
},
76+
jshint: {
77+
all: ['Gruntfile.js', 'src/**/*.js'],
78+
options: {
79+
curly: true,
80+
eqeqeq: true,
81+
unused: true,
82+
immed: true,
83+
latedef: true,
84+
newcap: true,
85+
noarg: true,
86+
sub: true,
87+
undef: true,
88+
boss: true,
89+
eqnull: true,
90+
browser: true,
91+
globals: {
92+
jQuery: true,
93+
require: false
94+
}
95+
}
96+
},
97+
version: {
98+
patch: {
99+
src: [
100+
'package.json',
101+
'<%= pluginName %>.jquery.json',
102+
'bower.json',
103+
'src/jquery.<%= pluginName %>.js',
104+
'jquery.<%= pluginName %>.js'
105+
],
106+
options: {
107+
release: 'patch'
108+
}
109+
},
110+
same: {
111+
src: ['package.json', 'src/jquery.<%= pluginName %>.js', 'jquery.<%= pluginName %>.js']
112+
},
113+
bannerPatch: {
114+
src: ['jquery.<%= pluginName %>.js'],
115+
options: {
116+
prefix: '- v',
117+
release: 'patch'
118+
}
119+
}
120+
}
121+
});
122+
123+
grunt.registerTask( 'configs', 'Update json configs based on package.json', function() {
124+
var pkg = grunt.file.readJSON('package.json'),
125+
pkgBasename = grunt.config('pluginName'),
126+
bowerFile = grunt.config('bower'),
127+
bower = grunt.file.readJSON(bowerFile),
128+
jqConfigFile = pkgBasename + '.jquery.json',
129+
jqConfig = grunt.file.readJSON(jqConfigFile);
130+
131+
['main', 'version', 'dependencies', 'keywords'].forEach(function(el) {
132+
bower[el] = pkg[el];
133+
jqConfig[el] = pkg[el];
134+
});
135+
136+
['author', 'repository', 'homepage', 'docs', 'bugs', 'demo', 'licenses'].forEach(function(el) {
137+
jqConfig[el] = pkg[el];
138+
});
139+
140+
jqConfig.keywords.shift();
141+
142+
jqConfig.name = pkgBasename;
143+
bower.name = 'jquery-' + pkgBasename;
144+
145+
grunt.file.write( bowerFile, JSON.stringify(bower, null, 2) + '\n');
146+
grunt.log.writeln( 'File "' + bowerFile + '" updated."' );
147+
148+
while ( /jquery/i.test(jqConfig.keywords[0]) ) {
149+
jqConfig.keywords.shift();
150+
}
151+
152+
grunt.file.write( jqConfigFile, JSON.stringify(jqConfig, null, 2) + '\n');
153+
grunt.log.writeln( 'File "' + jqConfigFile + '" updated."' );
154+
});
155+
156+
grunt.registerTask('docs', 'Convert readme.md to html and concat with header and footer for index.html', function() {
157+
var readme = grunt.file.read('readme.md'),
158+
head = grunt.template.process( grunt.file.read('lib/tmpl/header.tpl') ),
159+
foot = grunt.file.read('lib/tmpl/footer.tpl'),
160+
doc = marked(readme);
161+
162+
grunt.file.write('index.html', head + doc + foot);
163+
});
164+
165+
grunt.registerTask('build', ['jshint', 'concat', 'version:same', 'configs', 'uglify', 'docs']);
166+
grunt.registerTask('patch', ['jshint', 'concat', 'version:bannerPatch', 'version:patch', 'configs', 'uglify']);
167+
grunt.registerTask('default', ['build']);
168+
169+
grunt.loadNpmTasks('grunt-contrib-jshint');
170+
grunt.loadNpmTasks('grunt-contrib-uglify');
171+
grunt.loadNpmTasks('grunt-contrib-concat');
172+
grunt.loadNpmTasks('grunt-contrib-watch');
173+
grunt.loadNpmTasks('grunt-version');
174+
};

LICENSE-MIT

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
Copyright (c) 2012 Karl Swedberg
2-
31
Permission is hereby granted, free of charge, to any person
42
obtaining a copy of this software and associated documentation
53
files (the "Software"), to deal in the Software without

bower.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "jquery-smooth-scroll",
3+
"version": "1.5.5",
4+
"dependencies": {
5+
"jquery": ">=1.3"
6+
},
7+
"main": "jquery.smooth-scroll.js",
8+
"ignore": [
9+
"demo/",
10+
"lib/",
11+
"src/",
12+
"Gruntfile.js",
13+
"package.json",
14+
"smooth-scroll.jquery.json"
15+
],
16+
"keywords": [
17+
"jquery-plugin",
18+
"scroll",
19+
"animation"
20+
]
21+
}

demo/bbq-fixed.html

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616
}
1717
#nav {
1818
position: fixed;
19-
margin-left: -200px
19+
margin-left: -200px;
20+
width: 140px;
2021
}
2122
</style>
2223
</head>
@@ -34,25 +35,24 @@ <h2>Smooth Scroll jQuery Plugin with Back Button Support</h2>
3435
</ul>
3536
<p id="p1">p1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
3637
<p id="p2">p2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
37-
<a href="#nav">back to nav</a>
38+
3839
<p id="p3">p3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
39-
<a href="#nav">back to nav</a>
40+
4041
<p id="p4">p4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
41-
<a href="#nav">back to nav</a>
42+
4243
<p id="p5">p5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
43-
<a href="#nav">back to nav</a>
44+
4445
<p id="p6">p6 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
45-
<a href="#nav">back to nav</a>
46+
4647

4748
</div>
48-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
49-
<script>!window.jQuery && document.write(unescape('%3Cscript src="../lib/jquery/jquery.js"%3E%3C/script%3E'));</script>
49+
<script src="../lib/jquery/jquery.js"></script>
5050
<script src="../src/jquery.smooth-scroll.js"></script>
5151
<script src="../lib/jquery.ba-bbq.js"></script>
5252
<script>
5353
$(document).ready(function() {
5454

55-
$('a[href*="#"]').live('click', function() {
55+
$(document).on('click', 'a[href*="#"]', function() {
5656
var slashedHash = '#/' + this.hash.slice(1);
5757
if ( this.hash ) {
5858

@@ -67,7 +67,6 @@ <h2>Smooth Scroll jQuery Plugin with Back Button Support</h2>
6767
});
6868

6969
$(window).bind('hashchange', function(event) {
70-
console.log('hashchange');
7170
var tgt = location.hash.replace(/^#\/?/,'');
7271
if ( document.getElementById(tgt) ) {
7372
$.smoothScroll({scrollTarget: '#' + tgt});

demo/bbq.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ <h2>Smooth Scroll jQuery Plugin with Back Button Support</h2>
2525
<li><a href="#p3">p3</a></li>
2626
<li><a href="#p4">p4</a></li>
2727
<li><a href="#p5">p5</a></li>
28+
<li><a href="index.html#p5">index.html#p5</a> (goes to new page)</li>
2829
<li><a href="#">#</a></li>
30+
2931
<li><a href="#not-here">not-here</a></li>
3032
</ul>
3133
<p id="p1">p1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
@@ -41,20 +43,18 @@ <h2>Smooth Scroll jQuery Plugin with Back Button Support</h2>
4143
<a href="#nav">back to nav</a>
4244

4345
</div>
44-
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
45-
<script>!window.jQuery && document.write(unescape('%3Cscript src="../lib/jquery/jquery.js"%3E%3C/script%3E'));</script>
46+
<script src="../lib/jquery/jquery.js"></script>
4647
<script src="../src/jquery.smooth-scroll.js"></script>
4748
<script src="../lib/jquery.ba-bbq.js"></script>
4849
<script>
49-
$(document).ready(function() {
50-
51-
$('a[href*="#"]').live('click', function() {
52-
if ( this.hash ) {
53-
$.bbq.pushState( '#/' + this.hash.slice(1) );
54-
return false;
55-
}
56-
});
57-
50+
$(document)
51+
.on('click', 'a[href*="#"]', function() {
52+
if ( this.hash && this.pathname === location.pathname ) {
53+
$.bbq.pushState( '#/' + this.hash.slice(1) );
54+
return false;
55+
}
56+
})
57+
.ready(function() {
5858
$(window).bind('hashchange', function(event) {
5959
var tgt = location.hash.replace(/^#\/?/,'');
6060
if ( document.getElementById(tgt) ) {

0 commit comments

Comments
 (0)