Skip to content
This repository
Browse code

The bootstrap.css and bootstrap-responsive.css files were combined.

The embedded style was moved to its own file, minified, compressed and pushed to blob storage.

The github ribbon got moved to blob storage.

The facebook part became a backbone model, was wrapped in a require definition and pushed to blob storage.  Its logic was simplified to only initialize Facebook's app and wrap some of its methods.

The todos app was wrapped in its own require definition and pushed to blob storage.

The login part was moved to its own file and pushed to blob storage.

All backbone objects use the required reference to backbone instead of the global one.
  • Loading branch information...
commit 4cec9139d73578c16da8cb0b93ec491891150156 1 parent b29d658
David Cabiness authored April 24, 2012
8  dcabines.Web/Scripts/main.min.js
... ...
@@ -1,5 +1,3 @@
1  
-require.config({paths:{text:"http://davidstorage.blob.core.windows.net/libs/text",backbone:"http://davidstorage.blob.core.windows.net/libs/backbone",templates:"../templates"}});define("home",["text!templates/home.html","backbone"],function(c){return Backbone.View.extend({el:".content",render:function(){this.$el.html(c);$(".nav li").removeClass("active")}})});
2  
-define("facebook",["http://connect.facebook.net/en_US/all.js"],function(){FB.init({appId:"359670380741025",status:!0,cookie:!0,xfbml:!0,oauth:!0});var c={status:function(b){FB.getLoginStatus(function(a){b(a)})},login:function(b){c.status(function(a){"connected"!=a.status?FB.login(function(a){a.authResponse&&b()}):b()})},logout:function(){c.status(function(b){"connected"==b.status&&FB.logout()})},info:function(b,a){FB.api("/"+(a||"me"),function(a){b(a)})},authInfo:function(b,a){c.login(function(){c.info(b,
3  
-a)})}};return c});define("login",["facebook","backbone"],function(c){return Backbone.View.extend({el:".navbar .login",message:this.$(".message"),template:$("#login-message").html(),button:this.$("button"),events:{"click button":"login"},login:function(){c.authInfo(function(b){this.message.html(_.template(this.template,b));this.message.find("i").click(function(){c.logout();this.button.show().siblings().empty()});this.button.hide()})}})});
4  
-require(["facebook","login","backbone"],function(c,b){var a=function(a){require([a],function(a){(new a).render();$(window).scrollTop(0)})},d=Backbone.Router.extend({routes:{about:"about",privacy:"privacy",terms:"terms",help:"help",todo:"todo","*actions":"defaultAction"},about:function(){a("views/about.min")},privacy:function(){a("views/privacy.min")},terms:function(){a("views/terms.min")},help:function(){a("views/help.min")},todo:function(){a("views/todo.min")},defaultAction:function(){a("home")}}),
5  
-e=new b;c.status(function(a){"connected"==a.status&&e.login()});new d;Backbone.history.start()});
  1
+require.config({paths:{text:"http://davidstorage.blob.core.windows.net/libs/text",backbone:"http://davidstorage.blob.core.windows.net/libs/backbone",facebook:"http://davidstorage.blob.core.windows.net/scripts/facebook.min",login:"http://davidstorage.blob.core.windows.net/scripts/login.min",TodoApp:"http://davidstorage.blob.core.windows.net/scripts/todos.min",templates:"../templates"}});
  2
+require(["login","backbone","require"],function(c,b,d){var a=function(a){d([a],function(a){(new a).render();$(window).scrollTop(0)})},e=b.Router.extend({routes:{about:"about",privacy:"privacy",terms:"terms",help:"help",todo:"todo","*actions":"defaultAction"},about:function(){a("views/about.min")},privacy:function(){a("views/privacy.min")},terms:function(){a("views/terms.min")},help:function(){a("views/help.min")},todo:function(){a("views/todo.min")},defaultAction:function(){a("views/home.min")}});
  3
+new c;new e;b.history.start()});
97  dcabines.Web/Scripts/main.simple.js
@@ -2,101 +2,23 @@ require.config({
2 2
     paths: {
3 3
         text: 'http://' + 'davidstorage.blob.core.windows.net/libs/text',
4 4
         backbone: 'http://' + 'davidstorage.blob.core.windows.net/libs/backbone',
  5
+        facebook: 'http://' + 'davidstorage.blob.core.windows.net/scripts/facebook.min',
  6
+        login: 'http://' + 'davidstorage.blob.core.windows.net/scripts/login.min',
  7
+        TodoApp: 'http://' + 'davidstorage.blob.core.windows.net/scripts/todos.min',
5 8
         templates: '../templates'
6 9
     }
7 10
 });
8 11
 
9  
-define('home', ['text!templates/home.html', 'backbone'], function(template) {
10  
-    var view = Backbone.View.extend({
11  
-        el: '.content',
12  
-        render: function() {
13  
-            this.$el.html(template);
14  
-            $('.nav li').removeClass('active');
15  
-        }
16  
-    });
17  
-
18  
-    return view;
19  
-});
20  
-
21  
-define('facebook', ['http://' + 'connect.facebook.net/en_US/all.js'], function() {
22  
-    FB.init({
23  
-        appId: '359670380741025',
24  
-        status: true,
25  
-        cookie: true,
26  
-        xfbml: true,
27  
-        oauth: true
28  
-    });
29  
-
30  
-    var facebook = {
31  
-        status: function(callback) {
32  
-            FB.getLoginStatus(function(loginStatus) {
33  
-                callback(loginStatus);
34  
-            });
35  
-        },
36  
-        login: function(callback) {
37  
-            facebook.status(function(loginStatus) {
38  
-                if (loginStatus.status != 'connected')
39  
-                    FB.login(function(response) {
40  
-                        if (response.authResponse) callback();
41  
-                    });
42  
-                else callback();
43  
-            });
44  
-        },
45  
-        logout: function() {
46  
-            facebook.status(function(loginStatus) {
47  
-                if (loginStatus.status == 'connected') FB.logout();
48  
-            });
49  
-        },
50  
-        info: function(callback, id) {
51  
-            FB.api('/' + (id || 'me'), function(user) {
52  
-                callback(user);
53  
-            });
54  
-        },
55  
-        authInfo: function(callback, id) {
56  
-            facebook.login(function() {
57  
-                facebook.info(callback, id);
58  
-            });
59  
-        }
60  
-    };
61  
-
62  
-    return facebook;
63  
-});
64  
-
65  
-define('login', ['facebook', 'backbone'], function (facebook) {
66  
-    var view = Backbone.View.extend({
67  
-        el: '.navbar .login',
68  
-        message: this.$('.message'),
69  
-        template: $('#login-message').html(),
70  
-        button: this.$("button"),
71  
-        events: {
72  
-            "click button": "login"
73  
-        },
74  
-        login: function () {
75  
-            facebook.authInfo(function (user) {
76  
-                var compiledTemplate = _.template(this.template, user);
77  
-                this.message.html(compiledTemplate);
78  
-                this.message.find('i').click(function () {
79  
-                    facebook.logout();
80  
-                    this.button.show().siblings().empty();
81  
-                });
82  
-                this.button.hide();
83  
-            });
84  
-        }
85  
-    });
86  
-
87  
-    return view;
88  
-});
89  
-
90  
-require(['facebook', 'login', 'backbone'], function (facebook, loginView) {
  12
+require(['login', 'backbone', 'require'], function (loginView, backbone, require) {
91 13
 
92 14
     var fetch = function (name) {
93  
-        require([name], function (view) {
  15
+        require([name], function(view) {
94 16
             new view().render();
95 17
             $(window).scrollTop(0);
96 18
         });
97 19
     };
98 20
 
99  
-    var router = Backbone.Router.extend({
  21
+    var router = backbone.Router.extend({
100 22
         routes: {
101 23
             'about': 'about',
102 24
             'privacy': 'privacy',
@@ -121,14 +43,11 @@ require(['facebook', 'login', 'backbone'], function (facebook, loginView) {
121 43
             fetch('views/todo.min');
122 44
         },
123 45
         defaultAction: function () {
124  
-            fetch('home');
  46
+            fetch('views/home.min');
125 47
         }
126 48
     });
127 49
 
128 50
     var l = new loginView;
129  
-    facebook.status(function (loginStatus) {
130  
-        if (loginStatus.status == 'connected') l.login();
131  
-    });
132 51
     var z = new router;
133  
-    Backbone.history.start();
  52
+    backbone.history.start();
134 53
 });
1  dcabines.Web/Scripts/other/facebook.min.js
... ...
@@ -0,0 +1 @@
  1
+define(["backbone","http://connect.facebook.net/en_US/all.js"],function(c){return new (c.Model.extend({initialize:function(){FB.init({appId:this.get("appID"),status:!0,cookie:!0,xfbml:!0,oauth:!0})},status:function(b){FB.getLoginStatus(function(a){b(a)})},login:function(b){FB.login(function(a){b(a)})},logout:function(){FB.logout()},info:function(b,a){FB.api("/"+(a||"me"),function(a){b(a)})}}))({appID:"359670380741025"})});
27  dcabines.Web/Scripts/other/facebook.simple.js
... ...
@@ -0,0 +1,27 @@
  1
+define(['backbone', 'http://' + 'connect.facebook.net/en_US/all.js'], function (backbone) {
  2
+    var facebook = backbone.Model.extend({
  3
+        initialize: function () {
  4
+            FB.init({
  5
+                appId: this.get('appID'),
  6
+                status: true,
  7
+                cookie: true,
  8
+                xfbml: true,
  9
+                oauth: true
  10
+            });
  11
+        },
  12
+        status: function (callback) {
  13
+            FB.getLoginStatus(function (response) { callback(response); });
  14
+        },
  15
+        login: function (callback) {
  16
+            FB.login(function (response) { callback(response); });
  17
+        },
  18
+        logout: function () {
  19
+            FB.logout();
  20
+        },
  21
+        info: function (callback, id) {
  22
+            FB.api('/' + (id || 'me'), function (response) { callback(response); });
  23
+        }
  24
+    });
  25
+    var fb = new facebook({ appID: '359670380741025' });
  26
+    return fb;
  27
+});
2  dcabines.Web/Scripts/other/login.min.js
... ...
@@ -0,0 +1,2 @@
  1
+define(["backbone","facebook"],function(c,d){return c.View.extend({el:".navbar .login",message:this.$(".message"),button:this.$("button"),events:{"click button":"login"},initialize:function(){this.login()},authInfo:function(a,b){d.status(function(c){"connected"==c.status?d.info(a,b):d.login(function(c){c.authResponse&&d.info(a,b)})})},login:function(){var a=this;this.authInfo(function(b){b=_.template($("#login-message").html(),b);a.message.html(b);a.button.hide();a.message.find("i").click(function(){d.logout();
  2
+a.button.show().siblings().empty()})})}})});
34  dcabines.Web/Scripts/other/login.simple.js
... ...
@@ -0,0 +1,34 @@
  1
+define(['backbone', 'facebook'], function (backbone, facebook) {
  2
+    var view = backbone.View.extend({
  3
+        el: '.navbar .login',
  4
+        message: this.$('.message'),
  5
+        button: this.$("button"),
  6
+        events: { "click button": "login" },
  7
+        initialize: function () {
  8
+            this.login();
  9
+        },
  10
+        authInfo: function (callback, id) {
  11
+            facebook.status(function (status) {
  12
+                if (status.status == 'connected') facebook.info(callback, id);
  13
+                else
  14
+                    facebook.login(function (response) {
  15
+                        if (response.authResponse) facebook.info(callback, id);
  16
+                    });
  17
+            });
  18
+        },
  19
+        login: function () {
  20
+            var me = this;
  21
+            this.authInfo(function (user) {
  22
+                var compiledTemplate = _.template($('#login-message').html(), user);
  23
+                me.message.html(compiledTemplate);
  24
+                me.button.hide();
  25
+                me.message.find('i').click(function () {
  26
+                    facebook.logout();
  27
+                    me.button.show().siblings().empty();
  28
+                });
  29
+            });
  30
+        }
  31
+    });
  32
+
  33
+    return view;
  34
+});
5  dcabines.Web/Scripts/other/todos.min.js
... ...
@@ -0,0 +1,5 @@
  1
+define(["backbone"],function(b){var c=b.Model.extend({defaults:function(){return{title:"empty todo...",done:!1}},urlRoot:"Todo",initialize:function(){this.get("title")||this.set({title:this.defaults.title})},toggle:function(a){this.save({done:!this.get("done")},{success:a})},clear:function(){this.destroy()}}),c=b.Collection.extend({model:c,url:"Todo",done:function(){return this.filter(function(a){return a.get("done")})},remaining:function(){return this.without.apply(this,this.done())}}),d=b.View.extend({tagName:"li",
  2
+template:_.template($("#item-template").html()),events:{"click .toggle":"toggleDone",dblclick:"edit","click .remove":"clear","keypress .edit":"updateOnEnter","blur .edit":"close"},initialize:function(){this.model.bind("change",this.render,this);this.model.bind("destroy",this.remove,this)},render:function(){this.$el.html(this.template(this.model.toJSON()));this.$el.toggleClass("done",this.model.get("done"));this.model.get("done")&&this.$el.find(".toggle").removeClass("icon-ok").addClass("icon-remove");
  3
+this.input=this.$(".edit");return this},toggleDone:function(){var a=this;this.model.toggle(function(){a.model.get("done")?a.$el.addClass("done").find(".toggle").removeClass("icon-ok").addClass("icon-remove"):a.$el.removeClass("done").find(".toggle").removeClass("icon-remove").addClass("icon-ok")})},edit:function(){this.$el.addClass("editing");this.input.focus()},close:function(){var a=this.input.val();a||this.clear();this.model.save({title:a});this.$el.removeClass("editing")},updateOnEnter:function(a){13==
  4
+a.keyCode&&this.close()},clear:function(){this.model.clear()}});return b.View.extend({todos:new c,el:"#Todos",events:{"submit form":"preventDefault","keypress #new-todo":"createOnEnter","click button":"create"},preventDefault:function(a){a.preventDefault()},addOne:function(a){a=new d({model:a});this.$(".todo-list").append(a.render().el)},addAll:function(){this.todos.each(this.addOne)},createOnEnter:function(a){13==a.keyCode&&this.create()},create:function(){var a=this.$("#new-todo");a.val()&&(this.todos.create({title:a.val()}),
  5
+a.val(""))},initialize:function(){this.todos.bind("add",this.addOne,this);this.todos.bind("reset",this.addAll,this)},render:function(){this.$el=$("#Todos");this.delegateEvents(this.events);this.todos.fetch({success:function(){this.$(".loading").hide()}})}})});
122  dcabines.Web/Scripts/other/todos.simple.js
... ...
@@ -0,0 +1,122 @@
  1
+define(['backbone'], function (backbone) {
  2
+    var Todo = backbone.Model.extend({
  3
+        defaults: function () {
  4
+            return {
  5
+                title: "empty todo...",
  6
+                done: false
  7
+            };
  8
+        },
  9
+        urlRoot: 'Todo',
  10
+        initialize: function () {
  11
+            if (!this.get("title")) this.set({ "title": this.defaults.title });
  12
+        },
  13
+        toggle: function (callback) {
  14
+            this.save({ done: !this.get("done") }, { success: callback });
  15
+        },
  16
+        clear: function () {
  17
+            this.destroy();
  18
+        }
  19
+    });
  20
+    var TodoList = backbone.Collection.extend({
  21
+        model: Todo,
  22
+        url: 'Todo',
  23
+        done: function () {
  24
+            return this.filter(function (todo) { return todo.get('done'); });
  25
+        },
  26
+        remaining: function () {
  27
+            return this.without.apply(this, this.done());
  28
+        }
  29
+    });
  30
+    var TodoView = backbone.View.extend({
  31
+        tagName: "li",
  32
+        template: _.template($('#item-template').html()),
  33
+        events: {
  34
+            "click .toggle": "toggleDone",
  35
+            "dblclick": "edit",
  36
+            "click .remove": "clear",
  37
+            "keypress .edit": "updateOnEnter",
  38
+            "blur .edit": "close"
  39
+        },
  40
+        initialize: function () {
  41
+            this.model.bind('change', this.render, this);
  42
+            this.model.bind('destroy', this.remove, this);
  43
+        },
  44
+        render: function () {
  45
+            this.$el.html(this.template(this.model.toJSON()));
  46
+            this.$el.toggleClass('done', this.model.get('done'));
  47
+            if (this.model.get('done')) this.$el.find('.toggle').removeClass('icon-ok').addClass('icon-remove');
  48
+            this.input = this.$('.edit');
  49
+            return this;
  50
+        },
  51
+        toggleDone: function () {
  52
+            var me = this;
  53
+            this.model.toggle(function () {
  54
+                if (me.model.get('done')) {
  55
+                    me.$el.addClass('done').find('.toggle').removeClass('icon-ok').addClass('icon-remove');
  56
+                } else {
  57
+                    me.$el.removeClass('done').find('.toggle').removeClass('icon-remove').addClass('icon-ok');
  58
+                }
  59
+            });
  60
+        },
  61
+        edit: function () {
  62
+            this.$el.addClass("editing");
  63
+            this.input.focus();
  64
+        },
  65
+        close: function () {
  66
+            var value = this.input.val();
  67
+            if (!value) this.clear();
  68
+            this.model.save({ title: value });
  69
+            this.$el.removeClass("editing");
  70
+        },
  71
+        updateOnEnter: function (e) {
  72
+            if (e.keyCode == 13) this.close();
  73
+        },
  74
+        clear: function () {
  75
+            this.model.clear();
  76
+        }
  77
+    });
  78
+    var TodoListView = backbone.View.extend({
  79
+        todos: new TodoList,
  80
+        el: '#Todos',
  81
+        events: {
  82
+            "submit form": "preventDefault",
  83
+            "keypress #new-todo": "createOnEnter",
  84
+            "click button": "create"
  85
+        },
  86
+        preventDefault: function (e) {
  87
+            e.preventDefault();
  88
+        },
  89
+        addOne: function (todo) {
  90
+            var tView = new TodoView({ model: todo });
  91
+            this.$('.todo-list').append(tView.render().el);
  92
+        },
  93
+        addAll: function () {
  94
+            this.todos.each(this.addOne);
  95
+        },
  96
+        createOnEnter: function (e) {
  97
+            if (e.keyCode != 13) return;
  98
+            this.create();
  99
+        },
  100
+        create: function () {
  101
+            var input = this.$('#new-todo');
  102
+            if (!input.val()) return;
  103
+            this.todos.create({ title: input.val() });
  104
+            input.val('');
  105
+        },
  106
+        initialize: function () {
  107
+            this.todos.bind('add', this.addOne, this);
  108
+            this.todos.bind('reset', this.addAll, this);
  109
+        },
  110
+        render: function () {
  111
+            this.$el = $('#Todos');
  112
+            this.delegateEvents(this.events);
  113
+            this.todos.fetch({
  114
+                success: function () {
  115
+                    this.$('.loading').hide();
  116
+                }
  117
+            });
  118
+        }
  119
+    });
  120
+
  121
+    return TodoListView;
  122
+});
2  dcabines.Web/Scripts/views/about.min.js
... ...
@@ -1 +1 @@
1  
-define(["facebook","text!templates/about.html"],function(c,d){var a={myinfo:null,populate:function(b){null==a.myinfo?c.info(function(e){a.myinfo=e;b(a.myinfo)},"301800493"):b(a.myinfo)}};return Backbone.View.extend({el:".content",render:function(){var b=this.$el;a.populate(function(a){a=_.template(d,a);b.html(a);$('.nav a[href$="about"]').parent().addClass("active").siblings().removeClass("active")})}})});
  1
+define(["facebook","text!templates/about.html","backbone"],function(c,d,e){var a={myinfo:null,populate:function(b){null==a.myinfo?c.info(function(f){a.myinfo=f;b(a.myinfo)},"301800493"):b(a.myinfo)}};return e.View.extend({el:".content",render:function(){var b=this.$el;a.populate(function(a){a=_.template(d,a);b.html(a);$('.nav a[href$="about"]').parent().addClass("active").siblings().removeClass("active")})}})});
4  dcabines.Web/Scripts/views/about.simple.js
... ...
@@ -1,4 +1,4 @@
1  
-define(['facebook', 'text!templates/about.html'], function(facebook, template) {
  1
+define(['facebook', 'text!templates/about.html', 'backbone'], function(facebook, template, backbone) {
2 2
     var data = {
3 3
         myinfo: null,
4 4
         populate: function(callback) {
@@ -10,7 +10,7 @@
10 10
             else callback(data.myinfo);
11 11
         }
12 12
     };
13  
-    var view = Backbone.View.extend({
  13
+    var view = backbone.View.extend({
14 14
         el: '.content',
15 15
         render: function() {
16 16
             var el = this.$el;
1  dcabines.Web/Scripts/views/home.min.js
... ...
@@ -0,0 +1 @@
  1
+define(["text!templates/home.html","backbone"],function(a,b){return b.View.extend({el:".content",render:function(){this.$el.html(a);$(".nav li").removeClass("active")}})});
11  dcabines.Web/Scripts/views/home.simple.js
... ...
@@ -0,0 +1,11 @@
  1
+define(['text!templates/home.html', 'backbone'], function (template, backbone) {
  2
+    var view = backbone.View.extend({
  3
+        el: '.content',
  4
+        render: function () {
  5
+            this.$el.html(template);
  6
+            $('.nav li').removeClass('active');
  7
+        }
  8
+    });
  9
+
  10
+    return view;
  11
+});
6  dcabines.Web/Scripts/views/todo.min.js
... ...
@@ -1,5 +1 @@
1  
-define(["text!templates/todo.html"],function(c){var b=Backbone.Model.extend({defaults:function(){return{title:"empty todo...",done:!1}},urlRoot:"Todo",initialize:function(){this.get("title")||this.set({title:this.defaults.title})},toggle:function(a){this.save({done:!this.get("done")},{success:a})},clear:function(){this.destroy()}}),b=Backbone.Collection.extend({model:b,url:"Todo",done:function(){return this.filter(function(a){return a.get("done")})},remaining:function(){return this.without.apply(this,
2  
-this.done())}}),d=Backbone.View.extend({tagName:"li",template:_.template($("#item-template").html()),events:{"click .toggle":"toggleDone",dblclick:"edit","click .remove":"clear","keypress .edit":"updateOnEnter","blur .edit":"close"},initialize:function(){this.model.bind("change",this.render,this);this.model.bind("destroy",this.remove,this)},render:function(){this.$el.html(this.template(this.model.toJSON()));this.$el.toggleClass("done",this.model.get("done"));this.model.get("done")&&this.$el.find(".toggle").removeClass("icon-ok").addClass("icon-remove");
3  
-this.input=this.$(".edit");return this},toggleDone:function(){var a=this;this.model.toggle(function(){a.model.get("done")?a.$el.addClass("done").find(".toggle").removeClass("icon-ok").addClass("icon-remove"):a.$el.removeClass("done").find(".toggle").removeClass("icon-remove").addClass("icon-ok")})},edit:function(){this.$el.addClass("editing");this.input.focus()},close:function(){var a=this.input.val();a||this.clear();this.model.save({title:a});this.$el.removeClass("editing")},updateOnEnter:function(a){13==
4  
-a.keyCode&&this.close()},clear:function(){this.model.clear()}}),b=Backbone.View.extend({todos:new b,el:"#Todos",events:{"submit form":"preventDefault","keypress #new-todo":"createOnEnter","click button":"create"},preventDefault:function(a){a.preventDefault()},addOne:function(a){a=new d({model:a});this.$(".todo-list").append(a.render().el)},addAll:function(){this.todos.each(this.addOne)},createOnEnter:function(a){13==a.keyCode&&this.create()},create:function(){var a=this.$("#new-todo");a.val()&&(this.todos.create({title:a.val()}),
5  
-a.val(""))},initialize:function(){this.todos.bind("add",this.addOne,this);this.todos.bind("reset",this.addAll,this)},render:function(){this.$el=$("#Todos");this.delegateEvents(this.events);this.todos.fetch({success:function(){this.$(".loading").hide()}})}});return Backbone.View.extend({el:".content",app:new b,render:function(){this.$el.html(c);this.app.render();$('.nav a[href$="todo"]').parent().addClass("active").siblings().removeClass("active")}})});
  1
+define(["text!templates/todo.html","TodoApp","backbone"],function(a,b,c){return c.View.extend({el:".content",app:new b,render:function(){this.$el.html(a);this.app.render();$('.nav a[href$="todo"]').parent().addClass("active").siblings().removeClass("active")}})});
126  dcabines.Web/Scripts/views/todo.simple.js
... ...
@@ -1,126 +1,8 @@
1  
-define(['text!templates/todo.html'], function (template) {
2  
-    var Todo = Backbone.Model.extend({
3  
-        defaults: function () {
4  
-            return {
5  
-                title: "empty todo...",
6  
-                done: false
7  
-            };
8  
-        },
9  
-        urlRoot: 'Todo',
10  
-        initialize: function () {
11  
-            if (!this.get("title")) this.set({ "title": this.defaults.title });
12  
-        },
13  
-        toggle: function (callback) {
14  
-            this.save({ done: !this.get("done") }, { success: callback });
15  
-        },
16  
-        clear: function () {
17  
-            this.destroy();
18  
-        }
19  
-    });
20  
-    var TodoList = Backbone.Collection.extend({
21  
-        model: Todo,
22  
-        url: 'Todo',
23  
-        done: function () {
24  
-            return this.filter(function (todo) { return todo.get('done'); });
25  
-        },
26  
-        remaining: function () {
27  
-            return this.without.apply(this, this.done());
28  
-        }
29  
-    });
30  
-    var TodoView = Backbone.View.extend({
31  
-        tagName: "li",
32  
-        template: _.template($('#item-template').html()),
33  
-        events: {
34  
-            "click .toggle": "toggleDone",
35  
-            "dblclick": "edit",
36  
-            "click .remove": "clear",
37  
-            "keypress .edit": "updateOnEnter",
38  
-            "blur .edit": "close"
39  
-        },
40  
-        initialize: function () {
41  
-            this.model.bind('change', this.render, this);
42  
-            this.model.bind('destroy', this.remove, this);
43  
-        },
44  
-        render: function () {
45  
-            this.$el.html(this.template(this.model.toJSON()));
46  
-            this.$el.toggleClass('done', this.model.get('done'));
47  
-            if (this.model.get('done')) this.$el.find('.toggle').removeClass('icon-ok').addClass('icon-remove');
48  
-            this.input = this.$('.edit');
49  
-            return this;
50  
-        },
51  
-        toggleDone: function () {
52  
-            var me = this;
53  
-            this.model.toggle(function () {
54  
-                if (me.model.get('done')) {
55  
-                    me.$el.addClass('done').find('.toggle').removeClass('icon-ok').addClass('icon-remove');
56  
-                } else {
57  
-                    me.$el.removeClass('done').find('.toggle').removeClass('icon-remove').addClass('icon-ok');
58  
-                }
59  
-            });
60  
-        },
61  
-        edit: function () {
62  
-            this.$el.addClass("editing");
63  
-            this.input.focus();
64  
-        },
65  
-        close: function () {
66  
-            var value = this.input.val();
67  
-            if (!value) this.clear();
68  
-            this.model.save({ title: value });
69  
-            this.$el.removeClass("editing");
70  
-        },
71  
-        updateOnEnter: function (e) {
72  
-            if (e.keyCode == 13) this.close();
73  
-        },
74  
-        clear: function () {
75  
-            this.model.clear();
76  
-        }
77  
-    });
78  
-    var TodoListView = Backbone.View.extend({
79  
-        todos: new TodoList,
80  
-        el: '#Todos',
81  
-        events: {
82  
-            "submit form": "preventDefault",
83  
-            "keypress #new-todo": "createOnEnter",
84  
-            "click button": "create"
85  
-        },
86  
-        preventDefault: function (e) {
87  
-            e.preventDefault();
88  
-        },
89  
-        addOne: function (todo) {
90  
-            var tView = new TodoView({ model: todo });
91  
-            this.$('.todo-list').append(tView.render().el);
92  
-        },
93  
-        addAll: function () {
94  
-            this.todos.each(this.addOne);
95  
-        },
96  
-        createOnEnter: function (e) {
97  
-            if (e.keyCode != 13) return;
98  
-            this.create();
99  
-        },
100  
-        create: function () {
101  
-            var input = this.$('#new-todo');
102  
-            if (!input.val()) return;
103  
-            this.todos.create({ title: input.val() });
104  
-            input.val('');
105  
-        },
106  
-        initialize: function () {
107  
-            this.todos.bind('add', this.addOne, this);
108  
-            this.todos.bind('reset', this.addAll, this);
109  
-        },
110  
-        render: function () {
111  
-            this.$el = $('#Todos');
112  
-            this.delegateEvents(this.events);
113  
-            this.todos.fetch({
114  
-                success: function () {
115  
-                    this.$('.loading').hide();
116  
-                }
117  
-            });
118  
-        }
119  
-    });
120  
-    var view = Backbone.View.extend({
  1
+define(['text!templates/todo.html', 'TodoApp', 'backbone'], function(template, todoApp, backbone) {
  2
+    var view = backbone.View.extend({
121 3
         el: '.content',
122  
-        app: new TodoListView,
123  
-        render: function () {
  4
+        app: new todoApp,
  5
+        render: function() {
124 6
             this.$el.html(template);
125 7
             this.app.render();
126 8
             $('.nav a[href$="todo"]').parent().addClass('active').siblings().removeClass('active');
59  dcabines.Web/Styles/base.css
... ...
@@ -1,59 +0,0 @@
1  
-body { padding-top: 60px; }
2  
-
3  
-.navbar .login i {
4  
-    cursor: pointer;
5  
-    visibility: hidden;
6  
-}
7  
-
8  
-.navbar .login:hover i { visibility: visible; }
9  
-
10  
-.tcenter { text-align: center; }
11  
-
12  
-.todo-list li { padding: 5px; }
13  
-
14  
-.todo-list li:hover { background-color: #E6E6E6; }
15  
-
16  
-.todo-list li.done {
17  
-    background-color: #dff0d8;
18  
-    color: #468847;
19  
-}
20  
-
21  
-.todo-list li.done:hover { background-color: #D5E6CF; }
22  
-
23  
-.todo-list input { display: none; }
24  
-
25  
-.todo-list i {
26  
-    cursor: pointer;
27  
-    margin: 3px;
28  
-    visibility: hidden;
29  
-}
30  
-
31  
-.todo-list li:hover i { visibility: visible; }
32  
-
33  
-.editing .view { display: none; }
34  
-
35  
-.editing input { display: block; }
36  
-
37  
-.loading {
38  
-    background-image: url(http://davidstorage.blob.core.windows.net/content/images/loading.gif);
39  
-    display: block;
40  
-    width: 16px;
41  
-    height: 11px;
42  
-    margin: 0 auto;
43  
-}
44  
-
45  
-@media (min-width: 980px) {
46  
-    .fork-me {
47  
-        position: fixed;
48  
-        top: 40px;
49  
-        right: 0;
50  
-        border: 0;
51  
-        background-image: url(https://a248.e.akamai.net/camo.github.com/7afbc8b248c68eb468279e8c17986ad46549fb71/687474703a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6461726b626c75655f3132313632312e706e67);
52  
-        width: 149px;
53  
-        height: 149px;
54  
-    }
55  
-}
56  
-
57  
-@media (max-width: 979px) {
58  
-    .fork-me { display: none; }
59  
-}
2  dcabines.Web/Templates/login.html
... ...
@@ -1,2 +0,0 @@
1  
-<h1>Login</h1>
2  
-<div class="fb-login-button">Login</div>
15  dcabines.Web/Views/Home/Index.cshtml
... ...
@@ -1,15 +1,16 @@
1  
-@{
2  
-    ViewBag.Title = "David Cabiness";
3  
-}
  1
+@{ ViewBag.Title = "David Cabiness"; }
  2
+
4 3
 @section head{
5  
-    @Html.Link(Url.Blob("content/bootstrap.min.css"))
6  
-    @Html.Link(Url.Content("~/Styles/base.css"))
7  
-    @Html.Link(Url.Blob("content/bootstrap-responsive.min.css"))
  4
+    @Html.Link(Url.Blob("content/bootstrap-combined.min.css"))
  5
+    @Html.Link(Url.Blob("content/base.min.css"))
8 6
 }
  7
+
9 8
 @section scripts{
10  
-    @Html.Script(Url.Blob("libs/combined.js"), "Scripts/main.min")
  9
+    @Html.Script(Url.Blob("libs/combined.js"), "scripts/main.min")
11 10
 }
  11
+
12 12
 @Html.Partial("Navbar")
  13
+
13 14
 <a class="fork-me" href="http://github.com/dcabines" target="_blank"></a>
14 15
 <div class="container">
15 16
     <div class="content">Loading...</div>
5  dcabines.Web/Views/Home/Templates.cshtml
... ...
@@ -1,5 +1,8 @@
1 1
 <script type="text/template" id="login-message">
2  
-    <p class="navbar-text">Logged in as <a href="http://www.facebook.com/<%=id %>"><%=name %></a> <i class="icon-remove-sign icon-white" title="Logout"></i></p>
  2
+    <p class="navbar-text">
  3
+        Logged in as <a href="http://www.facebook.com/<%=id %>"><%=name %></a>
  4
+        <i class="icon-remove-sign icon-white" title="Logout"></i>
  5
+    </p>
3 6
 </script>
4 7
 
5 8
 <script type="text/template" id="item-template">
20  dcabines.Web/dcabines.Web.csproj
@@ -97,6 +97,18 @@
97 97
       <DependentUpon>main.simple.js</DependentUpon>
98 98
     </Content>
99 99
     <Content Include="Scripts\main.simple.js" />
  100
+    <Content Include="Scripts\other\facebook.min.js">
  101
+      <DependentUpon>facebook.simple.js</DependentUpon>
  102
+    </Content>
  103
+    <Content Include="Scripts\other\facebook.simple.js" />
  104
+    <Content Include="Scripts\other\login.min.js">
  105
+      <DependentUpon>login.simple.js</DependentUpon>
  106
+    </Content>
  107
+    <Content Include="Scripts\other\login.simple.js" />
  108
+    <Content Include="Scripts\other\todos.min.js">
  109
+      <DependentUpon>todos.simple.js</DependentUpon>
  110
+    </Content>
  111
+    <Content Include="Scripts\other\todos.simple.js" />
100 112
     <Content Include="Scripts\views\about.min.js">
101 113
       <DependentUpon>about.simple.js</DependentUpon>
102 114
     </Content>
@@ -105,6 +117,10 @@
105 117
       <DependentUpon>help.simple.js</DependentUpon>
106 118
     </Content>
107 119
     <Content Include="Scripts\views\help.simple.js" />
  120
+    <Content Include="Scripts\views\home.min.js">
  121
+      <DependentUpon>home.simple.js</DependentUpon>
  122
+    </Content>
  123
+    <Content Include="Scripts\views\home.simple.js" />
108 124
     <Content Include="Scripts\views\privacy.min.js">
109 125
       <DependentUpon>privacy.simple.js</DependentUpon>
110 126
     </Content>
@@ -117,11 +133,9 @@
117 133
       <DependentUpon>todo.simple.js</DependentUpon>
118 134
     </Content>
119 135
     <Content Include="Scripts\views\todo.simple.js" />
120  
-    <Content Include="Styles\base.css" />
121 136
     <Content Include="Templates\about.html" />
122 137
     <Content Include="Templates\help.html" />
123 138
     <Content Include="Templates\home.html" />
124  
-    <Content Include="Templates\login.html" />
125 139
     <Content Include="Templates\privacy.html" />
126 140
     <Content Include="Templates\terms.html" />
127 141
     <Content Include="Templates\todo.html" />
@@ -171,7 +185,7 @@
171 185
         <WebProjectProperties>
172 186
           <UseIIS>False</UseIIS>
173 187
           <AutoAssignPort>True</AutoAssignPort>
174  
-          <DevelopmentServerPort>50495</DevelopmentServerPort>
  188
+          <DevelopmentServerPort>55808</DevelopmentServerPort>
175 189
           <DevelopmentServerVPath>/</DevelopmentServerVPath>
176 190
           <IISUrl>
177 191
           </IISUrl>

0 notes on commit 4cec913

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