Skip to content

Instantly share code, notes, and snippets.

View lifeart's full-sized avatar
🐹
Working from home

Alex Kanunnikov lifeart

🐹
Working from home
View GitHub Profile
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@lifeart
lifeart / patch.js
Created February 16, 2018 15:12
Angular 1.6+ directive ad-hock replace
angular.module('moduleName')._invokeQueue.forEach(([provider, type, el]) => {
if (provider && type === 'directive' && el[0] === 'directiveName') {
el[1] = ['dependency', function(dependency) {}];
}
});
@lifeart
lifeart / components.frozen-table.js
Last active February 17, 2018 21:44
FrozenTable
import Ember from 'ember';
const {Component,computed, String} = Ember;
const {htmlSafe} = String;
function createResizeHandler(rightContainer, relativeContainer, leftContainer) {
return function () {
let width = relativeContainer.outerWidth() - leftContainer.outerWidth();
rightContainer.width(width);
}
}
@lifeart
lifeart / 0 README.md
Created February 18, 2018 11:24 — forked from caseywatts/0 README.md
d3 & c3 npm shim to es6 module for Ember

app.import() works with node_modules now! As of Ember 2.15. Previously it only worked with bower_components and vendor.

Docs for app.import are here: https://ember-cli.com/managing-dependencies#standard-non-amd-asset

This method (vendor-shim) wraps the global export into an es6 module (but the global one is still present). It doesn't use an es6 interface even if the library offers one, but that's okay for my use case.

Things could still be easier, see this thread for the current state of that.

import ModalDialog from 'ember-modal-dialog/components/modal-dialog';
import $ from 'jquery';
const ESC_KEY = 27;
export default ModalDialog.extend({
didInsertElement() {
this._super(...arguments);
this._initEscListener();
$('.internal-button').focus();
@lifeart
lifeart / ember-cli-build.js
Last active March 11, 2018 21:07
Ember-cli-es6-imports
// install ember-cli-es6-transform
function importFromNPM(app,moduleName) {
let relPath = `node_modules/${moduleName}`;
let nodePath = `./${relPath}`;
let config = require(`${nodePath}/package.json`);
if (config.style) {
app.import(`${relPath}/${config.style}`);
}
@lifeart
lifeart / controllers.application.js
Last active March 15, 2018 18:13
Unload & Destroy
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
records: Ember.computed(function(){
return this.store.peekAll('test');
}),
actions: {
unloadRecord(model) {
this.store.unloadRecord(model);
@lifeart
lifeart / any-model-form.hbs
Created April 12, 2018 05:21
Ember Any Model Edit
{{#each relationships as |attributeElement|}}
<div class="row">
<div class="col-xs-8 col-xs-offset-1">
{{#if (eq attributeElement.kind 'hasMany')}}
{{form-select
searchEnabled=true
multiple=true
label=attributeElement.niceKey
errorText=(v-get model attributeElement.key 'message')
selected=(get model attributeElement.key)
@lifeart
lifeart / keybase.md
Created April 14, 2018 17:46
Keybase proof

Keybase proof

I hereby claim:

  • I am lifeart on github.
  • I am lifeart (https://keybase.io/lifeart) on keybase.
  • I have a public key ASApsoX__9zelvr6iw4OsdWA_kR_Lgbp_2HRhed0kWrHiAo

To claim this, I am signing this object:

import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
table: Ember.computed('models.@each.sortIndex', function(){
return this.get('models');
}),
models: Ember.computed(function(){
return Ember.A([
Ember.Object.extend({sortIndex:1}).create(),