]>
git.wh0rd.org - tt-rss.git/blob - lib/dojo/_base/NodeList.js.uncompressed.js
1 define("dojo/_base/NodeList", ["./kernel", "../query", "./array", "./html", "../NodeList-dom"], function(dojo
, query
, array
){
8 // This module extends dojo/NodeList with the legacy connect(), coords(),
9 // blur(), focus(), change(), click(), error(), keydown(), keypress(),
10 // keyup(), load(), mousedown(), mouseenter(), mouseleave(), mousemove(),
11 // mouseout(), mouseover(), mouseup(), and submit() methods.
15 var NodeList
= query
.NodeList
,
16 nlp
= NodeList
.prototype;
18 nlp
.connect
= NodeList
._adaptAsForEach(function(){
19 // don't bind early to dojo.connect since we no longer explicitly depend on it
20 return dojo
.connect
.apply(this, arguments
);
23 nlp.connect = function(methodName, objOrFunc, funcName){
25 // Attach event handlers to every item of the NodeList. Uses dojo.connect()
26 // so event properties are normalized.
28 // Application must manually require() "dojo/_base/connect" before using this method.
30 // the name of the method to attach to. For DOM events, this should be
31 // the lower-case name of the event
32 // objOrFunc: Object|Function|String
33 // if 2 arguments are passed (methodName, objOrFunc), objOrFunc should
34 // reference a function or be the name of the function in the global
35 // namespace to attach. If 3 arguments are provided
36 // (methodName, objOrFunc, funcName), objOrFunc must be the scope to
37 // locate the bound function in
39 // optional. A string naming the function in objOrFunc to bind to the
40 // event. May also be a function reference.
42 // add an onclick handler to every button on the page
43 // | query("div:nth-child(odd)").connect("onclick", function(e){
44 // | console.log("clicked!");
47 // attach foo.bar() to every odd div's onmouseover
48 // | query("div:nth-child(odd)").connect("onmouseover", foo, "bar");
50 return null; // NodeList
54 nlp
.coords
= NodeList
._adaptAsMap(dojo
.coords
);
56 nlp.coords = function(){
58 // Deprecated: Use position() for border-box x/y/w/h
59 // or marginBox() for margin-box w/h/l/t.
60 // Returns the box objects of all elements in a node list as
61 // an Array (*not* a NodeList). Acts like `domGeom.coords`, though assumes
62 // the node passed is each node in this list.
70 // list of all DOM events used in NodeList
71 "blur", "focus", "change", "click", "error", "keydown", "keypress",
72 "keyup", "load", "mousedown", "mouseenter", "mouseleave", "mousemove",
73 "mouseout", "mouseover", "mouseup", "submit"
76 // FIXME: pseudo-doc the above automatically generated on-event functions
78 // syntactic sugar for DOM events
79 array
.forEach(NodeList
.events
, function(evt
){
81 nlp
[_oe
] = function(a
, b
){
82 return this.connect(_oe
, a
, b
);
84 // FIXME: should these events trigger publishes?
86 return (a ? this.connect(_oe, a, b) :
87 this.forEach(function(n){
89 // listeners get buried by
90 // addEventListener and can't be dug back
91 // out to be triggered externally.
93 // http://developer.mozilla.org/en/docs/DOM:element
95 console.log(n, evt, _oe);
97 // FIXME: need synthetic event support!
98 var _e = { target: n, faux: true, type: evt };
99 // dojo._event_listener._synthesizeEvent({}, { target: n, faux: true, type: evt });
100 try{ n[evt](_e); }catch(e){ console.log(e); }
101 try{ n[_oe](_e); }catch(e){ console.log(e); }
108 dojo
.NodeList
= NodeList
;