Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updates #152

Merged
merged 19 commits into from
Nov 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,24 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
indent_size = 4

[*.js]
indent_style = space
indent_size = 2
indent_size = 4

[*.hbs]
insert_final_newline = false
indent_style = space
indent_size = 2
indent_size = 4

[*.css]
indent_style = space
indent_size = 2
indent_size = 4

[*.html]
indent_style = space
indent_size = 2
indent_size = 4

[*.md]
[*.{diff,md}]
trim_trailing_whitespace = false
16 changes: 7 additions & 9 deletions .jshintrc
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
{
"predef": {
"document": true,
"window": true,
"-Promise": true,
"moment": true,
"google": true
},
"browser" : true,
"boss" : true,
"predef": [
"document",
"window",
"-Promise"
],
"browser": true,
"boss": true,
"curly": true,
"debug": false,
"devel": true,
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ which enables tweaking the UI of the site without actually having the server
running locally. To get up and running with just the UI, run:

```
npm run startui
npm run start:ui
```

This will give you a local server to browse while using the staging backend
Expand Down
4 changes: 2 additions & 2 deletions app/adapters/dependency.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import ApplicationAdapter from './application';

export default ApplicationAdapter.extend({
findQuery: function(store, type, query) {
findQuery(store, type, query) {
if (!query.reverse) {
return this._super(store, type, query);
return this._super(...arguments);
}
delete query.reverse;
var crate = query.crate;
Expand Down
4 changes: 3 additions & 1 deletion app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ var App = Ember.Application.extend({
});

loadInitializers(App, config.modulePrefix);
Ember.$.ajaxSetup({cache: false});
Ember.$.ajaxSetup({
cache: false
});

export default App;
14 changes: 7 additions & 7 deletions app/components/user-avatar.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
import Ember from 'ember';

const { computed } = Ember;

export default Ember.Component.extend({
size: 'small',
user: null,
attributeBindings: ['src', 'width', 'height'],
tagName: 'img',

width: function() {
width: computed('size', function() {
if (this.get('size') === 'small') {
return 22;
} else if (this.get('size') === 'medium-small') {
return 32;
} else {
return 85; // medium
}
}.property('size'),
}),

height: function() {
return this.get('width');
}.property('width'),
height: computed.readOnly('width'),

src: function() {
src: computed('size', 'user', function() {
return this.get('user.avatar') + '&s=' + this.get('width');
}.property('size', 'user'),
})
});
13 changes: 6 additions & 7 deletions app/components/user-link.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import Ember from 'ember';

const { computed } = Ember;

export default Ember.Component.extend({
user: null,
attributeBindings: ['title', 'href'],
tagName: 'a',

title: function() {
return this.get('user.login');
}.property('user'),

'href': function() {
title: computed.readOnly('user.login'),
href: computed('user', function() {
// TODO replace this with a link to a native crates.io profile
// page when they exist.
return 'https://github.com/' + this.get('user.login');
}.property('user'),
return `https://github.com/${this.get('user.login')}`;
})
});
31 changes: 21 additions & 10 deletions app/controllers/application.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Ember from 'ember';

const { observer } = Ember;

export default Ember.Controller.extend({
needs: ['search'],

Expand All @@ -8,42 +10,51 @@ export default Ember.Controller.extend({
showUserOptions: false,
search: Ember.computed.oneWay('controllers.search.q'),

stepFlash: function() {
stepFlash() {
this.set('flashError', this.get('nextFlashError'));
this.set('nextFlashError', null);
},

aboutToTransition: function() {
aboutToTransition() {
Ember.$(document).trigger('mousedown');
},

resetDropdownOption: function(controller, option) {
// don't use this from other controllers..
resetDropdownOption(controller, option) {
controller.set(option, !controller.get(option));
if (controller.get(option)) {
Ember.$(document).on('mousedown.useroptions', function(e) {
Ember.$(document).on('mousedown.useroptions', (e) => {
if (Ember.$(e.target).prop('tagName') === 'INPUT') {
return;
}
Ember.run.later(function() {
Ember.run.later(() => {
controller.set(option, false);
}, 150);
Ember.$(document).off('mousedown.useroptions');
});
}
},

currentPathChanged: function () {
_scrollToTop() {
window.scrollTo(0, 0);
}.observes('currentPath'),
},

// TODO: remove observer & DOM mutation in controller..
currentPathChanged: observer('currentPath', function () {
Ember.run.scheduleOnce('afterRender', this, this._scrollToTop);
}),

actions: {
search: function(query) {
search(q) {
this.transitionToRoute('search', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I prefer to leave trailing commas wherever possible, but is it invalid syntax now?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only invalid for older browsers, valid in newer

queryParams: {q: query, page: 1}
queryParams: {
q,
page: 1
}
});
},

toggleUserOptions: function() {
toggleUserOptions() {
this.resetDropdownOption(this, 'showUserOptions');
},
},
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/catch-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Ember from 'ember';

export default Ember.Controller.extend({
actions: {
search: function(query) {
search(query) {
return this.transitionToRoute('search', {queryParams: {q: query}});
},
},
Expand Down
Loading