Index: iframe-proxy.php
===================================================================
RCS file: iframe-proxy.php
diff -N iframe-proxy.php
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ iframe-proxy.php 9 Dec 2009 17:14:11 -0000
@@ -0,0 +1,15 @@
+/U', '
', $response);
+}
+
+die($response);
Index: iframe.js
===================================================================
RCS file: iframe.js
diff -N iframe.js
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ iframe.js 9 Dec 2009 17:14:11 -0000
@@ -0,0 +1,7 @@
+Drupal.behaviors.iframe_resize = function() {
+ for (var i in Drupal.settings.iframe) {
+ $('#' + i)[0].contentWindow.onload = function() {
+ $(this)[0].frameElement.style.height = ($(this)[0].document.body.scrollHeight + 18) + "px";
+ };
+ };
+}
Index: iframe.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/iframe/iframe.module,v
retrieving revision 1.12
diff -u -p -r1.12 iframe.module
--- iframe.module 10 May 2009 00:04:27 -0000 1.12
+++ iframe.module 9 Dec 2009 17:14:11 -0000
@@ -118,7 +118,7 @@ function iframe_field_settings($op, $fie
$form['attributes']['height'] = array(
'#type' => 'textfield',
'#title' => t('height of the iframe'),
- '#description' => t('iframes need fix width and height, only numbers are allowed.'),
+ '#description' => t("Either a fixed number for pixels or 'auto' for the full height of the iframed content."),
'#default_value' => empty($field['attributes']['height']) ? '700' : $field['attributes']['height'],
'#maxlength' => 4,
'#size' => 4,
@@ -146,7 +146,7 @@ function iframe_field_settings($op, $fie
if (empty($field['attributes']['width']) || (int)$field['attributes']['width']<1) {
form_set_error('width_value', t('A default width and height must be provided.'));
}
- if (empty($field['attributes']['height']) || (int)$field['attributes']['height']<1) {
+ if (empty($field['attributes']['height']) || ((int)$field['attributes']['height'] < 1 && $field['attributes']['height'] != 'auto')) {
form_set_error('height_value', t('A default width and height must be provided.'));
}
break;
@@ -537,6 +537,7 @@ function iframe_process($element, $edit,
'#maxlength' => '4',
'#size' => '4',
'#title' => t('Height'),
+ '#description' => t("Either a fixed number for pixels or 'auto' for the full height of the iframed content."),
'#required' => ($delta == 0 && $field['height'] == 'required') ? $field['required'] : FALSE,
'#default_value' => !empty($element['#value']['attributes']['height'])? $element['#value']['attributes']['height'] : $field['attributes']['height'],
);
@@ -590,6 +591,29 @@ function theme_iframe_formatter_default(
dmsg(3,'func theme_iframe_formatter_default');
// If no url given display nothing.
if (empty($element['#item']['url'])) return '';
+
+ if ($element['#item']['attributes']['height'] == 'auto') {
+
+ // We can only control an IFRAME height on a percentage basis if it is served
+ // from the same domain, so if it's not then we run it through our proxy.
+ $url_local = parse_url(url('', array('absolute' => TRUE)));
+ $url_iframe = parse_url($element['#item']['url']);
+ if ($url_local['scheme'] != $url_iframe['scheme'] || $url_local['host'] != $url_iframe['host']) {
+ $url_options = array(
+ 'query' => array(
+ 'url' => urlencode($element['#item']['url']),
+ ),
+ 'absolute' => TRUE
+ );
+ $element['#item']['url'] = url(drupal_get_path('module', 'iframe') .'/iframe-proxy.php', $url_options);
+ }
+
+ drupal_add_js(drupal_get_path('module', 'iframe') .'/iframe.js');
+ drupal_add_js(array('iframe' => array($element['#item']['html-id'] => 'auto')), 'setting');
+ $element['#item']['attributes']['height'] = '100';
+
+ }
+
// Display all
return iframe_iframe($element['#item']['display_title'], $element['#item']['url'], $element['#item']);
}
@@ -601,6 +625,29 @@ function theme_iframe_formatter_iframeon
dmsg(3,'func theme_iframe_formatter_iframeonly');
// If no url given display nothing.
if (empty($element['#item']['url'])) return '';
+
+ if ($element['#item']['attributes']['height'] == 'auto') {
+
+ // We can only control an IFRAME height on a percentage basis if it is served
+ // from the same domain, so if it's not then we run it through our proxy.
+ $url_local = parse_url(url('', array('absolute' => TRUE)));
+ $url_iframe = parse_url($element['#item']['url']);
+ if ($url_local['scheme'] != $url_iframe['scheme'] || $url_local['host'] != $url_iframe['host']) {
+ $url_options = array(
+ 'query' => array(
+ 'url' => urlencode($element['#item']['url']),
+ ),
+ 'absolute' => TRUE
+ );
+ $element['#item']['url'] = url(drupal_get_path('module', 'iframe') .'/iframe-proxy.php', $url_options);
+ }
+
+ drupal_add_js(drupal_get_path('module', 'iframe') .'/iframe.js');
+ drupal_add_js(array('iframe' => array($element['#item']['html-id'] => 'auto')), 'setting');
+ $element['#item']['attributes']['height'] = '100';
+
+ }
+
// Display all
return iframe_iframe('', $element['#item']['url'], $element['#item']);
}