Skip to content

Instantly share code, notes, and snippets.

View made-by-chris's full-sized avatar
🏁

Christopher Shelley made-by-chris

🏁
View GitHub Profile
$ = function(parameters) {
this.state = {};
this.state.nodeList = document.querySelectorAll(parameters)
this.state.dom = [].slice.call(state.nodeList)
return this instanceof $ ? this : new $(parameters)
}
$.prototype = {
left: function(){
console.log(this.state.dom.length, "turning left")
return this
@made-by-chris
made-by-chris / fm.js
Last active December 5, 2016 04:37
fm - minimal observer with model
const fm = (() => {
let model = {}
let observers = { fm_observe_all: [] }
return {
save: (key, val) => {
model[key] = val
emit(key)
},
silentSave: (key, val) => {
model[key] = val
$ = function(domSelector) {
this.state = {};
this.state.nodeList = document.querySelectorAll(domSelector)
this.state.dom = [].slice.call(state.nodeList)
return this instanceof $ ? this : new $(domSelector)
}
$.prototype = {
show : function() {
this.state.dom.forEach(function(node) {
node.style.display = ''
$ = function(parameters) {
var state = {}
state.nodeList = document.querySelectorAll(parameters)
state.dom = [].slice.call(state.nodeList)
return {
left: function(){
console.log(state.dom, “turning left”)
return this
},
right: function(){
$ = function(parameters) {
console.log(parameters)
return {
left: function(){
console.log(parameters, "turning left")
return this
},
right: function(){
console.log(parameters, "turning right")
return this
$(".my-list li").left().right()
// logs "Uncaught TypeError: $ is not a function"
$ = {
left: function() {
console.log("turning left")
return this
},
right: function() {
console.log("turning right")
return this
}
}
$.left().right()
// logs "Uncaught TypeError: Cannot read property 'right' of undefined"
@made-by-chris
made-by-chris / 1.js
Created December 2, 2016 06:55
An object with methods.
$ = {
left: function() {
console.log("turning left")
},
right: function() {
console.log("turning right")
}
}
$.left()
// logs "turning left"
@made-by-chris
made-by-chris / snippets.cson
Created January 6, 2016 09:48
Atom snippets - Marionette layoutView, ItemView, CollectionView
//appen this to the end of your /.atom/snippets.cson
'.source.js':
'Marionette.ItemView':
'prefix': 'mit'
'body': """
var MyItemViewTemplate = require("./my-view.ejs");
var MyItemView = Marionette.ItemView.extend({
template: "#some-template",
initialize: function(options){}
});