Skip to content

Commit fb8aa99

Browse files
author
Chris K
committed
Finished implementation of new view overlay.
1 parent b83f2d2 commit fb8aa99

File tree

13 files changed

+267
-35
lines changed

13 files changed

+267
-35
lines changed

src/client-en.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ window.load_screen_timeout = window.setTimeout(function()
278278
<script src="./ui-scripts/view.js"/>
279279
<script src="./ui-scripts/tempview.js"/>
280280
<script src="./ui-scripts/compositeView.js"/>
281+
<script src="./ui-scripts/overlayview.js"/>
281282
<script src="./ui-scripts/settingView.js"/>
282283
<script src="./ui-scripts/ui-base.js"/>
283284
<script src="./ui-scripts/TopUIBase.js"/>
@@ -307,6 +308,7 @@ window.load_screen_timeout = window.setTimeout(function()
307308
<script src="./ui-scripts/containers.js"/>
308309
<script src="./ui-scripts/topContainers.js"/>
309310
<script src="./ui-scripts/windowContainers.js"/>
311+
<script src="./ui-scripts/overlaybackground.js"/>
310312
<script src="./ui-scripts/tab.js"/>
311313
<script src="./ui-scripts/status.js"/>
312314
<script src="./ui-scripts/ui-templates.js"/>
@@ -335,6 +337,7 @@ window.load_screen_timeout = window.setTimeout(function()
335337
<script src="./ui-scripts/pixelmagnifier.js"/>
336338

337339

340+
338341
<script src="./build-application/build_application.js"></script>
339342
<script src="./build-application/build_window_manager_2_0.js"></script>
340343
<script src="./build-application/build_console_logger_2_0.js"></script>

src/network/network_view.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -933,10 +933,7 @@ cls.DetailOverlayView = function(id, container_class, html, default_handler, ser
933933
{
934934
container.innerHTML = "<h2>hello</h2>";
935935
};
936-
this.ondestroy = function()
937-
{
938-
opera.postError(this.id + " destroyed")
939-
}
936+
940937
// overlay view has no name
941938
this.init(id, container_class, html, default_handler);
942939

src/ui-scripts/celloverlay.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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();

src/ui-scripts/cells.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@
158158
if (this.overlay)
159159
this.overlay.hide();
160160
this.overlay = new CellOverlay(view.id, this, view.parent_view_id);
161+
if (!window.toolbars[view.id])
162+
new ToolbarConfig({view: view.id, groups: [Toolbar.overlay_close_button]});
161163
}
162164
return this.overlay.show();
163165
};
@@ -174,14 +176,17 @@
174176
if (view && view.isvisible())
175177
{
176178
var cell = this.get_cell(view_id);
177-
var container_id = 'container-to-' + cell.id;
178-
var toolbar_id = 'toolbar-to-' + cell.id;
179+
var container_id = "container-to-" + cell.id;
179180
window.messages.post("hide-view", {id: view_id});
180181
view.removeContainerId(container_id);
182+
var toolbar_id = "toolbar-to-" + cell.id;
181183
var toolbar = window.toolbars[view_id];
182184
if (toolbar)
183185
toolbar.removeContainerId(toolbar_id);
184-
[container_id, toolbar_id].forEach(function(id)
186+
[container_id,
187+
toolbar_id,
188+
"overlay-background-to-" + cell.id,
189+
"slider-for-" + cell.id].forEach(function(id)
185190
{
186191
var ele = document.getElementById(id);
187192
if (ele)
@@ -310,6 +315,7 @@
310315
this.container_id = container_id; // think about this
311316
this.is_dirty = true;
312317
this.is_empty = Boolean(rough_cell.is_empty);
318+
this.overlay_background = null;
313319

314320
dir = dir == HOR ? VER : HOR;
315321

@@ -380,6 +386,11 @@
380386
var view_id = this.tab && this.tab.activeTab;
381387
if (view_id)
382388
{
389+
if (window.views[view_id] && window.views[view_id].type == "overlay" && !this.overlay_background)
390+
this.overlay_background = new OverlayBackground(this);
391+
392+
if (this.overlay_background)
393+
this.overlay_background.setup();
383394
this.toolbar.setup(view_id);
384395
var search = UI.get_instance().get_search(view_id);
385396
this.searchbar = search && search.get_searchbar() || null;
@@ -448,6 +459,11 @@
448459
}
449460
else
450461
{
462+
if (this.overlay_background)
463+
this.overlay_background.setDimensions(force_redraw);
464+
465+
if (this.overlay)
466+
this.overlay.update(this.left, this.top, force_redraw, is_resize);
451467
this.tab.setDimensions(force_redraw);
452468
this.toolbar.setDimensions(force_redraw);
453469
if (this.searchbar)
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
var OverlayBackground = function(cell)
2+
{
3+
this.init(cell);
4+
};
5+
6+
var OverlayBackgroundPrototype = function()
7+
{
8+
this.type = "overlay-background";
9+
this.height = 0;
10+
this.width = 0;
11+
this.top = 0;
12+
this.left = 0;
13+
this.is_dirty = true;
14+
15+
this.setDimensions = function(force_redraw)
16+
{
17+
18+
if(!this.horizontal_border_padding)
19+
this.setCSSProperties();
20+
21+
var dim = this.cell.top - 1;
22+
if( dim != this.top)
23+
{
24+
this.is_dirty = true;
25+
this.top = dim;
26+
}
27+
28+
dim = this.cell.left;
29+
if( dim != this.left)
30+
{
31+
this.is_dirty = true;
32+
this.left = dim;
33+
}
34+
35+
dim = this.cell.width - this.horizontal_border_padding;
36+
if( dim != this.width)
37+
{
38+
this.is_dirty = true;
39+
this.width = dim;
40+
}
41+
42+
dim = this.cell.height - this.vertical_border_padding + 1;
43+
if( dim != this.height)
44+
{
45+
this.is_dirty = true;
46+
this.height = dim;
47+
}
48+
this.update(force_redraw);
49+
};
50+
51+
this.setup = function(view_id)
52+
{
53+
if (!document.getElementById(this.type + '-to-' + this.cell.id))
54+
this.update();
55+
};
56+
57+
this.update = function(force_redraw)
58+
{
59+
if (force_redraw)
60+
this.is_dirty = true;
61+
var id = this.type + '-to-' + this.cell.id;
62+
var ele = document.getElementById(id);
63+
if (!ele)
64+
{
65+
ele = document.render(["div", "class", "background-overlay", "id", id]);
66+
viewport.appendChild(ele);
67+
}
68+
69+
if (this.is_dirty)
70+
{
71+
this.is_dirty = false;
72+
this.update_style(ele.style);
73+
this.update_sub_class();
74+
}
75+
return ele;
76+
}
77+
78+
this.init = function(cell)
79+
{
80+
this.cell = cell;
81+
this.initBase();
82+
};
83+
};
84+
85+
OverlayBackgroundPrototype.prototype = UIBase;
86+
OverlayBackground.prototype = new OverlayBackgroundPrototype();

src/ui-scripts/overlayview.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
var OverlayView = function(id, container_class, html, default_handler) {};
2+
var OverlayViewPrototype = function()
3+
{
4+
this.type = "overlay";
5+
6+
this.show = function()
7+
{
8+
var cell = window.topCell.get_cell(this.parent_view_id);
9+
if (cell)
10+
this.is_active = cell.show_overlay(this);
11+
};
12+
13+
this.hide = function()
14+
{
15+
var cell = window.topCell.get_cell(this.parent_view_id);
16+
if (cell)
17+
cell.hide_overlay(this.id);
18+
this.is_active = false;
19+
};
20+
21+
this.init = function(id, container_class, html, default_handler)
22+
{
23+
ViewBase.init.call(this, id, "", container_class, html, default_handler);
24+
};
25+
};
26+
OverlayViewPrototype.prototype = ViewBase;
27+
OverlayView.prototype = new OverlayViewPrototype();

src/ui-scripts/toolbar.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ var ToolbarBase = function()
167167
var search = this.filters.length && UI.get_instance().get_search(view_id);
168168
if (this.__is_visible)
169169
{
170+
var view = window.views[view_id];
171+
if (view && view.type == "overlay" && this.groups[0] != Toolbar.overlay_close_button)
172+
this.groups.unshift(Toolbar.overlay_close_button);
173+
170174
if (this.filters.length)
171175
{
172176
toolbar.render(templates.filters(this.filters));
@@ -233,7 +237,6 @@ var ToolbarBase = function()
233237
toolbar.render(custom.template(views[view_id]));
234238
}
235239
}
236-
237240
if (!window.views[view_id].is_enabled && toolbars[view_id])
238241
toolbars[view_id].disable();
239242
}
@@ -372,3 +375,16 @@ window.templates["toolbar-separator"] = function()
372375
return ["toolbar-separator"];
373376
};
374377

378+
Toolbar.overlay_close_button =
379+
{
380+
type: UI.TYPE_BUTTONS,
381+
items:
382+
[
383+
{
384+
handler: "close-overlay-view",
385+
icon: "close-overlay-view",
386+
title: ui_strings.S_CLOSE_OVERLAY_VIEW
387+
}
388+
]
389+
};
390+

src/ui-scripts/ui-actions.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,6 +306,15 @@ eventHandlers.click["toolbar-single-select"] = function(event, target)
306306
}
307307
}
308308

309+
eventHandlers.click["close-overlay-view"] = function(event, target)
310+
{
311+
var ui_id = target.get_ancestor_attr("ui-id");
312+
var toolbar = UIBase.getUIById(ui_id);
313+
var view = toolbar && window.views[toolbar.cell.tab.activeTab];
314+
if (view)
315+
view.hide();
316+
};
317+
309318

310319
/***** change handler *****/
311320

src/ui-scripts/ui-base.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,9 @@ var UIBase = new function()
177177
for( ; item = resolve_map[i]; i++)
178178
{
179179
container.innerHTML = '';
180-
source = container.appendChild(document.createElement(item.source));
180+
source = item.source
181+
? container.appendChild(document.createElement(item.source))
182+
: container.render(item.template);
181183
if (item.source_attrs)
182184
{
183185
for (var key in item.source_attrs)

src/ui-scripts/ui_framework.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,11 @@ var ui_framework = new function()
116116
}
117117
]
118118
},
119+
{
120+
template: ["div", "class", "background-overlay"],
121+
target: OverlayBackground.prototype,
122+
properties: resolve_map_properties
123+
},
119124
];
120125

121126

0 commit comments

Comments
 (0)