Skip to content

Commit

Permalink
all: fix smoothscroll in safari6 with jquery plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspark committed Mar 15, 2013
1 parent 9d91657 commit d3a35fc
Show file tree
Hide file tree
Showing 17 changed files with 23 additions and 52 deletions.
1 change: 1 addition & 0 deletions amelia/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions cerulean/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions cosmo/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions cyborg/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions default/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,7 @@ <h3>Base Admin</h3>


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="js/jquery.smooth-scroll.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootswatch.js"></script>
<script type="text/javascript">
Expand Down
1 change: 1 addition & 0 deletions journal/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
53 changes: 1 addition & 52 deletions js/bootswatch.js
Original file line number Diff line number Diff line change
@@ -1,61 +1,10 @@
// tooltips

$('a[rel=tooltip]').tooltip({
'placement': 'bottom'
});

// smooth scroll

$(document).ready(function() {
function filterPath(string) {
return string
.replace(/^\//,'')
.replace(/(index|default).[a-zA-Z]{3,4}$/,'')
.replace(/\/$/,'');
}
var locationPath = filterPath(location.pathname);
var scrollElem = scrollableElement('html', 'body');

$('a[href^=#]').each(function() {
var thisPath = filterPath(this.pathname) || locationPath;
if ( locationPath == thisPath
&& (location.hostname == this.hostname || !this.hostname)
&& this.hash.replace(/#/,'') ) {
var $target = $(this.hash), target = this.hash;
if (target) {
var targetOffset = $target.offset().top;
$(this).click(function(event) {
event.preventDefault();
$(scrollElem).animate({scrollTop: targetOffset}, 400, function() {
location.hash = target;
});
});
}
}
});

// use the first element that is "scrollable"
function scrollableElement(els) {
for (var i = 0, argLength = arguments.length; i <argLength; i++) {
var el = arguments[i],
$scrollElement = $(el);
if ($scrollElement.scrollTop()> 0) {
return el;
} else {
$scrollElement.scrollTop(1);
var isScrollable = $scrollElement.scrollTop()> 0;
$scrollElement.scrollTop(0);
if (isScrollable) {
return el;
}
}
}
return [];
}

});
$('.subnav a').smoothScroll();

// subnav

(function ($) {

Expand Down
7 changes: 7 additions & 0 deletions js/jquery.smooth-scroll.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions readable/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions shamrock/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions simplex/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions slate/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions spacelab/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions spruce/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions superhero/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -890,6 +890,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down
1 change: 1 addition & 0 deletions united/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,7 @@ <h4 class="alert-heading">Alert block</h4>
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="../js/jquery.smooth-scroll.min.js"></script>
<script src="../js/bootstrap.min.js"></script>
<script src="../js/bootswatch.js"></script>

Expand Down

0 comments on commit d3a35fc

Please sign in to comment.