diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33eeb2c --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Dependency directory +# Commenting this out is preferred by some people, see +# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git- +node_modules + +build \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js new file mode 100644 index 0000000..4bd7af6 --- /dev/null +++ b/Gruntfile.js @@ -0,0 +1,32 @@ +module.exports = function(grunt) { + + // Project configuration. + grunt.initConfig({ + pkg: grunt.file.readJSON('package.json'), + ngmin:{ + main:{ + src: [ + "src/ngAutocomplete.js" + ], + dest: "build/<%= pkg.name %>.ngmin.js" + } + }, + uglify: { + options: { + banner: '/*! <%= pkg.name %> <%= grunt.template.today("yyyy-mm-dd") %> */\n' + }, + build: { + src: 'build/<%= pkg.name %>.ngmin.js', + dest: 'dist/<%= pkg.name %>.min.js' + } + } + }); + + // Load the plugin that provides the "uglify" task. + grunt.loadNpmTasks('grunt-contrib-uglify'); + grunt.loadNpmTasks('grunt-ngmin'); + + // Default task(s). + grunt.registerTask('default', ['ngmin:main','uglify']); + +}; \ No newline at end of file diff --git a/bower.json b/bower.json index 8b61562..b42970d 100644 --- a/bower.json +++ b/bower.json @@ -5,4 +5,5 @@ "dependencies": { "angular": ">=1.2.0" } + } \ No newline at end of file diff --git a/dist/ngAutocomplete.min.js b/dist/ngAutocomplete.min.js new file mode 100644 index 0000000..0676633 --- /dev/null +++ b/dist/ngAutocomplete.min.js @@ -0,0 +1,2 @@ +/*! ngAutocomplete 2014-12-12 */ +"use strict";angular.module("ngAutocomplete",[]).directive("ngAutocomplete",function(){return{require:"ngModel",scope:{ngModel:"=",options:"=?",details:"=?"},link:function(a,b,c,d){var e,f=!1,g=function(){e={},a.options&&(f=a.options.watchEnter!==!0?!1:!0,a.options.types?(e.types=[],e.types.push(a.options.types),a.gPlace.setTypes(e.types)):a.gPlace.setTypes([]),a.options.bounds?(e.bounds=a.options.bounds,a.gPlace.setBounds(e.bounds)):a.gPlace.setBounds(null),a.options.country?(e.componentRestrictions={country:a.options.country},a.gPlace.setComponentRestrictions(e.componentRestrictions)):a.gPlace.setComponentRestrictions(null))};void 0==a.gPlace&&(a.gPlace=new google.maps.places.Autocomplete(b[0],{})),google.maps.event.addListener(a.gPlace,"place_changed",function(){var c=a.gPlace.getPlace();void 0!==c&&(void 0!==c.address_components?a.$apply(function(){a.details=c,d.$setViewValue(b.val())}):f&&h(c))});var h=function(c){var e=new google.maps.places.AutocompleteService;c.name.length>0&&e.getPlacePredictions({input:c.name,offset:c.name.length},function(c){if(null==c||0==c.length)a.$apply(function(){a.details=null});else{var e=new google.maps.places.PlacesService(b[0]);e.getDetails({reference:c[0].reference},function(c,e){e==google.maps.GeocoderStatus.OK&&a.$apply(function(){d.$setViewValue(c.formatted_address),b.val(c.formatted_address),a.details=c;b.on("focusout",function(){b.val(c.formatted_address),b.unbind("focusout")})})})}})};d.$render=function(){var a=d.$viewValue;b.val(a)},a.watchOptions=function(){return a.options},a.$watch(a.watchOptions,function(){g()},!0)}}}); \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..e4df5a2 --- /dev/null +++ b/package.json @@ -0,0 +1,32 @@ +{ + "name": "ngAutocomplete", + "version": "1.0.0", + "description": "Google Places Api autocomplete for angular JS", + "main": "ngAutocomplete.js", + "directories": { + "example": "examples" + }, + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "https://github.com/wpalahnuk/ngAutocomplete" + }, + "keywords": [ + "angular-js", + "google-places-api", + "autocomplete" + ], + "author": "https://github.com/wpalahnuk", + "license": "MIT", + "bugs": { + "url": "https://github.com/wpalahnuk/ngAutocomplete/issues" + }, + "homepage": "https://github.com/wpalahnuk/ngAutocomplete", + "devDependencies": { + "grunt": "~0.4.5", + "grunt-contrib-uglify": "~0.6.0", + "grunt-ngmin": "0.0.3" + } +}