Posts

javascript - Find element closest to click coordinates -

is there easy way detect closest child element coordinates of mouse click in container?. in case container div ex: <div style="white-space: pre-wrap"> <span>e1</span> <span>\n</span> <span>\n</span> <span>e4</span> <span>e5</span> </div> in above case determine span closest top/left coordinates click took place in div. due line breaks spans don't cover div in click event have access top/left through e.clienty; however, having difficulty traversing spans detect span closest coordinates of click inside div. click handler: function(e){ var yop = e.clienty; } here links might useful document.elementfrompoint : from summary on mdn link: returns element document elementfrompoint method being called topmost element lies under given point. element, specify point via coordinates, in css pixels, relative upper-left-most point in window or frame containing d...

c# - Reverse Generated Items & Tab Order of ItemsControl Collection -

so know itemscontrol generate items top-to-bottom in itemspanel. yes can change sort order , generate them in different ways here's actual problem. if have itemscontrol using itemtemplate multiple uielement 's , use example, stackpanel itemspanel end natural tab order of like; a. 1 2 3 4 5 b. 6 7 8 9 10 c. 11 12 13 14 15 expected, use either order of placement or flowdirection on itemtemplate get; a. 5 4 3 2 1 b. 10 9 8 7 6 c. 15 14 13 12 11 now, question how achieve? (in efficient way) order more like; c. 11 12 13 14 15 b. 6 7 8 9 10 a. 1 2 3 4 5 now if you're thinking.. "ugh, shift + tab dummy..." wish option. requirement using tab, , generating collection in reverse bottom top instead of top bottom , having tab order reversed while they're in control. wise try , hijack shift/tab event , convert tab somehow? if case answers part of question. hopefully someones ran before or enjoys interesting question insigh...

java - Is this a DAO manager pattern? What are the appropriate class and interface names? -

i have interface, somethingdao , , implementing class, somethingdaoimpl . interface consists of 11 methods, each method requires 1 or more complex sql queries. i broke implementing class several smaller classes, let's call them helper1 , helper2 , helper3 , ... helpern lack of better names. somethingdaoimpl has instance of each, , routes method calls each. public class somethingdaoimpl implements somethingdao { private helper1 helper1; private helper2 helper2; private helper3 helper3; // ... private helper8 helper8; public list<x> getx(...) { return helper1.getx(); } public list<y> gety(...) { return helper2.gety(); } public list<x> getdetailedx(...) { list<x> ds = getx(...); helper6.addto(ds); helper7.addto(ds); helper8.addto(ds); return ds; } } is there name technique? complex dao has several "worker" bees work it, , manages them...

python - Why is my method returning None? -

i have following method call: ncols = 3 npegs = 4 first_guess = [] print("calling first guess method") first_guess = firstguess(ncols, npegs, first_guess) print("after method call: " + str(first_guess)) firstguess method: def firstguess(ncols, npegs, first_guess): """used setting first guess of game""" print("in firstguess method") c in range(1, ncols + 1): if len(first_guess) == npegs: print("about return first guess: " + str(first_guess)) return first_guess else: first_guess.append(c) print("out of loop, first_guess len " + str(len(first_guess)) + ", " + str(first_guess)) if len(first_guess) <= npegs: #there less color options pegs firstguess(ncols, npegs, first_guess) this seems returning none reason cannot figure out. here output: calling first guess method in firstguess method out of loop, first_guess len 3, [1,...

google chrome - Cross-origin redirect with XHR -

i try realize following scenario: load page origin a.com start synchronous xhr request script on page resource on same origin a.com this request answered 302-redirect resource on origin b.com i expect cross-origin redirect processed, instead error returned xhr-send method , no request nor preflight request triggered. chrome (26): error message 'network_err: xmlhttprequest exception 101' firefox (20): error message [exception... "failure" nsresult: "0x80004005 (ns_error_failure)" ... ie9: no error message xhr send() returns status=12017 according xhr specification have expected redirect works cross-origin. any idea how cross-origin redirect running? that won't work because redirect handled browser , xhr sees page browser got redirected to—which means is cross domain—which means fail unless b.com explicitly allows a.com domain access it. you can have other page on a.com act proxy , download content on b.com , output respo...

ruby on rails - Search polygons within polygon with elasticsearch -

is there way search polygons inside polygon elasticsearch? if not, possible solr or system? with solr 4.3 became possible; finished working on couple weeks ago , i'm pretty excited it. learn how use new solr 4 spatial field, see: http://wiki.apache.org/solr/solradaptersforlucenespatial4 what's new can use "iswithin" , "contains" predicates; there's "isdisjointto" too. based on question, it's not clear me of want. imagine 3-part sentence in first/left part index data, there's spatial predicate, there's query shape. if want search indexed shapes within query shape, use "iswithin". update wiki show these predicates.

ASP.NET MVC 3 - How do I allow to enter in html textarea -

i want use granular data validation. [allowhtml] attribute not working formcollection . there alternative use validateinput(false) ? in metadata: [allowhtml] [datatype(datatype.multilinetext)] [display(name = "content")] public string content { get; set; } in edit action: [httppost] public virtual actionresult edit(int id, formcollection formcollection) { var obj = service.get(id); if (modelstate.isvalid) { updatemodel(obj, formcollection); service.update(obj); return onedited(obj); } return view(obj); } you can't use allowhtml formcollection. use [validateinput] attribute disabled validation values: [httppost] [validateinput(false)] public actionresult edit(formcollection collection, int id) { var myentity = _myrepo.get(id); tryupdatemodel(objective); return dosave(objective); } this being said use following: [httppost] public actionresult edit(myentity entity) { if (modelstate.isva...