dojox/dtl/tag/loop.js

  • Provides:

    • dojox.dtl.tag.loop
  • Requires:

    • dojox.dtl._base in common
    • dojox.string.tokenize in common
  • dojox.dtl.tag.loop.CycleNode

    • type
      Function
    • parameters:
      • cyclevars: (typeof )
      • name: (typeof )
      • text: (typeof )
      • shared: (typeof )
    • source: [view]
        this.cyclevars = cyclevars;
        this.name = name;
        this.contents = text;
        this.shared = shared || {counter: -1, map: {}};
    • summary
  • dojox.dtl.tag.loop.IfChangedNode

    • type
      Function
    • parameters:
      • nodes: (typeof )
      • vars: (typeof )
      • shared: (typeof )
    • source: [view]
        this.nodes = nodes;
        this._vars = vars;
        this.shared = shared || {last: null, counter: 0};
        this.vars = dojo.map(vars, function(item){
         return new dojox.dtl._Filter(item);
        });
    • summary
  • dojox.dtl.tag.loop.RegroupNode

    • type
      Function
    • parameters:
      • expression: (typeof )
      • key: (typeof )
      • alias: (typeof )
    • source: [view]
        this._expression = expression;
        this.expression = new dd._Filter(expression);
        this.key = key;
        this.alias = alias;
    • summary
  • dojox.dtl.tag.loop.CycleNode.cyclevars

    • summary
  • dojox.dtl.tag.loop.CycleNode.name

    • summary
  • dojox.dtl.tag.loop.CycleNode.contents

    • summary
  • dojox.dtl.tag.loop.CycleNode.shared

    • summary
  • dojox.dtl.tag.loop.CycleNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         if(context.forloop && !context.forloop.counter0){
          this.shared.counter = -1;
         }


         ++this.shared.counter;
         var value = this.cyclevars[this.shared.counter % this.cyclevars.length];


         var map = this.shared.map;
         if(!map[value]){
          map[value] = new dd._Filter(value);
         }
         value = map[value].resolve(context, buffer);


         if(this.name){
          context[this.name] = value;
         }
         this.contents.set(value);
         return this.contents.render(context, buffer);
    • summary
  • dojox.dtl.tag.loop.CycleNode.shared.counter

    • summary
  • dojox.dtl.tag.loop.CycleNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         return this.contents.unrender(context, buffer);
    • summary
  • dojox.dtl.tag.loop.CycleNode.clone

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.cyclevars, this.name, this.contents.clone(buffer), this.shared);
    • summary
  • dojox.dtl.tag.loop.IfChangedNode.nodes

    • summary
  • dojox.dtl.tag.loop.IfChangedNode._vars

    • summary
  • dojox.dtl.tag.loop.IfChangedNode.shared

    • summary
  • dojox.dtl.tag.loop.IfChangedNode.vars

    • summary
  • dojox.dtl.tag.loop.IfChangedNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         if(context.forloop){
          if(context.forloop.counter <= this.shared.counter){
           this.shared.last = null;
          }
          this.shared.counter = context.forloop.counter;
         }


         var change;
         if(this.vars.length){
          change = dojo.toJson(dojo.map(this.vars, function(item){
           return item.resolve(context);
          }));
         }else{
          change = this.nodes.dummyRender(context, buffer);
         }


         if(change != this.shared.last){
          var firstloop = (this.shared.last === null);
          this.shared.last = change;
          context = context.push();
          context.ifchanged = {firstloop: firstloop};
          buffer = this.nodes.render(context, buffer);
          context = context.pop();
         }else{
          buffer = this.nodes.unrender(context, buffer);
         }
         return buffer;
    • summary
  • dojox.dtl.tag.loop.IfChangedNode.shared.last

    • summary
  • dojox.dtl.tag.loop.IfChangedNode.shared.counter

    • summary
  • dojox.dtl.tag.loop.IfChangedNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         return this.nodes.unrender(context, buffer);
    • summary
  • dojox.dtl.tag.loop.IfChangedNode.clone

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.nodes.clone(buffer), this._vars, this.shared);
    • summary
  • dojox.dtl.tag.loop.RegroupNode._expression

    • summary
  • dojox.dtl.tag.loop.RegroupNode.expression

    • summary
  • dojox.dtl.tag.loop.RegroupNode.key

    • summary
  • dojox.dtl.tag.loop.RegroupNode.alias

    • summary
  • dojox.dtl.tag.loop.RegroupNode._push

    • type
      Function
    • parameters:
      • container: (typeof )
      • grouper: (typeof )
      • stack: (typeof )
    • source: [view]
         if(stack.length){
          container.push({ grouper: grouper, list: stack });
         }
    • summary
  • dojox.dtl.tag.loop.RegroupNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         context[this.alias] = [];
         var list = this.expression.resolve(context);
         if(list){
          var last = null;
          var stack = [];
          for(var i = 0; i < list.length; i++){
           var id = list[i][this.key];
           if(last !== id){
            this._push(context[this.alias], last, stack);
            last = id;
            stack = [list[i]];
           }else{
            stack.push(list[i]);
           }
          }
          this._push(context[this.alias], last, stack);
         }
         return buffer;
    • summary
  • dojox.dtl.tag.loop.RegroupNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         return buffer;
    • summary
  • dojox.dtl.tag.loop.RegroupNode.clone

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         return this;
    • summary
  • dojox.dtl.tag.loop

    • type
      Object
    • summary
  • dojox.dtl.tag

    • type
      Object
    • summary
  • dojox.dtl

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary