Skip to content

Commit 92968cf

Browse files
author
Chris K
committed
Added token filter and context menu.
1 parent 551cdfa commit 92968cf

File tree

9 files changed

+135
-213
lines changed

9 files changed

+135
-213
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
*.pyc
22
build/*
3-
*/Thumbs.db
3+
Thumbs.db
44
.DS_Store

src/ecma-debugger/eventlisteners/evlisteners.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ cls.RTListUpdateCTX.prototype = new function()
5454

5555
this._check_rt = function(rt_id)
5656
{
57-
return this.rt_map.hasOwnProperty(rt_id) &&
57+
return this.rt_map.hasOwnProperty(rt_id) &&
5858
(!this.rt_map[rt_id] || (this.expanded_map[rt_id] &&
5959
this.expanded_map[rt_id].length === 0));
6060
};
@@ -99,7 +99,7 @@ cls.EventListeners.prototype = new function()
9999

100100
/*
101101
data structure:
102-
102+
103103
this._rts = [{rt_id: <rt-id>,
104104
obj_id: <obj-id>,
105105
event_types: [<EventType>, ...]}, ...]
@@ -120,7 +120,7 @@ cls.EventListeners.prototype = new function()
120120
if (live_rts.length != this._rts.length)
121121
{
122122
this._rts = live_rts;
123-
this._view.update();
123+
this._view.update();
124124
}
125125
if (new_rt_ids)
126126
this._update_rt_list(new_rt_ids);
@@ -292,7 +292,7 @@ cls.EventListeners.prototype = new function()
292292
};
293293

294294
/* implementation */
295-
295+
296296
this.update = function()
297297
{
298298
this._rts = [];

src/ecma-debugger/eventlisteners/evlistenersidepanel.js

Lines changed: 24 additions & 175 deletions
Original file line numberDiff line numberDiff line change
@@ -10,188 +10,37 @@ cls.EventListenerSidePanelView.prototype = SidePanelView.prototype;
1010

1111
cls.EventListenerSidePanelView.create_ui_widgets = function()
1212
{
13-
/*
14-
var element_style = window.element_style;
15-
16-
new ToolbarConfig
17-
(
18-
'dom-side-panel',
19-
null,
20-
[
21-
{
22-
handler: 'css-inspector-text-search',
23-
title: ui_strings.S_SEARCH_INPUT_TOOLTIP,
24-
label: ui_strings.S_INPUT_DEFAULT_TEXT_FILTER,
25-
type: "filter"
26-
}
27-
]
28-
);
29-
30-
new Settings
31-
(
32-
// id
33-
'css-comp-style',
34-
// key-value map
35-
{
36-
'show-initial-values': false
37-
},
38-
// key-label map
39-
{
40-
'show-initial-values': ui_strings.S_SWITCH_SHOW_INITIAL_VALUES
41-
},
42-
// settings map
43-
{
44-
checkboxes:
45-
[
46-
'show-initial-values'
47-
]
48-
},
49-
null,
50-
"document"
51-
);
52-
53-
new Settings
54-
(
55-
// id
56-
"dom-side-panel",
57-
// key-value map
58-
{
59-
"show-longhand-properties": false,
60-
"color-notation": "hhex"
61-
},
62-
// key-label map
63-
{
64-
"show-longhand-properties": ui_strings.S_EXPAND_SHORTHANDS,
65-
"color-notation": ui_strings.S_COLOR_NOTATION
66-
},
67-
// settings map
68-
{
69-
contextmenu:
70-
[
71-
"show-longhand-properties"
72-
],
73-
customSettings:
74-
[
75-
"color-notation"
76-
]
77-
},
78-
{
79-
"color-notation": function(setting)
80-
{
81-
return new StylesheetTemplates().color_notation_setting(setting);
82-
}
83-
},
84-
"document",
85-
{
86-
"show-longhand-properties": function(value)
87-
{
88-
window.settings["css-inspector"].set("show-longhand-properties", value);
89-
element_style.update();
90-
}
91-
}
92-
);
93-
94-
new ToolbarConfig('css-comp-style');
95-
96-
new Switches
97-
(
98-
'css-comp-style',
99-
[
100-
'show-initial-values'
101-
]
102-
);
103-
104-
["link", "visited", "hover", "active", "focus", "selection"].forEach(function(pseudo_item) {
105-
if (window.settings["css-inspector"].get(pseudo_item))
106-
{
107-
element_style.add_pseudo_item(pseudo_item);
108-
}
109-
});
110-
111-
new ToolbarConfig('css-inspector');
112-
113-
new CstSelectToolbarSettings
114-
(
115-
'css-inspector',
13+
var ev_listener_toolbar_config =
14+
{
15+
view: "ev-listeners-all",
16+
groups:
11617
[
117-
'link',
118-
'visited',
119-
'hover',
120-
'active',
121-
'focus',
122-
'selection'
123-
],
124-
'pseudo-items'
125-
);
126-
127-
var broker = ActionBroker.get_instance();
128-
var contextmenu = ContextMenu.get_instance();
129-
contextmenu.register("style-inspector-rule", [
130-
{
131-
callback: function(event, target)
13218
{
133-
var items = [
19+
type: "buttons",
20+
items:
21+
[
13422
{
135-
label: ui_strings.M_CONTEXTMENU_DISABLE_DECLARATIONS,
136-
handler: function(event, target) {
137-
broker.dispatch_action("css-inspector", "disable-all-properties", event, target);
138-
}
23+
handler: "update-ev-listeners",
24+
title: ui_strings.S_BUTTON_LABEL_REFETCH_EVENT_LISTENERS,
13925
},
26+
]
27+
},
28+
{
29+
type: "input",
30+
items:
31+
[
14032
{
141-
label: ui_strings.M_CONTEXTMENU_ADD_DECLARATION,
142-
handler: function(event, target) {
143-
broker.dispatch_action("css-inspector", "insert-declaration-edit", event, target);
144-
}
145-
}
146-
];
147-
148-
// Only add this for a declaration, not on the whole rule
149-
while (target && !target.hasClass("css-declaration"))
150-
{
151-
target = target.parentElement;
152-
}
153-
154-
if (target)
155-
{
156-
items.push({
157-
label: ui_strings.M_CONTEXTMENU_EDIT_DECLARATION,
158-
handler: function(event, target) {
159-
broker.dispatch_action("css-inspector", "edit-css", event, target);
160-
}
33+
handler: cls.EventListenersView.TOKEN_FILTER,
34+
shortcuts: cls.EventListenersView.TOKEN_FILTER,
35+
title: ui_strings.S_SEARCH_INPUT_TOOLTIP,
36+
label: ui_strings.S_INPUT_DEFAULT_TEXT_FILTER,
37+
type: "filter"
16138
},
162-
{
163-
label: ui_strings.M_CONTEXTMENU_REMOVE_DECLARATION,
164-
handler: function(event, target) {
165-
broker.dispatch_action("css-inspector", "remove-property", event, target);
166-
}
167-
});
168-
}
169-
170-
// Only add this for the color swatch
171-
var swatch = target && target.querySelector(".color-swatch");
172-
if (swatch)
173-
{
174-
items.push(
175-
ContextMenu.separator,
176-
{
177-
label: ui_strings.M_CONTEXTMENU_OPEN_COLOR_PICKER,
178-
handler: function(event, target) {
179-
window.views['color-selector'].show_color_picker(swatch);
180-
}
181-
}
182-
);
183-
}
184-
185-
return items;
39+
]
18640
}
187-
}
188-
]);
189-
190-
window.eventHandlers.change["color-notation"] = function(event, target)
191-
{
192-
window.settings["dom-side-panel"].set("color-notation", target.value);
193-
window.element_style.update();
41+
]
19442
};
195-
*/
43+
44+
new ToolbarConfig(ev_listener_toolbar_config);
19645
};
19746

src/ecma-debugger/eventlisteners/evlistenersview.js

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,33 @@
77

88
cls.EventListenersView = function(id, name, container_class)
99
{
10+
var for_each = Array.prototype.forEach.call.bind(Array.prototype.forEach);
11+
1012
this.createView = function(container)
1113
{
12-
var data = this._data.get_data();
13-
if (data)
14+
this._text_search.setContainer(container);
15+
var input = this.getToolbarControl(container, cls.EventListenersView.TOKEN_FILTER);
16+
this._text_search.setFormInput(input);
17+
this._container = container;
18+
this._create_view();
19+
};
20+
21+
this.ondestroy = function()
22+
{
23+
this._text_search.cleanup();
24+
this._container = null;
25+
};
26+
27+
this._create_view = function(search_term)
28+
{
29+
if (this._container)
1430
{
15-
var tmpl = window.templates.main_ev_listener_view(data);
16-
container.clearAndRender(tmpl);
31+
var data = this._data.get_data();
32+
if (data)
33+
{
34+
var tmpl = window.templates.main_ev_listener_view(data, search_term);
35+
this._container.clearAndRender(tmpl);
36+
}
1737
}
1838
};
1939

@@ -27,15 +47,18 @@ cls.EventListenersView = function(id, name, container_class)
2747
{
2848
if (this._data.is_expanded(rt_id, ev_name))
2949
{
30-
var ls = li_ele.querySelector(".ev-listener-list");
31-
if (ls)
32-
ls.parentNode.removeChild(ls);
50+
if (event.type != "contextmenu")
51+
{
52+
var ls = li_ele.querySelector(".ev-listener-list");
53+
if (ls)
54+
ls.parentNode.removeChild(ls);
3355

34-
var h3 = li_ele.querySelector("h3");
35-
if (h3)
36-
h3.removeClass("unfolded");
56+
var h3 = li_ele.querySelector("h3");
57+
if (h3)
58+
h3.removeClass("unfolded");
3759

38-
this._data.collapse_listeners(rt_id, ev_name);
60+
this._data.collapse_listeners(rt_id, ev_name);
61+
}
3962
}
4063
else
4164
{
@@ -69,16 +92,56 @@ cls.EventListenersView = function(id, name, container_class)
6992
li_ele.render(tmpl);
7093
};
7194

95+
this._onbeforesearch = function(msg)
96+
{
97+
this._create_view(msg.search_term);
98+
};
99+
100+
this._oninput = function(event, target)
101+
{
102+
this._text_search.searchDelayed(target.value);
103+
};
104+
105+
this._expand_all_types = function(event, target)
106+
{
107+
var list = event.target.get_ancestor(".ev-type-list");
108+
var types = list && list.querySelectorAll(".ev-type");
109+
if (types)
110+
for_each(types, this._toggle_event_listeners.bind(this, event));
111+
};
112+
72113
this._init = function(id, name, container_class)
73114
{
74115
this.init(id, name, container_class);
75116
this._data = new cls.EventListeners(this);
117+
var update_ev_listeners = this._update_ev_listeners.bind(this);
76118
var evh = window.event_handlers;
77119
evh.click["toggle-ev-listeners"] = this._toggle_event_listeners.bind(this);
78-
evh.click["update-ev-listeners"] = this._update_ev_listeners.bind(this);
120+
evh.click["update-ev-listeners"] = update_ev_listeners;
121+
this._text_search = new TextSearch(1);
122+
this._text_search.set_query_selector(".ev-type");
123+
this._text_search.add_listener("onbeforesearch", this._onbeforesearch.bind(this));
124+
evh.input[cls.EventListenersView.TOKEN_FILTER] = this._oninput.bind(this);
125+
var glob_handl = ActionBroker.get_instance().get_global_handler();
126+
var cb = cls.Helpers.shortcut_search_cb.bind(this._text_search);
127+
glob_handl.register_shortcut_listener(cls.EventListenersView.TOKEN_FILTER, cb);
128+
var contextmenu =
129+
[
130+
{
131+
label: ui_strings.S_LABEL_STORAGE_UPDATE,
132+
handler: update_ev_listeners
133+
},
134+
{
135+
label: ui_strings.S_SWITCH_EXPAND_ALL,
136+
handler: this._expand_all_types.bind(this)
137+
},
138+
];
139+
ContextMenu.get_instance().register("ev-listeners-all", contextmenu);
79140
};
80141

81142
this._init(id, name, container_class);
82143
};
83144

145+
cls.EventListenersView.TOKEN_FILTER = "ev-listeners-text-search";
146+
84147
cls.EventListenersView.prototype = ViewBase;

0 commit comments

Comments
 (0)