123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- export default function () {
- Ext.define('Ext.ux.IFrame', {
- extend: 'Ext.Component',
- alias: 'widget.uxiframe',
- loadMask: 'Loading...',
- src: 'about:blank',
- renderTpl: [
- '<iframe src="{src}" id="{id}-iframeEl" data-ref="iframeEl" name="{frameName}" width="100%" height="100%" frameborder="0"></iframe>'
- ],
- childEls: ['iframeEl'],
- initComponent: function () {
- this.superclass.initComponent.call(this)
- this.superclass.initEvents.call(this)
- this.frameName = this.frameName || this.id + '-frame';
- },
- initEvents: function () {
- var me = this;
- this.superclass.initEvents.call(this)
- me.iframeEl.on('load', me.onLoad, me);
- },
- initRenderData: function () {
- return Ext.apply(this.superclass.initRenderData.call(this), {
- src: this.src,
- frameName: this.frameName
- });
- },
- getBody: function () {
- var doc = this.getDoc();
- return doc.body || doc.documentElement;
- },
- getDoc: function () {
- try {
- return this.getWin().document;
- } catch (ex) {
- return null;
- }
- },
- getWin: function () {
- var me = this,
- name = me.frameName,
- win = Ext.isIE ? me.iframeEl.dom.contentWindow : window.frames[name];
- return win;
- },
- getFrame: function () {
- var me = this;
- return me.iframeEl.dom;
- },
- onLoad: function () {
- var me = this,
- doc = me.getDoc();
- if (doc) {
- this.el.unmask();
- this.fireEvent('load', this);
- } else if (me.src) {
- this.el.unmask();
- this.fireEvent('error', this);
- }
- },
- load: function (src) {
- var me = this,
- text = me.loadMask,
- frame = me.getFrame();
- if (me.fireEvent('beforeload', me, src) !== false) {
- if (text && me.el) {
- me.el.mask(text);
- }
- frame.src = me.src = (src || me.src);
- }
- }
- });
- }
|