Focus for first input - welcome app - should I send pull request or not?

22 views
Skip to first unread message

Mirek Zvolsky

unread,
Jul 4, 2016, 9:24:39 AM7/4/16
to web2py-developers
In my welcome/views/layout.html
I have wrapped {{block page_js}}{{end page_js}}

and now:
- first form element will receive focus in all forms (except of grid search element),
- I can control it inside the {{block page_js}}:
-- $.w2p.focus = $(selector)  //focus for different element as the first one
-- $.w2p.focus = null  //don't set focus
-- $.w2p.focus.enabled = false  //don't set focus
-- $.w2p.focus.enabled = true  //gives focus to grid search

Should I make pull request for this (for welcome app only (with no impact to existing applications), with removing .focus() from default/user.html)
or is this not suitable?


<script>
$.w2p = {};
$.w2p.focus = $("form *:visible:enabled:first");
if ($.w2p.focus) {
$.w2p.focus = $.w2p.focus[0];
$.w2p.focus._onfocus = $.w2p.focus.getAttribute('onfocus');
$.w2p.focus.enabled = !($.w2p.focus._onfocus && $.w2p.focus._onfocus.indexOf('#w2p_query_panel') > -1);
}
</script>
{{block page_js}}{{end page_js}}
<script>
if ($.w2p.focus && $.w2p.focus.enabled) {
$.w2p.focus.focus();
}
</script>
Reply all
Reply to author
Forward
0 new messages