Skip to content
Browse files

Clean up lint and whitespace issues

  • Loading branch information...
1 parent 31a7e9d commit bdcfac6afae1f9c5477cf83b2a59672192a5ee48 @kborchers kborchers committed Aug 13, 2012
View
4 client/src/main/webapp/app/main.js
@@ -58,7 +58,7 @@ function( namespace, $, $m, Backbone, Main, Catalog, Cart, Orders, messageTempla
},
catalog: function() {
- namespace.transitioner( new Catalog.Views.Categories, $( "#main" ) );
+ namespace.transitioner( new Catalog.Views.Categories(), $( "#main" ) );
},
items: function( catID ) {
@@ -70,7 +70,7 @@ function( namespace, $, $m, Backbone, Main, Catalog, Cart, Orders, messageTempla
},
cart: function() {
- namespace.transitioner( new Cart.Views.CartPage, $( "#main" ) );
+ namespace.transitioner( new Cart.Views.CartPage(), $( "#main" ) );
},
orders: function( hash ) {
View
32 client/src/main/webapp/app/modules/cart.js
@@ -30,12 +30,12 @@ function( namespace, $, $m, Backbone, cartTemplate, messageTemplate ) {
// Shopping cart page view
Cart.Views.CartPage = Backbone.View.extend({
- cart: new Cart.CartModel,
+ cart: new Cart.CartModel(),
done: null,
events: {
"click a.remove-button": "removeItem",
- "click a.checkout-button": "checkout",
+ "click a.checkout-button": "checkout"
},
render: function( done ) {
@@ -71,8 +71,8 @@ function( namespace, $, $m, Backbone, cartTemplate, messageTemplate ) {
case "STORE_CLOSED":
namespace.showMessageDialog( "#main", "#buyer/catalog", messageTemplate, response.message, 2000, namespace.app.router );
break;
- case "INVALID_USER":
default:
+ // INVALID_USER errors are also captured here
namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
break;
}
@@ -103,14 +103,11 @@ function( namespace, $, $m, Backbone, cartTemplate, messageTemplate ) {
},
error: function( jqXHR, textStatus, errorThrown ) {
var response = $.parseJSON( jqXHR.responseText );
- switch ( response.type ) {
- case "STORE_CLOSED":
- namespace.showMessageDialog( "#main", "#buyer/catalog", messageTemplate, response.message, 2000, namespace.app.router );
- break;
- case "INVALID_USER":
- default:
- namespace.showMessageDialog( "#main", "#logout", messageTemplate, $.parseJSON( jqXHR.responseText ).message, 2000, namespace.app.router );
- break;
+ if ( response.type == "STORE_CLOSED" ) {
+ namespace.showMessageDialog( "#main", "#buyer/catalog", messageTemplate, response.message, 2000, namespace.app.router );
+ } else {
+ // INVALID_USER are also captured here
+ namespace.showMessageDialog( "#main", "#logout", messageTemplate, $.parseJSON( jqXHR.responseText ).message, 2000, namespace.app.router );
}
}
}).done( function() {
@@ -135,14 +132,11 @@ function( namespace, $, $m, Backbone, cartTemplate, messageTemplate ) {
},
error: function( model, response ) {
response = $.parseJSON( response.responseText );
- switch ( response.type ) {
- case "STORE_CLOSED":
- namespace.showMessageDialog( "#main", "#buyer/catalog", messageTemplate, response.message, 2000, namespace.app.router );
- break;
- case "INVALID_USER":
- default:
- namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
- break;
+ if ( response.type == "STORE_CLOSED" ) {
+ namespace.showMessageDialog( "#main", "#buyer/catalog", messageTemplate, response.message, 2000, namespace.app.router );
+ } else {
+ // INVALID_USER errors are captured here
+ namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
}
}
});
View
8 client/src/main/webapp/app/modules/catalog.js
@@ -136,8 +136,8 @@ function( namespace, $, $m, Backbone, catalogTemplate, itemsTemplate, itemTempla
case "STORE_CLOSED":
namespace.showMessageDialog( "#main", "#buyer/catalog", messageTemplate, response.message, 2000, namespace.app.router );
break;
- case "INVALID_USER":
default:
+ // INVALID_USER errors are also captured here
namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
break;
}
@@ -147,7 +147,7 @@ function( namespace, $, $m, Backbone, catalogTemplate, itemsTemplate, itemTempla
$m.hidePageLoadingMsg();
}
});
- }
+ };
// Shared view renderer for all catalog views
Catalog.renderList = function( template, items, view, done ) {
@@ -157,7 +157,7 @@ function( namespace, $, $m, Backbone, catalogTemplate, itemsTemplate, itemTempla
if ( _.isFunction( done ) ) {
done( view.el );
}
- }
+ };
// Cache the catalog to prevent unnecessary REST calls and reload if it's more than one hour old
Catalog.buildCache = function() {
@@ -183,7 +183,7 @@ function( namespace, $, $m, Backbone, catalogTemplate, itemsTemplate, itemTempla
}
}
});
- }
+ };
// Required, return the module for AMD compliance
return Catalog;
View
12 client/src/main/webapp/app/modules/main.js
@@ -26,23 +26,23 @@ function( namespace, $, $m, Backbone, mainTemplate, roleTemplate, messageTemplat
urlRoot: namespace.serviceURL + "/user",
sync: function( method, model, options ) {
- var options = options || {};
+ options = options || {};
options.Accept = "application/json";
return Backbone.sync( method, model, options );
},
validate: function( attributes ) {
if ( !this.isNew() ) {
return '{"message": "You may not change roles", "type": "INVALID_REGISTRATION"}';
- } else if ( attributes.name == "" ) {
+ } else if ( attributes.name === "" ) {
return '{"message": "Please enter your name", "type": "INVALID_REGISTRATION"}';
}
}
});
// Default view with registration form
Main.Views.Registration = Backbone.View.extend({
- model: new Main.User,
+ model: new Main.User(),
events: {
"submit #profileForm": "register"
@@ -105,7 +105,7 @@ function( namespace, $, $m, Backbone, mainTemplate, roleTemplate, messageTemplat
// Registered user view with order summary
Main.Views.Role = Backbone.View.extend({
- model: new Main.User,
+ model: new Main.User(),
events: {
"click #approveButton": "approveOrder",
@@ -187,8 +187,8 @@ function( namespace, $, $m, Backbone, mainTemplate, roleTemplate, messageTemplat
case "ORDER_ASSIGNED_TO_OTHER":
namespace.showMessageDialog( "#main", "#" + user.role.toLowerCase() + "/orders", messageTemplate, response.message, 2000, namespace.app.router );
break;
- case "INVALID_USER":
default:
+ // INVALID_USER errors are also captured here
namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
break;
}
@@ -225,8 +225,8 @@ function( namespace, $, $m, Backbone, mainTemplate, roleTemplate, messageTemplat
case "ORDER_ASSIGNED_TO_OTHER":
namespace.showMessageDialog( "#main", "#" + user.role.toLowerCase() + "/orders", messageTemplate, response.message, 2000, namespace.app.router );
break;
- case "INVALID_USER":
default:
+ // INVALID_USER errors are also captured here
namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
break;
}
View
20 client/src/main/webapp/app/modules/orders.js
@@ -33,7 +33,7 @@ function( namespace, $, $m, Backbone, orderListTemplate, messageTemplate ) {
// View to display the list of orders in the collection
Orders.Views.OpenOrderView = Backbone.View.extend({
- orders: new Orders.OpenOrders,
+ orders: new Orders.OpenOrders(),
curLength: null,
events: {
@@ -117,17 +117,12 @@ function( namespace, $, $m, Backbone, orderListTemplate, messageTemplate ) {
},
error: function( jqXHR, textStatus, errorThrown ) {
var response = $.parseJSON( jqXHR.responseText );
- switch ( response.type ) {
- case "USER_ALREADY_ASSIGNEE":
- namespace.showMessageDialog( "#main", "#" + user.role.toLowerCase() + "/role", messageTemplate, response.message, 2000, namespace.app.router );
- break;
- case "INVALID_USER":
- case "INVALID_ROLE":
- default:
- namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
- break;
+ if ( response.type == "USER_ALREADY_ASSIGNEE" ) {
+ namespace.showMessageDialog( "#main", "#" + user.role.toLowerCase() + "/role", messageTemplate, response.message, 2000, namespace.app.router );
+ } else {
+ // INVALID_USER and INVALID_ROLE errors are captured here
+ namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );
}
-
},
done: function() {
$m.hidePageLoadingMsg();
@@ -164,9 +159,8 @@ function( namespace, $, $m, Backbone, orderListTemplate, messageTemplate ) {
clearTimeout( orderTimer );
namespace.showMessageDialog( "#main", "#" + user.role.toLowerCase() + "/role", messageTemplate, response.message, 2000, namespace.app.router );
break;
- case "INVALID_USER":
- case "INVALID_ROLE":
default:
+ // INVALID_USER and INVALID_ROLE errors are also captured here
// Stop the order list loop
clearTimeout( orderTimer );
namespace.showMessageDialog( "#main", "#logout", messageTemplate, response.message, 2000, namespace.app.router );

0 comments on commit bdcfac6

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