~atrauzzi/praxis/trunk

« back to all changes in this revision

Viewing changes to src/omegatech/praxis/Area.js

  • Committer: Alexander Trauzzi
  • Date: 2012-03-30 10:56:07 UTC
  • Revision ID: atrauzzi@gmail.com-20120330105607-hfw7dr1axlte9x5g
Bulk import of Praxis client codebase.  There will be some rewiring and fixing to get this back up and running.

Not the least of which - a static HTTP server implementation!

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
define(
 
2
        [
 
3
                "dojo/_base/declare",
 
4
                "dijit/Dialog"
 
5
        ],
 
6
        function (
 
7
                declare,
 
8
                Dialog
 
9
        ) {
 
10
 
 
11
                return(declare(null, {
 
12
 
 
13
                        controller: null,
 
14
 
 
15
                        label: null,
 
16
                        slug: null,
 
17
                        widget: null,
 
18
                        modal: false,
 
19
                        unsavedChanges: false,
 
20
 
 
21
                        // Areas can know about their parents to trigger results and other fun stuff on them.
 
22
                        // ToDo: Consider how this can be de-coupled?
 
23
                        previousArea: null,
 
24
 
 
25
                        constructor: function (controller, previousArea) {
 
26
 
 
27
                                // Store the reference to the controller we're operating under.
 
28
                                this.controller = controller;
 
29
                                this.previousArea = previousArea || null;
 
30
 
 
31
                        },
 
32
 
 
33
                        getLabel: function () {
 
34
                                return(this.label);
 
35
                        },
 
36
 
 
37
                        getSlug: function () {
 
38
                                return(this.slug);
 
39
                        },
 
40
 
 
41
                        // Returns the widget this Area wants to be represented by.
 
42
                        getWidget: function () {
 
43
                                return(this.widget);
 
44
                        },
 
45
 
 
46
                        // Returns all widgets this Area makes use of.
 
47
                        getWidgets: function () {
 
48
                        },
 
49
 
 
50
                        // Called before the Area is shown?
 
51
                        beforeShow: function () {
 
52
                                // ToDo: Implement??
 
53
                        },
 
54
 
 
55
                        close: function () {
 
56
 
 
57
                                if(this.unsavedChanges) {
 
58
 
 
59
                                        console.log("Praxis: Unsaved changes, prompting!");
 
60
 
 
61
                                        // Dijit style, but this has to be async...
 
62
                                        //var unsavedPrompt = new Dialog({
 
63
                                        //      title: "Unsaved Changes",
 
64
                                        //      content: "You have unsaved changes.  Are you sure you want to leave?"
 
65
                                        //});
 
66
                                        //unsavedPrompt.show();
 
67
 
 
68
                                        // Figure out a way to switch to async confirmation!!
 
69
                                        if(!confirm("You have unsaved changes.  Are you sure you want to leave?")) {
 
70
                                                return(false);
 
71
                                        }
 
72
 
 
73
                                }
 
74
 
 
75
                                // Only modal Areas actually get destroyed.
 
76
                                if(this.modal) {
 
77
 
 
78
                                        console.log("Praxis: Destroying modal Area.");
 
79
                                        console.log(this);
 
80
 
 
81
                                        this.controller.removeArea(this, this.previousArea);
 
82
                                        this.widget.destroyRecursive();
 
83
                                        this.widget.destroy();
 
84
 
 
85
                                }
 
86
 
 
87
                                return(true);
 
88
 
 
89
                        }
 
90
 
 
91
                }));
 
92
 
 
93
        }
 
94
);
 
95
 
 
96
 
 
97