|
| 1 | +var CellOverlay = function(view_id, parent_cell, parent_view_id) |
| 2 | +{ |
| 3 | + this._init(view_id, parent_cell, parent_view_id); |
| 4 | +}; |
| 5 | + |
| 6 | +CellOverlayPrototype = function() |
| 7 | +{ |
| 8 | + this._init = function(view_id, parent_cell, parent_view_id) |
| 9 | + { |
| 10 | + this.view_id = view_id; |
| 11 | + this.parent_cell = parent_cell; |
| 12 | + this.parent_view_id = parent_view_id; |
| 13 | + this.is_active = false; |
| 14 | + window.messages.add_listener("show-view", this._onview_show.bind(this)); |
| 15 | + window.messages.add_listener("hide-view", this._onview_hide.bind(this)); |
| 16 | + var layout_rough = |
| 17 | + { |
| 18 | + dir: "h", |
| 19 | + children: |
| 20 | + [ |
| 21 | + { tabbar: { tabs: [], is_hidden: true, is_empty: true } , width: 150, min_width: 7, name: view_id }, |
| 22 | + { tabbar: { tabs: [view_id], is_hidden: true } }, |
| 23 | + ] |
| 24 | + }; |
| 25 | + CellBase.init.call(this, layout_rough, layout_rough.dir); |
| 26 | + }; |
| 27 | + |
| 28 | + this._onview_show = function(msg) |
| 29 | + { |
| 30 | + if (this.is_active && msg.id == this.parent_view_id) |
| 31 | + this.show(); |
| 32 | + }; |
| 33 | + |
| 34 | + this._onview_hide = function(msg) |
| 35 | + { |
| 36 | + if (this.is_active && msg.id == this.parent_view_id) |
| 37 | + this.remove_ui_elements(this.view_id); |
| 38 | + }; |
| 39 | + |
| 40 | + this.show = function() |
| 41 | + { |
| 42 | + var view = window.views[this.view_id]; |
| 43 | + if (!view || view.isvisible()) |
| 44 | + return this.is_active; |
| 45 | + var parent_view = window.views[view.parent_view_id]; |
| 46 | + if (!parent_view || !parent_view.isvisible()) |
| 47 | + return this.is_active; |
| 48 | + var parent_toolbar = window.toolbars[this.parent_view_id]; |
| 49 | + if (parent_toolbar) |
| 50 | + parent_toolbar.disable(); |
| 51 | + this.is_active = true; |
| 52 | + this._update(); |
| 53 | + return this.is_active; |
| 54 | + }; |
| 55 | + |
| 56 | + this.update = function() |
| 57 | + { |
| 58 | + if (this.is_active && window.views[this.view_id] && window.views[this.view_id].isvisible()) |
| 59 | + this._update(); |
| 60 | + }; |
| 61 | + |
| 62 | + this._update = function() |
| 63 | + { |
| 64 | + var tabbar_height = this.parent_cell.tab.offsetHeight; |
| 65 | + this.width = this.parent_cell.width; |
| 66 | + this.height = this.parent_cell.height - tabbar_height; |
| 67 | + this.setDefaultDimensions(); |
| 68 | + CellBase.update.call(this, this.parent_cell.left, this.parent_cell.top + tabbar_height, true); |
| 69 | + }; |
| 70 | + |
| 71 | + this.hide = function() |
| 72 | + { |
| 73 | + var parent_toolbar = window.toolbars[this.parent_view_id]; |
| 74 | + if (parent_toolbar) |
| 75 | + parent_toolbar.enable(); |
| 76 | + this.is_active = false; |
| 77 | + this.remove_ui_elements(this.view_id); |
| 78 | + }; |
| 79 | +}; |
| 80 | + |
| 81 | +CellOverlayPrototype.prototype = CellBase; |
| 82 | +CellOverlay.prototype = new CellOverlayPrototype(); |
0 commit comments