-
Notifications
You must be signed in to change notification settings - Fork 9
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 431c6e9
Showing
45 changed files
with
886 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,3 @@ | ||
{ | ||
"directory": "vendor" | ||
} |
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 @@ | ||
* text=auto |
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,6 @@ | ||
node_modules | ||
bower_components | ||
vendor | ||
temp | ||
tmp | ||
*.log |
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,3 @@ | ||
# AUTHORS | ||
|
||
* Johnny Hauser (https://github.com/m59peacemaker) |
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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
The MIT License (MIT) | ||
|
||
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. |
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 @@ | ||
# Angular Components |
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 @@ | ||
{ | ||
"name": "angular-pmkr-components", | ||
"author": { | ||
"name": "Johnny Hauser", | ||
"email": "[email protected]", | ||
"url": "https://github.com/m59peacemaker" | ||
}, | ||
"keywords": [ | ||
"Angular", | ||
"Components", | ||
"Filters", | ||
"Services", | ||
"Directives" | ||
], | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/m59peacemaker/angular-pmkr-components" | ||
}, | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"ignore": [ | ||
".*", | ||
"gulpfile.js" | ||
], | ||
"dependencies": { | ||
"angular": "1.3.0-beta.18" | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,88 @@ | ||
var gulp = require('gulp'); | ||
var gutil = require('gulp-util'); | ||
var clean = require('gulp-clean'); | ||
var rename = require('gulp-rename'); | ||
var concat = require('gulp-concat'); | ||
var header = require('gulp-header'); | ||
var uglify = require('gulp-uglify'); | ||
|
||
var pkg = require('./package.json'); | ||
|
||
var banner = (function() { | ||
var tmpl = [ | ||
'pmkr.components v<%= pkg.version %>', | ||
'<%= pkg.repository.url %>', | ||
'License: <%= pkg.license %>', | ||
'Author: <%= pkg.author.name %>', | ||
'File created: <%= gutil.date(now, "m.d.yyyy") %>' | ||
].join('\n'); | ||
var obj = { | ||
tmpl : tmpl, | ||
ml : ['/*',tmpl,'*/','\n'].join('\n'), | ||
html : ['<!--',tmpl,'-->','\n'].join('\n'), | ||
data : {pkg:pkg, gutil:gutil, now:new Date()} | ||
}; | ||
return obj; | ||
}()); | ||
|
||
gulp.task('default', ['build']); | ||
|
||
gulp.task('build', [ | ||
'components', | ||
'banner' | ||
]); | ||
|
||
gulp.task('clean-build', function() { | ||
return gulp.src('build/**') | ||
.pipe(clean()) | ||
}); | ||
|
||
gulp.task('banner', [ | ||
'components' | ||
], function() { | ||
return gulp.src('**/*.js', { | ||
cwd: 'build', | ||
base:'build' | ||
}) | ||
.pipe(header(banner.ml, banner.data)) | ||
.pipe(gulp.dest('build')) | ||
}); | ||
|
||
gulp.task('services', function() { | ||
return gulp.src('src/services/**/*.js') | ||
.pipe(concat('services.js')) | ||
.pipe(uglify()) | ||
.pipe(rename('services.min.js')) | ||
.pipe(gulp.dest('build')) | ||
; | ||
}); | ||
|
||
gulp.task('filters', function() { | ||
return gulp.src('src/filters/**/*.js') | ||
.pipe(concat('filters.js')) | ||
.pipe(uglify()) | ||
.pipe(rename('filters.min.js')) | ||
.pipe(gulp.dest('build')) | ||
; | ||
}); | ||
|
||
gulp.task('directives', function() { | ||
return gulp.src('src/directives/**/*.js') | ||
.pipe(concat('directives.js')) | ||
.pipe(uglify()) | ||
.pipe(rename('directives.min.js')) | ||
.pipe(gulp.dest('build')) | ||
; | ||
}); | ||
|
||
gulp.task('components', [ | ||
'filters', | ||
'services', | ||
'directives' | ||
], function() { | ||
return gulp.src(['src/components.js', 'build/**/*.min.js']) | ||
.pipe(concat('components.js')) | ||
.pipe(uglify()) | ||
.pipe(rename('components.min.js')) | ||
.pipe(gulp.dest('build')) | ||
}); |
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 @@ | ||
{ | ||
"name": "angular-pmkr-components", | ||
"author": { | ||
"name": "Johnny Hauser", | ||
"email": "[email protected]", | ||
"url": "https://github.com/m59peacemaker" | ||
}, | ||
"keywords": [ | ||
"news" | ||
], | ||
"private": "true", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/m59peacemaker/angular-pmkr-components" | ||
}, | ||
"version": "0.0.0", | ||
"license": "MIT", | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"gulp": "^3.7.0", | ||
"gulp-clean": "^0.3.0", | ||
"gulp-concat": "^2.2.0", | ||
"gulp-header": "^1.0.2", | ||
"gulp-rename": "^1.2.0", | ||
"gulp-uglify": "^0.3.0", | ||
"gulp-util": "^2.2.16" | ||
} | ||
} |
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,5 @@ | ||
angular.module('pmkr.components', [ | ||
'pmkr.components.filters', | ||
'pmkr.components.services', | ||
'pmkr.components.directives' | ||
]); |
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,4 @@ | ||
angular.module('pmkr.components.directives', [ | ||
'pmkr.pristineOriginal', | ||
'pmkr.validateCustom' | ||
]); |
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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Pristine Original | ||
|
||
This directive returns an input element to `$pristine` state when its current value matches its original value. | ||
|
||
## Usage: | ||
|
||
```html | ||
<input ng-model="myModel" pmkr-pristine-original> | ||
``` |
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,36 @@ | ||
angular.module('pmkr.pristineOriginal', []) | ||
|
||
.directive('pmkrPristineOriginal', [ | ||
function() { | ||
|
||
var directive = { | ||
restrict : 'A', | ||
require : 'ngModel', | ||
link: function($scope, $element, $atts, $ngModel) { | ||
|
||
var pristineVal = null; | ||
|
||
$scope.$watch(function() { | ||
return $ngModel.$viewValue; | ||
}, function(val) { | ||
// set pristineVal to newVal the first time this function runs | ||
if (pristineVal === null) { | ||
pristineVal = $ngModel.$isEmpty(val) ? '' : val.toString(); | ||
} | ||
|
||
// newVal is the original value - set input to pristine state | ||
if (pristineVal === val) { | ||
$ngModel.$setPristine(); | ||
} | ||
|
||
}); | ||
|
||
} | ||
}; | ||
|
||
return directive; | ||
|
||
} | ||
]) | ||
|
||
; |
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
# Validate Custom | ||
|
||
A configurable directive to validate an input field using an asynchronous or synchronous function (service). | ||
|
||
Directive priority: 1 | ||
|
||
Runs at priority 1 so that default priority (0) directives can set `ngModel` state before `gate` function runs. | ||
|
||
## Dependencies | ||
|
||
[pmkr.debounce][1] | ||
|
||
## Usage | ||
|
||
```html | ||
<input | ||
name="my_input" | ||
ng-model="myInput" | ||
pmkr-validate-custom="{name:'my-validation', fn:validationFn, gate:validationGate, wait:500, props:'validationProps'}" | ||
> | ||
``` | ||
|
||
```javascript | ||
// Note that this ought to be in a service and referenced to $scope. This is just for demonstration. | ||
$scope.validationFn = function(value) { | ||
return $http.get(validationUrl+value).then(function(resp) { | ||
// use resp to determine if value valid | ||
return isValid; // true or false | ||
}); | ||
} | ||
|
||
// The directive is gated off when this function returns true. | ||
$scope.validationGate = function(value, $ngModel) { | ||
return !value || $ngModel.$pristine; | ||
}; | ||
``` | ||
|
||
### Parameters | ||
|
||
#### name | ||
|
||
Type: `String` | ||
|
||
The validation name. `$error._____`, `ng-invalid-_____`, etc. | ||
|
||
#### fn | ||
|
||
Type: `Function` | ||
Parameters: value | ||
|
||
Asynchronous or synchronous funcion that returns `true` or `false`. Return true if `value` is valid or false if invalid. | ||
|
||
#### gate | ||
|
||
Type: `Function` | ||
Parameters: value, ngModel | ||
|
||
Synchronous function that returns true or false. Return true if validation should be skipped. | ||
|
||
#### wait | ||
|
||
Type: `Number` | ||
|
||
Amount of `ms` to debounce validation. | ||
|
||
#### props | ||
|
||
Type: 'String' | ||
|
||
Name of the `$scope` property to which the directive will assign useful properties for updating the view. | ||
|
||
- `pending` - `true` while debounce and validation are in progress. | ||
- `validating` - `true` while the validation `fn` is in progress. | ||
- `valid` - `true` when the field is valid AND `pending` is `false`. | ||
- `invalid` - `true` when the field is invalid AND `pending` is `false`. | ||
- `checkedValue` - the value that was validated | ||
|
||
[1]: https://github.com/m59peacemaker/angular-pmkr-components/tree/master/services/debounce |
Oops, something went wrong.