Debian Codegraph @

dojox/dtl/demos/demo_Blog.html

raw symbols SCIP
1 <html>
2 <head>
3 <title>Testing dojox.dtl using a blog example</title>
4 <script src="../../../dojo/dojo.js" djConfig="usePlainJson: true, parseOnLoad: true"></script>
5 <script>
6 dojo.require("dijit._WidgetBase");
7 dojo.require("dojox.dtl._DomTemplated");
8 dojo.require("dojo.parser");
9
10 dojo.declare("demo.Blog", [dijit._WidgetBase, dojox.dtl._DomTemplated],
11 {
12 templatePath: dojo.moduleUrl("dojox.dtl.demos.templates", "blog_list.html"),
13 base: {
14 url: dojo.moduleUrl("dojox.dtl.demos.templates", "blog_base.html"),
15 shared: true
16 },
17 constructor: function(props, node){
18 this.list = false;
19 this.blogs = {};
20 this.pages = {};
21 },
22 postCreate: function(){
23 if(!this.list){
24 dojo.xhrGet({
25 url: dojo.moduleUrl("dojox.dtl.demos.json.blog", "get_blog_list.json"),
26 handleAs: "json"
27 }).addCallback(this, "_loadList");
28 }
29 },
30 _showList: function(obj){
31 this.title = "Blog Posts";
32 this.setTemplate(this.templatePath);
33 },
34 _showDetail: function(obj){
35 var key = obj.target.className.substring(5);
36
37 if(this.blogs[key]){
38 this.title = "Blog Post";
39 this.blog = this.blogs[key];
40 this.blog.title = this.blog_list[key].title;
41 this.setTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "blog_detail.html"));
42 }else{
43 dojo.xhrGet({
44 url: dojo.moduleUrl("dojox.dtl.demos.json.blog", "get_blog_" + key + ".json"),
45 handleAs: "json",
46 load: function(data){
47 data.key = key;
48 return data;
49 }
50 }).addCallback(this, "_loadDetail");
51 }
52 },
53 _showPage: function(obj){
54 var key = obj.target.className.substring(5);
55
56 if(this.pages[key]){
57 this.title = this.pages[key].title;
58 this.body = this.pages[key].body;
59 this.setTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "blog_page.html"));
60 }else{
61 dojo.xhrGet({
62 url: dojo.moduleUrl("dojox.dtl.demos.json.blog", "get_page_" + key + ".json"),
63 handleAs: "json",
64 load: function(data){
65 data.key = key;
66 return data;
67 }
68 }).addCallback(this, "_loadPage");
69 }
70 },
71 _loadList: function(data){
72 this.title = "Blog Posts";
73 dojo.mixin(this, data);
74 this.render();
75 },
76 _loadDetail: function(data){
77 data.date = new Date(data.date);
78 this.blogs[data.key] = data;
79 this.title = "Blog Post";
80 this.blog = data;
81 this.blog.title = this.blog_list[data.key].title;
82 this.setTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "blog_detail.html"));
83 },
84 _loadPage: function(data){
85 this.pages[data.key] = data;
86 dojo.mixin(this, data);
87 this.setTemplate(dojo.moduleUrl("dojox.dtl.demos.templates", "blog_page.html"));
88 }
89 });
90 </script>
91 </head>
92 <body>
93 <div dojoType="demo.Blog"></div>
94 </body>
95 </html>