Skip to content

Instantly share code, notes, and snippets.

View ilucin's full-sized avatar

Ivan Lučin ilucin

View GitHub Profile
import Controller from '@ember/controller';
export default class ApplicationController extends Controller {
session = {user: {name: 'Ivan'}};
}
function proxyMethods(proxyObj, originalObj, props) {
props.forEach(function(method) {
proxyObj[method] = function() {
return originalObj[method](...arguments);
};
});
}
function proxyProps(proxyObj, originalObj, props) {
props.forEach(function(prop) {
(function() {
var trix = document.querySelector('trix-editor');
var btn = document.createElement('button');
btn.innerHTML = 'Press me';
btn.addEventListener('click', function() {
trix.editor.loadJSON({document: []});
trix.editor.insertHTML('');
});
trix.parentElement.appendChild(btn);
})();
@ilucin
ilucin / branched-routing.md
Last active August 19, 2016 23:30 — forked from janvarljen/branched-routing.md
Ember branched routing

The problem

Applications often need to expose a part of the app in different context without breaking the current context. The simplified example would be the "settings" modal. You want to be able to open the settings modal from everywhere in you app without losing the current context.

Let's say we have a really simple app:

Router.map(function() {
  this.route('projects', {}, function() {
    this.route('dashboard');
@ilucin
ilucin / controllers.application.js
Last active July 12, 2016 15:41
Observer on hasMany
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import InfinityLoaderComponent from 'ember-infinity/components/infinity-loader';
InfinityLoaderComponent.reopen({
loadingText: 'Loading data...',
loadedText: 'All data loaded.',
classNameBindings: ['infinityModel.reachedInfinity:has-reached-infinity'],
// Remove this hack when https://github.com/hhff/ember-infinity/issues/100 gets resolved
_shouldLoadMore() {
if (this.get('developmentMode') || this.isDestroying || this.isDestroyed) {
function() {
var isFixed = false;
$(window).on('scroll', function() {
if (isFixed && shouldGoToStaticCondition) {
$(el).removeClass('fixed');
isFixed = false;
}
else if (!isFixed && shouldGoToFixCondition) {
$(el).addClass('fixed');