Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Created December 12, 2009 00:27
Show Gist options
  • Save ryanflorence/254634 to your computer and use it in GitHub Desktop.
Save ryanflorence/254634 to your computer and use it in GitHub Desktop.
// http://mooshell.net/tbdZW/
(function(){
var parseDimensions = function(element){
var array = element.get('class').match(/mooshell:[0-9]+:?([0-9]+)?/)[0].split(':');
var dimensions = { height: array[1] };
dimensions.width = (array[2]) ? dimensions.width = array[2] : '100%';
return dimensions;
};
Element.implement({
embedShell: function(dimensions){
var dimensions = (dimensions) ? dimensions : parseDimensions(this);
var iframe = new Element('iframe',{
'width': dimensions.width,
'height': dimensions.height,
'src': this.get('href')
});
iframe.inject(this,'after');
this.destroy();
return iframe;
}
});
})();
// usage
// <a href="http://mooshell.net/rpflo/928fj2" class="mooshell:100:600">MooShell Demo</a>
$('link').embedShell();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment