diff --git a/Gruntfile.js b/Gruntfile.js index 1ceed14..7794058 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,3 +1,5 @@ +"use strict"; + module.exports = function(grunt) { // Project configuration grunt.initConfig({ @@ -34,21 +36,23 @@ module.exports = function(grunt) { options: { globals: { JQuery: true, - $: true + $: true, + require: true, + define: true, + _: true, + Backbone: true, + Tabletop: true, + google: true } }, files: { src: [ - 'src/scripts/*.js', - 'src/scripts/entities/*.js', - 'src/scripts/apps/bills/*.js', - 'src/scripts/apps/bills/show/*.js', - 'src/scripts/apps/members/*.js', - 'src/scripts/apps/members/list/*.js', - 'src/scripts/apps/members/show/*.js', - 'src/scripts/apps/watched_bills/*.js', - 'src/scripts/apps/watched_bills/list/*.js', - 'src/scripts/apps/watched_bills/show/*.js' + 'src/scripts/**/*.js', + '!src/scripts/build.js', + // TODO: Remove built files from `src/` directory + '!src/scripts/require_main.built*', + '!src/scripts/underscore*', + '!src/scripts/lib/**/*' ] } }, diff --git a/src/scripts/app.js b/src/scripts/app.js index 16c3aec..965cb2d 100644 --- a/src/scripts/app.js +++ b/src/scripts/app.js @@ -1,4 +1,6 @@ define(["marionette"], function(Marionette) { + "use strict"; + var GeneralAssemblyApp = new Marionette.Application(); GeneralAssemblyApp.addRegions({ @@ -6,7 +8,7 @@ define(["marionette"], function(Marionette) { }); GeneralAssemblyApp.navigate = function(route, options) { - options || (options = {}); + options = options || {}; Backbone.history.navigate(route, options); }; @@ -23,14 +25,13 @@ define(["marionette"], function(Marionette) { // GeneralAssemblyApp.trigger("welcome:show"); // } - var public_spreadsheet_url = 'https://docs.google.com/spreadsheet/pub?key=0Ap9h1zLSgOWUdEhsQi1Yb0JZV3REUVExV1hqT2h6NHc&output=html'; Tabletop.init({ key: 'https://docs.google.com/spreadsheet/pub?key=0Ap9h1zLSgOWUdEhsQi1Yb0JZV3REUVExV1hqT2h6NHc&output=html', simpleSheet: true, proxie: 'https://s3.amazonaws.com/obscure-atoll-3469', - callback: function(data, tabletop) { - text = {}; - _.each(data, function(row) { text[row.id] = row.text }); + callback: function(data) { + var text = {}; + _.each(data, function(row) { text[row.id] = row.text; }); GeneralAssemblyApp.text = text; } }); diff --git a/src/scripts/apps/about/about_app.js b/src/scripts/apps/about/about_app.js index 9bb241b..663b984 100644 --- a/src/scripts/apps/about/about_app.js +++ b/src/scripts/apps/about/about_app.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("AboutApp", function(AboutApp, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("AboutApp", function(AboutApp, GeneralAssemblyApp, Backbone, Marionette) { AboutApp.Router = Marionette.AppRouter.extend({ appRoutes: { "about": "about" diff --git a/src/scripts/apps/about/about_controller.js b/src/scripts/apps/about/about_controller.js index abb415d..f71327c 100644 --- a/src/scripts/apps/about/about_controller.js +++ b/src/scripts/apps/about/about_controller.js @@ -1,5 +1,7 @@ define(["app","apps/about/about_view"], function(GeneralAssemblyApp, View) { - GeneralAssemblyApp.module("AboutApp", function(AboutApp, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("AboutApp", function(AboutApp, GeneralAssemblyApp) { AboutApp.Controler = { showAbout: function() { var aboutView = new View.AboutView(); diff --git a/src/scripts/apps/about/about_view.js b/src/scripts/apps/about/about_view.js index e89da10..bb743ac 100644 --- a/src/scripts/apps/about/about_view.js +++ b/src/scripts/apps/about/about_view.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("AboutApp.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("AboutApp.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.AboutView = Marionette.ItemView.extend({ template: "#about-template", onShow: function() { diff --git a/src/scripts/apps/bills/bills_app.js b/src/scripts/apps/bills/bills_app.js index c9f6f0d..5adfdde 100644 --- a/src/scripts/apps/bills/bills_app.js +++ b/src/scripts/apps/bills/bills_app.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("BillsApp", function(BillsApp, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("BillsApp", function(BillsApp, GeneralAssemblyApp, Backbone, Marionette) { BillsApp.Router = Marionette.AppRouter.extend({ appRoutes: { "bills(?:query)": "listBills", @@ -9,8 +11,9 @@ define(["app"], function(GeneralAssemblyApp) { }); var API = { - listBills: function(query) { - require(["apps/bills/list/list_controller"], function (ListController) { + listBills: function() { + require(["apps/bills/list/list_controller"], function () { + // TODO: Do something with required module? }); }, showBill: function(id) { diff --git a/src/scripts/apps/bills/list/list_controller.js b/src/scripts/apps/bills/list/list_controller.js index a649dc3..2f1bc1f 100644 --- a/src/scripts/apps/bills/list/list_controller.js +++ b/src/scripts/apps/bills/list/list_controller.js @@ -1,10 +1,14 @@ -define(["app","apps/bills/list/list_view"], function(GeneralAssemblyApp, View) { - GeneralAssemblyApp.module("BillsApp.List", function(List, GeneralAssemblyApp, Backbone, Marionette, $, _) { +// TODO: Remove dependency on "list_view" module if it has no side-effects +define(["app","apps/bills/list/list_view"], function(GeneralAssemblyApp) { + "use strict"; + + // TODO: Determine if this is dead code and remove if so. + GeneralAssemblyApp.module("BillsApp.List", function(List) { List.Controller = { - ListBills: function(criterion) { + ListBills: function() { require(["entities/bills"], function() { }); - }; + } }; }); return GeneralAssemblyApp.BillsApp.List.Controller; diff --git a/src/scripts/apps/bills/list/list_view.js b/src/scripts/apps/bills/list/list_view.js index cd13e0c..42508a9 100644 --- a/src/scripts/apps/bills/list/list_view.js +++ b/src/scripts/apps/bills/list/list_view.js @@ -1,10 +1,13 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("BillsApp.List.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { - View.BillView = Marrionette.ItemView,extend({ + "use strict"; + + GeneralAssemblyApp.module("BillsApp.List.View", function(View, GeneralAssemblyApp, Backbone, Marionette) { + // TODO: Determine if this is dead code and remove if so. + View.BillView = Marionette.ItemView.extend({ template: "bill-item-template" }); - view.BillListView = Marrinonette.CompositView.extend({ + View.BillListView = Marionette.CompositView.extend({ template: "bill-search-list-template", itemView: View.BillView, tagName: "tr", diff --git a/src/scripts/apps/bills/show/show_controller.js b/src/scripts/apps/bills/show/show_controller.js index 85f2e43..58b7536 100644 --- a/src/scripts/apps/bills/show/show_controller.js +++ b/src/scripts/apps/bills/show/show_controller.js @@ -1,5 +1,7 @@ define(["app","apps/bills/show/show_view"], function(GeneralAssemblyApp, View) { - GeneralAssemblyApp.module("BillsApp.Show", function(Show, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("BillsApp.Show", function(Show, GeneralAssemblyApp, Backbone, Marionette, $) { Show.Controller = { showBill: function(param) { // param is appended to the end of hte api request url -- it can be @@ -11,24 +13,24 @@ define(["app","apps/bills/show/show_view"], function(GeneralAssemblyApp, View) { $.when(fetchingBill).done(function(bill) { window.bill = bill; - billView = new View.BillView({ + var billView = new View.BillView({ model: bill }); - author = new GeneralAssemblyApp.Entities.BillAuthors( bill.get("author") ); - authorView = new View.AuthorsView({ collection: author }); + var author = new GeneralAssemblyApp.Entities.BillAuthors( bill.get("author") ); + var authorView = new View.AuthorsView({ collection: author }); - coauthors = new GeneralAssemblyApp.Entities.BillAuthors( bill.get("coauthors") ); - coauthorsView = new View.AuthorsView({ collection: coauthors }); + var coauthors = new GeneralAssemblyApp.Entities.BillAuthors( bill.get("coauthors") ); + var coauthorsView = new View.AuthorsView({ collection: coauthors }); - bill_status_listings = new GeneralAssemblyApp.Entities.BillStatusListings( bill.get("bill_status_listings" ) ); - stausListingsView = new View.StatusListingsView({ collection: bill_status_listings }); + var bill_status_listings = new GeneralAssemblyApp.Entities.BillStatusListings( bill.get("bill_status_listings" ) ); + var stausListingsView = new View.StatusListingsView({ collection: bill_status_listings }); - bill_versions = new GeneralAssemblyApp.Entities.BillVersions( bill.get("versions") ); - versionListingsView = new View.VersionsListingView({ collection: bill_versions }); + var bill_versions = new GeneralAssemblyApp.Entities.BillVersions( bill.get("versions") ); + var versionListingsView = new View.VersionsListingView({ collection: bill_versions }); - bill_votes = new GeneralAssemblyApp.Entities.BillVotes( bill.get("votes") ); - votesListingsView = new View.VotesListingView({ collection: bill_votes }); + var bill_votes = new GeneralAssemblyApp.Entities.BillVotes( bill.get("votes") ); + var votesListingsView = new View.VotesListingView({ collection: bill_votes }); billLayout.on("show", function() { billLayout.billRegion.show(billView); diff --git a/src/scripts/apps/bills/show/show_view.js b/src/scripts/apps/bills/show/show_view.js index 914af21..a55fb9d 100644 --- a/src/scripts/apps/bills/show/show_view.js +++ b/src/scripts/apps/bills/show/show_view.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("BillsApp.Show.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("BillsApp.Show.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.BillLayout = Marionette.Layout.extend({ template: "#bill-detail-layout", className: "container", @@ -34,7 +36,7 @@ define(["app"], function(GeneralAssemblyApp) { }); if (crossover_status === -1) { - var billnum = $(".billnumhed") + var billnum = $(".billnumhed"); $(billnum).addClass("red"); } } @@ -44,7 +46,7 @@ define(["app"], function(GeneralAssemblyApp) { View.AuthorView = Marionette.ItemView.extend({ tagName: "li", className: function() { - return "media " + this.model.get("party") + return "media " + this.model.get("party"); }, template: "#bill-author-template" }); diff --git a/src/scripts/apps/members/list/list_controller.js b/src/scripts/apps/members/list/list_controller.js index f07e39b..d4d4b11 100644 --- a/src/scripts/apps/members/list/list_controller.js +++ b/src/scripts/apps/members/list/list_controller.js @@ -1,5 +1,7 @@ define(["app","apps/members/list/list_view"], function(GeneralAssemblyApp, View) { - GeneralAssemblyApp.module("MembersApp.List", function(List, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("MembersApp.List", function(List, GeneralAssemblyApp, Backbone, Marionette, $) { List.Controller = { listMembers: function(criterion) { require(["entities/member"], function() { @@ -9,7 +11,7 @@ define(["app","apps/members/list/list_view"], function(GeneralAssemblyApp, View) var membersListPanel = new View.MemberPanel(); $.when(fetchingMembers).done(function(members) { - filteredMembers = GeneralAssemblyApp.Entities.FilteredCollection({ + var filteredMembers = GeneralAssemblyApp.Entities.FilteredCollection({ collection: members, filterCriterion: criterion }); diff --git a/src/scripts/apps/members/list/list_view.js b/src/scripts/apps/members/list/list_view.js index f521443..0716242 100644 --- a/src/scripts/apps/members/list/list_view.js +++ b/src/scripts/apps/members/list/list_view.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("MembersApp.List.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("MembersApp.List.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.MemberLayout = Marionette.Layout.extend({ template: "#member-list-layout", regions: { @@ -63,7 +65,8 @@ define(["app"], function(GeneralAssemblyApp) { if ((navPos.top+jumboHeight) < offset){ $('#panel-region').addClass('fixed'); $('#members-region').css({'margin-top':'50px'}); - } if ((navPos.top+jumboHeight) >= offset){ + } + if ((navPos.top+jumboHeight) >= offset){ $('#members-region').css({'margin-top':'0px'}); $('#panel-region').removeClass('fixed'); } diff --git a/src/scripts/apps/members/members_app.js b/src/scripts/apps/members/members_app.js index fbceac9..52529b0 100644 --- a/src/scripts/apps/members/members_app.js +++ b/src/scripts/apps/members/members_app.js @@ -1,4 +1,6 @@ define(["app"], function(GeneralAssemblyApp) { + "use strict"; + GeneralAssemblyApp.module("MembersApp", function(MembersApp, GeneralAssemblyApp, Backbone, Marionette, $, _) { MembersApp.Router = Marionette.AppRouter.extend({ appRoutes: { diff --git a/src/scripts/apps/members/show/show_controller.js b/src/scripts/apps/members/show/show_controller.js index 963a7c0..527004f 100644 --- a/src/scripts/apps/members/show/show_controller.js +++ b/src/scripts/apps/members/show/show_controller.js @@ -1,5 +1,7 @@ define(["app","apps/members/show/show_view"], function(GeneralAssemblyApp, View) { - GeneralAssemblyApp.module("MembersApp.Show", function(Show, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("MembersApp.Show", function(Show, GeneralAssemblyApp, Backbone, Marionette, $) { Show.Controller = { showMember: function(id) { require(["entities/member","entities/top_contributors"], function() { diff --git a/src/scripts/apps/members/show/show_view.js b/src/scripts/apps/members/show/show_view.js index 5077721..860776d 100644 --- a/src/scripts/apps/members/show/show_view.js +++ b/src/scripts/apps/members/show/show_view.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp){ - GeneralAssemblyApp.module("MembersApp.Show.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("MembersApp.Show.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.Layout = Marionette.Layout.extend({ template: "#member-show-layout", regions: { diff --git a/src/scripts/apps/watched_bills/list/list_controller.js b/src/scripts/apps/watched_bills/list/list_controller.js index 90aea5a..4d872c2 100644 --- a/src/scripts/apps/watched_bills/list/list_controller.js +++ b/src/scripts/apps/watched_bills/list/list_controller.js @@ -1,4 +1,6 @@ define(["app","apps/watched_bills/list/list_view"], function(GeneralAssemblyApp, View) { + "use strict"; + GeneralAssemblyApp.module("WatchedBillsApp.List", function(List, GeneralAssemblyApp, Backbone, Marionette, $, _) { List.Controller = { listCategories: function() { @@ -8,20 +10,19 @@ define(["app","apps/watched_bills/list/list_view"], function(GeneralAssemblyApp, var categories_layout = new View.CategoriesLayout(); $.when(fetchingWatchedBills, fetchingBillsCount).done(function(watched_bills, bills_count) { - category_model_data = _.chain(watched_bills.models) - .countBy(function(model) { return model.get("category") }) + var category_model_data = _.chain(watched_bills.models) + .countBy(function(model) { return model.get("category"); }) .pairs() .map(function(model) { return {name: model[0], count: model[1]}; }) .value(); - window.category_model_data = category_model_data - categories = new GeneralAssemblyApp.Entities.BillCategories( category_model_data ); + var categories = new GeneralAssemblyApp.Entities.BillCategories( category_model_data ); - categories_view = new View.CategoriesView({ + var categories_view = new View.CategoriesView({ collection: categories }); - bills_count_view = new GeneralAssemblyApp.Common.View.BillsCountView({ + var bills_count_view = new GeneralAssemblyApp.Common.View.BillsCountView({ model: bills_count, className: "jumbotron" }); @@ -35,9 +36,9 @@ define(["app","apps/watched_bills/list/list_view"], function(GeneralAssemblyApp, }); }); }, - listWatchedBills: function(category) { + listWatchedBills: function() { } - } + }; }); return GeneralAssemblyApp.WatchedBillsApp.List.Controller; }); diff --git a/src/scripts/apps/watched_bills/list/list_view.js b/src/scripts/apps/watched_bills/list/list_view.js index 77d2953..3af0a51 100644 --- a/src/scripts/apps/watched_bills/list/list_view.js +++ b/src/scripts/apps/watched_bills/list/list_view.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("WatchedBillsApp.List.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("WatchedBillsApp.List.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.CategoriesLayout = Marionette.Layout.extend({ template: "#bill-category-layout", regions: { @@ -27,7 +29,7 @@ define(["app"], function(GeneralAssemblyApp) { showBillsCategory: function(e) { e.preventDefault(); e.stopPropagation(); - GeneralAssemblyApp.trigger("watchedbills:categories:show", this.model.get("name")) + GeneralAssemblyApp.trigger("watchedbills:categories:show", this.model.get("name")); } }); diff --git a/src/scripts/apps/watched_bills/show/show_controller.js b/src/scripts/apps/watched_bills/show/show_controller.js index 4337006..f673df8 100644 --- a/src/scripts/apps/watched_bills/show/show_controller.js +++ b/src/scripts/apps/watched_bills/show/show_controller.js @@ -1,5 +1,7 @@ define(["app","apps/watched_bills/show/show_view"], function(GeneralAssemblyApp, View) { - GeneralAssemblyApp.module("WatchedBillsApp.Show", function(Show, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("WatchedBillsApp.Show", function(Show, GeneralAssemblyApp, Backbone, Marionette, $) { Show.Controller = { showBillsForCategory: function(category) { require(["entities/watched_bill"], function() { @@ -7,18 +9,18 @@ define(["app","apps/watched_bills/show/show_view"], function(GeneralAssemblyApp, var categoryLayout = new View.CategoryLayout(); $.when(fetchingWatchedBills).done(function(watched_bills) { - billsForCategory = GeneralAssemblyApp.Entities.FilteredCollection({ + var billsForCategory = GeneralAssemblyApp.Entities.FilteredCollection({ collection: watched_bills }); billsForCategory.filter({category: category}); - categoryView = new View.CategoryCollectionView({ + var categoryView = new View.CategoryCollectionView({ collection: billsForCategory }); - headline = new GeneralAssemblyApp.Entities.CetegoryHeadline({category: category.replace(/\_/g, " ")}); - headlineView = new View.CategoryHeadlineView({ + var headline = new GeneralAssemblyApp.Entities.CetegoryHeadline({category: category.replace(/\_/g, " ")}); + var headlineView = new View.CategoryHeadlineView({ model: headline }); @@ -37,5 +39,5 @@ define(["app","apps/watched_bills/show/show_view"], function(GeneralAssemblyApp, } }; }); -return GeneralAssemblyApp.WatchedBillsApp.Show.Controller; + return GeneralAssemblyApp.WatchedBillsApp.Show.Controller; }); diff --git a/src/scripts/apps/watched_bills/show/show_view.js b/src/scripts/apps/watched_bills/show/show_view.js index da57e8f..57b24a7 100644 --- a/src/scripts/apps/watched_bills/show/show_view.js +++ b/src/scripts/apps/watched_bills/show/show_view.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("WatchedBillsApp.Show.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("WatchedBillsApp.Show.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.CategoryLayout = Marionette.Layout.extend({ template: "#show-category-layout", regions: { diff --git a/src/scripts/apps/watched_bills/watched_bills_app.js b/src/scripts/apps/watched_bills/watched_bills_app.js index a8b9386..2b5818c 100644 --- a/src/scripts/apps/watched_bills/watched_bills_app.js +++ b/src/scripts/apps/watched_bills/watched_bills_app.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("WatchedBillsApp", function(WatchedBillsApp, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("WatchedBillsApp", function(WatchedBillsApp, GeneralAssemblyApp, Backbone, Marionette) { WatchedBillsApp.Router = Marionette.AppRouter.extend({ appRoutes: { "watched_bills": "listBillCategories", diff --git a/src/scripts/apps/welcome/welcome_app.js b/src/scripts/apps/welcome/welcome_app.js index 46d0057..12652ec 100644 --- a/src/scripts/apps/welcome/welcome_app.js +++ b/src/scripts/apps/welcome/welcome_app.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("WelcomeApp", function(WelcomeApp, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("WelcomeApp", function(WelcomeApp, GeneralAssemblyApp, Backbone, Marionette) { WelcomeApp.Router = Marionette.AppRouter.extend({ appRoutes: { "": "welcome" diff --git a/src/scripts/apps/welcome/welcome_controller.js b/src/scripts/apps/welcome/welcome_controller.js index 5c58017..7d209fd 100644 --- a/src/scripts/apps/welcome/welcome_controller.js +++ b/src/scripts/apps/welcome/welcome_controller.js @@ -1,5 +1,7 @@ define(["app","apps/welcome/welcome_view"], function(GeneralAssemblyApp, View) { - GeneralAssemblyApp.module("WelcomeApp", function(WelcomeApp, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("WelcomeApp", function(WelcomeApp, GeneralAssemblyApp, Backbone, Marionette, $) { WelcomeApp.Controler = { showWelcome: function() { require(["entities/bill","entities/days_left","goog!feeds,1"], function() { @@ -8,11 +10,11 @@ define(["app","apps/welcome/welcome_view"], function(GeneralAssemblyApp, View) { var fetchingDaysLeft = GeneralAssemblyApp.request("days:left"); $.when(fetchingBillsCount, fetchingDaysLeft).done(function(billsCount, daysLeft) { - billsCountView = new GeneralAssemblyApp.Common.View.BillsCountView({ + var billsCountView = new GeneralAssemblyApp.Common.View.BillsCountView({ model: billsCount }); - daysLeftView = new View.DaysLeftView({ + var daysLeftView = new View.DaysLeftView({ model: daysLeft }); diff --git a/src/scripts/apps/welcome/welcome_view.js b/src/scripts/apps/welcome/welcome_view.js index e8b2c93..e0a0b4e 100644 --- a/src/scripts/apps/welcome/welcome_view.js +++ b/src/scripts/apps/welcome/welcome_view.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("WelcomeApp.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("WelcomeApp.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.WelcomeLayout = Marionette.Layout.extend({ template: "#welcome-layout", regions: { diff --git a/src/scripts/common/app.js b/src/scripts/common/app.js index cc8e815..754e1bd 100644 --- a/src/scripts/common/app.js +++ b/src/scripts/common/app.js @@ -1,13 +1,15 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("Common", function(Common, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("Common", function(Common) { Common.tweet = function(d, s, id){ - var s = typeof s !== "undefined" ? s : "script"; - var id = typeof id !== "undefined" ? id : "twitter-wjs"; + s = typeof s !== "undefined" ? s : "script"; + id = typeof id !== "undefined" ? id : "twitter-wjs"; var js, fjs=d.getElementsByTagName(s)[1], p=/^http:/.test(d.location)?'http':'https'; - console.log(fjs); + if (!d.getElementById(id)) { js=d.createElement(s); js.id=id; @@ -17,17 +19,19 @@ define(["app"], function(GeneralAssemblyApp) { }; Common.facebook = function(d, s, id) { - var s = typeof s !== "undefined" ? s : 'script'; - var id = typeof id !== "undefined" ? id : 'facebook-jssdk'; + s = typeof s !== "undefined" ? s : 'script'; + id = typeof id !== "undefined" ? id : 'facebook-jssdk'; var js, fjs = d.getElementsByTagName(s)[0]; - console.log(fjs); - if (d.getElementById(id)) return; + + if (d.getElementById(id)) { + return; + } js = d.createElement(s); js.id = id; js.src = "http://connect.facebook.net/en_US/all.js#xfbml=1&appId=1446015978947149"; fjs.parentNode.insertBefore(js, fjs); - } + }; }); - return GeneralAssemblyApp.Common + return GeneralAssemblyApp.Common; }); diff --git a/src/scripts/common/views.js b/src/scripts/common/views.js index b1afd4c..66f69a4 100644 --- a/src/scripts/common/views.js +++ b/src/scripts/common/views.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("Common.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $, _) { + "use strict"; + + GeneralAssemblyApp.module("Common.View", function(View, GeneralAssemblyApp, Backbone, Marionette, $) { View.Loading = Marionette.ItemView.extend({ template: "#loading-template", onShow: function() { @@ -29,5 +31,5 @@ define(["app"], function(GeneralAssemblyApp) { template: "#bills-count-template" }); }); - return GeneralAssemblyApp.Common.View -}); \ No newline at end of file + return GeneralAssemblyApp.Common.View; +}); diff --git a/src/scripts/entities/bill.js b/src/scripts/entities/bill.js index 1cc8ab3..a92991d 100644 --- a/src/scripts/entities/bill.js +++ b/src/scripts/entities/bill.js @@ -1,11 +1,13 @@ define(["app"], function(GeneralAssemblyApp) { + "use strict"; + GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $, _){ // Bills Entities.bills_url = Entities.api_base + 'bills/'; Entities.Bill = Backbone.Model.extend({ initialize: function(id) { - this.url = Entities.bills_url + id + this.url = Entities.bills_url + id; } }); Entities.Bills = Backbone.Collection.extend({ @@ -22,8 +24,13 @@ define(["app"], function(GeneralAssemblyApp) { Entities.BillAuthor = Backbone.Model.extend({ initialize: function() { var full_name = this.get("name_first") + " "; - if ( ! _.isNull(this.get("name_middle")) ) full_name += this.get("name_middle") + " "; - if ( ! _.isNull(this.get("name_nickname")) ) full_name += "'" + this.get("name_nickname") + "' "; + if ( ! _.isNull(this.get("name_middle")) ) { + full_name += this.get("name_middle") + " "; + } + if ( ! _.isNull(this.get("name_nickname")) ) { + full_name += "'" + this.get("name_nickname") + "' "; + } + full_name += this.get("name_last"); this.set("full_name", full_name); } @@ -61,7 +68,7 @@ define(["app"], function(GeneralAssemblyApp) { var API = { getBillsCount: function() { var defer = $.Deferred(); - Entities.bills_count = new Entities.BillsCount() + Entities.bills_count = new Entities.BillsCount(); Entities.bills_count.fetch({ dataType: "jsonp", success: function(data) { @@ -76,11 +83,11 @@ define(["app"], function(GeneralAssemblyApp) { // either the bill id or a string with the doc type (i.e. HB) and // bill number separated by a '/' var defer = $.Deferred(); - bill = new Entities.Bill(param); + var bill = new Entities.Bill(param); bill.fetch({ dataType: "jsonp", success: function(data) { - defer.resolve(data) + defer.resolve(data); } }); return defer.promise(); @@ -88,11 +95,12 @@ define(["app"], function(GeneralAssemblyApp) { getBills: function() { var defer = $.Deferred(); - bills = new Entities.Bills(); + var bills = new Entities.Bills(); bills.fetch({ dataType: "jsonp", success: function() { - defer.resolve(data) + // TODO: Ensure this is not dead code and resolve with data + defer.resolve(); } }); return defer.promise(); diff --git a/src/scripts/entities/common.js b/src/scripts/entities/common.js index c8489f9..f2a14f7 100644 --- a/src/scripts/entities/common.js +++ b/src/scripts/entities/common.js @@ -1,4 +1,6 @@ define(["app"], function(GeneralAssemblyApp) { + "use strict"; + GeneralAssemblyApp.module("Entities", function(Entities, ContactManager, Backbone, Marionette, $, _){ Entities.api_base = "http://ajcgga-api.herokuapp.com/api/"; // Entities.api_base = "http://gga-api-staging.herokuapp.com/api/"; @@ -10,7 +12,7 @@ define(["app"], function(GeneralAssemblyApp) { filtered.filterCriterion = options.filterCriterion || {}; var applyFilter = function(filterCriterion, collection) { - var collection = collection || original; + collection = collection || original; var criterion = filterCriterion; var items = _.isEmpty(criterion) ? collection.models : collection.where(criterion); diff --git a/src/scripts/entities/days_left.js b/src/scripts/entities/days_left.js index 0731533..8320f2c 100644 --- a/src/scripts/entities/days_left.js +++ b/src/scripts/entities/days_left.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $, _){ + "use strict"; + + GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $){ Entities.DaysLeft = Backbone.Model.extend({ urlRoot: Entities.api_base + 'days_left', diff --git a/src/scripts/entities/member.js b/src/scripts/entities/member.js index f8172d9..565f034 100644 --- a/src/scripts/entities/member.js +++ b/src/scripts/entities/member.js @@ -1,10 +1,12 @@ define(["app"], function(GeneralAssemblyApp) { + "use strict"; + GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $, _){ Entities.members_url = Entities.api_base + "members/"; Entities.Member = Backbone.Model.extend({ urlRoot: Entities.members_url, - initialize: function(id) { + initialize: function() { // Create tooltip info string var tooltipInfo = this.get("full_name") + ", " + this.get("district_address_city"); if ( this.get("title") !== null ) { @@ -41,12 +43,12 @@ define(["app"], function(GeneralAssemblyApp) { Entities.MemberVote = Backbone.Model.extend({ initialize: function() { - this.set("vote_date", new Date(this.get("vote_date"))) + this.set("vote_date", new Date(this.get("vote_date"))); } }); Entities.MemberVotes = Backbone.Collection.extend({ initialize: function(id) { - this.url = Entities.members_url+ id + '/votes' + this.url = Entities.members_url+ id + '/votes'; }, model: Entities.MemberVote }); @@ -54,7 +56,7 @@ define(["app"], function(GeneralAssemblyApp) { var API = { getMembers: function() { var defer = $.Deferred(); - if (! Entities.members || Entities.members.length == 0) { + if (! Entities.members || Entities.members.length === 0) { Entities.members = new Entities.MembersCollection(); Entities.members.fetch({ dataType: "jsonp", @@ -71,7 +73,7 @@ define(["app"], function(GeneralAssemblyApp) { getMember: function(memberId) { // var member = Entities.members.where({id: memberId})[0]; var defer = $.Deferred(); - member = new Entities.Member({id: memberId}); + var member = new Entities.Member({id: memberId}); member.fetch({ dataType: "jsonp", success: function(data) { diff --git a/src/scripts/entities/news_items.js b/src/scripts/entities/news_items.js index 1d728b0..7fd92de 100644 --- a/src/scripts/entities/news_items.js +++ b/src/scripts/entities/news_items.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $, _){ + "use strict"; + + GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone){ Entities.NewsItem = Backbone.Model.extend(); Entities.NewsItemsCollection = Backbone.Collection.extend({ model: Entities.NewsItems diff --git a/src/scripts/entities/top_contributors.js b/src/scripts/entities/top_contributors.js index de9288c..cf82b6f 100644 --- a/src/scripts/entities/top_contributors.js +++ b/src/scripts/entities/top_contributors.js @@ -1,5 +1,7 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $, _){ + "use strict"; + + GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $){ Entities.TopContributor = Backbone.Model.extend({}); Entities.TopContributorsCollection = Backbone.Collection.extend({ diff --git a/src/scripts/entities/watched_bill.js b/src/scripts/entities/watched_bill.js index 31413d3..2497eb1 100644 --- a/src/scripts/entities/watched_bill.js +++ b/src/scripts/entities/watched_bill.js @@ -1,11 +1,15 @@ define(["app"], function(GeneralAssemblyApp) { - GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $, _){ + "use strict"; + + GeneralAssemblyApp.module("Entities", function(Entities, GeneralAssemblyApp, Backbone, Marionette, $){ Entities.watched_bills_url = Entities.api_base + 'watched_bills/'; Entities.WatchedBill = Backbone.Model.extend({ base_url: Entities.watched_bills_url, initialize: function() { - if ( this.get("category") ) this.set("category", this.get("category").replace(/ /g,'_')); + if ( this.get("category") ) { + this.set("category", this.get("category").replace(/ /g,'_')); + } this.set("status_date", new Date(this.get("status_date"))); } }); @@ -25,7 +29,7 @@ define(["app"], function(GeneralAssemblyApp) { var API = { getWatchedBills: function() { var defer = $.Deferred(); - if (! Entities.watched_bills || Entities.watched_bills.length == 0) { + if (! Entities.watched_bills || Entities.watched_bills.length === 0) { Entities.watched_bills = new Entities.WatchedBills(); Entities.watched_bills.fetch({ dataType: "jsonp", diff --git a/src/scripts/require_main.js b/src/scripts/require_main.js index e3e8ec1..5cf0fbd 100644 --- a/src/scripts/require_main.js +++ b/src/scripts/require_main.js @@ -1,4 +1,4 @@ -requirejs.config({ +require.config({ // enforceDefine: true, baseUrl: "scripts", paths: { @@ -53,6 +53,9 @@ requirejs.config({ require(["app","jquery-ui","jquery-scrolltofixed","jquery-datatables","datejs","underscore.string", "spin","spin.jquery","tabletop","goog"], function(GeneralAssemblyApp) { + "use strict"; + GeneralAssemblyApp.start(); -}); + } +);