-
-
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…
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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