13693261870
2022-09-16 354b3dbfbffb3df45212a2a44dbbf48b4acc2594
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html>
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <title>The source code</title>
  <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
  <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
  <style type="text/css">
    .highlight { display: block; background-color: #ddd; }
  </style>
  <script type="text/javascript">
    function highlight() {
      document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
    }
  </script>
</head>
<body onload="prettyPrint(); highlight();">
  <pre class="prettyprint lang-js">// This override adds diagnostics to the Ext.layout.ContextItem class.
 
<span id='Ext-diag-layout-ContextItem'>/**
</span> */
Ext.define('Ext.diag.layout.ContextItem', {
    override: 'Ext.layout.ContextItem',
 
<span id='global-property-requires'>    /** @ignore */
</span>    requires: [
        'Ext.layout.Context',
        'Ext.diag.layout.Context'
    ],
 
<span id='Ext-diag-layout-ContextItem-method-addBlock'>    addBlock: function (name, layout, propName) {
</span>        //Ext.log(this.id,'.',propName,' ',name,': ',this.getLayoutName(layout));
        (layout.blockedBy || (layout.blockedBy = {}))[
            this.id+'.'+propName+(name.substring(0,3)=='dom' ? ':dom' : '')] = 1;
 
        return this.callParent(arguments);
    },
 
<span id='Ext-diag-layout-ContextItem-method-addBoxChild'>    addBoxChild: function (boxChildItem) {
</span>        var ret = this.callParent(arguments),
            boxChildren = this.boxChildren,
            boxParents;
 
        if (boxChildren &amp;&amp; boxChildren.length == 1) {
            // the boxParent collection is created by the run override found in
            // Ext.diag.layout.Context, but IE sometimes does not load that override, so
            // we work around it for now
            boxParents = this.context.boxParents ||
                        (this.context.boxParents = new Ext.util.MixedCollection());
            boxParents.add(this);
        }
 
        return ret;
    },
 
<span id='Ext-diag-layout-ContextItem-method-addTrigger'>    addTrigger: function (propName, inDom) {
</span>        var layout = this.context.currentLayout,
            triggers;
 
        //Ext.log(this.id,'.',propName,' ',inDom ? ':dom' : '',' ',this.getLayoutName(layout));
        this.callParent(arguments);
 
        triggers = this.context.triggersByLayoutId;
        (triggers[layout.id] || (triggers[layout.id] = {}))[
            this.id+'.'+propName+(inDom ? ':dom' : '')] = {
                item: this,
                name: propName
            };
    },
 
<span id='Ext-layout-ContextItem-method-checkAuthority'>    checkAuthority: function (prop) {
</span>        var me = this,
            model = me[prop + 'Model'], // not me.sizeModel[prop] since it is immutable
            layout = me.context.currentLayout,
            ok,
            setBy;
 
        if (layout == me.target.ownerLayout) {
            // the ownerLayout is only allowed to set calculated dimensions
            ok = model.calculated;
        } else if (layout.isComponentLayout) {
            // the component's componentLayout (normally) is only allowed to set auto or
            // configured dimensions. The exception is when a component is run w/o its
            // ownerLayout in the picture (isTopLevel), someone must publish the lastBox
            // values and that lucky layout is the componentLayout (kinda had to be since
            // the ownerLayout is not running)
            ok = me.isTopLevel || model.auto || model.configured;
        }
 
        if (!ok) {
            setBy = me.getLayoutName(layout);
 
            Ext.log(setBy + ' cannot set ' + prop);
        }
    },
 
<span id='Ext-diag-layout-ContextItem-method-clearBlocks'>    clearBlocks: function (name, propName) {
</span>        var collection = this[name],
            blockedLayouts = collection &amp;&amp; collection[propName],
            key = this.id+'.'+propName+(name.substring(0,3)=='dom' ? ':dom' : ''),
            layout, layoutId;
 
        if (blockedLayouts) {
            for (layoutId in blockedLayouts) {
                layout = blockedLayouts[layoutId];
                delete layout.blockedBy[key];
            }
        }
        return this.callParent(arguments);
    },
 
<span id='Ext-diag-layout-ContextItem-method-getEl'>    getEl: function (el) {
</span>        var child = this.callParent(arguments);
        if (child &amp;&amp; child !== this &amp;&amp; child.parent !== this) {
            Ext.Error.raise({
                msg: 'Got element from wrong component'
            });
        }
        return child;
    },
 
<span id='Ext-diag-layout-ContextItem-method-init'>    init: function () {
</span>        var me = this,
            ret;
 
        ret = me.callParent(arguments);
 
        if (me.context.logOn.initItem) {
            Ext.log(me.id, ' consumers: content=', me.consumersContentWidth,'/',me.consumersContentHeight,
                ', container=', me.consumersContainerWidth,'/',me.consumersContainerHeight,
                ', size=', me.consumersWidth,'/',me.consumersHeight);
        }
 
        return ret;
    },
 
<span id='Ext-diag-layout-ContextItem-method-invalidate'>    invalidate: function () {
</span>        if (this.wrapsComponent) {
            if (this.context.logOn.invalidate) {
                Ext.log('invalidate: ', this.id);
            }
        } else {
            Ext.Error.raise({
                msg: 'Cannot invalidate an element contextItem'
            });
        }
        return this.callParent(arguments);
    },
 
<span id='Ext-diag-layout-ContextItem-method-setProp'>    setProp: function (propName, value, dirty) {
</span>        var me = this,
            layout = me.context.currentLayout,
            setBy = me.getLayoutName(layout),
            fullName = me.id + '.' + propName,
            setByProps;
 
        if (value !== null) {
            setByProps = me.setBy || (me.setBy = {});
            if (!setByProps[propName]) {
                setByProps[propName] = setBy;
            } else if (setByProps[propName] != setBy) {
                Ext.log({level: 'warn'}, 'BAD! ', fullName, ' set by ', setByProps[propName], ' and ', setBy);
            }
        }
 
        if (me.context.logOn.setProp) {
            if (typeof value != 'undefined' &amp;&amp; !isNaN(value) &amp;&amp; me.props[propName] !== value) {
                Ext.log('set ', fullName, ' = ', value, ' (', dirty, ')');
            }
        }
 
        return this.callParent(arguments);
    },
 
<span id='Ext-diag-layout-ContextItem-method-setHeight'>    setHeight: function (height, dirty, /* private */force) {
</span>        if (!force &amp;&amp; this.wrapsComponent) {
            this.checkAuthority('height');
        }
 
        return this.callParent(arguments);
    },
 
<span id='Ext-diag-layout-ContextItem-method-setWidth'>    setWidth: function (width, dirty, /* private */force) {
</span>        if (!force &amp;&amp; this.wrapsComponent) {
            this.checkAuthority('width');
        }
 
        return this.callParent(arguments);
    }
},
function () {
    this.prototype.getLayoutName = Ext.layout.Context.prototype.getLayoutName;
});
</pre>
</body>
</html>