Inline.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.dtl.Inline"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.dtl.Inline"] = true;
  8. dojo.provide("dojox.dtl.Inline");
  9. dojo.require("dojox.dtl._base");
  10. dojo.require("dijit._Widget");
  11. dojox.dtl.Inline = dojo.extend(function(args, node){
  12. this.create(args, node);
  13. },
  14. dijit._Widget.prototype,
  15. {
  16. context: null,
  17. render: function(/*Object|dojox.dtl.Context?*/ context){
  18. this.context = context || this.context;
  19. this.postMixInProperties();
  20. dojo.query("*", this.domNode).orphan();
  21. this.domNode.innerHTML = this.template.render(this.context);
  22. },
  23. declaredClass: "dojox.dtl.Inline",
  24. buildRendering: function(){
  25. var div = this.domNode = document.createElement("div");
  26. var node = this.srcNodeRef;
  27. if(node.parentNode){
  28. node.parentNode.replaceChild(div, node);
  29. }
  30. this.template = new dojox.dtl.Template(dojo.trim(node.text), true);
  31. this.render();
  32. },
  33. postMixInProperties: function(){
  34. this.context = (this.context.get === dojox.dtl._Context.prototype.get) ? this.context : new dojox.dtl._Context(this.context);
  35. }
  36. });
  37. }