dojox/dtl/tag/logic.js

  • Provides:

    • dojox.dtl.tag.logic
  • Requires:

    • dojox.dtl._base in common
  • dojox.dtl.tag.logic.IfNode

    • type
      Function
    • parameters:
      • bools: (typeof )
      • trues: (typeof )
      • falses: (typeof )
      • type: (typeof )
    • source: [view]
        this.bools = bools;
        this.trues = trues;
        this.falses = falses;
        this.type = type;
    • summary
  • dojox.dtl.tag.logic.IfEqualNode

    • type
      Function
    • parameters:
      • var1: (typeof )
      • var2: (typeof )
      • trues: (typeof )
      • falses: (typeof )
      • negate: (typeof )
    • source: [view]
        this.var1 = new dd._Filter(var1);
        this.var2 = new dd._Filter(var2);
        this.trues = trues;
        this.falses = falses;
        this.negate = negate;
    • summary
  • dojox.dtl.tag.logic.ForNode

    • type
      Function
    • parameters:
      • assign: (typeof )
      • loop: (typeof )
      • reversed: (typeof )
      • nodelist: (typeof )
    • source: [view]
        this.assign = assign;
        this.loop = new dd._Filter(loop);
        this.reversed = reversed;
        this.nodelist = nodelist;
        this.pool = [];
    • summary
  • dojox.dtl.tag.logic.IfNode.bools

    • summary
  • dojox.dtl.tag.logic.IfNode.trues

    • summary
  • dojox.dtl.tag.logic.IfNode.falses

    • summary
  • dojox.dtl.tag.logic.IfNode.type

    • summary
  • dojox.dtl.tag.logic.IfNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var i, bool, ifnot, filter, value;
         if(this.type == "or"){
          for(i = 0; bool = this.bools[i]; i++){
           ifnot = bool[0];
           filter = bool[1];
           value = filter.resolve(context);
           if((value && !ifnot) || (ifnot && !value)){
            if(this.falses){
             buffer = this.falses.unrender(context, buffer);
            }
            return (this.trues) ? this.trues.render(context, buffer, this) : buffer;
           }
          }
          if(this.trues){
           buffer = this.trues.unrender(context, buffer);
          }
          return (this.falses) ? this.falses.render(context, buffer, this) : buffer;
         }else{
          for(i = 0; bool = this.bools[i]; i++){
           ifnot = bool[0];
           filter = bool[1];
           value = filter.resolve(context);
           // If we ever encounter a false value
           if(value == ifnot){
            if(this.trues){
             buffer = this.trues.unrender(context, buffer);
            }
            return (this.falses) ? this.falses.render(context, buffer, this) : buffer;
           }
          }
          if(this.falses){
           buffer = this.falses.unrender(context, buffer);
          }
          return (this.trues) ? this.trues.render(context, buffer, this) : buffer;
         }
         return buffer;
    • summary
  • dojox.dtl.tag.logic.IfNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         buffer = (this.trues) ? this.trues.unrender(context, buffer) : buffer;
         buffer = (this.falses) ? this.falses.unrender(context, buffer) : buffer;
         return buffer;
    • summary
  • dojox.dtl.tag.logic.IfNode.clone

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         var trues = (this.trues) ? this.trues.clone(buffer) : null;
         var falses = (this.falses) ? this.falses.clone(buffer) : null;
         return new this.constructor(this.bools, trues, falses, this.type);
    • summary
  • dojox.dtl.tag.logic.IfEqualNode.var1

    • summary
  • dojox.dtl.tag.logic.IfEqualNode.var2

    • summary
  • dojox.dtl.tag.logic.IfEqualNode.trues

    • summary
  • dojox.dtl.tag.logic.IfEqualNode.falses

    • summary
  • dojox.dtl.tag.logic.IfEqualNode.negate

    • summary
  • dojox.dtl.tag.logic.IfEqualNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var var1 = this.var1.resolve(context);
         var var2 = this.var2.resolve(context);
         var1 = (typeof var1 != "undefined") ? var1 : "";
         var2 = (typeof var1 != "undefined") ? var2 : "";
         if((this.negate && var1 != var2) || (!this.negate && var1 == var2)){
          if(this.falses){
           buffer = this.falses.unrender(context, buffer, this);
          }
          return (this.trues) ? this.trues.render(context, buffer, this) : buffer;
         }
         if(this.trues){
          buffer = this.trues.unrender(context, buffer, this);
         }
         return (this.falses) ? this.falses.render(context, buffer, this) : buffer;
    • summary
  • dojox.dtl.tag.logic.IfEqualNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         return ddtl.IfNode.prototype.unrender.call(this, context, buffer);
    • chains:
      • ddtl.IfNode.prototype.unrender: (call)
    • summary
  • dojox.dtl.tag.logic.IfEqualNode.clone

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         var trues = this.trues ? this.trues.clone(buffer) : null;
         var falses = this.falses ? this.falses.clone(buffer) : null;
         return new this.constructor(this.var1.getExpression(), this.var2.getExpression(), trues, falses, this.negate);
    • summary
  • dojox.dtl.tag.logic.ForNode.assign

    • summary
  • dojox.dtl.tag.logic.ForNode.loop

    • summary
  • dojox.dtl.tag.logic.ForNode.reversed

    • summary
  • dojox.dtl.tag.logic.ForNode.nodelist

    • summary
  • dojox.dtl.tag.logic.ForNode.pool

    • summary
  • dojox.dtl.tag.logic.ForNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var i, j, k;
         var dirty = false;
         var assign = this.assign;


         for(k = 0; k < assign.length; k++){
          if(typeof context[assign[k]] != "undefined"){
           dirty = true;
           context = context.push();
           break;
          }
         }
         if(!dirty && context.forloop){
          dirty = true;
          context = context.push();
         }


         var items = this.loop.resolve(context) || [];
         for(i = items.length; i < this.pool.length; i++){
          this.pool[i].unrender(context, buffer, this);
         }
         if(this.reversed){
          items = items.slice(0).reverse();
         }


         var isObject = dojo.isObject(items) && !dojo.isArrayLike(items);
         var arred = [];
         if(isObject){
          for(var key in items){
           arred.push(items[key]);
          }
         }else{
          arred = items;
         }


         var forloop = context.forloop = {
          parentloop: context.get("forloop", {})
         };
         var j = 0;
         for(i = 0; i < arred.length; i++){
          var item = arred[i];


          forloop.counter0 = j;
          forloop.counter = j + 1;
          forloop.revcounter0 = arred.length - j - 1;
          forloop.revcounter = arred.length - j;
          forloop.first = !j;
          forloop.last = (j == arred.length - 1);


          if(assign.length > 1 && dojo.isArrayLike(item)){
           if(!dirty){
            dirty = true;
            context = context.push();
           }
           var zipped = {};
           for(k = 0; k < item.length && k < assign.length; k++){
            zipped[assign[k]] = item[k];
           }
           dojo.mixin(context, zipped);
          }else{
           context[assign[0]] = item;
          }


          if(j + 1 > this.pool.length){
           this.pool.push(this.nodelist.clone(buffer));
          }
          buffer = this.pool[j++].render(context, buffer, this);
         }


         delete context.forloop;
         if(dirty){
          context = context.pop();
         }else{
          for(k = 0; k < assign.length; k++){
           delete context[assign[k]];
          }
         }
         return buffer;
    • summary
  • dojox.dtl.tag.logic.ForNode.unrender

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         for(var i = 0, pool; pool = this.pool[i]; i++){
          buffer = pool.unrender(context, buffer);
         }
         return buffer;
    • summary
  • dojox.dtl.tag.logic.ForNode.clone

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.assign, this.loop.getExpression(), this.reversed, this.nodelist.clone(buffer));
    • summary
  • context

    • mixins:
      • zipped: (normal)
    • summary
  • dojox.dtl.tag.logic

    • type
      Object
    • summary
  • dojox.dtl.tag

    • type
      Object
    • summary
  • dojox.dtl

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary