Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. $('a[href], area[href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), button:not([disabled]), iframe, object, embed, *[tabindex], *[contenteditable]')
  2.  
  3. function focusable( element ) {
  4. var map, mapName, img,
  5. nodeName = element.nodeName.toLowerCase(),
  6. isTabIndexNotNaN = !isNaN( $.attr( element, "tabindex" ) );
  7. if ( "area" === nodeName ) {
  8. map = element.parentNode;
  9. mapName = map.name;
  10. if ( !element.href || !mapName || map.nodeName.toLowerCase() !== "map" ) {
  11. return false;
  12. }
  13. img = $( "img[usemap=#" + mapName + "]" )[0];
  14. return !!img && visible( img );
  15. }
  16. return ( /input|select|textarea|button|object/.test( nodeName ) ?
  17. !element.disabled :
  18. "a" === nodeName ?
  19. element.href || isTabIndexNotNaN :
  20. isTabIndexNotNaN) &&
  21. // the element and all of its ancestors must be visible
  22. visible( element );
  23.  
  24. function visible( element ) {
  25. return $.expr.filters.visible( element ) &&
  26. !$( element ).parents().addBack().filter(function() {
  27. return $.css( this, "visibility" ) === "hidden";
  28. }).length;
  29. }
  30. }
  31.  
  32. $('*').each(function() {
  33. if(typeof this.focus == 'function') {
  34. // Do something with this element
  35. }
  36. }) ;
  37.  
  38. $(document.body).on("focus", "*", function(e) {
  39. //Scroll to e.target
  40. });
  41.  
  42. if ('focus' in element) {
  43. // element supports the foucs event
  44. }
  45.  
  46. $('a[href], area[href], input, select, textarea, button, iframe, object, embed, *[tabindex], *[contenteditable]')
  47. .filter(':not([tabindex=-1]):not([disabled]):visible');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement