Skip to content

Commit

Permalink
resolved merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
cew821 committed Aug 12, 2014
2 parents edf29e7 + 68cce92 commit b48f1bb
Show file tree
Hide file tree
Showing 6 changed files with 205 additions and 92 deletions.
2 changes: 1 addition & 1 deletion assets/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
display: inline;
padding: 0;
list-style-position: outside; }
#navigation_bar .active_play a {
#navigation_bar .active a {
background: #3a96b7;
color: white;
text-decoration: none; }
Expand Down
169 changes: 169 additions & 0 deletions assets/js/scrollspy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
/* ========================================================================
* Bootstrap: scrollspy.js v3.2.0
* http://getbootstrap.com/javascript/#scrollspy
* ========================================================================
* Copyright 2011-2014 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */


+function ($) {
'use strict';

// SCROLLSPY CLASS DEFINITION
// ==========================

function ScrollSpy(element, options) {
var process = $.proxy(this.process, this)

this.$body = $('body')
this.$scrollElement = $(element).is('body') ? $(window) : $(element)
this.options = $.extend({}, ScrollSpy.DEFAULTS, options)
this.selector = (this.options.target || '') + ' .nav li > a'
this.offsets = []
this.targets = []
this.activeTarget = null
this.scrollHeight = 0

this.$scrollElement.on('scroll.bs.scrollspy', process)
this.refresh()
this.process()
}

ScrollSpy.VERSION = '3.2.0'

ScrollSpy.DEFAULTS = {
offset: 10
}

ScrollSpy.prototype.getScrollHeight = function () {
return this.$scrollElement[0].scrollHeight || Math.max(this.$body[0].scrollHeight, document.documentElement.scrollHeight)
}

ScrollSpy.prototype.refresh = function () {
var offsetMethod = 'offset'
var offsetBase = 0

if (!$.isWindow(this.$scrollElement[0])) {
offsetMethod = 'position'
offsetBase = this.$scrollElement.scrollTop()
}

this.offsets = []
this.targets = []
this.scrollHeight = this.getScrollHeight()

var self = this
this.$body
.find(this.selector)
.map(function () {
var $el = $(this)
var href = $el.data('target') || $el.attr('href')
var $href = /^#./.test(href) && $(href)
return ($href
&& $href.length
// HACK - allow for invisible targets
// && $href.is(':visible')
&& [[$href[offsetMethod]().top + offsetBase, href]]) || null
})
.sort(function (a, b) { return a[0] - b[0] })
.each(function () {
self.offsets.push(this[0])
self.targets.push(this[1])
})
}

ScrollSpy.prototype.process = function () {
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
var scrollHeight = this.getScrollHeight()
var maxScroll = this.options.offset + scrollHeight - this.$scrollElement.height()
var offsets = this.offsets
var targets = this.targets
var activeTarget = this.activeTarget
var i

if (this.scrollHeight != scrollHeight) {
this.refresh()
}

if (scrollTop >= maxScroll) {
return activeTarget != (i = targets[targets.length - 1]) && this.activate(i)
}

if (activeTarget && scrollTop <= offsets[0]) {
return activeTarget != (i = targets[0]) && this.activate(i)
}

for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
&& this.activate(targets[i])
}
}

ScrollSpy.prototype.activate = function (target) {
this.activeTarget = target

$(this.selector)
.parentsUntil(this.options.target, '.active')
.removeClass('active')

var selector = this.selector +
'[data-target="' + target + '"],' +
this.selector + '[href="' + target + '"]'

var active = $(selector)
.parents('li')
.addClass('active')

if (active.parent('.dropdown-menu').length) {
active = active
.closest('li.dropdown')
.addClass('active')
}

active.trigger('activate.bs.scrollspy')
}


// SCROLLSPY PLUGIN DEFINITION
// ===========================

function Plugin(option) {
return this.each(function () {
var $this = $(this)
var data = $this.data('bs.scrollspy')
var options = typeof option == 'object' && option

if (!data) $this.data('bs.scrollspy', (data = new ScrollSpy(this, options)))
if (typeof option == 'string') data[option]()
})
}

var old = $.fn.scrollspy

$.fn.scrollspy = Plugin
$.fn.scrollspy.Constructor = ScrollSpy


// SCROLLSPY NO CONFLICT
// =====================

$.fn.scrollspy.noConflict = function () {
$.fn.scrollspy = old
return this
}


// SCROLLSPY DATA-API
// ==================

$(window).on('load.bs.scrollspy.data-api', function () {
$('[data-spy="scroll"]').each(function () {
var $spy = $(this)
Plugin.call($spy, $spy.data())
})
})

}(jQuery);
74 changes: 31 additions & 43 deletions assets/js/site.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,39 @@
$(function(){
$(document).ready( function() {
var navBarHeight = $('#navigation_bar').height();
var showNavBarMinimum = $('#introduction').height() - navBarHeight;

if ( getCurrentScroll() >= showNavBarMinimum ) {
$('#navigation_bar').addClass('show');
}
var $navBar = $('#navigation_bar');
var showNavBarMinimum = $('#introduction').height() - $navBar.height();

$(window).scroll(function() {
var scroll = getCurrentScroll();
if ( scroll >= showNavBarMinimum ) {
$('#navigation_bar').addClass('show');
}
else {
$('#navigation_bar').removeClass('show');
}
});
function getCurrentScroll() {
return window.pageYOffset;
var wasNavBarVisible = false;
// change nav bar visibility on scroll
function onScroll() {
var isNavBarVisible = window.pageYOffset >= showNavBarMinimum;
if ( isNavBarVisible != wasNavBarVisible ) {
$navBar.toggleClass('show');
wasNavBarVisible = isNavBarVisible;
}
});
});
}
// initial check
onScroll();

$(function($) {
$(document).ready( function() {
$('#navigation_bar').stickUp({
parts: {
0: 'play1',
1: 'play2',
2: 'play3',
3: 'play4',
4: 'play5',
5: 'play6',
6: 'play7',
7: 'play8',
8: 'play9',
9: 'play10',
10: 'play11',
11: 'play12',
12: 'play13'
},
itemClass: 'play_square',
itemHover: 'active_play'
});
});
});
// http://davidwalsh.name/function-debounce
function debounce( fn, wait ) {
var timeout;
return function() {
var _this = this;
var args = arguments;
var later = function() {
timeout = null;
fn.apply( _this, args );
};
clearTimeout( timeout );
timeout = setTimeout( later, wait || 100 );
};
}

$(window).scroll( debounce( onScroll, 30 ) );

$('body').scrollspy({ target: '#navigation_bar' });

$(function() {
// Scroll Animations
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
Expand All @@ -60,4 +47,5 @@ $(function() {
}
}
});

});
1 change: 0 additions & 1 deletion assets/js/stickUp.min.js

This file was deleted.

47 changes: 2 additions & 45 deletions assets/sass/styles.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ $slimmer: new-breakpoint(min-width 641px max-width 980px 12);
list-style-position: outside;
}

.active_play {
.active {
a {
background: $miami_vice_blue;
color: $white;
Expand Down Expand Up @@ -524,51 +524,8 @@ $slimmer: new-breakpoint(min-width 641px max-width 980px 12);
// belongs-to: $jessica;
// display: forever;
// date: August 23, 2014;
// url: jandc2014.com;
//}

// #play_navigation {
// ul, ol {
// @include span-columns(12);
// }

// ul {
// padding: 0;
// list-style-position: outside;
// background: $background_white;
// }

// .active_play {
// a {
// background: $miami_vice_blue;
// color: $white;
// text-decoration: none;
// }
// }

// li {
// float: left;
// margin-right: 20px;
// list-style-type: none;
// a {
// display: inline-block;
// background: none;
// height: 40px;
// width: 40px;
// text-align: center;
// padding: 7px 0px;
// font-size: 18px;
// font-family: $sans-serif;
// color: $miami_vice_blue;
// border: 1px solid $miami_vice_blue;
// }

// a:hover {
// background: $miami_vice_blue;
// color: $white;
// text-decoration: none;
// }
// }
// }
}

@media print {
Expand Down
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="outer_container">
<div class="inner_container">
<a href="#introduction"><h4>U.S. Digital Services Playbook</h4></a>
<ul>
<ul class="nav">
{% for play in site.plays %}
<li class="play_square"><a href="#play{{ play.id }}" title="View Play {{ play.title }}">{{ play.id }}</a></li>
{% endfor %}
Expand Down Expand Up @@ -76,7 +76,7 @@ <h2>{{ play.title }}</h2>
</div>

<script src='{{site.baseurl}}/assets/js/jquery-1.11.1.min.js'></script>
<script src='{{site.baseurl}}/assets/js/stickUp.min.js'></script>
<script src='{{site.baseurl}}/assets/js/scrollspy.js'></script>
<script src='{{site.baseurl}}/assets/js/site.js'></script>
<script id="_fed_an_js_tag" type="text/javascript" src="{{site.baseurl}}/assets/js/federated-analytics.all.min.js?agency=GSA&sub-agency=OGP"></script>
</body>
Expand Down

0 comments on commit b48f1bb

Please sign in to comment.