Skip to content
This repository has been archived by the owner on May 21, 2019. It is now read-only.

Commit

Permalink
* Updated Gruntfile.js.
Browse files Browse the repository at this point in the history
* Updated version number.
* Directive is now part of the whole plugin.
  • Loading branch information
dnasir committed Sep 24, 2014
1 parent 951135b commit f573ae5
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 261 deletions.
31 changes: 19 additions & 12 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module.exports = function ( grunt ) {
module.exports = function (grunt) {

grunt.loadNpmTasks('grunt-karma');

var taskConfig = {
Expand All @@ -13,35 +13,42 @@ module.exports = function ( grunt ) {
runnerPort: 9101,
background: true
},
continuous: {
single: {
singleRun: true
}
},

uglify: {
development: {
raw: {
options: {
beautify: true,
sourceMap: false,
mangle: false,
compress: false,
preserveComments: 'some'
preserveComments: 'some',
banner: ['/*!', ' * <%= pkg.name %> <%= pkg.version %>', ' * <%= pkg.homepage %>', ' * Copyright <%= grunt.template.today("yyyy") %>, <%= pkg.author %>', ' * Licensed under: <%= pkg.licenses.type %> (<%= pkg.licenses.url %>)\n */\n\n'].join('\n'),
enclose: {
angular: 'angular'
}
},
files: {
'dist/angular-dateparser.js': ['dateparser.js']
'dist/angular-dateparser.js': ['dateparser.js', 'dateparser.directive.js']
}
},
production: {
prod: {
options: {
sourceMap: true,
mangle: true,
compress: {
drop_console: true
},
preserveComments: 'some'
preserveComments: false,
banner: '/*! <%= pkg.name %> <%= pkg.version %> | ' +
'(c) <%= grunt.template.today("yyyy") %>, <%= pkg.author %> | ' +
'<%= pkg.licenses.type %> (<%= pkg.licenses.url %>) */'
},
files: {
'dist/angular-dateparser.min.js': ['dateparser.js']
'dist/angular-dateparser.min.js': ['dist/angular-dateparser.js']
}
}
},
Expand All @@ -54,6 +61,6 @@ module.exports = function ( grunt ) {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-clean');

grunt.registerTask('default', ['karma:continuous']);
grunt.registerTask('build', ['karma:continuous', 'clean', 'uglify']);
};
grunt.registerTask('default', ['karma:single']);
grunt.registerTask('build', [ 'karma:single', 'clean', 'uglify']);
};
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "angular-dateParser",
"version": "1.0.9",
"version": "1.0.10",
"homepage": "https://github.com/dnasir/angular-dateParser",
"authors": [
"Dzulqarnain Nasir"
Expand Down
18 changes: 8 additions & 10 deletions dateparser.directive.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ angular.module('dateParserDirective', ['dateParser'])
ngModel.$render();
});

var parseDate = function(viewValue) {
ngModel.$parsers.unshift(function(viewValue) {
var date = $dateParser(viewValue, dateFormat);

if(isNaN(date)) {
Expand All @@ -21,20 +21,18 @@ angular.module('dateParserDirective', ['dateParser'])
}

return date;
};
ngModel.$parsers.unshift(parseDate);
});

// Make sure we render using our format on init
ngModel.$render = function() {
var date = ngModel.$modelValue ? dateFilter(ngModel.$modelValue, dateFormat) : '';
element.val(date);
element.val(ngModel.$modelValue ? dateFilter(ngModel.$modelValue, dateFormat) : undefined);
scope.ngModel = ngModel.$modelValue;
};

element.bind('input change keyup', function() {
scope.$apply(function() {
scope.ngModel = ngModel.$modelValue;
});
});
// Format the new model value before it is displayed in the editor
ngModel.$formatters.push(function(modelValue) {
return modelValue ? dateFilter(modelValue, dateFormat) : '';
});
}
};
}]);
11 changes: 0 additions & 11 deletions dateparser.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
/*!
* Angular DateParser 1.0.9
* https://github.com/dnasir/angular-dateParser
*
* Copyright 2013, Dzulqarnain Nasir
* http://www.dnasir.com
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/

angular.module('dateParser', [])
.factory('dateParserHelpers', [function() {

Expand Down
Loading

0 comments on commit f573ae5

Please sign in to comment.