dojox/dtl/tag/misc.js

  • Provides:

    • dojox.dtl.tag.misc
  • Requires:

    • dojox.dtl._base in common
  • dojox.dtl.tag.misc.DebugNode

    • type
      Function
    • parameters:
      • text: (typeof )
    • source: [view]
        this.text = text;
    • summary
  • dojox.dtl.tag.misc.FilterNode

    • type
      Function
    • parameters:
      • varnode: (typeof )
      • nodelist: (typeof )
    • source: [view]
        this._varnode = varnode;
        this._nodelist = nodelist;
    • summary
  • dojox.dtl.tag.misc.FirstOfNode

    • type
      Function
    • parameters:
      • vars: (typeof )
      • text: (typeof )
    • source: [view]
        this._vars = vars;
        this.vars = dojo.map(vars, function(item){
         return new dojox.dtl._Filter(item);
        });
        this.contents = text;
    • summary
  • dojox.dtl.tag.misc.SpacelessNode

    • type
      Function
    • parameters:
      • nodelist: (typeof )
      • text: (typeof )
    • source: [view]
        this.nodelist = nodelist;
        this.contents = text;
    • summary
  • dojox.dtl.tag.misc.TemplateTagNode

    • type
      Function
    • parameters:
      • tag: (typeof )
      • text: (typeof )
    • source: [view]
        this.tag = tag;
        this.contents = text;
    • summary
  • dojox.dtl.tag.misc.WidthRatioNode

    • type
      Function
    • parameters:
      • current: (typeof )
      • max: (typeof )
      • width: (typeof )
      • text: (typeof )
    • source: [view]
        this.current = new dd._Filter(current);
        this.max = new dd._Filter(max);
        this.width = width;
        this.contents = text;
    • summary
  • dojox.dtl.tag.misc.WithNode

    • type
      Function
    • parameters:
      • target: (typeof )
      • alias: (typeof )
      • nodelist: (typeof )
    • source: [view]
        this.target = new dd._Filter(target);
        this.alias = alias;
        this.nodelist = nodelist;
    • summary
  • dojox.dtl.tag.misc.DebugNode.text

    • summary
  • dojox.dtl.tag.misc.DebugNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var keys = context.getKeys();
         var debug = [];
         var only = {};
         for(var i = 0, key; key = keys[i]; i++){
          only[key] = context[key];
          debug += "[" + key + ": " + typeof context[key] + "]\n";
         }
         console.debug(only);
         return this.text.set(debug).render(context, buffer, this);
    • summary
  • dojox.dtl.tag.misc.DebugNode.unrender

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

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.text.clone(buffer));
    • summary
  • dojox.dtl.tag.misc.DebugNode.toString

    • type
      Function
    • source: [view]
        toString: function(){ return "ddtm.DebugNode";
    • summary
  • dojox.dtl.tag.misc.FilterNode._varnode

    • summary
  • dojox.dtl.tag.misc.FilterNode._nodelist

    • summary
  • dojox.dtl.tag.misc.FilterNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
      dojo.provide("dojox.dtl.tag.misc");
      dojo.require("dojox.dtl._base");


      (function(){
       var dd = dojox.dtl;
       var ddtm = dd.tag.misc;


       ddtm.DebugNode = dojo.extend(function(text){
        this.text = text;
       },
       {
        render: function(context, buffer){
         var keys = context.getKeys();
         var debug = [];
         var only = {};
         for(var i = 0, key; key = keys[i]; i++){
          only[key] = context[key];
          debug += "[" + key + ": " + typeof context[key] + "]\n";
         }
         console.debug(only);
         return this.text.set(debug).render(context, buffer, this);
        },
        unrender: function(context, buffer){
         return buffer;
        },
        clone: function(buffer){
         return new this.constructor(this.text.clone(buffer));
        },
        toString: function(){ return "ddtm.DebugNode"; }
       });


       ddtm.FilterNode = dojo.extend(function(varnode, nodelist){
        this._varnode = varnode;
        this._nodelist = nodelist;
       },
       {
        render: function(context, buffer){
         // Doing this in HTML requires a different buffer with a fake root node
         var output = this._nodelist.render(context, new dojox.string.Builder());
         context = context.update({ "var": output.toString() });
         var filtered = this._varnode.render(context, buffer);
         context = context.pop();
         return buffer;
    • summary
  • dojox.dtl.tag.misc.FilterNode.unrender

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

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this._expression, this._nodelist.clone(buffer));
    • summary
  • dojox.dtl.tag.misc.FirstOfNode._vars

    • summary
  • dojox.dtl.tag.misc.FirstOfNode.vars

    • summary
  • dojox.dtl.tag.misc.FirstOfNode.contents

    • summary
  • dojox.dtl.tag.misc.FirstOfNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         for(var i = 0, item; item = this.vars[i]; i++){
          var resolved = item.resolve(context);
          if(typeof resolved != "undefined"){
           if(resolved === null){
            resolved = "null";
           }
           this.contents.set(resolved);
           return this.contents.render(context, buffer);
          }
         }
         return this.contents.unrender(context, buffer);
    • summary
  • dojox.dtl.tag.misc.FirstOfNode.unrender

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

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this._vars, this.contents.clone(buffer));
    • summary
  • dojox.dtl.tag.misc.SpacelessNode.nodelist

    • summary
  • dojox.dtl.tag.misc.SpacelessNode.contents

    • summary
  • dojox.dtl.tag.misc.SpacelessNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         if(buffer.getParent){
          // Unfortunately, we have to branch here
          var watch = [
           dojo.connect(buffer, "onAddNodeComplete", this, "_watch"),
           dojo.connect(buffer, "onSetParent", this, "_watchParent")
          ];
          buffer = this.nodelist.render(context, buffer);
          dojo.disconnect(watch[0]);
          dojo.disconnect(watch[1]);
         }else{
          var value = this.nodelist.dummyRender(context);
          this.contents.set(value.replace(/>\s+<'));
          buffer = this.contents.render(context, buffer);
         }
         return buffer;
    • summary
  • dojox.dtl.tag.misc.SpacelessNode.unrender

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

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.nodelist.clone(buffer), this.contents.clone(buffer));
    • summary
  • dojox.dtl.tag.misc.SpacelessNode._isEmpty

    • type
      Function
    • parameters:
      • node: (typeof )
    • source: [view]
         return (node.nodeType == 3 && !node.data.match(/[^\s\n]/));
    • summary
  • dojox.dtl.tag.misc.SpacelessNode._watch

    • type
      Function
    • parameters:
      • node: (typeof )
    • source: [view]
         if(this._isEmpty(node)){
          var remove = false;
          if(node.parentNode.firstChild == node){
           node.parentNode.removeChild(node);
          }
         }else{
          var children = node.parentNode.childNodes;
          if(node.nodeType == 1 && children.length > 2){
           for(var i = 2, child; child = children[i]; i++){
            if(children[i - 2].nodeType == 1 && this._isEmpty(children[i - 1])){
             node.parentNode.removeChild(children[i - 1]);
             return;
            }
           }
          }
         }
    • summary
  • dojox.dtl.tag.misc.SpacelessNode._watchParent

    • type
      Function
    • parameters:
      • node: (typeof )
    • source: [view]
         var children = node.childNodes;
         if(children.length){
          while(node.childNodes.length){
           var last = node.childNodes[node.childNodes.length - 1];
           if(!this._isEmpty(last)){
            return;
           }
           node.removeChild(last);
          }
         }
    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.tag

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.contents

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping

    • type
      Object
    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.openblock

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.closeblock

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.openvariable

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.closevariable

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.openbrace

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.closebrace

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.opencomment

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.mapping.closecomment

    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         this.contents.set(this.mapping[this.tag]);
         return this.contents.render(context, buffer);
    • summary
  • dojox.dtl.tag.misc.TemplateTagNode.unrender

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

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.tag, this.contents.clone(buffer));
    • summary
  • dojox.dtl.tag.misc.WidthRatioNode.current

    • summary
  • dojox.dtl.tag.misc.WidthRatioNode.max

    • summary
  • dojox.dtl.tag.misc.WidthRatioNode.width

    • summary
  • dojox.dtl.tag.misc.WidthRatioNode.contents

    • summary
  • dojox.dtl.tag.misc.WidthRatioNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var current = +this.current.resolve(context);
         var max = +this.max.resolve(context);
         if(typeof current != "number" || typeof max != "number" || !max){
          this.contents.set("");
         }else{
          this.contents.set("" + Math.round((current / max) * this.width));
         }
         return this.contents.render(context, buffer);
    • summary
  • dojox.dtl.tag.misc.WidthRatioNode.unrender

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

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.current.getExpression(), this.max.getExpression(), this.width, this.contents.clone(buffer));
    • summary
  • dojox.dtl.tag.misc.WithNode.target

    • summary
  • dojox.dtl.tag.misc.WithNode.alias

    • summary
  • dojox.dtl.tag.misc.WithNode.nodelist

    • summary
  • dojox.dtl.tag.misc.WithNode.render

    • type
      Function
    • parameters:
      • context: (typeof )
      • buffer: (typeof )
    • source: [view]
         var target = this.target.resolve(context);
         context = context.push();
         context[this.alias] = target;
         buffer = this.nodelist.render(context, buffer);
         context = context.pop();
         return buffer;
    • summary
  • dojox.dtl.tag.misc.WithNode.unrender

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

    • type
      Function
    • parameters:
      • buffer: (typeof )
    • source: [view]
         return new this.constructor(this.target.getExpression(), this.alias, this.nodelist.clone(buffer));
    • summary
  • dojox.dtl.tag.misc

    • type
      Object
    • summary
  • dojox.dtl.tag

    • type
      Object
    • summary
  • dojox.dtl

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary