From 5c0ca7cee94f08c6bab9cdb7642d0ee1d332c5ec Mon Sep 17 00:00:00 2001 From: Salvatore Iovene Date: Mon, 4 Feb 2013 15:02:27 +0200 Subject: [PATCH] (hoofbeats) Adds initial Ember skeleton. --- examples/hoofbeats/index.html | 31 +++++++++++++++- examples/hoofbeats/javascripts/app/app.js | 8 +++++ .../app/controllers/applicationController.js | 7 ++++ .../app/controllers/artistsController.js | 10 ++++++ .../javascripts/app/models/artistModel.js | 42 ++++++++++++++++++++++ examples/hoofbeats/javascripts/app/router.js | 26 ++++++++++++++ examples/hoofbeats/javascripts/app/store.js | 14 ++++++++ .../hoofbeats/javascripts/app/views/artistsView.js | 11 ++++++ grunt.js | 4 ++- 9 files changed, 151 insertions(+), 2 deletions(-) create mode 100644 examples/hoofbeats/javascripts/app/app.js create mode 100644 examples/hoofbeats/javascripts/app/controllers/applicationController.js create mode 100644 examples/hoofbeats/javascripts/app/controllers/artistsController.js create mode 100644 examples/hoofbeats/javascripts/app/models/artistModel.js create mode 100644 examples/hoofbeats/javascripts/app/router.js create mode 100644 examples/hoofbeats/javascripts/app/store.js create mode 100644 examples/hoofbeats/javascripts/app/views/artistsView.js diff --git a/examples/hoofbeats/index.html b/examples/hoofbeats/index.html index 19b6f78..c13a9ae 100644 --- a/examples/hoofbeats/index.html +++ b/examples/hoofbeats/index.html @@ -12,10 +12,39 @@ -
+
+ + + + + + + + + + + + + + + + + + diff --git a/examples/hoofbeats/javascripts/app/app.js b/examples/hoofbeats/javascripts/app/app.js new file mode 100644 index 0000000..4cbefae --- /dev/null +++ b/examples/hoofbeats/javascripts/app/app.js @@ -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 index 0000000..634cbc2 --- /dev/null +++ b/examples/hoofbeats/javascripts/app/controllers/applicationController.js @@ -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 index 0000000..2a6c008 --- /dev/null +++ b/examples/hoofbeats/javascripts/app/controllers/artistsController.js @@ -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 index 0000000..9c4a60d --- /dev/null +++ b/examples/hoofbeats/javascripts/app/models/artistModel.js @@ -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 index 0000000..2aa570d --- /dev/null +++ b/examples/hoofbeats/javascripts/app/router.js @@ -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 index 0000000..a7b8183 --- /dev/null +++ b/examples/hoofbeats/javascripts/app/store.js @@ -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 index 0000000..5798e86 --- /dev/null +++ b/examples/hoofbeats/javascripts/app/views/artistsView.js @@ -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); diff --git a/grunt.js b/grunt.js index 62c18d3..d5a0fda 100644 --- 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' ] } } -- 2.7.4