]> git.wh0rd.org - tt-rss.git/blobdiff - lib/dojo/behavior.js
upgrade Dojo to 1.6.1
[tt-rss.git] / lib / dojo / behavior.js
index 15f1f23a3ba7a3bcded0a009bd30a9214d9e7995..8b058892f311f2671c124f5d8166589bd16f3c40 100644 (file)
@@ -1,5 +1,5 @@
 /*
-       Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
+       Copyright (c) 2004-2011, The Dojo Foundation All Rights Reserved.
        Available via Academic Free License >= 2.1 OR the modified BSD license.
        see: http://dojotoolkit.org/license for details
 */
@@ -9,23 +9,24 @@ if(!dojo._hasResource["dojo.behavior"]){ //_hasResource checks added by build. D
 dojo._hasResource["dojo.behavior"] = true;
 dojo.provide("dojo.behavior");
 
+
 dojo.behavior = new function(){
-       // summary: 
+       // summary:
        //              Utility for unobtrusive/progressive event binding, DOM traversal,
        //              and manipulation.
        //
        // description:
-       //              
-       //              A very simple, lightweight mechanism for applying code to 
-       //              existing documents, based around `dojo.query` (CSS3 selectors) for node selection, 
+       //
+       //              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()`;
-       //      
-       //              Behaviors apply to a given page, and are registered following the syntax 
+       //
+       //              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".
-       //              
+       //
        //              Added behaviors are applied to the current DOM when .apply() is called,
-       //              matching only new nodes found since .apply() was last called. 
-       //              
+       //              matching only new nodes found since .apply() was last called.
+       //
        function arrIn(obj, name){
                if(!obj[name]){ obj[name] = []; }
                return obj[name];
@@ -51,7 +52,7 @@ dojo.behavior = new function(){
        this.add = function(/* Object */behaviorObj){
                //      summary:
                //              Add the specified behavior to the list of behaviors, ignoring existing
-               //              matches. 
+               //              matches.
                //
                //      description:
                //              Add the specified behavior to the list of behaviors which will
@@ -59,26 +60,26 @@ dojo.behavior = new function(){
                //              an already existing behavior do not replace the previous rules,
                //              but are instead additive. New nodes which match the rule will
                //              have all add()-ed behaviors applied to them when matched.
-               //              
+               //
                //              The "found" method is a generalized handler that's called as soon
                //              as the node matches the selector. Rules for values that follow also
                //              apply to the "found" key.
-               //              
-               //              The "on*" handlers are attached with `dojo.connect()`, using the 
+               //
+               //              The "on*" handlers are attached with `dojo.connect()`, using the
                //              matching node
-               //              
+               //
                //              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 
+               //              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.
                //
                //              There are a variety of formats permitted in the behaviorObject
-               //      
+               //
                //      example:
-               //              Simple list of properties. "found" is special. "Found" is assumed if 
+               //              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({
@@ -95,7 +96,7 @@ dojo.behavior = new function(){
                //      |               }
                //      |       });
                //
-               //      example: 
+               //      example:
                //               If property is a string, a dojo.publish will be issued on the channel:
                //
                //      |       dojo.behavior.add({
@@ -106,15 +107,15 @@ dojo.behavior = new function(){
                //      |               }
                //      |       });
                //      |       dojo.subscribe("/got/newAnchor", function(node){
-               //      |               // handle node finding when dojo.behavior.apply() is called, 
+               //      |               // handle node finding when dojo.behavior.apply() is called,
                //      |               // provided a newly matched node is found.
                //      |       });
                //
                //      example:
-               //              Scoping can be accomplished by passing an object as a property to 
+               //              Scoping can be accomplished by passing an object as a property to
                //              a connection handle (on*):
-               //      
-               //      |       dojo.behavior.add({ 
+               //
+               //      |       dojo.behavior.add({
                //      |                       "#id": {
                //      |                               // like calling dojo.hitch(foo,"bar"). execute foo.bar() in scope of foo
                //      |                               "onmouseenter": { targetObj: foo, targetFunc: "bar" },
@@ -122,7 +123,7 @@ dojo.behavior = new function(){
                //      |                       }
                //      |       });
                //
-               //      example: 
+               //      example:
                //              Bahaviors match on CSS3 Selectors, powered by dojo.query. Example selectors:
                //
                //      |       dojo.behavior.add({
@@ -130,31 +131,31 @@ dojo.behavior = new function(){
                //      |               "#id4 > *": function(element){
                //      |                       // ...
                //      |               },
-               //      |               
+               //      |
                //      |               // match the first child node that's an element
                //      |               "#id4 > :first-child": { ... },
-               //      |               
+               //      |
                //      |               // match the last child node that's an element
                //      |               "#id4 > :last-child":  { ... },
-               //      |               
+               //      |
                //      |               // all elements of type tagname
                //      |               "tagname": {
                //      |                       // ...
                //      |               },
-               //      |               
+               //      |
                //      |               "tagname1 tagname2 tagname3": {
                //      |                       // ...
                //      |               },
-               //      |               
+               //      |
                //      |               ".classname": {
                //      |                       // ...
                //      |               },
-               //      |               
+               //      |
                //      |               "tagname.classname": {
                //      |                       // ...
                //      |               }
                //      |       });
-               //   
+               //
 
                var tmpObj = {};
                forIn(behaviorObj, this, function(behavior, name){
@@ -171,7 +172,7 @@ dojo.behavior = new function(){
                                arrIn(cversion, ruleName).push(rule);
                        });
                });
-       }
+       };
 
        var _applyToNode = function(node, action, ruleSetName){
                if(dojo.isString(action)){
@@ -189,33 +190,33 @@ dojo.behavior = new function(){
                                dojo.connect(node, ruleSetName, action);
                        }
                }
-       }
+       };
 
        this.apply = function(){
                // summary:
                //              Applies all currently registered behaviors to the document.
-               // 
+               //
                // description:
                //              Applies all currently registered behaviors to the document,
                //              taking care to ensure that only incremental updates are made
-               //              since the last time add() or apply() were called. 
-               //      
+               //              since the last time add() or apply() were called.
+               //
                //              If new matching nodes have been added, all rules in a behavior will be
                //              applied to that node. For previously matched nodes, only
                //              behaviors which have been added since the last call to apply()
                //              will be added to the nodes.
                //
-               //              apply() is called once automatically by `dojo.addOnLoad`, so 
+               //              apply() is called once automatically by `dojo.addOnLoad`, so
                //              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 
+               //
+               //              Calling appy() manually after manipulating the DOM is required
                //              to rescan the DOM and apply newly .add()ed behaviors, or to match
-               //              nodes that match existing behaviors when those nodes are added to 
+               //              nodes that match existing behaviors when those nodes are added to
                //              the DOM.
-               //              
+               //
                forIn(this._behaviors, function(tBehavior, id){
-                       dojo.query(id).forEach( 
+                       dojo.query(id).forEach(
                                function(elem){
                                        var runFrom = 0;
                                        var bid = "_dj_behavior_"+tBehavior.id;
@@ -242,8 +243,8 @@ dojo.behavior = new function(){
                                }
                        );
                });
-       }
-}
+       };
+};
 
 dojo.addOnLoad(dojo.behavior, "apply");