diff options
| author | Jules Laplace <jules@okfoc.us> | 2016-11-28 18:12:34 -0500 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2016-11-28 18:12:34 -0500 |
| commit | ec41dd9dcc8e9af0d108297c6cfcfcef43d0d105 (patch) | |
| tree | ec9569f69a6420e965661b3c03c252b4212c99f2 /new-reality/public/assets/js/lib/nav | |
| parent | 2860b0ceae8e08704996b3397fb8b962ca60ab95 (diff) | |
new reality co
Diffstat (limited to 'new-reality/public/assets/js/lib/nav')
| -rw-r--r-- | new-reality/public/assets/js/lib/nav/DesktopNav.js | 83 | ||||
| -rw-r--r-- | new-reality/public/assets/js/lib/nav/MobileNav.js | 32 |
2 files changed, 115 insertions, 0 deletions
diff --git a/new-reality/public/assets/js/lib/nav/DesktopNav.js b/new-reality/public/assets/js/lib/nav/DesktopNav.js new file mode 100644 index 0000000..24f0f25 --- /dev/null +++ b/new-reality/public/assets/js/lib/nav/DesktopNav.js @@ -0,0 +1,83 @@ +var NavView = View.extend({ + + el: "#nav", + + events: { + "click .logo": "home", + "click li": "go", + "click #corner": "corner", + "mouseenter ul": "show_menu", + "mouseleave ul": "hide_menu", + }, + + initialize: function(){ + }, + + home: function(){ + app.router.go("/") + this.$headings.find(".active").removeClass("active") + if (app.mobile_nav && app.mobile_nav.state.open) { + app.mobile_nav.hamburger() + } + }, + + resetWidths: function(){ + this.$categories.each(function(){ + $(this).width( $(this).data("width") ) + }) + }, + + go: function(e){ + e.preventDefault() + + this.resetWidths() + + var $t = $(e.currentTarget) + this.$("li").removeClass("active") + $t.addClass("active") + + var href = $t.attr("href") + app.router.go(href) + if (is_mobile) { + app.mobile_nav.hamburger() + } + this.after_go() + }, + + after_go: function(){ + + }, + + setActive: function(id){ + var href = '/' + id + var $el = $('[href="' + href + '"]') + this.$('.active').removeClass('active') + if ($el.length) { + $el.addClass('active') + } + }, + + show_menu: function(e){ + var $el = $(e.currentTarget) + $el.addClass("hover") + + // var $parent = $el.parent() + var width = $el.data( "width" ) + $el.width(width) + console.log(width) + }, + + hide_menu: function(e){ + var $el = $(e.currentTarget) + $el.removeClass("hover") + + // var $parent = $el.parent() + var hover_width = $el.data( "hover-width" ) + $el.width(hover_width) + }, + + corner: function(){ + app.view && app.view.corner() + }, + +}); diff --git a/new-reality/public/assets/js/lib/nav/MobileNav.js b/new-reality/public/assets/js/lib/nav/MobileNav.js new file mode 100644 index 0000000..aec7090 --- /dev/null +++ b/new-reality/public/assets/js/lib/nav/MobileNav.js @@ -0,0 +1,32 @@ +var MobileNav = View.extend({ + + el: '#mobile_nav', + + events: { + 'touchstart .logo': 'home', + 'touchstart .hamburger': 'hamburger' + }, + + initialize: function(options){ + options = options || {} + this.state = { + open: false + } + }, + + home: function (){ + app.nav.home() + }, + + hamburger: function (e){ + $('html').toggleClass('navopen') + app.mobile_nav.state.open = ! app.mobile_nav.state.open + if (app.mobile_nav.state.open) { + $(".page-set").on("click", app.mobile_nav.hamburger) + } + else { + $(".page-set").off("click", app.mobile_nav.hamburger) + } + }, + +}) |
