-
Notifications
You must be signed in to change notification settings - Fork 267
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d6bf47c
Showing
6 changed files
with
164 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"plugins": ["transform-class-properties"], | ||
"presets": [ | ||
["env", { | ||
"targets": { | ||
"browsers": ["last 2 versions", "safari >= 7"] | ||
} | ||
}] | ||
] | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# http://editorconfig.org | ||
root = true | ||
|
||
[*] | ||
indent_style = space | ||
indent_size = 2 | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
insert_final_newline = true | ||
|
||
[*.md] | ||
trim_trailing_whitespace = false |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# Logs | ||
logs | ||
*.log | ||
|
||
# Runtime data | ||
pids | ||
*.pid | ||
*.seed | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
coverage | ||
|
||
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) | ||
.grunt | ||
|
||
# node-waf configuration | ||
.lock-wscript | ||
|
||
# Compiled binary addons (http://nodejs.org/api/addons.html) | ||
build/Release | ||
|
||
# Dependency directory | ||
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git | ||
node_modules | ||
.DS_Store | ||
dist | ||
|
||
# editor config | ||
.vscode/ |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "o2_base", | ||
"version": "0.0.1", | ||
"description": "o2_base", | ||
"main": "index.js", | ||
"scripts": { | ||
"build": "rm -rf dist && babel src -d dist" | ||
}, | ||
"keywords": [ | ||
"base" | ||
], | ||
"author": "luckyadam", | ||
"license": "MIT", | ||
"devDependencies": { | ||
"babel-cli": "^6.24.0", | ||
"babel-plugin-transform-class-properties": "^6.23.0", | ||
"babel-preset-env": "^1.2.2" | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
class Events { | ||
static eventSplitter = /\s+/; | ||
constructor (opts) { | ||
if (typeof opts !== 'undefined' && opts.callbacks) { | ||
this.callbacks = opts.callbacks; | ||
} else { | ||
this.callbacks = {}; | ||
} | ||
} | ||
|
||
on (events, callback, context) { | ||
let calls, event, node, tail, list; | ||
if (!callback) { | ||
return this; | ||
} | ||
events = events.split(Events.eventSplitter); | ||
calls = this.callbacks; | ||
while (event = events.shift()) { | ||
list = calls[event]; | ||
node = list ? list.tail : {}; | ||
node.next = tail = {}; | ||
node.context = context; | ||
node.callback = callback; | ||
calls[event] = { | ||
tail: tail, | ||
next: list ? list.next : node | ||
}; | ||
} | ||
return this; | ||
} | ||
|
||
off (events, callback, context) { | ||
let event, calls, node, tail, cb, ctx; | ||
if (!(calls = this.callbacks)) { | ||
return this; | ||
} | ||
if (!(events || callback || context)) { | ||
delete this.callbacks; | ||
return this; | ||
} | ||
events = events ? events.split(Events.eventSplitter) : Object.keys(calls); | ||
while (event = events.shift()) { | ||
node = calls[event]; | ||
delete calls[event]; | ||
if (!node || !(callback || context)) { | ||
continue; | ||
} | ||
tail = node.tail; | ||
while ((node = node.next) !== tail) { | ||
cb = node.callback; | ||
ctx = node.context; | ||
if ((callback && cb !== callback) || (context && ctx !== context)) { | ||
this.on(event, cb, ctx); | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
|
||
trigger (events) { | ||
let event, node, calls, tail, args, all, rest; | ||
if (!(calls = this.callbacks)) { | ||
return this; | ||
} | ||
events = events.split(Events.eventSplitter); | ||
rest = [].slice.call(arguments, 1); | ||
while (event = events.shift()) { | ||
if (node = calls[event]) { | ||
tail = node.tail; | ||
while ((node = node.next) !== tail) { | ||
node.callback.apply(node.context || this, rest); | ||
} | ||
} | ||
} | ||
return this; | ||
} | ||
} |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class Widget { | ||
constructor ({ $el }) { | ||
this.$el = $el; | ||
this.template = ''; | ||
} | ||
|
||
fetch () { | ||
|
||
} | ||
|
||
update () { | ||
|
||
} | ||
} |