41 lines
1.3 KiB
JavaScript
41 lines
1.3 KiB
JavaScript
module.exports = {
|
|
forceHidden: true,
|
|
initialize: function(options) {
|
|
this.listenTo(this.app.router, 'route', this.onRouteChange);
|
|
this.onRouteChange(null,window.location.pathname.split("/").slice(1))
|
|
},
|
|
attach: function() {
|
|
var thisView = this;
|
|
$(window).scroll(function(e){
|
|
if(window.location.pathname.indexOf('services') == -1){return thisView.$el.removeClass('fixed')}
|
|
if(window.innerHeight > 900){thisView.plussy=60}else{thisView.plussy=0;}
|
|
var $sts = $('.snap-top-static');
|
|
|
|
if(!thisView.forceHidden && ($sts.length == 0 || $sts.offset().top < window.pageYOffset+thisView.plussy)){
|
|
thisView.$el.addClass('fixed')
|
|
$sts.addClass('hidden')
|
|
}
|
|
else {
|
|
thisView.$el.removeClass('fixed')
|
|
$sts.removeClass('hidden')
|
|
}
|
|
});
|
|
$(window).trigger('scroll');
|
|
},
|
|
onRouteChange: function(route, params) {
|
|
console.log("Params", params)
|
|
if((params[0] || "/").indexOf('services') == -1){
|
|
this.forceHidden = true;
|
|
this.$el.removeClass('fixed')
|
|
}else{
|
|
this.forceHidden = false;
|
|
if(params[0] == 'services/integration' || params[0] == 'services/security' || params[0] == 'services/entertainment'){
|
|
var thisView = this;
|
|
setTimeout(function(){thisView.$el.addClass('fixed')},500)
|
|
}else{
|
|
this.$el.removeClass('fixed')
|
|
}
|
|
}
|
|
}
|
|
};
|