Ticket #6284: within.harobed.patch

File within.harobed.patch, 1.2 kB (added by harobed, 10 months ago)

dojo.within patch

  • dojo/_base/html.js

     
    946946                mb.y = abs.y; 
    947947                return mb; 
    948948        } 
     949 
     950    dojo.within = function(/*DomNode|String*/node, x, y) { 
     951        return (y >= node.offsetTop && 
     952                y < node.offsetTop + node.offsetHeight && 
     953                x >= node.offsetLeft && 
     954                x < node.offsetLeft + node.offsetWidth); 
     955    } 
    949956})(); 
    950957 
    951958// ============================= 
  • dojo/tests/_base/html.html

     
    194194                                                        t.assertFalse(dojo.hasClass(node, "b")); 
    195195                                                        dojo.removeClass(node, "c"); 
    196196                                                        t.assertTrue(!node.className); 
    197                                                 } 
     197                                                }, 
     198                        function testWithinFunction(t){ 
     199                            t.assertTrue(dojo.within(dojo.byId('sq100'), 150, 150)); 
     200                            t.assertFalse(dojo.within(dojo.byId('sq100'), 250, 150)); 
     201                        } 
    198202                                        ] 
    199203                                ); 
    200204                                doh.run();