(hoofbeats) Adds initial Ember skeleton.
authorSalvatore Iovene <salvatore@iovene.com>
Mon, 4 Feb 2013 13:02:27 +0000 (15:02 +0200)
committerSalvatore Iovene <salvatore@iovene.com>
Mon, 4 Feb 2013 13:02:27 +0000 (15:02 +0200)
examples/hoofbeats/index.html
examples/hoofbeats/javascripts/app/app.js [new file with mode: 0644]
examples/hoofbeats/javascripts/app/controllers/applicationController.js [new file with mode: 0644]
examples/hoofbeats/javascripts/app/controllers/artistsController.js [new file with mode: 0644]
examples/hoofbeats/javascripts/app/models/artistModel.js [new file with mode: 0644]
examples/hoofbeats/javascripts/app/router.js [new file with mode: 0644]
examples/hoofbeats/javascripts/app/store.js [new file with mode: 0644]
examples/hoofbeats/javascripts/app/views/artistsView.js [new file with mode: 0644]
grunt.js

index 19b6f78..c13a9ae 100644 (file)
   </head>
 
   <body>
-       <div class="container">
+    <div class="container">
       <div id="application"></div>
     </div> <!-- container -->
 
+    <!-- initial template of our application; it just installs the outlet. -->
+    <script type="text/x-handlebars" data-template-name="application">
+      <div class="navbar navbar-inverse">
+        <div class="navbar-inner">
+          <ul class="nav">
+            <li><a {{action showArtists href=true}}>Artists</a></li>
+          </ul>
+        </div>
+      </div>
+
+      {{outlet library}}
+    </script>
+
+    <script type="text/x-handlebars" data-template-name="artists">
+    </script>
+
     <script src="lib/cowhide.js"></script>
+    <script src="lib/handlebars-1.0.rc.1.js"></script>
+    <script src="lib/ember-latest.js"></script>
+
+    <script src="javascripts/app/app.js"></script>
+    <script src="javascripts/app/router.js"></script>
+    <script src="javascripts/app/store.js"></script>
+
+    <script src="javascripts/app/models/artistModel.js"></script>
+
+    <script src="javascripts/app/controllers/applicationController.js"></script>
+    <script src="javascripts/app/controllers/artistsController.js"></script>
+
+    <script src="javascripts/app/views/artistsView.js"></script>
   </body>
 </html>
diff --git a/examples/hoofbeats/javascripts/app/app.js b/examples/hoofbeats/javascripts/app/app.js
new file mode 100644 (file)
index 0000000..4cbefae
--- /dev/null
@@ -0,0 +1,8 @@
+(function(win) {
+    'use strict';
+
+    win.Hoofbeats = window.Ember.Application.create({
+        VERSION: '0.1',
+        rootElement: '#application'
+    });
+})(window);
diff --git a/examples/hoofbeats/javascripts/app/controllers/applicationController.js b/examples/hoofbeats/javascripts/app/controllers/applicationController.js
new file mode 100644 (file)
index 0000000..634cbc2
--- /dev/null
@@ -0,0 +1,7 @@
+(function(app, Ember) {
+    'use strict';
+
+    var ApplicationController = Ember.Controller.extend({});
+
+    app.ApplicationController = ApplicationController;
+})(window.Hoofbeats, window.Ember);
diff --git a/examples/hoofbeats/javascripts/app/controllers/artistsController.js b/examples/hoofbeats/javascripts/app/controllers/artistsController.js
new file mode 100644 (file)
index 0000000..2a6c008
--- /dev/null
@@ -0,0 +1,10 @@
+(function(app, Ember, _) {
+    'use strict';
+
+    var ArtistsController = Ember.ArrayController.extend({
+        content: [],
+    });
+
+    app.ArtistsController = ArtistsController;
+    app.artistsController = ArtistsController.create();
+})(window.Hoofbeats, window.Ember);
diff --git a/examples/hoofbeats/javascripts/app/models/artistModel.js b/examples/hoofbeats/javascripts/app/models/artistModel.js
new file mode 100644 (file)
index 0000000..9c4a60d
--- /dev/null
@@ -0,0 +1,42 @@
+(function(app, Ember) {
+    'use strict';
+
+    var Artist = Ember.Object.extend({
+        id: null,
+        firstName: null,
+        lastName: null,
+        bandName: null,
+
+        name: function() {
+            var ret = "";
+            if (this.get('firstName') && this.get('lastName')) {
+                ret = "%@, %@".fmt(this.get('lastName', this.get('firstName')));
+                if(this.get('bandName')) {
+                    ret += " (%@)".fmt(this.get('bandName'));
+                }
+            } else {
+                ret = this.get('bandName');
+            }
+
+            return ret;
+        }.property('firstName', 'lastName', 'bandName'),
+
+        isBandOnly: function() {
+            if (this.get('firstName') === null &&
+                this.get('lastName') === null &&
+                this.get('bandName') !== null) {
+                return true;
+            }
+            return false;
+        }.property('firstName', 'lastName', 'bandName')
+    });
+
+
+    Artist.reopenClass({
+        find: function() {
+            return app.Store.getArtists();
+        }
+    });
+
+    app.Artist = Artist;
+})(window.Hoofbeats, window.Ember);
diff --git a/examples/hoofbeats/javascripts/app/router.js b/examples/hoofbeats/javascripts/app/router.js
new file mode 100644 (file)
index 0000000..2aa570d
--- /dev/null
@@ -0,0 +1,26 @@
+(function(app, Ember) {
+    'use strict';
+
+    var Router = Ember.Router.extend({
+        location: 'none',
+
+        showArtists: Ember.Route.transitionTo('artists'),
+
+        root: Ember.Route.extend({
+            index: Ember.Route.extend({
+                route: '/',
+                redirectsTo: 'artists'
+            }),
+
+            artists: Ember.Route.extend({
+                route: '/artists',
+                connectOutlets: function(router) {
+                    var controller = router.get('applicationController');
+                    controller.connectOutlet('library', 'artists', app.Artist.find());
+                }
+            })
+        })
+    });
+
+    app.Router = Router;
+})(window.Hoofbeats, window.Ember);
diff --git a/examples/hoofbeats/javascripts/app/store.js b/examples/hoofbeats/javascripts/app/store.js
new file mode 100644 (file)
index 0000000..a7b8183
--- /dev/null
@@ -0,0 +1,14 @@
+(function(app) {
+    'use strict';
+
+    var Store = function() {}
+
+    Store.prototype = {
+        getArtists: function() {
+            var artists = [];
+            return artists;
+        }
+    };
+
+    app.Store = new Store();
+})(window.Hoofbeats);
diff --git a/examples/hoofbeats/javascripts/app/views/artistsView.js b/examples/hoofbeats/javascripts/app/views/artistsView.js
new file mode 100644 (file)
index 0000000..5798e86
--- /dev/null
@@ -0,0 +1,11 @@
+(function(app, Ember) {
+    'use strict';
+
+    var ArtistsView = Ember.View.extend({
+        templateName: 'artists',
+        tagName: 'ul',
+        classNames: ['artists']
+    });
+
+    app.ArtistsView = ArtistsView;
+})(window.Hoofbeats, window.Ember);
index 62c18d3..d5a0fda 100644 (file)
--- a/grunt.js
+++ b/grunt.js
@@ -251,7 +251,9 @@ module.exports = function(grunt) {
           ],
           'dist/examples/hoofbeats/lib/': [
             'dist/cowhide-default.css',
-            'dist/cowhide.js'
+            'dist/cowhide.js',
+            'lib/handlebars-1.0.rc.1.js',
+            'lib/ember-latest.js'
           ]
         }
       }