namibia
c449ac80b48405f72fd700d5cd406397b3a17d8a
namibia / public / js / app / controller.js
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 |
;(function(){ _App.Controller = function( args ) { this.initialize( args ); }; _App.Controller.prototype = { initialize : function( args ) { for( var key in args ) { this[key] = args[key]; } this.getElems(); this.setupScrollListener(); }, getElems : function() { this.$_head = $('head'); this.$_body = $('body'); this.$_htmlBody = $('html, body'); this.$_navAnchors = $('#Header .nav a').map( function(i, a){ return $(a); }); }, changePage : function( pageName ) { App.Event.trigger('Controller.LoadingTemplate:' + pageName, {"pageName": pageName}); var prevPage = this.currentPage; this.currentPage = pageName || ''; this.$_el.addClass('loading'); //this.$_body.attr('id', this.currentPage.capitalize() + 'Page' ); this.$_navAnchors.each(function(i, $_a) { if ( $_a.attr('href') == window.location.hash ) { $_a.addClass('active'); } else { $_a.removeClass('active'); } }); $('div.hero-nav').remove(); App.activePage = false; if (_t[prevPage]) { App.Event.trigger('Controller.RemovingPage:' + prevPage, {"pageName": prevPage}); _t[prevPage].remove(); $('#PageContent').removeClass(prevPage); } App.Template.register( pageName, "page", pageName, 'PageContent', {}, $.proxy( this.renderPage, this ) ); }, renderPage : function( id, pageName ) { _t[pageName].publish(); App.Event.trigger( 'Controller.Published:' + pageName, {"id": "page", "pageName": pageName} ); this.$_el.removeClass('loading'); this.$_htmlBody.animate({ 'scrollTop' : 0 }, 250); $('#PageContent').addClass(pageName); App.activePage = pageName; }, setupScrollListener : function() { $(window).on('scroll', function() { if ( $(window).scrollTop() > 50 ) { $('#Header').addClass('compressed'); } else { $('#Header').removeClass('compressed'); } }); } }; })(); |
Commits for namibia/public/js/app/controller.js
Revision | Author | Commited | Message |
---|---|---|---|
df0489 ... | Mark | Fri 14 Oct, 2016 10:01:00 +0000 | initial commit |