Skip to content

Instantly share code, notes, and snippets.

@robertuniqid
Created January 25, 2016 22:35
Show Gist options
  • Save robertuniqid/8431cd86c1dfb2705215 to your computer and use it in GitHub Desktop.
Save robertuniqid/8431cd86c1dfb2705215 to your computer and use it in GitHub Desktop.
Force in-site iFrames to point to URL's and have an certain suffix or URL Paramter. I've used this to change the layout to a different one, in order to achieve an "Quick Access" Interface for minimal 2-3 inputs tables on a larger project. This is a great alternative if you're also working in Laravel and you want to avoid taking this case into ac…
var Layout = {
_handleSmartIFrameContainers : function() {
var objectInstance = this;
jQuery('[data-smart-iframe]').each(function() {
var smartIFrameContainer = jQuery(this);
jQuery(this).find(jQuery(this).attr('data-smart-iframe')).bind("click", function(event) {
event.preventDefault();
objectInstance._handleSmartIFrame( smartIFrameContainer, jQuery(this).attr("href") );
});
});
},
_handleSmartIFrame : function( smartIFrameContainer, target ) {
var objectInstance = this;
if( target.indexOf('empty-layout') == -1 )
target += ( target.indexOf("?") == -1 ? '?' : '&' ) + 'empty-layout=true';
smartIFrameContainer.find("> .content")
.html('<iframe src="' + target + '">Feature not available.</iframe>');
smartIFrameContainer.find("> .content > iframe").bind("load", function() {
var location = jQuery(this)[0].contentWindow.location.href;
if( location.indexOf('empty-layout') == -1 )
objectInstance._handleSmartIFrame( smartIFrameContainer, location );
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment