diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-03-29 15:07:28 -0400 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-03-29 15:07:28 -0400 |
| commit | df6365f6716c8f39376299ccf69985e0111a6e52 (patch) | |
| tree | f462916403e10955aac652ecd33e5486d7576db3 /public/assets/js/lib | |
| parent | d10b0f598492d40b350bdc8905fb3d557c9c5349 (diff) | |
permalinking
Diffstat (limited to 'public/assets/js/lib')
| -rw-r--r-- | public/assets/js/lib/HeaderView.js | 2 | ||||
| -rw-r--r-- | public/assets/js/lib/NavView.js | 9 | ||||
| -rw-r--r-- | public/assets/js/lib/ProjectView.js | 20 | ||||
| -rw-r--r-- | public/assets/js/lib/SiteRouter.js | 31 |
4 files changed, 57 insertions, 5 deletions
diff --git a/public/assets/js/lib/HeaderView.js b/public/assets/js/lib/HeaderView.js index b568ecb..bc64d85 100644 --- a/public/assets/js/lib/HeaderView.js +++ b/public/assets/js/lib/HeaderView.js @@ -25,7 +25,7 @@ var HeaderView = View.extend({ }, toggleNav: function(){ - $('body').toggleClass('navopen'); + $('body').toggleClass('navopen') }, }) diff --git a/public/assets/js/lib/NavView.js b/public/assets/js/lib/NavView.js index 0ed1d4f..f3dd97d 100644 --- a/public/assets/js/lib/NavView.js +++ b/public/assets/js/lib/NavView.js @@ -11,6 +11,10 @@ var NavView = View.extend({ click: function(e){ var id = $(e.target).data("id") + this.pick(id) + }, + + pick: function(id){ var view = app.lookup[ id ] this.swap( view ) }, @@ -28,6 +32,11 @@ var NavView = View.extend({ }, swap: function(view) { + if (view && ! app.view) { + app.view = view + app.view.show() + return + } if (! view || app.view == view || app.view.showing) { return } diff --git a/public/assets/js/lib/ProjectView.js b/public/assets/js/lib/ProjectView.js index 02d7d4e..e735c81 100644 --- a/public/assets/js/lib/ProjectView.js +++ b/public/assets/js/lib/ProjectView.js @@ -1,13 +1,13 @@ var ProjectView = View.extend({ events: { - "click": "next", + "click": "nextOrCloseNav", "click .page-up": "previous", "click .page-down": "next", }, initialize: function(opt){ - this.gallery = new GalleryView () + // this.gallery = new GalleryView () this.project_id = this.$el.data("id") this.page_number = opt.page_number console.log("INIT", this.project_id) @@ -21,6 +21,13 @@ var ProjectView = View.extend({ app.header.updateSlideCount( 1 ) $('body').removeClass('navopen') this.$el.removeClass("hidden") + + if (this.project_id == "cover") { + app.router.pushState("/") + } + else { + app.router.pushState("/project/" + this.project_id) + } this.showing = true addClassForPeriod( this.el, "showing", 200, function(){ @@ -39,9 +46,14 @@ var ProjectView = View.extend({ app.nav.previous() }, - next: function(e){ + nextOrCloseNav: function(e){ e.stopPropagation() - app.nav.next() + if ($('body').hasClass('navopen')) { + $('body').removeClass('navopen') + } + else { + app.nav.next() + } }, }) diff --git a/public/assets/js/lib/SiteRouter.js b/public/assets/js/lib/SiteRouter.js new file mode 100644 index 0000000..7f1cec6 --- /dev/null +++ b/public/assets/js/lib/SiteRouter.js @@ -0,0 +1,31 @@ +var SiteRouter = Router.extend({ + + el: 'body', + routeByHash: false, + + routes: { + '/': 'home', + '/page/:id': 'project', + '/project/:id': 'project', + }, + + initial_route: null, + launch: function(){ + if (this.initial_route) { + this.parseRoute( this.initial_route ) + } + else { + this.route() + } + this.initial_route = null + }, + + home: function(){ + app.nav.pick("cover") + }, + + project: function(id){ + app.nav.pick(id) + }, + +})
\ No newline at end of file |
