Skip to content

Commit 2b37717

Browse files
author
Chris K
committed
Added new class OverlayView.
1 parent 2257326 commit 2b37717

File tree

4 files changed

+122
-3
lines changed

4 files changed

+122
-3
lines changed

src/client-en.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ window.load_screen_timeout = window.setTimeout(function()
273273
<script src="./ui-scripts/defaults.js"/>
274274
<script src="./ui-scripts/window.js"/>
275275
<script src="./ui-scripts/cells.js"/>
276+
<script src="./ui-scripts/celloverlay.js"/>
276277
<script src="./ui-scripts/topCell.js"/>
277278
<script src="./ui-scripts/view.js"/>
278279
<script src="./ui-scripts/tempview.js"/>

src/network/network_view.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,12 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
425425

426426
this._on_clicked_request_bound = function(evt, target)
427427
{
428+
if (this._overlay.is_active)
429+
this._overlay.hide();
430+
else
431+
this._overlay.show();
432+
433+
return;
428434
var item_id = target.get_attr("parent-node-chain", "data-object-id");
429435
if (this._selected == item_id)
430436
{
@@ -731,6 +737,9 @@ cls.NetworkLogView = function(id, name, container_class, html, default_handler,
731737
}
732738
]);
733739

740+
this._overlay = this.register_overlay(new cls.DetailOverlayView("detail-overlay"));
741+
cls.DetailOverlayView.create_ui_widgets();
742+
734743
this._type_filters = ["all"].map(this._map_filter_bound);
735744
this.init(id, name, container_class, html, default_handler);
736745
};
@@ -917,3 +926,41 @@ cls.NetworkLog.create_ui_widgets = function()
917926
messages.addListener("view-created", on_view_created);
918927
messages.addListener("view-destroyed", on_view_destroyed);
919928
}
929+
930+
cls.DetailOverlayView = function(id, container_class, html, default_handler, service)
931+
{
932+
this.createView = function(container)
933+
{
934+
container.innerHTML = "<h2>hello</h2>";
935+
};
936+
this.ondestroy = function()
937+
{
938+
opera.postError(this.id + " destroyed")
939+
}
940+
// overlay view has no name
941+
this.init(id, container_class, html, default_handler);
942+
943+
};
944+
945+
cls.DetailOverlayView.prototype = new OverlayView();
946+
947+
cls.DetailOverlayView.create_ui_widgets = function()
948+
{
949+
var config =
950+
{
951+
view: "detail-overlay",
952+
groups: [
953+
{
954+
type: UI.TYPE_BUTTONS,
955+
items: [
956+
{
957+
handler: "clear-log-network-view",
958+
icon: "clear-log-network-view",
959+
title: ui_strings.S_CLEAR_NETWORK_LOG
960+
}
961+
]
962+
},
963+
]
964+
};
965+
new ToolbarConfig(config);
966+
};

src/ui-scripts/cells.js

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,45 @@
151151
return null;
152152
}
153153

154+
this.show_overlay = function(view)
155+
{
156+
if (!this.overlay || !this.overlay.view_id == view.id)
157+
{
158+
if (this.overlay)
159+
this.overlay.hide();
160+
this.overlay = new CellOverlay(view.id, this, view.parent_view_id);
161+
}
162+
return this.overlay.show();
163+
};
164+
165+
this.hide_overlay = function(view_id)
166+
{
167+
if (this.overlay && this.overlay.view_id == view_id)
168+
this.overlay.hide();
169+
};
170+
171+
this.remove_ui_elements = function(view_id)
172+
{
173+
var view = window.views[view_id];
174+
if (view && view.isvisible())
175+
{
176+
var cell = this.get_cell(view_id);
177+
var container_id = 'container-to-' + cell.id;
178+
var toolbar_id = 'toolbar-to-' + cell.id;
179+
window.messages.post("hide-view", {id: view_id});
180+
view.removeContainerId(container_id);
181+
var toolbar = window.toolbars[view_id];
182+
if (toolbar)
183+
toolbar.removeContainerId(toolbar_id);
184+
[container_id, toolbar_id].forEach(function(id)
185+
{
186+
var ele = document.getElementById(id);
187+
if (ele)
188+
ele.parentNode.removeChild(ele);
189+
});
190+
}
191+
};
192+
154193
this.add_searchbar = function(searchbar)
155194
{
156195
this.searchbar = searchbar;
@@ -265,6 +304,7 @@
265304
this.parent = parent;
266305
this.container_id = container_id; // think about this
267306
this.is_dirty = true;
307+
this.is_empty = Boolean(rough_cell.is_empty);
268308

269309
dir = dir == HOR ? VER : HOR;
270310

@@ -288,7 +328,7 @@
288328
// is previoue set for the last?
289329
}
290330
}
291-
else
331+
else if (!this.is_empty)
292332
{
293333
["tabs", "tabbar"].forEach(function(prop)
294334
{
@@ -329,6 +369,9 @@
329369

330370
this.setup = function(view_id)
331371
{
372+
if (this.is_empty)
373+
return;
374+
332375
var view_id = this.tab && this.tab.activeTab;
333376
if (view_id)
334377
{

src/ui-scripts/view.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,13 @@ var ViewBase = new function()
8383
messages.post('view-initialized', {'view_id': this.id});
8484
}
8585

86+
this.register_overlay = function(view)
87+
{
88+
this._overlay = view;
89+
view.parent_view_id = this.id;
90+
return view;
91+
};
92+
8693
this.addContainerId = function(id)
8794
{
8895
this.container_ids[this.container_ids.length] = id;
@@ -306,7 +313,28 @@ var View = function(id, name, container_class, html, default_handler)
306313

307314
View.prototype = ViewBase;
308315

316+
var OverlayView = function(id, container_class, html, default_handler) {};
317+
var OverlayViewPrototype = function()
318+
{
319+
this.show = function()
320+
{
321+
var cell = window.topCell.get_cell(this.parent_view_id);
322+
if (cell)
323+
this.is_active = cell.show_overlay(this);
324+
};
309325

326+
this.hide = function()
327+
{
328+
var cell = window.topCell.get_cell(this.parent_view_id);
329+
if (cell)
330+
cell.hide_overlay(this.id);
331+
this.is_active = false;
332+
};
310333

311-
312-
334+
this.init = function(id, container_class, html, default_handler)
335+
{
336+
ViewBase.init.call(this, id, "", container_class, html, default_handler);
337+
};
338+
};
339+
OverlayViewPrototype.prototype = ViewBase;
340+
OverlayView.prototype = new OverlayViewPrototype();

0 commit comments

Comments
 (0)