Skip to content

Commit

Permalink
DEV: Upgrade Ember to 3.15 and remove jQuery and lodash as dependenci…
Browse files Browse the repository at this point in the history
…es (#107)

* DEV: Upgrade Ember to 3.15 and remove jQuery and lodash as dependencies

* Experiment with decorators

* Rename bind to bound and use it everywhere

* pin byebug version
  • Loading branch information
OsamaSayegh committed Feb 7, 2020
1 parent 519e3b8 commit 9f33639
Show file tree
Hide file tree
Showing 28 changed files with 15,329 additions and 9,107 deletions.
385 changes: 199 additions & 186 deletions assets/javascript/client-app.js

Large diffs are not rendered by default.

10,965 changes: 5,132 additions & 5,833 deletions assets/javascript/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/stylesheets/client-app.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 17 additions & 5 deletions client-app/.eslintrc.js
@@ -1,8 +1,12 @@
module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
ecmaVersion: 2017,
sourceType: 'module'
ecmaVersion: 2018,
sourceType: 'module',
ecmaFeatures: {
legacyDecorators: true
}
},
plugins: [
'ember'
Expand All @@ -21,6 +25,7 @@ module.exports = {
browser: true
},
rules: {
'ember/no-jquery': 'error'
},
overrides: [
// node files
Expand All @@ -36,13 +41,20 @@ module.exports = {
'server/**/*.js'
],
parserOptions: {
sourceType: 'script',
ecmaVersion: 2015
sourceType: 'script'
},
env: {
browser: false,
node: true
}
},
plugins: ['node'],
rules: Object.assign({}, require('eslint-plugin-node').configs.recommended.rules, {
// add your custom rules and overrides for node files here

// this can be removed once the following is fixed
// https://github.com/mysticatea/eslint-plugin-node/issues/77
'node/no-unpublished-require': 'off'
})
}
]
};
7 changes: 4 additions & 3 deletions client-app/.travis.yml
@@ -1,7 +1,7 @@
---
language: node_js
node_js:
- "6"
- "8"

sudo: false
dist: trusty
Expand All @@ -18,8 +18,9 @@ env:
# See https://git.io/vdao3 for details.
- JOBS=1

before_install:
- npm config set spin false
branches:
only:
- master

script:
- npm run lint:hbs
Expand Down
12 changes: 5 additions & 7 deletions client-app/app/app.js
Expand Up @@ -3,12 +3,10 @@ import Resolver from "./resolver";
import loadInitializers from "ember-load-initializers";
import config from "./config/environment";

const App = Application.extend({
modulePrefix: config.modulePrefix,
podModulePrefix: config.podModulePrefix,
Resolver
});
export default class App extends Application {
modulePrefix = config.modulePrefix;
podModulePrefix = config.podModulePrefix;
Resolver = Resolver;
}

loadInitializers(App, config.modulePrefix);

export default App;
41 changes: 24 additions & 17 deletions client-app/app/components/actions-menu.js
@@ -1,40 +1,47 @@
import Component from "@ember/component";
import { observer } from "@ember/object";
import { bound } from "client-app/lib/decorators";

export default Component.extend({
showMenu: false,
tagName: "span",

init() {
this._super(...arguments);
this.bindingFunction = this.bindingFunction.bind(this);
},

bindingFunction(event) {
const context = this.$()[0];
if (!Em.$.contains(context, event.target) && context !== event.target) {
@bound
outsideClickHandler(event) {
if (
this.element &&
!this.element.contains(event.target) &&
this.element !== event.target
) {
this.set("showMenu", false);
this.updateMenu();
}
},

bindDocument: observer("showMenu", function() {
const $document = Em.$(document);
if (this.get("showMenu")) {
$document.on("click", this.get("bindingFunction"));
updateMenu() {
if (this.showMenu) {
this.addOutsideClickHandler();
} else {
$document.off("click", this.get("bindingFunction"));
this.removeOutsideClickHandler();
}
}),
},

addOutsideClickHandler() {
document.addEventListener("click", this.outsideClickHandler);
},

removeOutsideClickHandler() {
document.removeEventListener("click", this.outsideClickHandler);
},

willDestroyElement() {
this._super(...arguments);
const $document = Em.$(document);
$document.off("click", this.get("bindingFunction"));
this.removeOutsideClickHandler();
},

actions: {
expandMenu() {
this.toggleProperty("showMenu");
this.updateMenu();
},
share() {
this.share();
Expand Down

0 comments on commit 9f33639

Please sign in to comment.