-
13 Apr 2008 8:30 AM #1
[2.0 only] ux.ManagedIframe/Panel (1.2.7)
[2.0 only] ux.ManagedIframe/Panel (1.2.7)
ux.ManagedIFrame/Panel (Current Release 1.2.7, for Ext 2.2.x or under only)
A version for Ext 3.0 can be found here.
The latest build is also available on code.google.
Some features available:- UpdateManager.update and load support (to IFrames document).
- advanced scripting support.
- loadMask support.
- Cross-frame messaging
- documentloaded
- domready (fired when used with Updatemanager.update method, or when the document DOM reports ready)
- message[: subject]
- exception
- blur (fired when the frame window loses focus)
- focus (fired when the frame window receives focus)
- unload (fired when the frame document is unloaded)
Licensing: MIF/MIFP v1.2 or higher is dual-licensed: LGPL 3.0 or CDL for commercial use.
Related Links:- Wiki Manual here.
- MIF Frame Security and the "same-origin" policy.
- FF IFRAME Refresh Troubles?
- For an advanced demonstration, see post: "Load Ext once, and apply it to your frames".
- Previous 1.0 Baseline Forum thread.
More Examples:PHP Code:var newFrame = yourTabPanel.add({
xtype : 'iframepanel',
id : 'mifp_1',
title : 'Loading...',
loadMask : true,
frameConfig: {{autoCreate:{id: 'frame1'}}, //optional, give the frame your own id and name
defaultSrc : 'assets/someURL.html',
listeners: {
domready : function(frame){ //only raised for "same-origin" documents
//Set the tab Title to the Document Title
var doc= frame.getDocument();
if(doc){ frame.ownerCt.setTitle(doc.title); }
//Add some custom CSS Rules to the frame document
var rule = 'p.fancyP {padding:5px 10px 5px 10px;border:1px solid;' +
'font:normal 11px tahoma,arial,helvetica,sans-serif;}';
frame.CSS.createStyleSheet( rule, 'fancyP' );
//Find all the 'p' tags in the frame docuement, and add the fancyP className to them
frame.select('p').addClass('fancyP');
}
}
});
yourTabPanel.doLayout(); //if TabPanel is already rendered
yourTabPanel.setActiveTab(newFrame);
Extract the current source and demo files from miframe1_2.zip directly into a new/existing: /examples/miframe directory of your standard 2.x Ext.distribution (except for the desktop.zip demo -- that should go in /examples/desktop).
Updated: Version 1.1 This new baseline (1.1) adds:- frame Ext.Element support (ie. MIF.get, getDom, getDoc, fly ),
- frame CSS selector queries (eg. MIF.select/query) ,
- frame CSS.styleSheet interface (create, modify, remove frame-embedded style rules)
- frame Ext.EventManager support to DOM elements embedded in a frames document. (Use the MIF interface to query embedded DOM elements just like you would in the parent document; all without loading the Ext framework within the embedded page):
Set EventListeners on a frames DOM elements for handling with scripts hosted in the parent page:PHP Code:MIF.select('img',true).setOpacity(.5); or
MIFPanel.getFrame().select('img',true).setOpacity(.5);
Updated (8/22/08): Version 1.2 released. Adds FF3 compatibility fixes, and improved loadMask support.PHP Code:MIF.getDoc().on('click',function(e){ alert( 'Image ' + e.getTarget().id + ' was Clicked.') },null, {delegate:'img'});
Updated (4/26/09): Version 1.2.4 released. Adds [s]Ext 3.0 compatibility[s/] no longer, and adds 'resize' event support.
Updated (5/16/09): V 1.2.5 fixes X-Frame Messaging bug.
Updated (6/30/09): V 1.2.6 fixes domready bug, adds submitAsTarget method.
Updated (11/10/09): V 1.2.7 fixes another domready bug.
Thanks to all for the valuable feedback.
Note: the current vBulletin config gzips attachments which IE hates. Download this with Firefox (or other browser) instead of IE.Last edited by hendricd; 25 Nov 2009 at 5:50 AM. Reason: 1.2.7 Release
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
13 Apr 2008 10:44 AM #2
Great Stuff! Thanks for such a useful Extension!
Extensions:
Ext.ux.DatePickerPlus (Multimonth,Multiselect,...)
Ext.ux.menu.StoreMenu - Ajax Store as menu-item config
Extended Window - Aero Shadows, nested grayscaled modal windows
Ext.MessageBox.promptCombo/promptRadio/promptCheckbox
Ext.ux.plugin.triggerfieldTooltip (for Comboboxes, Datefields...)
Ext.util.MD5
Ext.util.Utf8 (encode/decode)
Ext.util.base64 (encode/decode)
Using:
ExtJS 3.4.1.1/4.2
XPsp3/W7sp1
IE8/9/10
FF 20
Chrome 26
-
13 Apr 2008 1:54 PM #3
If I were to point this to say a PDF file or Word document would any event fire after the file had been launched?
-
13 Apr 2008 2:31 PM #4
@Zakaroonikov -- If you are speaking of "same-origin" documents, you can get the MIF's 'domready' event working for you as it would fire immediately after the frames' new page markup as been DOMized.
Also, there is the 'documentloaded' event which is raised when all the 'assets' are finally loaded.
Short of that, you'd need a browser.plugin event to guarantee full 'load' status."be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
13 Apr 2008 10:35 PM #5
Can anyone give some scenario that must use ManagedIframePanel instead of other component?
-
14 Apr 2008 3:21 AM #6
@fangzhouxing -- other component?
"be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
14 Apr 2008 6:18 AM #7
This is fantastic! Thanks hendricd. You might also want to note that in 1.1 you have to hook listeners to the ManagedIframePanel itself, rather than putting them in the frameConfig as you did with 1.0x. Unless, that is, I was just doing something "unsupported" that happened to work.

Keep up the great work on this extension, it's been a lifesaver for me.
-
14 Apr 2008 6:21 AM #8
-
14 Apr 2008 6:29 AM #9
@nkohari -- No, that is by design. The MIF events are actually "relayed" to the MIFPanel listeners if you define them on the Panel.
The frameConfig allows the same listeners to be passed to MIF class too (via the Panel), your choice."be dom-ready..."
Doug Hendricks
Maintaining ux: ManagedIFrame, MIF2 (FAQ, Wiki), ux.Media/Flash, AudioEvents, ux.Chart[Fusion,OFC,amChart], ext-basex.js/$JIT, Documentation Site.
Got Sencha licensing questions? Find out more here.
-
14 Apr 2008 9:49 AM #10
OK, maybe this is a little over the top, but...
If you run the above code in the iframe, on document load, it fixes all the non-local-domain links so they open in a new window. I give you this code because it doesn't require you to load Ext into the iframe...Code:window.onload = function() { var base = top.location.href; base = base.replace(/\?.*$/, ""); base = base.replace(/\#.*$/, ""); var base_len = base.length; var anchorTags = document.getElementsByTagName('a'); for (var i = 0; i < anchorTags.length; i++) { var url = anchorTags[i].href; if (url.substr(0, base_len) != base) { anchorTags[i].onclick = function() { var i = 0; window.open(url); return false; } } else { anchorTags[i].onclick = function() { location.href = url; return false; } } } }
Now if you display some user generated HTML content in the iframe that has a link in it, when the user clicks on the link, it doesn't wipe out the entire desktop to load the new page in the browser.
You could run that code for people if some config variable is passed to iframe constructor.
Feel free to modify it to suit your purposes





Reply With Quote