Skip to content

Commit

Permalink
Merge pull request #76 from nsftx/task/CU-8694e4r05/enable_override_f…
Browse files Browse the repository at this point in the history
…or_autoResize_from_slave

Enable override for auto resize from slave
  • Loading branch information
dajanaGJ authored May 21, 2024
2 parents 23adb84 + 0cddada commit d4411da
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
7 changes: 6 additions & 1 deletion src/master_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,10 @@ var masterGateway = {
logger.out('info', '[GG] Master:', 'Master is outdated, please update to latest version - ' + event.data.VERSION);
}

if(typeof slaveData.autoResize === 'undefined' || slaveData.autoResize !== false) {
var shouldAutoResizeFromParent = typeof slaveData.autoResize === 'undefined' || slaveData.autoResize !== false;
var shouldSlaveAutoResize = event.data.autoResize || (typeof event.data.autoResize === 'undefined' && shouldAutoResizeFromParent);

if(shouldSlaveAutoResize) {
//On every init reset the frame sizes
contentHandler.resetFrameSize(slaveData.frameId);
}
Expand All @@ -250,6 +253,8 @@ var masterGateway = {
//Curry the sendMessage function with frameId argument in this special case
this.eventHandler = eventHandler(event.data.eventListeners, this.sendMessage.bind(this, slaveData.frameId), 'Master.Event');
}

slaveData.autoResize = shouldSlaveAutoResize;
this.slaveLoad(slaveData);
},

Expand Down
9 changes: 7 additions & 2 deletions src/slave_gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ var slaveGateway = {

config : null,

autoResize: null,

initialized : false,

load : null,
Expand All @@ -42,11 +44,12 @@ var slaveGateway = {
muteTimeout: null,

calculateFixedAndAbsoluteElements: false,

init: function(config){
this.initialized = true;
this.config = config;
this.slaveId = config.slaveId || config.productId;
this.autoResize = config.autoResize;
this.load = config.load || null;
this.calculateFixedAndAbsoluteElements = config.calculateFixedAndAbsoluteElements || false;
this.setAllowedDomains();
Expand Down Expand Up @@ -81,6 +84,7 @@ var slaveGateway = {
startSlaveInitialization : function() {
this.sendMessage({
action: 'Slave.Init',
autoResize: this.autoResize,
data: this.config.data,
eventPropagation : this.config.eventPropagation,
eventListeners : this.config.eventListeners,
Expand Down Expand Up @@ -230,7 +234,8 @@ var slaveGateway = {
slaveLoad : function(event) {
var self = this;
logger.out('info', '[GG] Slave.' + this.slaveId + ':', 'Starting to load.', event.data);
if (event.data.autoResize) {

if (this.autoResize || (typeof this.autoResize === 'undefined' && event.data.autoResize)) {
//Pass the event callback, and event name
contentHandler.init(this.sendMessage.bind(this), 'Slave.Resize', {
calculateFixedAndAbsoluteElements: self.calculateFixedAndAbsoluteElements,
Expand Down

0 comments on commit d4411da

Please sign in to comment.