-define("dojo/behavior", ["./_base/kernel", "./_base/lang", "./_base/array", "./_base/connect", "./query", "./ready"], function(dojo, lang, darray, connect, query, ready) {
- // module:
- // dojo/behavior
- // summary:
- // TODOC
+define("dojo/behavior", ["./_base/kernel", "./_base/lang", "./_base/array", "./_base/connect", "./query", "./ready"],
+function(dojo, lang, darray, connect, query, ready){
+
+// module:
+// dojo/behavior
+dojo.deprecated("dojo.behavior", "Use dojo/on with event delegation (on.selector())");
-dojo.behavior = new function(){
+var Behavior = function(){
// summary:
- // Utility for unobtrusive/progressive event binding, DOM traversal,
- // and manipulation.
- //
+ // Deprecated. dojo/behavior's functionality can be achieved using event delegation using dojo/on
+ // and on.selector().
// description:
- //
// A very simple, lightweight mechanism for applying code to
- // existing documents, based around `dojo.query` (CSS3 selectors) for node selection,
- // and a simple two-command API: `dojo.behavior.add()` and `dojo.behavior.apply()`;
+ // existing documents, based around `dojo/query` (CSS3 selectors) for node selection,
+ // and a simple two-command API: `add()` and `apply()`;
//
// Behaviors apply to a given page, and are registered following the syntax
- // options described by `dojo.behavior.add` to match nodes to actions, or "behaviors".
+ // options described by `add()` to match nodes to actions, or "behaviors".
//
// Added behaviors are applied to the current DOM when .apply() is called,
// matching only new nodes found since .apply() was last called.
- //
+
function arrIn(obj, name){
if(!obj[name]){ obj[name] = []; }
return obj[name];
// If the value corresponding to the ID key is a function and not a
// list, it's treated as though it was the value of "found".
//
- // dojo.behavior.add() can be called any number of times before
- // the DOM is ready. `dojo.behavior.apply()` is called automatically
+ // dojo/behavior.add() can be called any number of times before
+ // the DOM is ready. `dojo/behavior.apply()` is called automatically
// by `dojo.addOnLoad`, though can be called to re-apply previously added
// behaviors anytime the DOM changes.
//
// Simple list of properties. "found" is special. "Found" is assumed if
// no property object for a given selector, and property is a function.
//
- // | dojo.behavior.add({
+ // | behavior.add({
// | "#id": {
// | "found": function(element){
// | // node match found
// example:
// If property is a string, a dojo.publish will be issued on the channel:
//
- // | dojo.behavior.add({
- // | // dojo.publish() whenever class="noclick" found on anchors
+ // | behavior.add({
+ // | // topic.publish() whenever class="noclick" found on anchors
// | "a.noclick": "/got/newAnchor",
// | "div.wrapper": {
// | "onclick": "/node/wasClicked"
// | }
// | });
- // | dojo.subscribe("/got/newAnchor", function(node){
- // | // handle node finding when dojo.behavior.apply() is called,
+ // | topic.subscribe("/got/newAnchor", function(node){
+ // | // handle node finding when dojo/behavior.apply() is called,
// | // provided a newly matched node is found.
// | });
//
// Scoping can be accomplished by passing an object as a property to
// a connection handle (on*):
//
- // | dojo.behavior.add({
+ // | behavior.add({
// | "#id": {
// | // like calling dojo.hitch(foo,"bar"). execute foo.bar() in scope of foo
// | "onmouseenter": { targetObj: foo, targetFunc: "bar" },
// | });
//
// example:
- // Bahaviors match on CSS3 Selectors, powered by dojo.query. Example selectors:
+ // Behaviors match on CSS3 Selectors, powered by dojo/query. Example selectors:
//
- // | dojo.behavior.add({
+ // | behavior.add({
// | // match all direct descendants
// | "#id4 > *": function(element){
// | // ...
// will be added to the nodes.
//
// apply() is called once automatically by `dojo.addOnLoad`, so
- // registering behaviors with `dojo.behavior.add` before the DOM is
+ // registering behaviors with `dojo/behavior.add()` before the DOM is
// ready is acceptable, provided the dojo.behavior module is ready.
//
// Calling appy() manually after manipulating the DOM is required
};
};
+dojo.behavior = new Behavior();
+
ready(dojo.behavior, "apply"); // FIXME: should this use a priority? before/after parser priority?
return dojo.behavior;