Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require(["dojo", "dojo/parser", "dijit/registry", "dojo/Stateful", "dojo/_base/connect",
- "dijit/form/Button", "dojox/widget/Toaster"],
- function (
- dojo, parser, registry, Stateful, connect,
- Button, Toaster
- ) {
- connect.subscribe("/load", function () {
- var stateful, t, tokens, toaster;
- stateful = new Stateful();
- tokens = [];
- toaster = new Toaster({
- positionDirection: 'bl-up',
- duration: 500
- });
- t = connect.subscribe("alert", toaster, "_handleMessage");
- tokens.push(t);
- t = connect.subscribe("/unload", function () {
- registry.toArray().forEach(function (w) {
- w.destroy();
- });
- dojo.forEach(tokens, connect.unsubscribe);
- delete stateful;
- stateful = undefined;
- delete tokens;
- tokens = undefined;
- toaster.destroyRecursive();
- });
- tokens.push(t);
- t = connect.subscribe("CreateWijit", function () {
- var w = new Button({
- id: "myButtonId",
- label: "myButtonTitle",
- onClick: function () {
- connect.publish("alert", { message: "myButton" });
- }
- }, dojo.create("button", null, "workArea"));
- //dojo.byId("workArea").appendChild(w.domNode);
- stateful.watch("myButtonTitle", function (t) {
- w.set("label", stateful.get(t));
- });
- });
- tokens.push(t);
- t = connect.subscribe("DestroyWijit", function () {
- var widgets = registry.findWidgets(dojo.byId("workArea"));
- widgets.forEach(function (w) {
- w.destroyRecursive();
- });
- });
- tokens.push(t);
- t = connect.subscribe("UpdateLabel", function () {
- stateful.set("myButtonTitle", new Date().toLocaleTimeString());
- });
- tokens.push(t);
- new Button({
- topic: "CreateWijit",
- label: "Create Widget"
- }, dojo.create("button", null, "controlContainer"));
- new Button({
- topic: "DestroyWijit",
- label: "Destroy Widget"
- }, dojo.create("button", null, "controlContainer"));
- new Button({
- topic: "UpdateLabel",
- label: "Update Widget"
- }, dojo.create("button", null, "controlContainer"));
- connect.publish("alert", { message: "Ready!" });
- registry.toArray().forEach(function (w) {
- if (w.topic) {
- w.connect(w, "onClick", function () {
- connect.publish(w.topic);
- connect.publish("alert", { message: w.topic });
- });
- }
- });
- });
- parser.parse();
- window.unloadReload = function () {
- connect.publish("/unload");
- connect.publish("/load");
- };
- connect.publish("/load");
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement