]>
Commit | Line | Data |
---|---|---|
947f0963 TL |
1 | /** |
2 | * @private | |
3 | */ | |
4 | Ext.define('Ext.grid.locking.RowSynchronizer', { | |
5 | constructor: function(view, rowEl) { | |
6 | var me = this, | |
7 | rowTpl; | |
8 | ||
9 | me.view = view; | |
10 | me.rowEl = rowEl; | |
11 | me.els = {}; | |
12 | ||
13 | me.add('data', view.rowSelector); | |
14 | ||
15 | for (rowTpl = view.rowTpl; rowTpl; rowTpl = rowTpl.nextTpl) { | |
16 | if (rowTpl.beginRowSync) { | |
17 | rowTpl.beginRowSync(me); | |
18 | } | |
19 | } | |
20 | }, | |
21 | ||
22 | add: function(name, selector) { | |
23 | var el = Ext.fly(this.rowEl).down(selector, true); | |
24 | ||
25 | if (el) { | |
26 | this.els[name] = { | |
27 | el: el | |
28 | }; | |
29 | } | |
30 | }, | |
31 | ||
32 | finish: function(other) { | |
33 | var me = this, | |
34 | els = me.els, | |
35 | otherEls = other.els, | |
36 | otherEl, | |
37 | growth = 0, | |
38 | otherGrowth = 0, | |
39 | delta, name, otherHeight; | |
40 | ||
41 | for (name in els) { | |
42 | otherEl = otherEls[name]; | |
43 | ||
44 | // Partner RowSynchronizer may not have the element. | |
45 | // For example, group summary may not be wanted in locking side. | |
46 | otherHeight = otherEl ? otherEl.height : 0; | |
47 | delta = otherHeight - els[name].height; | |
48 | ||
49 | if (delta > 0) { | |
50 | growth += delta; | |
51 | Ext.fly(els[name].el).setHeight(otherHeight); | |
52 | } | |
53 | else { | |
54 | otherGrowth -= delta; | |
55 | } | |
56 | } | |
57 | ||
58 | // Compare the growth to both rows and see if this row is lacking. | |
59 | otherHeight = other.rowHeight + otherGrowth; | |
60 | ||
61 | //<feature legacyBrowser> | |
62 | // IE9 uses content box sizing on table, so height must not include border | |
63 | if (Ext.isIE9 && me.view.ownerGrid.rowLines) { | |
64 | otherHeight--; | |
65 | } | |
66 | //</feature> | |
67 | ||
68 | if (me.rowHeight + growth < otherHeight) { | |
69 | Ext.fly(me.rowEl).setHeight(otherHeight); | |
70 | } | |
71 | }, | |
72 | ||
73 | measure: function() { | |
74 | var me = this, | |
75 | els = me.els, | |
76 | grid = me.view.ownerGrid, | |
77 | name; | |
78 | ||
79 | me.rowHeight = grid.getElementHeight(me.rowEl); | |
80 | ||
81 | for (name in els) { | |
82 | els[name].height = grid.getElementHeight(els[name].el); | |
83 | } | |
84 | }, | |
85 | ||
86 | reset: function() { | |
87 | var els = this.els, | |
88 | name; | |
89 | ||
90 | this.rowEl.style.height = ''; | |
91 | ||
92 | for (name in els) { | |
93 | els[name].el.style.height = ''; | |
94 | } | |
95 | } | |
96 | }); |