Skip to content

Commit 86badb5

Browse files
author
Cole Davis
committed
interim commit working with new application object and other fixes/updates
Enyo-DCO-1.1-Signed-off-by: Cole Davis <[email protected]>
1 parent b4b8da5 commit 86badb5

24 files changed

+157
-108
lines changed

debug.html

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,5 @@
1616
<script src="source/package.js" type="text/javascript"></script>
1717
</head>
1818
<body class="enyo-unselectable">
19-
<script>
20-
enyo.start();
21-
</script>
2219
</body>
2320
</html>

gendocs.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
docco -t assets/docco/pagelet.jst -c assets/docco/docco.less \
44
-o assets/docco/generated \
5-
source/Core.js \
5+
source/start.js \
66
source/controllers/PanelsController.js \
77
source/controllers/DocumentsController.js \
88
source/controllers/EditorController.js \
@@ -11,11 +11,12 @@ docco -t assets/docco/pagelet.jst -c assets/docco/docco.less \
1111
source/models/Collections/RollerCollection.js \
1212
source/models/Models/RollerModel.js \
1313
source/models/Scaffold.js \
14-
source/views/App.js \
14+
source/views/RootView.js \
1515
source/views/Editor.js \
1616
source/views/Toolbar.js \
1717
source/views/Main/Divider.js \
1818
source/views/Main/Main.js \
1919
source/views/Main/Documents/Documents.js \
2020
source/views/Main/Roller/Roller.js \
21-
source/views/Main/Roller/RollerPanel.js
21+
source/views/Main/Roller/RollerPanel.js \
22+
source/apps/Sample.js

index.html

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,6 @@
1616
<script src="build/app.js"></script>
1717
</head>
1818
<body class="enyo-unselectable">
19-
<script>
20-
if (!window.enyo) {
21-
alert('No application build found, redirecting to debug.html.');
22-
location = 'debug.html';
23-
}
24-
enyo.start();
25-
</script>
19+
<script type="text/javascript">if (undefined === window.enyo) location = "debug.html";</script>
2620
</body>
2721
</html>

source/apps/Sample.js

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,42 @@
11

2+
// The `Sample.Application` kind
3+
// -----------------------------
4+
// There can be multiple `enyo.Application`s running simultaneously
5+
// if you needed. In our case, we only need one. That being said the
6+
// concept of an `enyo.Application` is simple: coordinate startup and
7+
// initialization of a group of objects, if there is a view, render that
8+
// when appropriate.
29
enyo.kind({
10+
// While the namespace of the application is `Sample` the namespace
11+
// of the instanced application is up to the developers discretion.
12+
// Go look at our `start.js` file if you haven't to see how this was
13+
// done.
314
name: "Sample.Application",
415
kind: "enyo.Application",
5-
autoStart: false,
6-
renderOnStart: true,
16+
// The `autoStart` flag is `true` by default but its explicitly
17+
// designated here for clarity. Since it is true, the `enyo.Application`
18+
// `start` method will be executed as soon as the constructor is called
19+
// on our application.
20+
autoStart: true,
21+
// Every application can potentially _own a single view_. This means that
22+
// it can programatically determine when to render its _view_ into the
23+
// DOM and where to render it when it does.
724
view: "Sample.RootView",
25+
// The `enyo.Application` also lets us declare what controllers we want
26+
// to initialize for this application at the _application scope_. This is
27+
// a _very important concept_. Notice the name properties of these
28+
// declarations and also note the namespace of this _kind_. Its `Sample`.
29+
// By default, the `enyo.Application` will attempt to create instances of
30+
// these controllers in the namespace of _the application kind that owns them_.
31+
// In our case, this means that when the application is created there should
32+
// immediately be available 2 controllers on the `Sample` object: `Sample.panels`
33+
// and `Sample.documents`. This allows any other objects in the application to
34+
// reference these controllers at those paths. It is possible to instantiate
35+
// them in a different namespace (or none at all) by setting a flag on these
36+
// declarations `global: true`. The application will not attempt to prefix the
37+
// `name` with the namespace of the given _kind_.
838
controllers: [
939
{name: "panels", kind: "Sample.PanelsController"},
1040
{name: "documents", kind: "Sample.DocumentsController"}
1141
]
12-
});
42+
});

source/apps/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
enyo.depends(
22
"Sample.js"
3-
);
3+
);

source/controllers/DocumentsController.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
// Locally-scoped variable that contains the fixed names of each of
44
// the documentation files we're going to load via `enyo.Ajax` calls.
5-
var documents = [ "App", "PanelsController", "Core", "Divider",
5+
var documents = [ "RootView", "PanelsController", "start", "Divider",
66
"Documents", "DocumentsController", "Editor", "EditorController",
77
"FitToTargetBoundsLayout", "Main", "Roller", "RollerCollection",
88
"RollerLayout", "RollerModel", "RollerPanel", "Scaffold",
@@ -31,9 +31,9 @@
3131
xhr.response(loaded).go();
3232
};
3333

34-
// The `App.DocumentsController` kind
35-
// ----------------------------------
36-
// `App.DocumentsController` is derived from `enyo.ArrayController`,
34+
// The `Sample.DocumentsController` kind
35+
// -------------------------------------
36+
// `Sample.DocumentsController` is derived from `enyo.ArrayController`,
3737
// a kind designed to act like an array, but with support for bindings
3838
// and observers. Because it inherits from `enyo.Controller`, it can
3939
// have multiple event targets, which makes it a perfect fit for our
@@ -45,7 +45,7 @@
4545
// events to this controller, and when the `selected` property changes,
4646
// the `Documents.js` view responds.
4747
enyo.kind({
48-
name: "App.DocumentsController",
48+
name: "Sample.DocumentsController",
4949
kind: "enyo.ArrayController",
5050
handlers: {
5151
onSelect: "selectSource",

source/controllers/EditorController.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11

2-
// The `App.EditorController` kind
2+
// The `Sample.EditorController` kind
33
// -------------------------------
44
// The editor controller is responsible for setting up the content in
5-
// the `App.Editor` view. It extends `enyo.ModelController` and proxies
5+
// the `Sample.Editor` view. It extends `enyo.ModelController` and proxies
66
// the selected record.
77
enyo.kind({
88
// There is convention (not a requirement) to keep the names of
99
// presentation objects closely linked with those of their
1010
// associated controllers. The controller name is typically formed
1111
// by appending `"Controller"` to the name of the view.
12-
name: "App.EditorController",
12+
name: "Sample.EditorController",
1313
// Be sure to read the documentation for `enyo.ModelController`.
1414
kind: "enyo.ModelController",
1515
// Even though the textarea is in the view, we are owned by the
@@ -21,18 +21,18 @@ enyo.kind({
2121
},
2222
constructor: function () {
2323
this.inherited(arguments);
24-
App.panels.addDispatchTarget(this);
24+
Sample.panels.addDispatchTarget(this);
2525
},
2626
// We map the selected index from the panels controller to our own
2727
// `index` property.
2828
bindings: [
29-
{from: "App.panels.index", to: "index"}
29+
{from: "Sample.panels.index", to: "index"}
3030
],
3131
// Note that we can set up a `changed` event listener for a property
3232
// that only exists locally through bindings.
3333
indexChanged: function () {
3434
var idx = this.index;
35-
var model = App.panels.at(idx);
35+
var model = Sample.panels.at(idx);
3636
if (model && model !== this.model) this.set("model", model);
3737
},
3838
input: function () {
@@ -47,6 +47,6 @@ enyo.kind({
4747
// (since it exists).
4848
done: function () {
4949
// We are all done editing and can reset the state property.
50-
App.panels.set("isEditing", false);
50+
Sample.panels.set("isEditing", false);
5151
}
5252
});

source/controllers/PanelsController.js

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11

2-
// The `App.PanelsController` kind
2+
// The `Sample.PanelsController` kind
33
// -------------------------------
44
// This is the kind definition for the global singleton application
5-
// panels controller (`App.panels`) instantiated in the `main` function
5+
// panels controller (`Sample.panels`) instantiated in the `main` function
66
// in `Core.js`.
77
enyo.kind({
88
// We give the kind a name in the application namespace.
9-
name: "App.PanelsController",
9+
name: "Sample.PanelsController",
1010
// We base this kind on `enyo.CollectionController` because we know
1111
// we need the collection controller's built-in methods. Even
1212
// though this is an `enyo.CollectionController`, we can add
@@ -18,14 +18,14 @@ enyo.kind({
1818
// global instance of the collection. We will hand this controller
1919
// a kind reference and it will instantiate the collection kind when
2020
// it is created.
21-
collection: "App.RollerCollection",
21+
collection: "Sample.RollerCollection",
2222
// While in Enyo 2.2+ it is not required to create the `published`
2323
// hash so that the corresponding getters and setters are created,
2424
// this is still considered to be a best practice.
2525
published: {
2626
// The entire application has state. One possible state is the
2727
// is the editing state. While the `isEditing` property is
28-
// designed to be used directly with the `App.Roller` view kind,
28+
// designed to be used directly with the `Sample.Roller` view kind,
2929
// any other component in the application may respond to it as
3030
// well (as we will see).
3131
isEditing: false,
@@ -50,11 +50,6 @@ enyo.kind({
5050
},
5151
// The timer reference as returned by `setInterval`
5252
timer: null,
53-
// We listen for the special `ready` event to signal that we're ready
54-
// to start inspecting and listening on our property observers.
55-
handlers: {
56-
onready: "collectionChanged"
57-
},
5853
// The following methods are actually dispatch event targets of an
5954
// `enyo.View` (the toolbar). These methods are executed in response
6055
// to events bubbled from the view layer.
File renamed without changes.

source/css/package.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
enyo.depends(
2-
"App.less",
2+
"RootView.less",
33
"Roller.less",
44
"Main.less",
55
"Editor.less",

0 commit comments

Comments
 (0)