Skip to content

Commit ce51a55

Browse files
author
Chris K
committed
Show script on clicking handler and show reload dialog on clicking '<missing script source>'.
1 parent fb83ed2 commit ce51a55

File tree

7 files changed

+60
-12
lines changed

7 files changed

+60
-12
lines changed

src/ecma-debugger/eventlisteners/evlisteners.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
margin: 0;
1414
}
1515

16+
.ev-missing-script:hover
17+
{
18+
border-radius: 2px;
19+
box-shadow: 0 0 0 1px #d3dff8;
20+
background-color: #d3dff8;
21+
}
22+
1623
.ev-listener
1724
{
1825
display: inline-block;
@@ -38,7 +45,7 @@
3845

3946
.ev-listener-tooltip .ev-type
4047
{
41-
background-color: hsla(0, 0%, 0%, 0.05);
48+
background-color: hsla(0, 0%, 0%, 0.04);
4249
padding: 2px 8px;
4350
margin: 0 -8px;
4451
}
@@ -61,7 +68,7 @@
6168

6269
.tooltip-function-source .js-source-line-numbers
6370
{
64-
background-color: hsla(0, 0%, 0%, .03);
71+
xbackground-color: hsla(0, 0%, 0%, .03);
6572
border-radius: 0 0 0 3px;
6673
}
6774

src/ecma-debugger/eventlisteners/evlistenertemplates.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@
134134
"data-rt-id", String(rt_id),
135135
"data-obj-id", String(listener[LISTENER_OBJECT_ID]),
136136
"data-class-name", "Function",
137+
"handler", "ev-function-source",
137138
"class", "ev-origin"]]);
138139
}
139140
var script_id = position && position[SCRIPT_ID];
@@ -153,7 +154,9 @@
153154
}
154155
}
155156
else
156-
ret.push(["dd", ui_strings.S_INFO_MISSING_JS_SOURCE_FILE]);
157+
ret.push(["dd", ui_strings.S_INFO_MISSING_JS_SOURCE_FILE,
158+
"handler", "reload-script-dialog",
159+
"class", "ev-missing-script"]);
157160

158161
return ret;
159162
};

src/ecma-debugger/eventlisteners/evlistenertooltip.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,16 +73,31 @@ cls.EvListenerTooltip = function()
7373
}
7474
};
7575

76+
var _handle_function_source = function(event, target)
77+
{
78+
var inspection_tooltip = cls.JSInspectionTooltip.get_tooltip();
79+
if (inspection_tooltip)
80+
inspection_tooltip.handle_function_source(event, target);
81+
};
82+
83+
var _reload_script_dialog = function(event, target)
84+
{
85+
new ConfirmDialog(ui_strings.D_RELOAD_SCRIPTS,
86+
function(){ window.runtimes.reloadWindow(); }).show();
87+
};
88+
7689
var _init = function(view)
7790
{
7891
_tooltip = Tooltips.register(cls.EvListenerTooltip.tooltip_name, true);
7992
_url_tooltip = Tooltips.register("url-tooltip", true);
93+
window.event_handlers.click["ev-function-source"] = _handle_function_source;
8094

8195
_tooltip.ontooltip = _ontooltip;
8296
_tooltip.onhide = _hide_tooltip;
8397
//_tooltip.ontooltipenter = _ontooltipenter;
8498
//_tooltip.ontooltipleave = _ontooltipleave;
8599
_tooltip.ontooltipclick = _ontooltipclick;
100+
window.event_handlers.click["reload-script-dialog"] = _reload_script_dialog;
86101
};
87102

88103
_init();

src/ecma-debugger/js-source-view.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,15 @@ cls.JsSourceView = function(id, name, container_class)
450450
}
451451
}
452452

453+
this.show_script = function(script_id, line_no_start, line_no_end)
454+
{
455+
// This will also be set from show_and_flash_line, but setting it before showing
456+
// the view prevents the old script from flashing.
457+
window.runtimes.setSelectedScript(script_id);
458+
UI.get_instance().show_view("js_mode");
459+
this.show_and_flash_line(script_id, line_no_start, line_no_end);
460+
};
461+
453462
this.show_and_flash_line = function(script_id, line_no_start, line_no_end)
454463
{
455464
if (typeof line_no_start != "number")

src/ecma-debugger/objectinspection.6.0/inspectiontooltip.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,21 @@ cls.JSInspectionTooltip = function()
142142
}
143143
};
144144

145+
this.handle_function_source = function(event, target)
146+
{
147+
var rt_id = Number(target.get_ancestor_attr("data-rt-id"));
148+
var obj_id = Number(target.get_ancestor_attr("data-obj-id"));
149+
if (_cur_object && _cur_ctx &&
150+
_cur_object.rt_id == rt_id && _cur_object.obj_id == obj_id &&
151+
_cur_ctx.script && _cur_ctx.function_definition &&
152+
window.views.js_source)
153+
{
154+
window.views.js_source.show_script(_cur_ctx.script.script_id,
155+
_cur_ctx.function_definition.start_line,
156+
_cur_ctx.function_definition.end_line);
157+
}
158+
};
159+
145160
var _init = function(view)
146161
{
147162
_tooltip = Tooltips.register(cls.JSInspectionTooltip.tooltip_name, true, true,
@@ -168,3 +183,8 @@ cls.JSInspectionTooltip.register = function()
168183
{
169184
this._tooltip = new cls.JSInspectionTooltip();
170185
};
186+
187+
cls.JSInspectionTooltip.get_tooltip = function()
188+
{
189+
return this._tooltip;
190+
};

src/repl/repl_view.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -933,15 +933,8 @@ cls.ReplView = function(id, name, container_class, html, default_handler) {
933933
var script_id = Number(target.getAttribute("data-scriptid"));
934934
var start_line = Number(target.getAttribute("data-scriptline"));
935935
var end_line = Number(target.getAttribute("data-script-endline"));
936-
var sourceview = window.views.js_source;
937-
938-
// This will also be set from show_and_flash_line, but setting it before showing
939-
// the view prevents the old script from flashing.
940-
window.runtimes.setSelectedScript(script_id);
941-
UI.get_instance().show_view("js_mode");
942-
if (sourceview)
943-
sourceview.show_and_flash_line(script_id, start_line, end_line);
944-
936+
if (window.views.js_source)
937+
window.views.js_source.show_script(script_id, start_line, end_line);
945938
}.bind(this);
946939

947940
this.mode_labels = {

src/ui-scripts/tooltip/tooltip.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
background-color: #aac2f2;
1616
box-shadow: 0 0 0 1px #aac2f2;
1717
border-radius: 2px;
18+
text-shadow: none;
1819
}
1920

2021
.tooltip-container h2

0 commit comments

Comments
 (0)