Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
amenk committed Sep 1, 2016
1 parent fd46591 commit 8ebc897
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
22 changes: 16 additions & 6 deletions js/iframeResizer.contentWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
bodyObserver = null,
bodyPadding = '',
calculateWidth = false,
customSelector = '[data-iframe-height]',
doubleEventList = {'resize':1,'click':1},
eventCancelTimer = 128,
firstRun = true,
Expand Down Expand Up @@ -198,6 +199,8 @@
inPageLinks.enable = (undefined !== data[12]) ? strBool(data[12]): false;
resizeFrom = (undefined !== data[13]) ? data[13] : resizeFrom;
widthCalcMode = (undefined !== data[14]) ? data[14] : widthCalcMode;
customSelector = (undefined !== data[15]) ? data[15] : customSelector;
console.log(data);
}

function readDataFromPage(){
Expand Down Expand Up @@ -746,13 +749,13 @@
];
}

function getTaggedElements(side,tag){
function getSelectorElements(side,selector){
function noTaggedElementsFound(){
warn('No tagged elements ('+tag+') found on page');
return height; //current height
warn('No elements matching the selector ('+selector+') found on page');
return null; //current height
}

var elements = document.querySelectorAll('['+tag+']');
var elements = document.querySelectorAll(selector);

return 0 === elements.length ? noTaggedElementsFound() : getMaxElement(side,elements);
}
Expand Down Expand Up @@ -804,8 +807,15 @@
},

taggedElement: function getTaggedElementsHeight(){
return getTaggedElements('bottom','data-iframe-height');
var h = getSelectorElements('bottom', customSelector);
return (h == null) ? height : h;
},

taggedOrLowestElement: function getTaggedOrLowestElementsHeight(){
var h = getSelectorElements('bottom', customSelector);
return (h == null) ? this.lowestElement() : h;
}

},

getWidth = {
Expand Down Expand Up @@ -846,7 +856,7 @@
},

taggedElement: function getTaggedElementsWidth(){
return getTaggedElements('right', 'data-iframe-width');
return getSelectorElements('right', '[data-iframe-width]');
}
};

Expand Down
4 changes: 3 additions & 1 deletion js/iframeResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
bodyMarginV1 : 8,
bodyPadding : null,
checkOrigin : true,
customSelector : '',
inPageLinks : false,
enablePublicMethods : true,
heightCalculationMethod : 'bodyOffset',
Expand Down Expand Up @@ -664,7 +665,8 @@
':' + settings[iframeId].tolerance +
':' + settings[iframeId].inPageLinks +
':' + settings[iframeId].resizeFrom +
':' + settings[iframeId].widthCalculationMethod;
':' + settings[iframeId].widthCalculationMethod +
':' + settings[iframeId].customSelector;
}

function setupIFrame(iframe,options){
Expand Down

0 comments on commit 8ebc897

Please sign in to comment.