This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ = 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fm = (() => { | |
| let model = {} | |
| let observers = { fm_observe_all: [] } | |
| return { | |
| save: (key, val) => { | |
| model[key] = val | |
| emit(key) | |
| }, | |
| silentSave: (key, val) => { | |
| model[key] = val |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ = 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 = '' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ = 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(){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ = function(parameters) { | |
| console.log(parameters) | |
| return { | |
| left: function(){ | |
| console.log(parameters, "turning left") | |
| return this | |
| }, | |
| right: function(){ | |
| console.log(parameters, "turning right") | |
| return this |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $(".my-list li").left().right() | |
| // logs "Uncaught TypeError: $ is not a function" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ = { | |
| left: function() { | |
| console.log("turning left") | |
| return this | |
| }, | |
| right: function() { | |
| console.log("turning right") | |
| return this | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.left().right() | |
| // logs "Uncaught TypeError: Cannot read property 'right' of undefined" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ = { | |
| left: function() { | |
| console.log("turning left") | |
| }, | |
| right: function() { | |
| console.log("turning right") | |
| } | |
| } | |
| $.left() | |
| // logs "turning left" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //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){} | |
| }); |