Skip to content
Browse files

Implement Service.

  • Loading branch information...
1 parent 9383e4b commit e26faeb625767a2a404b2f0dc56b4ce98c0bacb3 @grifotv committed Aug 21, 2012
Showing with 932 additions and 483 deletions.
  1. +282 −269 bin/js/app.js
  2. +1 −1 bin/js/app.min.js
  3. +438 −29 grifotv_portfolio.sublime-workspace
  4. +77 −52 src/App.coffee
  5. +127 −3 src/AppService.coffee
  6. +1 −1 src/collection/stream/BlogCollection.coffee
  7. +6 −128 src/view/AppView.coffee
View
551 bin/js/app.js
@@ -1,11 +1,12 @@
(function() {
var AboutPageView, AbstractPageView, AbstractView, AppConfig, AppRouter, AppService, AppState, AppView, BlogCollection, BlogModel, BlogView, BrandCollection, BrandModel, BrandView, CreditCollection, CreditGroupCollection, CreditGroupModel, CreditGroupView, CreditModel, CreditView, ExperienceCollection, ExperienceGroupCollection, ExperienceGroupModel, ExperienceGroupView, ExperienceModel, FlickrCollection, FlickrModel, FlickrView, GithubCollection, GithubModel, GithubView, HeaderBgView, HeaderView, LabelCollection, LabelModel, NavView, ProfileCollection, ProfileModel, ProfileView, ProjectCollection, ProjectModel, ProjectPageView, ProjectsPageView, ShareView, StreamPageView, TagCollection, TagGroupCollection, TagGroupModel, TagGroupView, TagModel, TagView, TagsPageView, ThumbnailView, TwitterCollection, TwitterModel, TwitterView, Utils, WordStreamLineView, YoutubeCollection, YoutubeModel, YoutubeView;
- var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; }, __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
+ var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; }, __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor; child.__super__ = parent.prototype; return child; };
$(function() {
window.grifo = {
state: null,
config: null,
+ service: null,
view: null,
router: null,
labelCollection: null,
@@ -22,16 +23,26 @@
twitterCollection: null,
githubCollection: null,
flickrCollection: null,
- blogCollection: null
+ blogCollection: null,
+ loaded: 0.0,
+ numLoaded: 2.0,
+ onLoaded: null
};
grifo.state = new AppState();
grifo.config = new AppConfig();
+ grifo.service = new AppService();
grifo.view = new AppView();
- return grifo.view.on(AppView.EVENT_DATA_LOADED, function() {
+ grifo.onLoaded = function() {
+ grifo.loaded++;
+ if (grifo.loaded < grifo.numLoaded) return;
+ grifo.view.start();
grifo.router = new AppRouter();
grifo.router.on(AppRouter.EVENT_HASH_CHANGED, grifo.view.onHashChanged);
return grifo.router.start();
- });
+ };
+ grifo.service.on(AppService.EVENT_LOADED, grifo.onLoaded);
+ grifo.view.on(AppView.EVENT_LOADED, grifo.onLoaded);
+ return grifo.service.start();
});
if (!window['console']) {
@@ -210,12 +221,170 @@
AppService = (function() {
- AppService.prototype.test = false;
+ AppService.EVENT_LOADED = 'EVENT_LOADED';
+
+ AppService.prototype.loaded = 0.0;
+
+ AppService.prototype.numLoaded = 14.0;
function AppService() {
- console.log(this.test);
+ this.onLoad = __bind(this.onLoad, this); _.extend(this, Backbone.Events);
}
+ AppService.prototype.start = function() {
+ var _this = this;
+ grifo.projectCollection = new ProjectCollection;
+ grifo.projectCollection.url = grifo.config.URL_PROJECTS;
+ grifo.projectCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.tagCollection = new TagCollection();
+ grifo.tagCollection.url = grifo.config.URL_TAGS;
+ grifo.tagCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.tagGroupCollection = new TagGroupCollection();
+ grifo.tagGroupCollection.url = grifo.config.URL_TAG_GROUPS;
+ grifo.tagGroupCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.creditCollection = new CreditCollection();
+ grifo.creditCollection.url = grifo.config.URL_CREDITS;
+ grifo.creditCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.creditGroupCollection = new CreditGroupCollection();
+ grifo.creditGroupCollection.url = grifo.config.URL_CREDIT_GROUPS;
+ grifo.creditGroupCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.experienceCollection = new ExperienceCollection();
+ grifo.experienceCollection.url = grifo.config.URL_EXPERIENCES;
+ grifo.experienceCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.experienceGroupCollection = new ExperienceGroupCollection();
+ grifo.experienceGroupCollection.url = grifo.config.URL_EXPERIENCE_GROUPS;
+ grifo.experienceGroupCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.profileCollection = new ProfileCollection();
+ grifo.profileCollection.url = grifo.config.URL_PROFILES;
+ grifo.profileCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.brandCollection = new BrandCollection();
+ grifo.brandCollection.url = grifo.config.URL_BRANDS;
+ grifo.brandCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.labelCollection = new LabelCollection();
+ grifo.labelCollection.url = grifo.config.URL_LABELS;
+ grifo.labelCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.youtubeCollection = new YoutubeCollection();
+ grifo.youtubeCollection.url = grifo.config.URL_YOUTUBE;
+ grifo.youtubeCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.twitterCollection = new TwitterCollection();
+ grifo.twitterCollection.url = grifo.config.URL_TWITTER;
+ grifo.twitterCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.githubCollection = new GithubCollection();
+ grifo.githubCollection.url = grifo.config.URL_GITHUB;
+ grifo.githubCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.flickrCollection = new FlickrCollection();
+ grifo.flickrCollection.url = grifo.config.URL_FLICKR;
+ grifo.flickrCollection.fetch({
+ success: function(model_, response_) {
+ return _this.onLoad();
+ },
+ error: function(model_, response_) {
+ return _this.onLoad();
+ }
+ });
+ grifo.blogCollection = new BlogCollection();
+ grifo.blogCollection.url = grifo.config.URL_BLOG;
+ return grifo.blogCollection.load();
+ };
+
+ AppService.prototype.onLoad = function() {
+ this.loaded++;
+ if (this.loaded === this.numLoaded) {
+ return this.trigger(AppService.EVENT_LOADED);
+ }
+ };
+
return AppService;
})();
@@ -393,106 +562,6 @@
})();
- BlogModel = (function() {
-
- __extends(BlogModel, Backbone.Model);
-
- function BlogModel() {
- BlogModel.__super__.constructor.apply(this, arguments);
- }
-
- BlogModel.prototype.defaults = {
- title: '',
- url: '',
- description: '',
- date: ''
- };
-
- return BlogModel;
-
- })();
-
- FlickrModel = (function() {
-
- __extends(FlickrModel, Backbone.Model);
-
- function FlickrModel() {
- FlickrModel.__super__.constructor.apply(this, arguments);
- }
-
- FlickrModel.prototype.defaults = {
- title: '',
- url: '',
- image: '',
- date: '',
- is_portrait: false
- };
-
- return FlickrModel;
-
- })();
-
- GithubModel = (function() {
-
- __extends(GithubModel, Backbone.Model);
-
- function GithubModel() {
- GithubModel.__super__.constructor.apply(this, arguments);
- }
-
- GithubModel.prototype.defaults = {
- type: '',
- text: '',
- date: '',
- url: ''
- };
-
- return GithubModel;
-
- })();
-
- TwitterModel = (function() {
-
- __extends(TwitterModel, Backbone.Model);
-
- function TwitterModel() {
- TwitterModel.__super__.constructor.apply(this, arguments);
- }
-
- TwitterModel.prototype.defaults = {
- id: '',
- text: '',
- date: '',
- url: ''
- };
-
- return TwitterModel;
-
- })();
-
- YoutubeModel = (function() {
-
- __extends(YoutubeModel, Backbone.Model);
-
- function YoutubeModel() {
- YoutubeModel.__super__.constructor.apply(this, arguments);
- }
-
- YoutubeModel.prototype.defaults = {
- id: '',
- url: '',
- date: '',
- title: '',
- content: '',
- thumbnail_low: '',
- thumbnail_medium: '',
- is_portrait: false
- };
-
- return YoutubeModel;
-
- })();
-
BrandModel = (function() {
__extends(BrandModel, Backbone.Model);
@@ -734,6 +803,106 @@
})();
+ BlogModel = (function() {
+
+ __extends(BlogModel, Backbone.Model);
+
+ function BlogModel() {
+ BlogModel.__super__.constructor.apply(this, arguments);
+ }
+
+ BlogModel.prototype.defaults = {
+ title: '',
+ url: '',
+ description: '',
+ date: ''
+ };
+
+ return BlogModel;
+
+ })();
+
+ FlickrModel = (function() {
+
+ __extends(FlickrModel, Backbone.Model);
+
+ function FlickrModel() {
+ FlickrModel.__super__.constructor.apply(this, arguments);
+ }
+
+ FlickrModel.prototype.defaults = {
+ title: '',
+ url: '',
+ image: '',
+ date: '',
+ is_portrait: false
+ };
+
+ return FlickrModel;
+
+ })();
+
+ GithubModel = (function() {
+
+ __extends(GithubModel, Backbone.Model);
+
+ function GithubModel() {
+ GithubModel.__super__.constructor.apply(this, arguments);
+ }
+
+ GithubModel.prototype.defaults = {
+ type: '',
+ text: '',
+ date: '',
+ url: ''
+ };
+
+ return GithubModel;
+
+ })();
+
+ TwitterModel = (function() {
+
+ __extends(TwitterModel, Backbone.Model);
+
+ function TwitterModel() {
+ TwitterModel.__super__.constructor.apply(this, arguments);
+ }
+
+ TwitterModel.prototype.defaults = {
+ id: '',
+ text: '',
+ date: '',
+ url: ''
+ };
+
+ return TwitterModel;
+
+ })();
+
+ YoutubeModel = (function() {
+
+ __extends(YoutubeModel, Backbone.Model);
+
+ function YoutubeModel() {
+ YoutubeModel.__super__.constructor.apply(this, arguments);
+ }
+
+ YoutubeModel.prototype.defaults = {
+ id: '',
+ url: '',
+ date: '',
+ title: '',
+ content: '',
+ thumbnail_low: '',
+ thumbnail_medium: '',
+ is_portrait: false
+ };
+
+ return YoutubeModel;
+
+ })();
+
BrandCollection = (function() {
__extends(BrandCollection, Backbone.Collection);
@@ -1086,7 +1255,7 @@
BlogCollection.prototype.parseAndAdd = function(response_) {
this.add(this.parse(response_));
- return grifo.view.onLoad();
+ return grifo.service.onLoad();
};
BlogCollection.prototype.parse = function(response_) {
@@ -1369,11 +1538,10 @@
this.onHashChanged = __bind(this.onHashChanged, this);
this.show = __bind(this.show, this);
this.render = __bind(this.render, this);
- this.onLoad = __bind(this.onLoad, this);
AppView.__super__.constructor.apply(this, arguments);
}
- AppView.EVENT_DATA_LOADED = 'EVENT_DATA_LOADED';
+ AppView.EVENT_LOADED = 'EVENT_LOADED';
AppView.EVENT_REALIGNED = 'EVENT_REALIGNED';
@@ -1385,10 +1553,6 @@
AppView.prototype.template = null;
- AppView.prototype.loaded = 0.0;
-
- AppView.prototype.numLoaded = 15.0;
-
AppView.prototype.headerView = null;
AppView.prototype.headerBgView = null;
@@ -1404,171 +1568,20 @@
AppView.prototype.aboutPageView = null;
AppView.prototype.initialize = function() {
+ var _this = this;
this.$el = $(this.el);
this.$window = $(window);
this.template = _.template($('#template_app').html());
this.$window.scroll(this.realign);
this.$window.resize(this.realign);
- this.$window.load(this.onLoad);
- return this.loadData();
- };
-
- AppView.prototype.loadData = function() {
- var _this = this;
- grifo.projectCollection = new ProjectCollection;
- grifo.projectCollection.url = grifo.config.URL_PROJECTS;
- grifo.projectCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.tagCollection = new TagCollection();
- grifo.tagCollection.url = grifo.config.URL_TAGS;
- grifo.tagCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
+ return this.$window.load(function() {
+ return _this.trigger(AppView.EVENT_LOADED);
});
- grifo.tagGroupCollection = new TagGroupCollection();
- grifo.tagGroupCollection.url = grifo.config.URL_TAG_GROUPS;
- grifo.tagGroupCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.creditCollection = new CreditCollection();
- grifo.creditCollection.url = grifo.config.URL_CREDITS;
- grifo.creditCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.creditGroupCollection = new CreditGroupCollection();
- grifo.creditGroupCollection.url = grifo.config.URL_CREDIT_GROUPS;
- grifo.creditGroupCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.experienceCollection = new ExperienceCollection();
- grifo.experienceCollection.url = grifo.config.URL_EXPERIENCES;
- grifo.experienceCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.experienceGroupCollection = new ExperienceGroupCollection();
- grifo.experienceGroupCollection.url = grifo.config.URL_EXPERIENCE_GROUPS;
- grifo.experienceGroupCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.profileCollection = new ProfileCollection();
- grifo.profileCollection.url = grifo.config.URL_PROFILES;
- grifo.profileCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.brandCollection = new BrandCollection();
- grifo.brandCollection.url = grifo.config.URL_BRANDS;
- grifo.brandCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.labelCollection = new LabelCollection();
- grifo.labelCollection.url = grifo.config.URL_LABELS;
- grifo.labelCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.youtubeCollection = new YoutubeCollection();
- grifo.youtubeCollection.url = grifo.config.URL_YOUTUBE;
- grifo.youtubeCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.twitterCollection = new TwitterCollection();
- grifo.twitterCollection.url = grifo.config.URL_TWITTER;
- grifo.twitterCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.githubCollection = new GithubCollection();
- grifo.githubCollection.url = grifo.config.URL_GITHUB;
- grifo.githubCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.flickrCollection = new FlickrCollection();
- grifo.flickrCollection.url = grifo.config.URL_FLICKR;
- grifo.flickrCollection.fetch({
- success: function(model_, response_) {
- return _this.onLoad();
- },
- error: function(model_, response_) {
- return _this.onLoad();
- }
- });
- grifo.blogCollection = new BlogCollection();
- grifo.blogCollection.url = grifo.config.URL_BLOG;
- return grifo.blogCollection.load();
- };
-
- AppView.prototype.onLoad = function() {
- this.loaded++;
- if (this.loaded === this.numLoaded) return this.onLoadComplete();
};
- AppView.prototype.onLoadComplete = function() {
+ AppView.prototype.start = function() {
this.render();
- this.show();
- return this.trigger(AppView.EVENT_DATA_LOADED);
+ return this.show();
};
AppView.prototype.render = function() {
View
2 bin/js/app.min.js
1 addition, 1 deletion not shown because the diff is too large. Please use a local Git client to view these changes.
View
467 grifotv_portfolio.sublime-workspace
@@ -23,15 +23,15 @@
"file": "src/App.coffee",
"settings":
{
- "buffer_size": 1429,
+ "buffer_size": 1404,
"line_ending": "Unix"
}
},
{
"file": "src/view/page/project/ProjectPageView.coffee",
"settings":
{
- "buffer_size": 2500,
+ "buffer_size": 2488,
"line_ending": "Unix"
}
},
@@ -60,10 +60,90 @@
}
},
{
+ "file": "src/AppState.coffee",
+ "settings":
+ {
+ "buffer_size": 1371,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/router/AppRouter.coffee",
+ "settings":
+ {
+ "buffer_size": 2587,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/view/page/projects/ThumbnailView.coffee",
+ "settings":
+ {
+ "buffer_size": 1875,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/view/page/stream/BlogView.coffee",
+ "settings":
+ {
+ "buffer_size": 451,
+ "line_ending": "Unix"
+ }
+ },
+ {
"file": "src/view/AppView.coffee",
"settings":
{
- "buffer_size": 11032,
+ "buffer_size": 10918,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/view/component/TagView.coffee",
+ "settings":
+ {
+ "buffer_size": 1027,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/view/header/ShareView.coffee",
+ "settings":
+ {
+ "buffer_size": 729,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/collection/stream/BlogCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 1008,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/collection/stream/FlickrCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 1349,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/collection/stream/GithubCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 3065,
+ "line_ending": "Unix"
+ }
+ },
+ {
+ "file": "src/collection/stream/TwitterCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 1426,
"line_ending": "Unix"
}
}
@@ -241,6 +321,16 @@
"case_sensitive": false,
"find_history":
[
+ "grifo.appConfig",
+ "grifo.app",
+ "grifo.appC",
+ "grifo.appS",
+ "grifo.app",
+ "grifo.appState",
+ "appConfig",
+ "app",
+ "appConfig",
+ "app",
"EVENT",
"event",
"appStatus",
@@ -358,17 +448,7 @@
"\"images\": \"\",",
"tag",
"webfonts/",
- "tag",
- "0a9fe1",
- "tag",
- "tags",
- "border-radius",
- "tag",
- "-moz-border-radius",
- "tag",
- "creative & art d",
- "video-container",
- "video"
+ "tag"
],
"highlight": true,
"in_selection": false,
@@ -423,15 +503,15 @@
"file": "src/App.coffee",
"settings":
{
- "buffer_size": 1429,
+ "buffer_size": 1404,
"regions":
{
},
"selection":
[
[
- 1001,
- 1001
+ 1199,
+ 1199
]
],
"settings":
@@ -450,15 +530,19 @@
"file": "src/view/page/project/ProjectPageView.coffee",
"settings":
{
- "buffer_size": 2500,
+ "buffer_size": 2488,
"regions":
{
},
"selection":
[
[
- 1064,
- 1064
+ 1097,
+ 1097
+ ],
+ [
+ 1242,
+ 1242
]
],
"settings":
@@ -468,7 +552,7 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
- "translation.y": 0.0,
+ "translation.y": 176.0,
"zoom_level": 1.0
},
"type": "text"
@@ -538,8 +622,8 @@
"selection":
[
[
- 17213,
- 17213
+ 17332,
+ 17335
]
],
"settings":
@@ -549,30 +633,271 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
- "translation.y": 7242.0,
+ "translation.y": 7156.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 6,
+ "file": "src/AppState.coffee",
+ "settings":
+ {
+ "buffer_size": 1371,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 6,
+ 9
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 7,
+ "file": "src/router/AppRouter.coffee",
+ "settings":
+ {
+ "buffer_size": 2587,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 6,
+ 9
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 8,
+ "file": "src/view/page/projects/ThumbnailView.coffee",
+ "settings":
+ {
+ "buffer_size": 1875,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 1529,
+ 1529
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 9,
+ "file": "src/view/page/stream/BlogView.coffee",
+ "settings":
+ {
+ "buffer_size": 451,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 0,
+ 0
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
}
]
},
{
+ "selected": 3,
"sheets":
[
{
- "buffer": 6,
+ "buffer": 10,
"file": "src/view/AppView.coffee",
"settings":
{
- "buffer_size": 11032,
+ "buffer_size": 10918,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 5814,
+ 5814
+ ],
+ [
+ 7507,
+ 7507
+ ],
+ [
+ 7540,
+ 7540
+ ],
+ [
+ 7572,
+ 7572
+ ],
+ [
+ 7605,
+ 7605
+ ],
+ [
+ 7640,
+ 7640
+ ],
+ [
+ 7673,
+ 7673
+ ],
+ [
+ 7712,
+ 7712
+ ],
+ [
+ 7757,
+ 7757
+ ],
+ [
+ 7805,
+ 7805
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 2085.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 11,
+ "file": "src/view/component/TagView.coffee",
+ "settings":
+ {
+ "buffer_size": 1027,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 935,
+ 935
+ ],
+ [
+ 989,
+ 989
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 12,
+ "file": "src/view/header/ShareView.coffee",
+ "settings":
+ {
+ "buffer_size": 729,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 384,
+ 384
+ ],
+ [
+ 560,
+ 560
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 13,
+ "file": "src/collection/stream/BlogCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 1008,
"regions":
{
},
"selection":
[
[
- 5810,
- 5810
+ 207,
+ 207
]
],
"settings":
@@ -582,7 +907,91 @@
"translate_tabs_to_spaces": true
},
"translation.x": 0.0,
- "translation.y": 1989.0,
+ "translation.y": 0.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 14,
+ "file": "src/collection/stream/FlickrCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 1349,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 1070,
+ 1070
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 15,
+ "file": "src/collection/stream/GithubCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 3065,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 2974,
+ 2974
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 286.0,
+ "zoom_level": 1.0
+ },
+ "type": "text"
+ },
+ {
+ "buffer": 16,
+ "file": "src/collection/stream/TwitterCollection.coffee",
+ "settings":
+ {
+ "buffer_size": 1426,
+ "regions":
+ {
+ },
+ "selection":
+ [
+ [
+ 1330,
+ 1330
+ ]
+ ],
+ "settings":
+ {
+ "syntax": "Packages/CoffeeScript/CoffeeScript.tmLanguage",
+ "tab_size": 4,
+ "translate_tabs_to_spaces": true
+ },
+ "translation.x": 0.0,
+ "translation.y": 0.0,
"zoom_level": 1.0
},
"type": "text"
View
129 src/App.coffee
@@ -1,58 +1,83 @@
# on ready
$ ->
- # only global property
- window.grifo =
-
- # app state
- state : null
-
- # app config
- config : null
-
- # app view
- view : null
-
- # app router
- router : null
-
- # portfolio collections
- labelCollection : null
- brandCollection : null
- profileCollection : null
- experienceCollection : null
- experienceGroupCollection : null
- tagGroupCollection : null
- tagCollection : null
- creditGroupCollection : null
- creditCollection : null
- projectCollection : null
-
- # stream collections
- youtubeCollection : null
- twitterCollection : null
- githubCollection : null
- flickrCollection : null
- blogCollection : null
-
-
- # start app
- grifo.state = new AppState()
- grifo.config = new AppConfig()
- grifo.view = new AppView()
-
-
- # on data loaded
- grifo.view.on AppView.EVENT_DATA_LOADED, ->
-
- # start router
- grifo.router = new AppRouter()
-
- # bind router event to view callback
- grifo.router.on AppRouter.EVENT_HASH_CHANGED , grifo.view.onHashChanged
-
- # bootstrap
- grifo.router.start()
+ # only global property
+ window.grifo =
+
+ # app state
+ state : null
+
+ # app config
+ config : null
+
+ # app service
+ service : null
+
+ # app view
+ view : null
+
+ # app router
+ router : null
+
+ # portfolio collections
+ labelCollection : null
+ brandCollection : null
+ profileCollection : null
+ experienceCollection : null
+ experienceGroupCollection : null
+ tagGroupCollection : null
+ tagCollection : null
+ creditGroupCollection : null
+ creditCollection : null
+ projectCollection : null
+
+ # stream collections
+ youtubeCollection : null
+ twitterCollection : null
+ githubCollection : null
+ flickrCollection : null
+ blogCollection : null
+
+ # ints
+ loaded : 0.0
+ numLoaded : 2.0
+
+ # callback
+ onLoaded : null
+
+
+ # start app
+ grifo.state = new AppState()
+ grifo.config = new AppConfig()
+ grifo.service = new AppService()
+ grifo.view = new AppView()
+
+
+ # define onLoaded callback
+ grifo.onLoaded = ->
+
+ grifo.loaded++
+ return if grifo.loaded < grifo.numLoaded
+
+ # start view
+ grifo.view.start()
+
+ # start router
+ grifo.router = new AppRouter()
+
+ # bind router event to view callback
+ grifo.router.on AppRouter.EVENT_HASH_CHANGED , grifo.view.onHashChanged
+
+ # bootstrap
+ grifo.router.start()
+
+
+ # bind on loaded events to single callback
+ grifo.service.on AppService.EVENT_LOADED, grifo.onLoaded
+ grifo.view.on AppView.EVENT_LOADED, grifo.onLoaded
+
+ # preload data
+ grifo.service.start()
# adding fake console to browsers that doesn't have it
View
130 src/AppService.coffee
@@ -1,8 +1,132 @@
class AppService
- test : false
+ # events
+ @EVENT_LOADED : 'EVENT_LOADED'
+
+ # ints
+ loaded : 0.0
+ numLoaded : 14.0 # total of 15
- constructor : ->
+ constructor :->
+
+ _.extend @, Backbone.Events
- console.log @test
+
+ start : ->
+
+ # PORTFOLIO COLLECTIONS
+
+ # 1 - load projects
+ grifo.projectCollection = new ProjectCollection
+ grifo.projectCollection.url = grifo.config.URL_PROJECTS
+ grifo.projectCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 2 - load tags
+ grifo.tagCollection = new TagCollection()
+ grifo.tagCollection.url = grifo.config.URL_TAGS
+ grifo.tagCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 3 - load tag groups
+ grifo.tagGroupCollection = new TagGroupCollection()
+ grifo.tagGroupCollection.url = grifo.config.URL_TAG_GROUPS
+ grifo.tagGroupCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 4 - load credits
+ grifo.creditCollection = new CreditCollection()
+ grifo.creditCollection.url = grifo.config.URL_CREDITS
+ grifo.creditCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 5 - load credit groups
+ grifo.creditGroupCollection = new CreditGroupCollection()
+ grifo.creditGroupCollection.url = grifo.config.URL_CREDIT_GROUPS
+ grifo.creditGroupCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 6 - load experiences
+ grifo.experienceCollection = new ExperienceCollection()
+ grifo.experienceCollection.url = grifo.config.URL_EXPERIENCES
+ grifo.experienceCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 7 - load experience groups
+ grifo.experienceGroupCollection = new ExperienceGroupCollection()
+ grifo.experienceGroupCollection.url = grifo.config.URL_EXPERIENCE_GROUPS
+ grifo.experienceGroupCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 8 - load profiles
+ grifo.profileCollection = new ProfileCollection()
+ grifo.profileCollection.url = grifo.config.URL_PROFILES
+ grifo.profileCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 9 - load brands
+ grifo.brandCollection = new BrandCollection()
+ grifo.brandCollection.url = grifo.config.URL_BRANDS
+ grifo.brandCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 10 - load labels
+ grifo.labelCollection = new LabelCollection()
+ grifo.labelCollection.url = grifo.config.URL_LABELS
+ grifo.labelCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+
+ # STREAM COLLECTIONS
+
+ # 11 - load youtube
+ grifo.youtubeCollection = new YoutubeCollection()
+ grifo.youtubeCollection.url = grifo.config.URL_YOUTUBE
+ grifo.youtubeCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 12 - load twitter
+ grifo.twitterCollection = new TwitterCollection()
+ grifo.twitterCollection.url = grifo.config.URL_TWITTER
+ grifo.twitterCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 13 - load github
+ grifo.githubCollection = new GithubCollection()
+ grifo.githubCollection.url = grifo.config.URL_GITHUB
+ grifo.githubCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 14 - load flickr
+ grifo.flickrCollection = new FlickrCollection()
+ grifo.flickrCollection.url = grifo.config.URL_FLICKR
+ grifo.flickrCollection.fetch
+ success : ( model_, response_ ) => @onLoad()
+ error : ( model_, response_ ) => @onLoad()
+
+ # 15 - load blog
+ grifo.blogCollection = new BlogCollection()
+ grifo.blogCollection.url = grifo.config.URL_BLOG
+ grifo.blogCollection.load()
+
+
+ onLoad: =>
+
+ @loaded++
+
+ if @loaded == @numLoaded
+ @trigger AppService.EVENT_LOADED
View
2 src/collection/stream/BlogCollection.coffee
@@ -7,7 +7,7 @@ class BlogCollection extends Backbone.Collection
parseAndAdd : ( response_ ) =>
@add @parse( response_ )
- grifo.view.onLoad()
+ grifo.service.onLoad()
parse : ( response_ ) ->
View
134 src/view/AppView.coffee
@@ -1,18 +1,14 @@
class AppView extends Backbone.View
# events
- @EVENT_DATA_LOADED : 'EVENT_DATA_LOADED'
+ @EVENT_LOADED : 'EVENT_LOADED'
@EVENT_REALIGNED : 'EVENT_REALIGNED'
# el
el : 'body'
$el : null
$window : null
template : null
-
- # ints
- loaded : 0.0
- numLoaded : 15.0 # total of 16
# header views
headerView : null
@@ -36,135 +32,15 @@ class AppView extends Backbone.View
@$window.resize @realign
# 1 - load dom
- @$window.load @onLoad
-
- @loadData()
-
-
- loadData: ->
-
- # PORTFOLIO COLLECTIONS
-
- # 2 - load projects
- grifo.projectCollection = new ProjectCollection
- grifo.projectCollection.url = grifo.config.URL_PROJECTS
- grifo.projectCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 3 - load tags
- grifo.tagCollection = new TagCollection()
- grifo.tagCollection.url = grifo.config.URL_TAGS
- grifo.tagCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 4 - load tag groups
- grifo.tagGroupCollection = new TagGroupCollection()
- grifo.tagGroupCollection.url = grifo.config.URL_TAG_GROUPS
- grifo.tagGroupCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 5 - load credits
- grifo.creditCollection = new CreditCollection()
- grifo.creditCollection.url = grifo.config.URL_CREDITS
- grifo.creditCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 6 - load credit groups
- grifo.creditGroupCollection = new CreditGroupCollection()
- grifo.creditGroupCollection.url = grifo.config.URL_CREDIT_GROUPS
- grifo.creditGroupCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 7 - load experiences
- grifo.experienceCollection = new ExperienceCollection()
- grifo.experienceCollection.url = grifo.config.URL_EXPERIENCES
- grifo.experienceCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 8 - load experience groups
- grifo.experienceGroupCollection = new ExperienceGroupCollection()
- grifo.experienceGroupCollection.url = grifo.config.URL_EXPERIENCE_GROUPS
- grifo.experienceGroupCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 9 - load profiles
- grifo.profileCollection = new ProfileCollection()
- grifo.profileCollection.url = grifo.config.URL_PROFILES
- grifo.profileCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 10 - load brands
- grifo.brandCollection = new BrandCollection()
- grifo.brandCollection.url = grifo.config.URL_BRANDS
- grifo.brandCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 11 - load labels
- grifo.labelCollection = new LabelCollection()
- grifo.labelCollection.url = grifo.config.URL_LABELS
- grifo.labelCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
-
- # STREAM COLLECTIONS
-
- # 12 - load youtube
- grifo.youtubeCollection = new YoutubeCollection()
- grifo.youtubeCollection.url = grifo.config.URL_YOUTUBE
- grifo.youtubeCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 13 - load twitter
- grifo.twitterCollection = new TwitterCollection()
- grifo.twitterCollection.url = grifo.config.URL_TWITTER
- grifo.twitterCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 14 - load github
- grifo.githubCollection = new GithubCollection()
- grifo.githubCollection.url = grifo.config.URL_GITHUB
- grifo.githubCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 15 - load flickr
- grifo.flickrCollection = new FlickrCollection()
- grifo.flickrCollection.url = grifo.config.URL_FLICKR
- grifo.flickrCollection.fetch
- success : ( model_, response_ ) => @onLoad()
- error : ( model_, response_ ) => @onLoad()
-
- # 16 - load blog
- grifo.blogCollection = new BlogCollection()
- grifo.blogCollection.url = grifo.config.URL_BLOG
- grifo.blogCollection.load()
-
-
- onLoad: =>
-
- @loaded++
- @onLoadComplete() if @loaded == @numLoaded
+ @$window.load =>
+ @trigger AppView.EVENT_LOADED
- onLoadComplete: ->
+ start: ->
@render()
@show()
- @trigger AppView.EVENT_DATA_LOADED
-
render: =>
@@ -322,7 +198,9 @@ class AppView extends Backbone.View
$( 'html,body' ).stop().animate { scrollTop: y_ } , { duration: difY, easing: 'easeOutExpo' }
+
realign: =>
+
if !@headerView || !@headerBgView
return

0 comments on commit e26faeb

Please sign in to comment.
Something went wrong with that request. Please try again.