Skip to content

Instantly share code, notes, and snippets.

@ShawnOakley
Created March 5, 2014 21:05
Show Gist options
  • Save ShawnOakley/9376558 to your computer and use it in GitHub Desktop.
Save ShawnOakley/9376558 to your computer and use it in GitHub Desktop.
Window resize function using height variable
CRM.module("DashboardApp.Show", function(Show, CRM, Backbone, Marionette, $, _){
Show.Dashboard = Marionette.Layout.extend({
className: "container-fluid",
template: "backbone/crm/templates/dashboard/show",
regions: {
contacts: "#contacts",
filter: "#filter"
},
// var CRM.DashboardApp.Show.origHeight = 0,
initialize: function(){
console.log(Show.Dashboard)
$(window).on('resize', this.updateWindow);
var origHeight = $('#main-region').height();
console.log('Initialized height: ');
console.log(origHeight);
// this.origHeight = function(){
// return origHeight;
// };
// this.setOrigHeight = function(value) {
// origHeight = value;
// }
},
updateWindow: function(){
console.log('Original height: ');
console.log(this.origHeight);
console.log('New region height: ')
console.log($('#main-region').height());
var newHeight = $('#main-region').height();
var changeAmt = newHeight - this.origHeight;
$('.container-fluid').height($('.container-fluid').height() + changeAmt);
$('#display-row').height($('#display-row').height() + changeAmt);
console.log('New heights: ')
console.log($('#display-row').height());
console.log($('.container-fluid').height());
this.origHeight = newHeight;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment