Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 760bcb7

Browse files
committed
Merge branch 'dev' into tom-add-design-thumbnails
2 parents d41c608 + 8fb7747 commit 760bcb7

File tree

146 files changed

+7173
-684
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

146 files changed

+7173
-684
lines changed

.project

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>topcoder-app</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
</buildSpec>
9+
<natures>
10+
</natures>
11+
</projectDescription>

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Topcoder-App
22
This repository houses any new topcoder pages or refactored Angular apps/pages from the tc-site repository.
33

4-
The technologies used are Jade, SCSS, ES6, Angular, and Gulp.
4+
The technologies used are Jade, SCSS, Angular, and Gulp.
55

66
## Installation
77

@@ -13,6 +13,8 @@ Install dependencies by running the following in the root of the project:
1313
- npm install
1414
- bower install
1515

16+
In order to test a logged in user, you must make an entry in your /etc/hosts file, pointing local.topcoder-dev.com to localhost. For example, open your /etc/hosts file with something like `vim /etc/hosts` and add `127.0.0.1 local.topcoder-dev.com`. After you run `gulp serve`, which launches a new window or tab, change `http://localhost:3000/sample/` to `http://local.topcoder-dev.com:3000/sample/`. You will then be able to login and pick up information from the cookies with `.topcoder-dev.com` as the domain.
17+
1618
## Gulpfile Commands
1719
- Run `gulp` to get the full list of commands
1820
- To run locally without minification: `gulp serve`
@@ -89,7 +91,7 @@ SCSS Files
8991
- Store new variables and mixins in the appropriate file in `assets/css/partials`
9092
- Since a class with the current state name is added to the ui-view (see the Creating New Views/Pages section), wrap your .scss file with this class, in order to write specific SCSS in its own file for that page.
9193

92-
JS/ES6
94+
JavaScript
9395
- See this section on [naming conventions and style guide](https://github.com/appirio-tech/topcoder-app/blob/dev/README.md#style-guide-and-naming-conventions)
9496

9597
Creating New Views/Pages

app/account/account.routes.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@
103103
url: '/logout/',
104104
controller: ['TcAuthService', function(TcAuthService) {
105105
TcAuthService.logout();
106-
}]
106+
}],
107+
data: {
108+
authRequired: false
109+
}
107110
}
108111
};
109112

app/account/login/login.controller.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
if ($stateParams.userJWTToken) {
1515
// user logged in
1616
AuthTokenService.setV3Token($stateParams.userJWTToken);
17-
UserService.setUserIdentity($stateParams.userJWTToken);
1817
Helpers.redirectPostLogin($stateParams.next);
1918
}
2019

@@ -34,7 +33,7 @@
3433
AuthTokenService.getTokenFromAuth0Code($stateParams.code).then(
3534
function(v3Token) {
3635
$log.debug('logged in using social');
37-
Helpers.redirectPostLogin($stateParams.next);
36+
return Helpers.redirectPostLogin($stateParams.next);
3837
}
3938
);
4039
}
@@ -44,11 +43,11 @@
4443
}
4544

4645
function _doLogin(usernameOrEmail, password) {
47-
TcAuthService.login(usernameOrEmail, password).then(
46+
return TcAuthService.login(usernameOrEmail, password).then(
4847
function(data) {
4948
// success
5049
$log.debug('logged in');
51-
Helpers.redirectPostLogin($stateParams.next);
50+
return Helpers.redirectPostLogin($stateParams.next);
5251
},
5352
function(err) {
5453
// handle error
@@ -102,6 +101,7 @@
102101
TcAuthService.socialLogin(backend, callbackUrl);
103102
};
104103

104+
vm.$stateParams = $stateParams;
105105
}
106106

107107
})();

app/account/login/login.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
a.forgot-password(ui-sref="resetPassword") Forgot Password?
3333

3434
p.redirect Don't have an account?
35-
a(ui-sref="register") Join Now.
35+
a(ui-sref="register(vm.$stateParams)") Join Now.
3636

app/account/register/register.controller.js

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,14 @@
5656
.then(function(obj) {
5757
vm.countryObj = obj;
5858
});
59+
5960
vm.countries = ISO3166.getAllCountryObjects();
60-
vm.countryUpdated = function ($item) {
61-
// update country
62-
vm.country = _.get($item, "originalObject.name", undefined);
61+
62+
vm.updateCountry = function (angucompleteCountryObj) {
63+
var countryCode = _.get(angucompleteCountryObj, 'originalObject.alpha3', undefined);
64+
65+
var isValidCountry = _.isUndefined(countryCode) ? false : true;
66+
vm.registerForm.country.$setValidity('required', isValidCountry);
6367
};
6468

6569
vm.register = function() {
@@ -83,12 +87,19 @@
8387
userId: vm.socialUserId,
8488
name: vm.firstname + " " + vm.lastname,
8589
email: vm.socialProfile.email,
86-
emailVerified: vm.socialProfile.emailVerified,
90+
emailVerified: vm.socialProfile.email_verified,
8791
providerType: vm.socialProvider
8892
}
8993
}
9094

91-
TcAuthService.register({param: userInfo})
95+
var body = {
96+
param: userInfo,
97+
options: {
98+
afterActivationURL: CONSTANTS.MAIN_URL + '/my-dashboard/'
99+
}
100+
}
101+
102+
TcAuthService.register(body)
92103
.then(function(data) {
93104
$log.debug('registered successfully');
94105

@@ -104,8 +115,12 @@
104115
auth0Register.login({
105116
scope: "openid profile offline_access",
106117
state: callbackUrl,
107-
response_type: 'token'
118+
connection: backend,
119+
response_type: 'token',
120+
callbackURL: callbackUrl
108121
});
109122
}
123+
124+
vm.$stateParams = $stateParams;
110125
}
111126
})();

app/account/register/register.jade

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
.register-container
22
h1 Join Topcoder
33

4-
form(name="vm.registerForm", role="form", ng-submit="vm.registerForm.$valid && vm.register()", novalidate)
4+
form(name="vm.registerForm", role="form", ng-submit="vm.registerForm.$valid && vm.register()", novalidate, autocomplete="off")
5+
6+
// Stops Chrome from autofilling and autocompleting (along with autocomplete="off" on the form)
7+
input(autocomplete="false", name="hidden", type="text", style="display:none;")
58

69
p.form-error(ng-show="vm.errMsg") {{vm.errMsg}}
7-
br
810

911
.first-last-names
1012
input(right-placeholder, focused-placeholder="First", ng-model="vm.firstname", maxlength="64", name="firstname", placeholder="First Name", type="text", required)
@@ -15,23 +17,23 @@
1517
//- .form-errors
1618
//- p.form-error(ng-show="vm.registerForm.firstname.$dirty && vm.registerForm.firstname.$error.pattern") Names must not contain symbols or numbers.
1719
18-
//- input(ng-model="vm.country", name="country", placeholder="Country", type="text", required)
1920
.country-dropdown
2021
angucomplete-alt(
21-
id="countryId",
22+
input-name="country",
2223
placeholder="Country",
2324
pause="100",
24-
selected-object="vm.countryUpdated",
25+
selected-object="vm.updateCountry",
2526
local-data="vm.countries",
27+
initial-value="vm.countryObj",
2628
search-fields="name",
2729
title-field="name",
28-
match-class="highlight",
29-
initial-value="vm.countryObj",
30-
minlength="1",
31-
auto-match=true,
32-
field-required=true,
30+
match-class="angucomplete-highlight",
31+
minlength="1"
3332
)
3433

34+
.form-errors
35+
p.form-error(ng-show="vm.registerForm.country.$error.required") Please enter a valid country.
36+
3537
.validation-bar(ng-class="{ 'error-bar': (vm.registerForm.username.$error.usernameIsFree || vm.registerForm.username.$error.minlength || vm.registerForm.username.$error.maxlength), 'success-bar': (vm.registerForm.username.$valid && !vm.registerForm.username.$error.usernameIsFree) }")
3638
input(right-placeholder, focused-placeholder="Username", ng-model="vm.username", ng-model-options="{ debounce: {'default': 500} }", ng-focus="vm.usernameTips = true", ng-blur="vm.usernameTips = false", ng-minlength="2", ng-maxlength="15", name="username", placeholder="Username", type="text", username-is-free, required)
3739

@@ -52,7 +54,7 @@
5254
p.form-error(ng-show="vm.registerForm.username.$error.minlength || vm.registerForm.username.$error.maxlength") Username must be between 2 and 15 characters.
5355

5456
.validation-bar(ng-class="{ 'error-bar': (vm.registerForm.email.$dirty && vm.registerForm.email.$invalid), 'success-bar': (vm.registerForm.email.$valid) }")
55-
input(right-placeholder, focused-placeholder="Email", ng-model="vm.email", ng-focus="vm.emailTips = true", ng-blur="vm.emailTips = false", name="email", placeholder="Enter Your Email", type="email", email-is-available, required)
57+
input(right-placeholder, focused-placeholder="Email", ng-model="vm.email", ng-focus="vm.emailTips = true", ng-blur="vm.emailTips = false", name="email", placeholder="Enter Your Email", type="email", valid-email, email-is-available, required)
5658

5759
.tips.email-tips(ng-show="vm.emailTips")
5860
h3 Email Tips:
@@ -65,7 +67,7 @@
6567
p.form-error(ng-show="vm.registerForm.email.$dirty && vm.registerForm.email.$invalid") Please enter a valid email address.
6668

6769
.validation-bar(ng-class="{ 'success-bar': (vm.registerForm.password.$valid) }")
68-
toggle-password
70+
toggle-password(ng-if="!vm.isSocialRegistration")
6971

7072
.tips.password-tips(ng-show="vm.passwordFocus")
7173
h3 Password Tips:
@@ -94,4 +96,4 @@
9496
i.fa.fa-google-plus-square(ng-click="vm.socialRegister('google-oauth2')")
9597

9698
p.redirect Already have an account?
97-
a(ui-sref="login") Login.
99+
a(ui-sref="login(vm.$stateParams)") Login.

app/account/reset-password/reset-password.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
form.reset-form(name='vm.generateTokenForm', role="form", ng-submit="vm.generateTokenForm.$valid && vm.sendLink()", novalidate)
66

77
.validation-bar(ng-class="{ 'error-bar': (vm.generateTokenForm.email.$dirty && vm.generateTokenForm.email.$invalid), 'success-bar': (vm.generateTokenForm.email.$valid) }")
8-
input(right-placeholder, focused-placeholder="Email", ng-model="vm.email", ng-focus="vm.emailTips = true", ng-blur="vm.emailTips = false", name="email", placeholder="Enter Your Email", type="email", required email)
8+
input(right-placeholder, focused-placeholder="Email", ng-model="vm.email", ng-focus="vm.emailTips = true", ng-blur="vm.emailTips = false", name="email", placeholder="Enter Your Email", type="email", valid-email, required)
99

1010
.tips.email-tips(ng-show="vm.emailTips")
1111
h3 Email Tips:

app/directives/account/toggle-password/toggle-password.directive.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
templateUrl: 'directives/account/toggle-password/toggle-password.html',
1111
link: function(scope, element, attrs, formController) {
1212
var vm = scope.vm;
13+
vm.passwordField = formController.password;
1314
vm.placeholder = vm.defaultPlaceholder;
1415
vm.password = '';
1516

@@ -19,6 +20,12 @@
1920
passwordInput.focus();
2021
});
2122

23+
element.bind('keyup', function(event) {
24+
if (event.keyCode === 13) {
25+
passwordInput.blur();
26+
}
27+
});
28+
2229
vm.onFocus = function(event) {
2330
vm.passwordFocus = true;
2431
vm.placeholder = '';

app/directives/account/toggle-password/toggle-password.jade

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ input#password-input(
1919
has-number,
2020
required)
2121

22-
label(ng-show="vm.passwordFocus || vm.registerForm.password.$dirty") #[input(type="checkbox", ng-model="refocus", ng-change="vm.toggleInputType()")] Show
22+
label(ng-show="vm.passwordFocus || vm.passwordField.$dirty") #[input(type="checkbox", ng-model="refocus", ng-change="vm.toggleInputType()")] Show
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
(function() {
2+
'use strict';
3+
4+
angular.module('tcUIComponents')
5+
.directive('validEmail', validEmail);
6+
7+
function validEmail() {
8+
return {
9+
require: 'ngModel',
10+
link: function(scope, element, attrs, ctrl) {
11+
ctrl.$validators.validEmail = function(modelValue, viewValue) {
12+
if (/.+@.+\..+/.test(viewValue)) {
13+
return true;
14+
}
15+
return false;
16+
};
17+
}
18+
};
19+
}
20+
})();
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
2+
(function() {
3+
'use strict';
4+
5+
angular.module('tcUIComponents').directive('badgeTooltip', badgeTooltip);
6+
7+
/**
8+
* Add a badge tooltip.
9+
*/
10+
function badgeTooltip() {
11+
return {
12+
restrict: 'A',
13+
templateUrl: 'directives/badges/badge-tooltip.html',
14+
scope: {
15+
badge: '='
16+
},
17+
link : function(scope, element, attr) {
18+
scope.hide = true;
19+
return new TcBadgeTooltipDirective(scope, element, attr);
20+
}
21+
}
22+
}
23+
24+
/**
25+
* The link function of directive tc-badge-tooltip
26+
*/
27+
var TcBadgeTooltipDirective = function (scope, element, attr) {
28+
29+
var tooltipElement = element.children(0);
30+
if (!tooltipElement.hasClass('tooltip')) {
31+
return;
32+
}
33+
var tooltipHtml = tooltipElement[0];
34+
35+
var tooltipFn = this;
36+
37+
element.on('mouseenter', function() {
38+
tooltipElement.css('z-index', '-2000');
39+
scope.hide = false;
40+
// apply scope to display the tooltip element at z-index -2000
41+
// otherwise we won't get the height of the element
42+
scope.$apply();
43+
44+
var ht = tooltipHtml.offsetHeight;
45+
var wt = tooltipHtml.offsetWidth - element[0].offsetWidth;
46+
var top = element[0].offsetTop - ht - 10;
47+
var lt = element[0].offsetLeft - wt / 2;
48+
49+
tooltipElement.css("left", lt + 'px');
50+
tooltipElement.css("top", top + 'px');
51+
tooltipElement.css('z-index', '2000');
52+
});
53+
54+
element.on('mouseleave', function(){
55+
scope.hide = true;
56+
scope.$apply();
57+
});
58+
}
59+
})();
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.tooltip(ng-hide="hide")
2+
.inner
3+
header(ng-bind="badge.name")
4+
.data
5+
p.earnedOn(ng-bind="'Earned on ' + badge.date", ng-show="badge.date")
6+
p.earnedOn(ng-hide="badge.date") Not Earned Yet
7+
.data(ng-show="badge.currentlyEarned > 0")
8+
p.currentlyEarned
9+
span(ng-bind="badge.currentlyEarned")
10+
.arrow

0 commit comments

Comments
 (0)