summaryrefslogtreecommitdiff
path: root/public/assets/js/app.js
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2016-03-29 13:58:28 -0400
committerJules Laplace <jules@okfoc.us>2016-03-29 14:12:52 -0400
commita4a29d5d1b9f590db297ebeb1031f616aa536d4c (patch)
treec93c2697673dc1e931689982eaa75344e8d00f37 /public/assets/js/app.js
parent986eb5cbb2895adc310b301837df798ad47d2460 (diff)
extremely basic nav
Diffstat (limited to 'public/assets/js/app.js')
-rw-r--r--public/assets/js/app.js97
1 files changed, 45 insertions, 52 deletions
diff --git a/public/assets/js/app.js b/public/assets/js/app.js
index 13017f6..4c06729 100644
--- a/public/assets/js/app.js
+++ b/public/assets/js/app.js
@@ -1,16 +1,29 @@
var app = (function() {
var app = {}
+ app.iscroll_options = {
+ mouseWheel: true,
+ scrollbars: true,
+ click: is_android,
+ }
+
+ app.flickity_options = {
+ cellAlign: 'left',
+ contain: true,
+ pageDots: false,
+ wrapAround: true,
+ arrowShape: {
+ x0: 10,
+ x1: 35, y1: 25,
+ x2: 40, y2: 25,
+ x3: 15
+ }
+ }
+
app.init = function() {
app.bind()
app.build()
app.ready()
-
- app.iscroll_options = {
- mouseWheel: true,
- scrollbars: true,
- click: is_android,
- }
}
app.bind = function() {
@@ -20,17 +33,25 @@ var app = (function() {
})
FastClick.attach(document.body)
}
+
+ $(window).resize(app.resize)
}
app.build = function(data) {
+
+ app.header = new HeaderView()
+ app.nav = new NavView()
+
var items = $(".item")
app.lookup = {}
- app.projects = items.toArray().map(function(el){
- var view = new ProjectView ({ el: el })
+ app.projects = items.toArray().map(function(el, i){
+ var view = new ProjectView ({
+ el: el,
+ page_number: i,
+ })
app.lookup[ view.project_id ] = view
return view
})
- app.nav = new NavView()
}
app.ready = function() {
@@ -43,56 +64,28 @@ var app = (function() {
console.log("launched")
}
+
+ app.resize = function(){
+ $(".cell, .next, .previous").css({ 'display': 'none' })
+ $('body').addClass('resizing')
+ debounce(function() {
+ $(".cell, .next, .previous").css({ 'height': ($(".top").height() + 'px'), 'display': 'inline-block' })
+ $('.top').flickity('resize')
+ $('body').removeClass('resizing')
+ }, 400)
+ }
return app
})()
-$(".cell, .next").css({ 'height': ($(".top").height() + 'px') });
+$(".cell, .next").css({ 'height': ($(".top").height() + 'px') })
-$('.top').flickity({
- cellAlign: 'left',
- contain: true,
- pageDots: false,
- wrapAround: true,
- arrowShape: {
- x0: 10,
- x1: 35, y1: 25,
- x2: 40, y2: 25,
- x3: 15
- }
-}).on( 'cellSelect', function(e) {
+$('.top').flickity(app.flickity_options).on( 'cellSelect', function(e) {
var gallery = $(e.target).data('flickity')
- $(".slide-no").html(gallery.selectedIndex + 1)
+ app.header.updateSlideNumber( gallery.selectedIndex )
})
-$(".previous, .next").css({ 'height': ($(".top").height() + 'px') });
-
-$('.index').click(function() {
- $('body').toggleClass('navopen');
-});
-
-$('.item').click( function(){
- $('body').removeClass('navopen');
-});
-
-
-var delay = (function() {
- var timer = 0;
- return function(callback, ms) {
- clearTimeout(timer);
- timer = setTimeout(callback, ms);
- };
-})();
-
-$(window).resize(function() {
- $(".cell, .next, .previous").css({ 'display': 'none' });
- $('body').addClass('resizing');
- delay(function() {
- $(".cell, .next, .previous").css({ 'height': ($(".top").height() + 'px'), 'display': 'inline-block' });
- $('.top').flickity('resize');
- $('body').removeClass('resizing');
- }, 400);
-})
+$(".previous, .next").css({ 'height': ($(".top").height() + 'px') })
-// app.init()
+app.init()