mirror of
https://github.com/gwenhael-le-moine/ledgerrb.git
synced 2025-01-13 08:01:20 +01:00
add angular-underscore
This commit is contained in:
parent
475a770ea3
commit
7b032fbd0e
9 changed files with 303 additions and 2 deletions
22
public/app/bower_components/angular-underscore/.bower.json
vendored
Normal file
22
public/app/bower_components/angular-underscore/.bower.json
vendored
Normal file
|
@ -0,0 +1,22 @@
|
|||
{
|
||||
"name": "angular-underscore",
|
||||
"main": "angular-underscore.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
],
|
||||
"homepage": "https://github.com/floydsoft/angular-underscore",
|
||||
"_release": "9b470c1f2d",
|
||||
"_resolution": {
|
||||
"type": "branch",
|
||||
"branch": "master",
|
||||
"commit": "9b470c1f2de786c6e6d1289b49a757162efa1d6a"
|
||||
},
|
||||
"_source": "git://github.com/floydsoft/angular-underscore.git",
|
||||
"_target": "*",
|
||||
"_originalSource": "angular-underscore",
|
||||
"_direct": true
|
||||
}
|
95
public/app/bower_components/angular-underscore/README.md
vendored
Normal file
95
public/app/bower_components/angular-underscore/README.md
vendored
Normal file
|
@ -0,0 +1,95 @@
|
|||
# An AngularJS module adapting underscore
|
||||
|
||||
This module exposes underscore's API into angular app's root scope,
|
||||
and provides some filters from underscore.
|
||||
|
||||
|
||||
## Filters
|
||||
|
||||
Whole Underscore's API for Collections, Arrays and Objects except decision API
|
||||
(e.g. functions return true|false), side effect guys, and _.range(not making sense as a filter).
|
||||
|
||||
|
||||
For API details please check out http://underscorejs.org/
|
||||
|
||||
## How to use
|
||||
|
||||
### Install
|
||||
|
||||
After load angular.js and underscore.js:
|
||||
|
||||
```html
|
||||
<script type="text/javascript" src="angular-underscore.js"></script>
|
||||
```
|
||||
|
||||
### Load angular-underscore
|
||||
|
||||
#### Load whole stuff
|
||||
|
||||
```javascript
|
||||
angular.module('yourAwesomeApp', ['angular-underscore']);
|
||||
```
|
||||
|
||||
#### Load API only
|
||||
|
||||
```javascript
|
||||
angular.module('yourAwesomeApp', ['angular-underscore/utils']);
|
||||
```
|
||||
|
||||
#### Load filters only
|
||||
|
||||
```javascript
|
||||
angular.module('yourAwesomeApp', ['angular-underscore/filters']);
|
||||
```
|
||||
|
||||
#### Load specific feature only
|
||||
|
||||
```javascript
|
||||
// load `shuffle` only
|
||||
angular.module('yourAwesomeApp', ['angular-underscore/filters/shuffle']);
|
||||
```
|
||||
|
||||
### Usecase
|
||||
|
||||
#### From the Template
|
||||
|
||||
```html
|
||||
<script type="text/javascript">
|
||||
angular.module('example', ['angular-underscore']);
|
||||
</script>
|
||||
|
||||
<body ng-app="example">
|
||||
<!-- generate 10 unduplicated random number from 0 to 9 -->
|
||||
<div ng-repeat="num in range(10)|shuffle">{{num}}</div>
|
||||
</body>
|
||||
```
|
||||
|
||||
#### From the Controller
|
||||
|
||||
```javascript
|
||||
angular.module('yourAwesomeApp', ['angular-underscore'])
|
||||
.controller('yourAwesomeCtrl', function($scope) {
|
||||
$scope.sample([1, 2, 3]); // got 1, or 2, or 3.
|
||||
$scope._([1, 2, 3]); // underscore's chain, http://underscorejs.org/#chain
|
||||
});
|
||||
|
||||
```
|
||||
|
||||
### Local build
|
||||
|
||||
```
|
||||
$ npm install uglify-js -g
|
||||
$ uglifyjs angular-underscore.js > angular-underscore.min.js
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 <floydsoft@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
157
public/app/bower_components/angular-underscore/angular-underscore.js
vendored
Normal file
157
public/app/bower_components/angular-underscore/angular-underscore.js
vendored
Normal file
|
@ -0,0 +1,157 @@
|
|||
(function (ng, _) {
|
||||
'use strict';
|
||||
|
||||
var
|
||||
underscoreModule = ng.module('angular-underscore', []),
|
||||
utilsModule = ng.module('angular-underscore/utils', []),
|
||||
filtersModule = ng.module('angular-underscore/filters', []);
|
||||
|
||||
// begin custom _
|
||||
|
||||
function propGetterFactory(prop) {
|
||||
return function(obj) {return obj[prop];};
|
||||
}
|
||||
|
||||
_._ = _;
|
||||
|
||||
// Shiv "min", "max" ,"sortedIndex" to accept property predicate.
|
||||
_.each(['min', 'max', 'sortedIndex'], function(fnName) {
|
||||
_[fnName] = _.wrap(_[fnName], function(fn) {
|
||||
var args = _.toArray(arguments).slice(1);
|
||||
|
||||
if(_.isString(args[2])) {
|
||||
// for "sortedIndex", transmuting str to property getter
|
||||
args[2] = propGetterFactory(args[2]);
|
||||
}
|
||||
else if(_.isString(args[1])) {
|
||||
// for "min" or "max", transmuting str to property getter
|
||||
args[1] = propGetterFactory(args[1]);
|
||||
}
|
||||
|
||||
return fn.apply(_, args);
|
||||
});
|
||||
});
|
||||
|
||||
// Shiv "filter", "reject" to angular's built-in,
|
||||
// and reserve underscore's feature(works on obj).
|
||||
ng.injector(['ng']).invoke(['$filter', function($filter) {
|
||||
_.filter = _.select = _.wrap($filter('filter'), function(filter, obj, exp, comparator) {
|
||||
if(!(_.isArray(obj))) {
|
||||
obj = _.toArray(obj);
|
||||
}
|
||||
|
||||
return filter(obj, exp, comparator);
|
||||
});
|
||||
|
||||
_.reject = function(obj, exp) {
|
||||
// use angular built-in negated predicate
|
||||
if(_.isString(exp)) {
|
||||
return _.filter(obj, '!' + exp);
|
||||
}
|
||||
|
||||
var diff = _.bind(_.difference, _, obj);
|
||||
|
||||
return diff(_.filter(obj, exp));
|
||||
};
|
||||
}]);
|
||||
|
||||
// end custom _
|
||||
|
||||
|
||||
// begin register angular-underscore/utils
|
||||
|
||||
_.each(_.methods(_), function(methodName) {
|
||||
function register($rootScope) {$rootScope[methodName] = _.bind(_[methodName], _);}
|
||||
|
||||
_.each([
|
||||
underscoreModule,
|
||||
utilsModule,
|
||||
ng.module('angular-underscore/utils/' + methodName, [])
|
||||
], function(module) {
|
||||
module.run(['$rootScope', register]);
|
||||
});
|
||||
});
|
||||
|
||||
// end register angular-underscore/utils
|
||||
|
||||
|
||||
// begin register angular-underscore/filters
|
||||
|
||||
var
|
||||
adapList = [
|
||||
['map', 'collect'],
|
||||
['reduce', 'inject', 'foldl'],
|
||||
['reduceRight', 'foldr'],
|
||||
['find', 'detect'],
|
||||
['filter', 'select'],
|
||||
'where',
|
||||
'findWhere',
|
||||
'reject',
|
||||
'invoke',
|
||||
'pluck',
|
||||
'max',
|
||||
'min',
|
||||
'sortBy',
|
||||
'groupBy',
|
||||
'indexBy',
|
||||
'countBy',
|
||||
'shuffle',
|
||||
'sample',
|
||||
'toArray',
|
||||
'size',
|
||||
['first', 'head', 'take'],
|
||||
'initial',
|
||||
'last',
|
||||
['rest', 'tail', 'drop'],
|
||||
'compact',
|
||||
'flatten',
|
||||
'without',
|
||||
'partition',
|
||||
'union',
|
||||
'intersection',
|
||||
'difference',
|
||||
['uniq', 'unique'],
|
||||
'zip',
|
||||
'object',
|
||||
'indexOf',
|
||||
'lastIndexOf',
|
||||
'sortedIndex',
|
||||
'keys',
|
||||
'values',
|
||||
'pairs',
|
||||
'invert',
|
||||
['functions', 'methods'],
|
||||
'pick',
|
||||
'omit',
|
||||
'tap',
|
||||
'identity',
|
||||
'uniqueId',
|
||||
'escape',
|
||||
'unescape',
|
||||
'result',
|
||||
'template'
|
||||
];
|
||||
|
||||
_.each(adapList, function(filterNames) {
|
||||
if(!(_.isArray(filterNames))) {
|
||||
filterNames = [filterNames];
|
||||
}
|
||||
|
||||
var
|
||||
filter = _.bind(_[filterNames[0]], _),
|
||||
filterFactory = function() {return filter;};
|
||||
|
||||
_.each(filterNames, function(filterName) {
|
||||
_.each([
|
||||
underscoreModule,
|
||||
filtersModule,
|
||||
ng.module('angular-underscore/filters/' + filterName, [])
|
||||
], function(module) {
|
||||
module.filter(filterName, filterFactory);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// end register angular-underscore/filters
|
||||
|
||||
}(angular, _));
|
1
public/app/bower_components/angular-underscore/angular-underscore.min.js
vendored
Normal file
1
public/app/bower_components/angular-underscore/angular-underscore.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
(function(ng,_){"use strict";var underscoreModule=ng.module("angular-underscore",[]),utilsModule=ng.module("angular-underscore/utils",[]),filtersModule=ng.module("angular-underscore/filters",[]);function propGetterFactory(prop){return function(obj){return obj[prop]}}_._=_;_.each(["min","max","sortedIndex"],function(fnName){_[fnName]=_.wrap(_[fnName],function(fn){var args=_.toArray(arguments).slice(1);if(_.isString(args[2])){args[2]=propGetterFactory(args[2])}else if(_.isString(args[1])){args[1]=propGetterFactory(args[1])}return fn.apply(_,args)})});ng.injector(["ng"]).invoke(["$filter",function($filter){_.filter=_.select=_.wrap($filter("filter"),function(filter,obj,exp){if(!_.isArray(obj)){obj=_.toArray(obj)}return filter(obj,exp)});_.reject=function(obj,exp){if(_.isString(exp)){return _.filter(obj,"!"+exp)}var diff=_.bind(_.difference,_,obj);return diff(_.filter(obj,exp))}}]);_.each(_.methods(_),function(methodName){function register($rootScope){$rootScope[methodName]=_.bind(_[methodName],_)}_.each([underscoreModule,utilsModule,ng.module("angular-underscore/utils/"+methodName,[])],function(module){module.run(["$rootScope",register])})});var adapList=[["map","collect"],["reduce","inject","foldl"],["reduceRight","foldr"],["find","detect"],["filter","select"],"where","findWhere","reject","invoke","pluck","max","min","sortBy","groupBy","countBy","shuffle","toArray","size",["first","head","take"],"initial","last",["rest","tail","drop"],"compact","flatten","without","union","intersection","difference",["uniq","unique"],"zip","object","indexOf","lastIndexOf","sortedIndex","keys","values","pairs","invert",["functions","methods"],"pick","omit","tap","identity","uniqueId","escape","result","template"];_.each(adapList,function(filterNames){if(!_.isArray(filterNames)){filterNames=[filterNames]}var filter=_.bind(_[filterNames[0]],_),filterFactory=function(){return filter};_.each(filterNames,function(filterName){_.each([underscoreModule,filtersModule,ng.module("angular-underscore/filters/"+filterName,[])],function(module){module.filter(filterName,filterFactory)})})})})(angular,_);
|
12
public/app/bower_components/angular-underscore/bower.json
vendored
Normal file
12
public/app/bower_components/angular-underscore/bower.json
vendored
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"name": "angular-underscore",
|
||||
"version": "0.4.0",
|
||||
"main": "angular-underscore.js",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
11
public/app/bower_components/angular-underscore/package.json
vendored
Normal file
11
public/app/bower_components/angular-underscore/package.json
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"name": "angular-underscore",
|
||||
"description": "Underscore adapter for AngularJS.",
|
||||
"version": "0.4.0",
|
||||
"author": "floydsoft <floydsoft@gmail.com>",
|
||||
"main": "angular-underscore.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/floydsoft/angular-underscore"
|
||||
}
|
||||
}
|
|
@ -46,6 +46,7 @@
|
|||
<script src="/bower_components/angular-moment/angular-moment.min.js"></script>
|
||||
<script src="/bower_components/angularjs-nvd3-directives/dist/angularjs-nvd3-directives.min.js"></script>
|
||||
<script src="/bower_components/angular-loading-bar/build/loading-bar.min.js"></script>
|
||||
<script src="/bower_components/angular-underscore/angular-underscore.min.js"></script>
|
||||
<script src="/bower_components/ng-table/ng-table.min.js"></script>
|
||||
|
||||
<!-- APP -->
|
||||
|
|
|
@ -2,5 +2,6 @@ var app = angular.module( 'app', [ 'ui.router',
|
|||
'nvd3ChartDirectives',
|
||||
'angularMoment',
|
||||
'chieffancypants.loadingBar',
|
||||
'ngTable'
|
||||
'ngTable',
|
||||
'angular-underscore'
|
||||
] );
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
"angularjs-nvd3-directives": "latest",
|
||||
"html5-boilerplate": "latest",
|
||||
"ng-table": "latest",
|
||||
"underscore": "latest"
|
||||
"underscore": "latest",
|
||||
"angular-underscore": "latest"
|
||||
},
|
||||
"resolutions": {
|
||||
"angular": "^1.3.0-beta.18",
|
||||
|
|
Loading…
Reference in a new issue