source: Dev/trunk/src/client/dojox/widget/tests/test_PortletInGridContainer.js

Last change on this file was 483, checked in by hendrikvanantwerpen, 11 years ago

Added Dojo 1.9.3 release.

File size: 7.0 KB
Line 
1dojo.provide("dojox.widget.tests.test_PortletInGridContainer");
2dojo.require("dijit.dijit");
3dojo.require("dojo.date.locale");
4dojo.require("dojo.cookie");
5dojo.require("dijit.form.CheckBox");
6dojo.require("dijit.form.TextBox");
7dojo.require("dijit.form.Slider");
8dojo.require("dijit.layout.TabContainer");
9dojo.require("dijit.layout.AccordionContainer");
10dojo.require("dijit.layout.BorderContainer");
11dojo.require("dijit.Tooltip");
12dojo.require("dijit.Tree");
13dojo.require("dijit.tree.ForestStoreModel");
14dojo.require("dojox.image.Gallery");
15dojo.require("dojox.widget.PlaceholderMenuItem");
16dojo.require("dojox.data.FileStore");
17dojo.require("dojox.charting.widget.Chart2D");
18dojo.require("dojox.charting.themes.Grasslands");
19dojo.require("dojox.charting.themes.PlotKit.orange");
20dojo.require("dojox.widget.Calendar");
21dojo.require("dojox.widget.Portlet");
22dojo.require("dojox.layout.GridContainer");
23dojo.require("dojox.layout.TableContainer");
24dojo.require("dojox.grid.DataGrid");
25dojo.require("dojox.data.HtmlStore");
26dojo.require("dojox.data.FlickrRestStore");
27dojo.require("dojox.fx.text");
28dojo.require("dojox.layout.ExpandoPane");
29dojo.require("dojox.charting.Chart3D");
30dojo.require("dojox.charting.action2d.Highlight");
31dojo.require("dojox.charting.action2d.MoveSlice");
32dojo.require("dojox.charting.action2d.Tooltip");
33
34//This must be included on the page for FeedPortlets that
35//load local feeds.
36dojo.require("dojox.data.AtomReadStore");
37
38dojo.require("dojo.parser");
39
40dojo.addOnLoad(function(){
41        dojo.parser.parse();
42
43        var chart = window.chart = new dojox.charting.Chart2D("zoomer");
44        chart.setTheme(dojox.charting.themes.PlotKit.orange);
45        chart.addAxis("x", {fixLower: "minor", natural: true, stroke: "grey",
46                majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}});
47        chart.addAxis("y", {vertical: true, min: 0, max: 30, majorTickStep: 5, minorTickStep: 1, stroke: "grey",
48                majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}});
49        chart.addPlot("default", {type: "Areas"});
50        chart.addSeries("Series A", [0, 25, 5, 20, 10, 15, 5, 20, 0, 25]);
51        chart.addAxis("x2", {fixLower: "minor", natural: true, leftBottom: false, stroke: "grey",
52                majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}});
53        chart.addAxis("y2", {vertical: true, min: 0, max: 20, leftBottom: false, stroke: "grey",
54                majorTick: {stroke: "black", length: 4}, minorTick: {stroke: "gray", length: 2}});
55        chart.addPlot("plot2", {type: "Areas", hAxis: "x2", vAxis: "y2"});
56        chart.addSeries("Series B", [15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15, 0, 15], {plot: "plot2"});
57        chart.addPlot("grid", {type: "Grid", hMinorLines: true});
58        chart.render();
59
60        var show = setInterval(function(){
61                var w = dijit.byId("gridContainer");
62                if (w && w.domNode) {
63                        dojo.body().removeChild(dojo.byId("masker"));
64                        clearInterval(show);
65                }
66        }, 500);
67
68
69        var scaleX = 1, scaleY = 1, offsetX = 0, offsetY = 0;
70        dojo.connect(dijit.byId("scaleXSlider"), "onChange", function(value){
71                scaleX = value;
72                console.log("calling update");
73                update();
74        });
75
76        function update() {
77                chart.setWindow(scaleX, scaleY, offsetX, offsetY).render();
78        }
79
80        var _init = null;
81        var onMouseDown = function(e){
82                _init = {x: e.clientX, y: e.clientY, ox: offsetX, oy: offsetY};
83                dojo.stopEvent(e);
84        };
85
86        var onMouseUp = function(e){
87                if(_init){
88                        _init = null;
89                        dojo.stopEvent(e);
90                }
91        };
92
93        var onMouseMove = function(e){
94                if(_init){
95                        var dx = e.clientX - _init.x,
96                                dy = e.clientY - _init.y;
97                        offsetX = _init.ox - dx;
98                        offsetY = _init.oy + dy;
99                        chart.setWindow(scaleX, scaleY, offsetX, offsetY).render();
100                        dojo.stopEvent(e);
101                }
102        };
103
104        dojo.connect(chart.node, "onmousedown", onMouseDown);
105        dojo.connect(chart.node, "onmousemove", onMouseMove);
106        dojo.connect(chart.node, "onmouseup",   onMouseUp);
107
108
109        createProgrammaticPortlet();
110});
111
112function createProgrammaticPortlet() {
113        var portlet = new dojox.widget.FeedPortlet({
114                id: "ProgrammaticPortlet",
115                dndType: "Portlet",
116                title: "Programmatic FeedPortlet with multiple feeds"
117        }, dojo.create("div", {
118                innerHTML: "This portlet was created programmatically, and has mulitple feeds to select from."
119                                + " Click the settings icon in the title bar to choose another feed."
120        }));
121        var settings = new dojox.widget.PortletFeedSettings({
122                id: "ProgrammaticPortletSettings",
123                urls: [
124                        {
125                                url: "http://news.google.com/news?hl=en&topic=t&output=atom",
126                                label: "Google News"
127                        },
128                        {
129                                url: "http://shaneosullivan.wordpress.com/category/dojo/feed/",
130                                label: "Dojo Blatherings"
131                        },
132                        {
133                                url: "http://www.dojotoolkit.org/aggregator/rss",
134                                label: "Planet Dojo"
135                        }
136                ]
137        });
138        portlet.addChild(settings);
139        dijit.byId("gridContainer2").addService(portlet, 0, 0);
140}
141
142var count = 0;
143function loadFeed(url, nodeId, emptyMsg, type) {
144
145        var query = {
146                url: url
147        };
148        var request = {query:query};
149
150        var maxBufSize = 8;
151        var outNode = dojo.byId(nodeId);
152
153        var testStore = new dojox.data.GoogleFeedStore();
154
155        function doAppend(items){
156                console.log(items);
157                if (items.length > 0) {
158      if (type == "list") {
159                                dojo.addClass(outNode, "feedList");
160
161              var ul = dojo.create("ul", null, outNode);
162                                dojo.forEach(items, function(item){
163                                        var li = dojo.create("li", {
164                                                innerHTML: '<a href="' + testStore.getValue(item, 'link') + '">'
165                                                                                                + testStore.getValue(item, 'title') + '</a>'
166                                        },ul);
167
168                                        dojo.connect(li, "onmouseover", function() {
169                                                dijit.showTooltip(testStore.getValue(item, "content"), li);
170                                        });
171                                        dojo.connect(li, "onmouseout", function() {
172                                                dijit.hideTooltip(li);
173                                        });
174                                });
175                        }
176                        else {
177                                var accordion = new dijit.layout.AccordionContainer({});
178                                dojo.byId(nodeId).appendChild(accordion.domNode);
179
180                                dojo.forEach(items, function(item){
181                                        var summary = testStore.getValue(item, "title");
182
183                                        if (summary.length > 40) {
184                                                summary = summary.substring(0, 50);
185                                        }
186                                        var contentPane = new dijit.layout.ContentPane({
187                                                title: summary,
188                                                content: testStore.getValue(item, "content")
189                                        });
190                                        dojo.style(contentPane.domNode, "width", "100%");
191                                        accordion.addChild(contentPane);
192                                        contentPane.startup();
193                                });
194
195                                var portlet = dijit.getEnclosingWidget(dojo.byId(nodeId));
196                                portlet.addChild(accordion);
197                        }
198          } else {
199                        dojo.byId(nodeId).innerHTML = emptyMsg || "No results";
200                }
201        }
202
203        request.onBegin = function(numItems){};
204
205        request.onComplete = doAppend;
206
207        request.count = 4;
208
209        testStore.fetch(request);
210}
211
212var layoutHtmlTable = [
213         [
214                {name: 'First Name', field: 'First Name', width: '50%'},
215                {name: 'Last Name', field: 'Last Name', width: '25%'},
216                {name: 'DOB', field: 'DOB', width: '25%'}
217                ]
218        ];
219
220var text_explode_2 = function(node){
221
222        if(node.style.height){
223                return;
224        }
225        var originalText = node.innerHTML;
226        var properties = {
227                node: node,
228                words: true,
229                distance: 1.5,
230                duration: 1500,
231                random: 0.5
232        };
233        properties.onEnd = function(){
234                currentAnimation = dojox.fx.text.converge(dojo.mixin(properties,{
235                        onEnd: undefined,
236                        text: originalText
237                }));
238                currentAnimation.play();
239        };
240        currentAnimation = dojox.fx.text.explode(properties).play();
241};
Note: See TracBrowser for help on using the repository browser.