widget.js 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. if (!dojo._hasResource["dojox.dtl.widget"]) { // _hasResource checks added by
  2. // build. Do not use
  3. // _hasResource directly in your
  4. // code.
  5. dojo._hasResource["dojox.dtl.widget"] = true;
  6. dojo.provide("dojox.dtl.widget");
  7. dojo.require("dijit._Widget");
  8. dojo.require("dijit._Container")
  9. dojo.require("dojox.dtl.html");
  10. dojo.require("dojox.dtl.render.html");
  11. dojo.declare("dojox.dtl._Widget", [dijit._Widget, dijit._Contained], {
  12. buffer : 0,
  13. buildRendering : function() {
  14. this.domNode = this.srcNodeRef;
  15. if (this.domNode) {
  16. var parent = this.getParent();
  17. if (parent) {
  18. this.setAttachPoint(parent);
  19. }
  20. }
  21. },
  22. setAttachPoint : function(/* dojox.dtl.AttachPoint */attach) {
  23. this._attach = attach;
  24. },
  25. render : function(/* dojox.dtl.HtmlTemplate */tpl, /* dojox.dtl.Context */
  26. context) {
  27. if (!this._attach) {
  28. throw new Error("You must use an attach point with dojox.dtl.TemplatedWidget");
  29. }
  30. context.setThis(this);
  31. this._attach.render(tpl, context);
  32. }
  33. });
  34. dojo.declare("dojox.dtl.AttachPoint", [dijit._Widget, dijit._Container], {
  35. constructor : function(props, node) {
  36. this._render = new dojox.dtl.render.html.Render(node);
  37. },
  38. render : function(/* dojox.dtl.HtmlTemplate */tpl, /* dojox.dtl.Context */
  39. context) {
  40. this._render.render(tpl, context);
  41. }
  42. });
  43. }