-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfullstack.js
More file actions
204 lines (165 loc) · 5.59 KB
/
fullstack.js
File metadata and controls
204 lines (165 loc) · 5.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
/*
* Project: Full Stack Foundry
* Description: Napkin stage talent, tools, and capital in Vancouver, BC.
* Author: Shawn Adrian <shawn@nerdburn.com> | Input Logic Inc.
*
*/
(function($, window, document){
// options
var opts = {
url: $.url() // a jquery plugin for working with urls
};
// namespace rawr
function Fullstack() {
this.init();
this.route();
}
/*
INIT
- sets up page options and calls router
*/
Fullstack.prototype.init = function() {
var self = this;
}
/*
ROUTE
- execute different js based on the real URL
*/
Fullstack.prototype.route = function() {
var self = this;
//console.log(opts.url.attr('path'));
// home page
crossroads.addRoute('/', function(){
// initiate map + scrolling stuff
self.initMap();
self.initScrolling();
});
// temporary home page
crossroads.addRoute('/index-template.html', function(){
// initiate map + scrolling stuff
self.initMap();
self.initScrolling();
});
// blog pages
crossroads.addRoute('/post.html', function(){
self.initBlog();
});
// initiate route detection - use url.js to get current path
crossroads.parse(opts.url.attr('path'));
// init footer (stuff for all pages)
self.initFooter();
}
/*
INIT BLOG
*/
Fullstack.prototype.initBlog = function() {
var self = this;
// disable links that don't go anywhere yet
$('a[href="#"]').live('click', function(e){
e.preventDefault();
alert("This link doesn't work yet, sorry.");
});
// disable subscribe form for now
$('form.subscribe').submit(function(e){
e.preventDefault();
alert("Sorry, subscribe isn't working yet.");
});
}
/*
INIT SCROLLING
- sets up the hiding nav on scroll and scrolling on nav click
*/
Fullstack.prototype.initScrolling = function() {
var self = this;
// hide header until ready for showing
$('header').hide();
$(window).scroll(function(){
if($(window).scrollTop() >= 672){
$("header").slideDown("fast");
$('header').removeClass('hide').addClass('show');
}
});
$(window).scroll(function(){
if($(window).scrollTop() < 672){
$("header").slideUp("fast");
}
});
$(document).ready(function(){
$('ul.jsnav a, ul.poly-links a, a.jslink').bind('click',function(e){
e.preventDefault();
var id = $(this).attr('href');
var el = $(id);
var top = el.offset().top;
$('html, body').stop().animate({
scrollTop: top
}, 750, 'easeInOutExpo');
});
$('a.home-link').bind('click', function(e){
e.preventDefault();
$('html, body').stop().animate({
scrollTop: 0
}, 750, 'easeInOutExpo');
});
});
}
/*
INIT MAP
- used on contact page
*/
Fullstack.prototype.initMap = function() {
var self = this;
// Create map
var map = mapbox.map('map', null, null, []);
map.addLayer(mapbox.layer().id('nerdburn.map-1qedyuol'));
// Create and add marker layer
var markerLayer = mapbox.markers.layer().features([{
"geometry": { "type": "Point", "coordinates": [-123.103423, 49.28247]},
"properties": { "image": "images/marker.png" }
}]).factory(function(f) {
// Define a new factory function. This takes a GeoJSON object
// as its input and returns an element - in this case an image -
// that represents the point.
var img = document.createElement('img');
img.className = 'marker-image';
img.setAttribute('src', f.properties.image);
return img;
});
map.addLayer(markerLayer).setExtent(markerLayer.extent());
map.centerzoom({lat: 49.28247, lon: -123.103423 }, 16);
}
/*
INIT FOOTER
- used on all pages
*/
Fullstack.prototype.initFooter = function() {
var self = this;
$(document).ready(function(){
// make form subscribe work
$('a.subscribe-btn').click(function(e){
e.preventDefault();
$(this).closest('form.subscribe').submit();
});
// make footer fixed on bigass screens
var winHeight = $(window).height();
var footer = $('footer');
var fpos = footer.position();
var fbottom = fpos.top + footer.height();
if(fbottom < winHeight)
{
footer.css({
'position': 'fixed',
'bottom': '0px',
'left': '0px',
'width': '100%'
});
}
// fix firefox positioning on hex elements
if($.browser.mozilla == true)
{
$('span.hex span.ss-icon').css({ 'padding-top': '33px' });
$('a.angel-logo').css({ 'top': '9px' });
}
});
}
window.Fullstack = new Fullstack;
})($, window, document);