mirror of
https://github.com/rkd77/elinks.git
synced 2025-01-03 14:57:44 -05:00
ecmascript: Added onchange hook for SELECT.
It works, but not for test case yet.
This commit is contained in:
parent
95b5e67bd9
commit
0f58529b7d
@ -69,6 +69,7 @@ struct script_event_hook {
|
||||
SEVHOOK_ONFOCUS,
|
||||
SEVHOOK_ONMOUSEOUT,
|
||||
SEVHOOK_ONBLUR,
|
||||
SEVHOOK_ONCHANGE,
|
||||
} type;
|
||||
unsigned char *src;
|
||||
};
|
||||
|
@ -155,6 +155,7 @@ done_form_control(struct form_control *fc)
|
||||
mem_free_if(fc->name);
|
||||
mem_free_if(fc->alt);
|
||||
mem_free_if(fc->default_value);
|
||||
mem_free_if(fc->onchange);
|
||||
|
||||
for (i = 0; i < fc->nvalues; i++) {
|
||||
mem_free_if(fc->values[i]);
|
||||
|
@ -87,6 +87,8 @@ struct form_control {
|
||||
unsigned char *name;
|
||||
unsigned char *alt;
|
||||
unsigned char *default_value;
|
||||
/* For FC_SELECT. I have not found better place for it. --witekfl */
|
||||
unsigned char *onchange;
|
||||
int default_state;
|
||||
int size;
|
||||
int cols, rows;
|
||||
|
@ -481,6 +481,7 @@ end_parse:
|
||||
|
||||
fc->id = get_attr_val(attr, "id", html_context->options->cp);
|
||||
fc->name = get_attr_val(attr, "name", html_context->options->cp);
|
||||
fc->onchange = get_attr_val(attr, "onchange", html_context->options->cp);
|
||||
fc->default_state = preselect < 0 ? 0 : preselect;
|
||||
fc->default_value = order ? stracpy(values[fc->default_state]) : stracpy("");
|
||||
fc->nvalues = order;
|
||||
|
@ -1169,6 +1169,12 @@ init_link_event_hooks(struct html_context *html_context, struct link *link)
|
||||
add_evhook(link->event_hooks, SEVHOOK_ONMOUSEOUT, format.onmouseout);
|
||||
add_evhook(link->event_hooks, SEVHOOK_ONBLUR, format.onblur);
|
||||
|
||||
if (link->type == LINK_SELECT) {
|
||||
struct form_control *fc = link->data.form_control;
|
||||
|
||||
add_evhook(link->event_hooks, SEVHOOK_ONCHANGE, fc->onchange);
|
||||
}
|
||||
|
||||
#undef add_evhook
|
||||
}
|
||||
|
||||
|
@ -147,6 +147,7 @@ selected_item(struct terminal *term, void *item_, void *ses_)
|
||||
}
|
||||
|
||||
refresh_view(ses, doc_view, 0);
|
||||
select_on_change(doc_view);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -99,6 +99,12 @@ do { \
|
||||
} while (0)
|
||||
|
||||
|
||||
int
|
||||
select_on_change(struct document_view *doc_view)
|
||||
{
|
||||
return current_link_evhook(doc_view, SEVHOOK_ONCHANGE);
|
||||
}
|
||||
|
||||
void
|
||||
set_link(struct document_view *doc_view)
|
||||
{
|
||||
|
@ -13,6 +13,8 @@ struct terminal;
|
||||
struct uri;
|
||||
struct conv_table;
|
||||
|
||||
int select_on_change(struct document_view *doc_view);
|
||||
|
||||
void set_link(struct document_view *doc_view);
|
||||
void clear_link(struct terminal *term, struct document_view *doc_view);
|
||||
void draw_current_link(struct session *ses, struct document_view *doc_view);
|
||||
|
Loading…
Reference in New Issue
Block a user