فهرست منبع

Merge remote-tracking branch 'origin/master'

yuliang 3 سال پیش
والد
کامیت
a2b36ca47b
4فایلهای تغییر یافته به همراه99 افزوده شده و 3 حذف شده
  1. 87 0
      src/controls/iframe.js
  2. 2 0
      src/init.ts
  3. 10 1
      src/lib/lib.ts
  4. 0 2
      src/wotu-ui.css

+ 87 - 0
src/controls/iframe.js

@@ -0,0 +1,87 @@
+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);
+            }
+        }
+    });
+}

+ 2 - 0
src/init.ts

@@ -27,6 +27,7 @@ import initRows from './controls/rows'
 import initForm from './controls/form'
 import initCols from './controls/cols'
 import initButton from './controls/button'
+import initIframe from './controls/iframe'
 import initStores from './controls/stores'
 import {lookupFn, lookupScope} from "./lib/lib"
 import * as SystemLib from './lib/systemLib'
@@ -189,4 +190,5 @@ export function init() {
     initPickerPlus()
     initCombogrid()
     initComboGridMulti()
+    initIframe()
 }

+ 10 - 1
src/lib/lib.ts

@@ -113,7 +113,12 @@ export function lookupFn(scope: Scope, event: string): Function {
     const keys: any[] = []
     const values: any[] = []
     _.forOwn(data, (value, key) => {
-        keys.push(key)
+        const idxKey = key.indexOf('//')
+        if (idxKey >= 0) {
+            keys.push(key.substr(0, idxKey))
+        } else {
+            keys.push(key)
+        }
         values.push(value)
     })
 
@@ -141,6 +146,10 @@ export function lookupScope(extHandle: any): Scope {
     if (extHandle.isScope) {
         return extHandle
     }
+    if (extHandle.column) {
+        // 列上的组件
+        return extHandle.column.lookupReferenceHolder().yvanScope
+    }
     const vm = extHandle.lookupViewModel()
     return vm.yvanScope
 }

+ 0 - 2
src/wotu-ui.css

@@ -617,9 +617,7 @@
     outline: 1px double #5fa2dd;
     */
 
-    /*
     background-color: #ffefbb;
-     */
 }
 .wotu-ui .x-segmented-button-item-horizontal.x-btn-default-small{
     border:none;