import'dart:html';DivElementtoggle=querySelector('#menu-dropdown');DivElementmenu=querySelector('#menuDiv-dropdown');voidcheck(Evente){if(!checkParent(e.target,menu)){//click NOT on the menuif(checkParent(e.target,toggle)){// click on the link// http://stackoverflow.com/questions/13789879/getting-elements-global-document-coordinates-in-dart-aka-some-offsetmenu.style.left=toggle.getBoundingClientRect().left.toString()+'px';// http://stackoverflow.com/questions/17756044/how-do-i-toggle-a-css-class-based-on-a-boolean-with-dartmenu.classes.toggle('invisible');}else{// click both outside link and outside menu, hide menumenu.classes.add('invisible');}}}boolcheckParent(target,elm){while(target.parent!=null){if(target==elm){returntrue;}target=target.parent;}returnfalse;}voidmain(){document.onClick.listen(check);}