-
Notifications
You must be signed in to change notification settings - Fork 190
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
Showing
23 changed files
with
1,233 additions
and
1 deletion.
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,9 @@ | ||
# top-most EditorConfig file | ||
root = true | ||
|
||
# Unix-style newlines with a newline ending every file | ||
[*.{js,css}] | ||
end_of_line = lf | ||
insert_final_newline = true | ||
indent_style = space | ||
indent_size = 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,27 @@ | ||
*.iml | ||
*.log | ||
.idea/ | ||
.ipr | ||
.iws | ||
*~ | ||
~* | ||
*.diff | ||
*.patch | ||
*.bak | ||
.DS_Store | ||
Thumbs.db | ||
.project | ||
.*proj | ||
.svn/ | ||
*.swp | ||
*.swo | ||
*.pyc | ||
*.pyo | ||
.build | ||
node_modules | ||
_site | ||
sea-modules | ||
spm_modules | ||
.cache | ||
dist | ||
assets/**/*.css |
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,27 @@ | ||
{ | ||
"requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"], | ||
"requireSpaceAfterKeywords": ["if", "else", "for", "while", "do", "switch", "return", "try", "catch"], | ||
"requireSpacesInFunctionExpression": { | ||
"beforeOpeningCurlyBrace": true | ||
}, | ||
"disallowSpacesInsideArrayBrackets": true, | ||
"disallowSpacesInsideObjectBrackets": true, | ||
"disallowSpacesInsideParentheses": true, | ||
"disallowQuotedKeysInObjects": "allButReserved", | ||
"disallowSpaceAfterObjectKeys": true, | ||
"requireSpaceBeforeBinaryOperators": ["-", "/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<=" ], | ||
"requireSpacesInConditionalExpression": { | ||
"afterTest": true, | ||
"beforeConsequent": true, | ||
"afterConsequent": true, | ||
"beforeAlternate": true | ||
}, | ||
"requireSpaceAfterBinaryOperators": ["/", "*", "=", "==", "===", "!=", "!==", ">", ">=", "<", "<="], | ||
"disallowKeywords": [ "with" ], | ||
"disallowSpaceAfterPrefixUnaryOperators": [ "!" , "++", "--", "+", "-", "~"], | ||
"disallowSpaceBeforePostfixUnaryOperators": ["++", "--", ","], | ||
"disallowMultipleLineBreaks": true, | ||
"disallowKeywordsOnNewLine": ["else"], | ||
"safeContextKeyword": "self", | ||
"excludeFiles": ["lib/**/parser.js"] | ||
} |
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,28 @@ | ||
{ | ||
"camelcase": true, | ||
"curly": true, | ||
"eqeqeq": true, | ||
"freeze": true, | ||
"indent": 4, | ||
"latedef": "nofunc", | ||
"quotmark": "false", | ||
"nonew": true, | ||
"newcap": false, | ||
"immed": true, | ||
"noarg": true, | ||
"eqnull": true, | ||
"trailing": true, | ||
"undef": true, | ||
"unused": true, | ||
"browser": true, | ||
"node": true, | ||
"esnext": true, | ||
"globals": { | ||
"describe": false, | ||
"expect": false, | ||
"beforeEach": false, | ||
"afterEach": false, | ||
"modulex": false, | ||
"it": 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,28 @@ | ||
bower_components/ | ||
*.cfg | ||
node_modules/ | ||
nohup.out | ||
*.iml | ||
.idea/ | ||
.ipr | ||
.iws | ||
*~ | ||
~* | ||
*.diff | ||
*.log | ||
*.patch | ||
*.bak | ||
.DS_Store | ||
Thumbs.db | ||
.project | ||
.*proj | ||
.svn/ | ||
*.swp | ||
out/ | ||
.build | ||
node_modules | ||
_site | ||
sea-modules | ||
spm_modules | ||
.cache | ||
dist |
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,29 @@ | ||
bower_components/ | ||
node_modules/ | ||
nohup.out | ||
*.iml | ||
.idea/ | ||
.ipr | ||
.iws | ||
*~ | ||
~* | ||
*.diff | ||
*.log | ||
*.patch | ||
*.bak | ||
.DS_Store | ||
Thumbs.db | ||
.project | ||
.*proj | ||
.svn/ | ||
*.swp | ||
out/ | ||
.build | ||
_site | ||
sea-modules | ||
spm_modules | ||
.cache | ||
dist | ||
assets/**/*.less | ||
tests/ | ||
examples/ |
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 @@ | ||
language: node_js | ||
notifications: | ||
email: | ||
- yiminghe@gmail.com | ||
node_js: | ||
- 0.11 | ||
before_script: | ||
- npm start & | ||
- npm install mocha-phantomjs -g | ||
- phantomjs --version | ||
script: | ||
- npm test | ||
- npm run-script browser-test | ||
- npm run-script browser-test-cover |
Empty file.
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 |
---|---|---|
@@ -1,2 +1,76 @@ | ||
# util | ||
# rc-util | ||
--- | ||
|
||
Common Utils For React Component | ||
|
||
[![NPM version][npm-image]][npm-url] | ||
[![SPM version](http://spmjs.io/badge/rc-util)](http://spmjs.io/package/rc-util) | ||
[![gemnasium deps][gemnasium-image]][gemnasium-url] | ||
[![node version][node-image]][node-url] | ||
[![npm download][download-image]][download-url] | ||
|
||
[npm-image]: http://img.shields.io/npm/v/rc-util.svg?style=flat-square | ||
[npm-url]: http://npmjs.org/package/rc-util | ||
[travis-image]: https://img.shields.io/travis/react-component/util.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/react-component/util | ||
[coveralls-image]: https://img.shields.io/coveralls/react-component/util.svg?style=flat-square | ||
[coveralls-url]: https://coveralls.io/r/react-component/util?branch=master | ||
[gemnasium-image]: http://img.shields.io/gemnasium/react-component/util.svg?style=flat-square | ||
[gemnasium-url]: https://gemnasium.com/react-component/util | ||
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.10-green.svg?style=flat-square | ||
[node-url]: http://nodejs.org/download/ | ||
[download-image]: https://img.shields.io/npm/dm/rc-util.svg?style=flat-square | ||
[download-url]: https://npmjs.org/package/rc-util | ||
|
||
## install | ||
|
||
[![rc-util](https://nodei.co/npm/rc-util.png)](https://npmjs.org/package/rc-util) | ||
|
||
## Usage | ||
|
||
```js | ||
var rcUtil = require('rc-util'); | ||
console.log(rcUtil.classSet({x:1,y:0})); | ||
``` | ||
|
||
## API | ||
|
||
### classSet:function | ||
|
||
http://facebook.github.io/react/docs/class-name-manipulation.html | ||
|
||
### shallowEqual:function | ||
|
||
### KeyCode:enum | ||
|
||
enum of KeyCode | ||
|
||
``` | ||
KeyCode.ENTER | ||
KeyCode.DOWN | ||
``` | ||
|
||
### guid:function | ||
|
||
return string represent a global unique id across current application | ||
|
||
### createChainedFunction:function | ||
|
||
### cloneWithProps:function | ||
|
||
http://facebook.github.io/react/docs/clone-with-props.html | ||
|
||
### Dom.addEventListener:function | ||
|
||
### Dom.contains:function | ||
|
||
### Children.toArray | ||
|
||
transform React Children into Array type | ||
|
||
|
||
|
||
|
||
## License | ||
|
||
rc-util is released under the MIT license. |
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 @@ | ||
# rc-util@1.x | ||
--- | ||
|
||
````js | ||
/** @jsx React.DOM */ | ||
var rcUtil = require('../'); | ||
console.log(rcUtil.classSet({ | ||
x:true, | ||
y:true, | ||
z: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,17 @@ | ||
module.exports = { | ||
guid: require('./lib/guid'), | ||
classSet: require('./lib/classSet'), | ||
joinClasses: require('./lib/joinClasses'), | ||
KeyCode: require('./lib/KeyCode'), | ||
PureRenderMixin: require('./lib/PureRenderMixin'), | ||
shallowEqual: require('./lib/shallowEqual'), | ||
createChainedFunction: require('./lib/createChainedFunction'), | ||
cloneWithProps: require('./lib/cloneWithProps'), | ||
Dom: { | ||
addEventListener: require('./lib/Dom/addEventListener'), | ||
contains: require('./lib/Dom/contains') | ||
}, | ||
Children: { | ||
toArray: require('./lib/Children/toArray') | ||
} | ||
}; |
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,9 @@ | ||
var React = require('react'); | ||
|
||
module.exports = function (children) { | ||
var ret = []; | ||
React.Children.forEach(children, function (c) { | ||
ret.push(c); | ||
}); | ||
return ret; | ||
}; |
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,17 @@ | ||
module.exports = function (target, eventType, callback) { | ||
if (target.addEventListener) { | ||
target.addEventListener(eventType, callback, false); | ||
return { | ||
remove: function () { | ||
target.removeEventListener(eventType, callback, false); | ||
} | ||
}; | ||
} else if (target.attachEvent) { | ||
target.attachEvent('on' + eventType, callback); | ||
return { | ||
remove: function () { | ||
target.detachEvent('on' + eventType, callback); | ||
} | ||
}; | ||
} | ||
}; |
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 @@ | ||
module.exports = function (root, node) { | ||
while (node) { | ||
if (node === root) { | ||
return true; | ||
} | ||
node = node.parentNode; | ||
} | ||
|
||
return false; | ||
}; |
Oops, something went wrong.