From 70cc4427d06feca09481406a435f3bd40050cf63 Mon Sep 17 00:00:00 2001 From: Mateusz Uzdowski Date: Fri, 1 Jun 2012 17:21:05 +1200 Subject: [PATCH 1/2] ENHANCEMENT: add auto-sizing iframes, cleanup --- _config.php | 3 -- code/IFramePage.php | 52 ++++++++++++++++++++-------------- css/IFramePage.css | 8 ------ javascript/IFramePage.js | 46 ------------------------------ templates/Layout/IFramePage.ss | 12 ++++---- 5 files changed, 36 insertions(+), 85 deletions(-) delete mode 100644 css/IFramePage.css delete mode 100644 javascript/IFramePage.js diff --git a/_config.php b/_config.php index 64387dd..a4abe2d 100644 --- a/_config.php +++ b/_config.php @@ -1,5 +1,2 @@ diff --git a/code/IFramePage.php b/code/IFramePage.php index 4957a82..36a30ff 100644 --- a/code/IFramePage.php +++ b/code/IFramePage.php @@ -11,29 +11,39 @@ class IFramePage extends Page { function getCMSFields() { $fields = parent::getCMSFields(); - - $fields->removeFieldFromTab('Root.Content.Main', 'Content'); - $fields->addFieldToTab('Root.Content.Main', new TextField('IFrameUrl', 'IFrame URL')); - //$fields->addFieldToTab('Root.Content.Main', new CheckboxField('DynamicHeight', 'Dynamically resize the IFrame height (this doesn\'t work if IFrame URL is on a different domain)')); - $fields->addFieldToTab('Root.Content.Main', new NumericField('FixedHeight', 'Fixed Height (in pixels)')); - $fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('Content', 'Content (appears above IFrame)')); - $fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('BottomContent', 'Content (appears below IFrame)')); - $fields->addFieldToTab('Root.Content.Main', new HtmlEditorField('AlternateContent', 'Alternate Content (appears when user has IFrames disabled)')); - - - return $fields; - } -} -class IFramePage_Controller extends Page_Controller { - function Height() { - /*if($this->DynamicHeight) { - return 'class="iframeautosize"'; - } else {*/ - return 'style="height: ' . $this->FixedHeight . 'px;"'; - //} + $fields->removeFieldFromTab('Root.Main', 'Content'); + $fields->addFieldToTab('Root.Main', new TextField('IFrameUrl', 'IFrame URL')); + $fields->addFieldToTab('Root.Main', new CheckboxField('DynamicHeight', 'Dynamically resize the IFrame height (this doesn\'t work if IFrame URL is on a different domain)')); + $fields->addFieldToTab('Root.Main', new NumericField('FixedHeight', 'Fixed Height (in pixels)')); + $fields->addFieldToTab('Root.Main', new HtmlEditorField('Content', 'Content (appears above IFrame)')); + $fields->addFieldToTab('Root.Main', new HtmlEditorField('BottomContent', 'Content (appears below IFrame)')); + $fields->addFieldToTab('Root.Main', new HtmlEditorField('AlternateContent', 'Alternate Content (appears when user has IFrames disabled)')); + + return $fields; } } +class IFramePage_Controller extends Page_Controller { + function init() { + parent::init(); -?> + if ($this->DynamicHeight) { + Requirements::customScript(<<