diff --git a/Gruntfile.js b/Gruntfile.js
index 9c51abed..67cff4f2 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -15,7 +15,6 @@ module.exports = function (grunt) {
// Lint & run unit tests in Karma
// Just running `$ grunt watch` will only lint your code; to run tests
// on watch, use `$ grunt watch:karma` to start a Karma server first
- files: ['src/select2.js', 'test/select2Spec.js'],
tasks: ['jshint', 'karma:unit:run']
}
},
@@ -37,8 +36,8 @@ module.exports = function (grunt) {
jshint: {
all:[
'gruntFile.js',
- 'angucomplete.js',
- 'test/**/*Spec.js'
+ 'angucomplete-alt.js',
+ 'test/**/*.spec.js'
],
options: {
jshintrc: '.jshintrc'
diff --git a/README.md b/README.md
index e6f27737..e0319e61 100644
--- a/README.md
+++ b/README.md
@@ -1,9 +1,9 @@
-angucomplete-extra
+angucomplete-alt
============
-A simple but powerful AngularJS directive that allows you to quickly create autocomplete boxes that pull data either from a server or local variable.
+This is a fork of Daryl Rowland's angucomplete (https://github.com/darylrowland/angucomplete) with a bit of tweaks here and there.
-To see a demo go here: http://ghiden.github.io/angucomplete-extra
+To see a demo go here: http://ghiden.github.io/angucomplete-alt
###Key Features
* Show just a title, a title and a description or a title, description and image in your autocomplete list
@@ -16,23 +16,23 @@ To see a demo go here: http://ghiden.github.io/angucomplete-extra
* Clear on selection: when you select an item, input field is cleared.
### Getting Started
-Download the code, and include the angucomplete.js file in your page. Then add the angucomplete module to your Angular App file, e.g.
+Download the code, and include the angucomplete-alt.js file in your page. Then add the angucomplete-alt module to your Angular App file, e.g.
```html
-var app = angular.module('app', ["angucomplete"]);
+var app = angular.module('app', ["angucomplete-alt"]);
```
### Local Usage
```html
-
+ input-class="form-control form-control-small"/>
```
### Remote Usage
@@ -41,13 +41,13 @@ var app = angular.module('app', ["angucomplete"]);
+ selected-object="testObj"
+ remote-url="http://myserver.com/api/user/find?s="
+ remote-url-data-field="results"
+ title-field="firstName,surname"
+ description-field="email"
+ image-field="profilePic"
+ input-class="form-control form-control-small"/>
```
### Description of attributes
@@ -56,16 +56,16 @@ var app = angular.module('app', ["angucomplete"]);
| id | A unique ID for the field | Yes | members |
| placeholder | Placeholder text for the search field | No | Search members |
| pause | The time to wait (in milliseconds) before searching when the user enters new characters | No | 400 |
-| selectedObject | Where to store the selected object in your model/controller (like ng-model) | Yes | myObject |
-| url | The remote URL to hit to query for results in JSON. angucomplete will automatically append the search string on the end of this, so it must be a GET request | No | http://myserver.com/api/users/find?searchstr= |
-| datafield | The name of the field in the JSON object returned back that holds the Array of objects to be used for the autocomplete list. | No | results |
-| titlefield | The name of the field in the JSON objects returned back that should be used for displaying the title in the autocomplete list. Note, if you want to combine fields together, you can comma separate them here (e.g. for a first and last name combined) | Yes | firstName,lastName |
-| descriptionfield | The name of the field in the JSON objects returned back that should be used for displaying the description in the autocomplete list | No | twitterUsername |
-| imagefield | The name of the field in the JSON objects returned back that should be used for displaying an image in the autocomplete list | No | pic |
+| selected-object | Where to store the selected object in your model/controller (like ng-model) | Yes | myObject |
+| remote-url | The remote URL to hit to query for results in JSON. angucomplete will automatically append the search string on the end of this, so it must be a GET request | No | http://myserver.com/api/users/find?searchstr= |
+| remote-url-data-field | The name of the field in the JSON object returned back that holds the Array of objects to be used for the autocomplete list. | No | results |
+| title-field | The name of the field in the JSON objects returned back that should be used for displaying the title in the autocomplete list. Note, if you want to combine fields together, you can comma separate them here (e.g. for a first and last name combined) | Yes | firstName,lastName |
+| description-field | The name of the field in the JSON objects returned back that should be used for displaying the description in the autocomplete list | No | twitterUsername |
+| image-field | The name of the field in the JSON objects returned back that should be used for displaying an image in the autocomplete list | No | pic |
| minlength | The minimum length of string required before searching | No | 3 |
-| inputclass | The classes to use for styling the input box | No | form-control |
-| localdata | The local data variable to use from your controller. Should be an array of objects | No | countriesList |
-| searchfields | The fields from your local data to search on (comma separate them) | No | title,description |
-| dataformatfn | A function that takes a query string and returns parameter(s) for GET. It should take the query string as argument and returns a key-value object.| No | Suppose if you need to send a query keyword and a timestamp to search API, you can write a function like this in the parent scope. $scope.dataFormatFn = function(str) { return {q: str, timestamp: +new Date()}; } |
-| clearselected | To clear out input field upon selecting an item, set this attribute to true. | No | true |
+| input-class | The classes to use for styling the input box | No | form-control |
+| local-data | The local data variable to use from your controller. Should be an array of objects | No | countriesList |
+| search-fields | The fields from your local data to search on (comma separate them) | No | title,description |
+| remote-url-request-formatter | A function that takes a query string and returns parameter(s) for GET. It should take the query string as argument and returns a key-value object.| No | Suppose if you need to send a query keyword and a timestamp to search API, you can write a function like this in the parent scope. $scope.dataFormatFn = function(str) { return {q: str, timestamp: +new Date()}; } |
+| clear-selected | To clear out input field upon selecting an item, set this attribute to true. | No | true |
diff --git a/angucomplete.css b/angucomplete-alt.css
similarity index 100%
rename from angucomplete.css
rename to angucomplete-alt.css
diff --git a/angucomplete-alt.js b/angucomplete-alt.js
new file mode 100644
index 00000000..6f9ca2df
--- /dev/null
+++ b/angucomplete-alt.js
@@ -0,0 +1,252 @@
+/**
+ * angucomplete-extra
+ * Autocomplete directive for AngularJS
+ * This is a fork of Daryl Rowland's angucomplete with some extra features.
+ * By Hidenari Nozaki
+ */
+'use strict';
+
+angular.module('angucomplete-alt', [] ).directive('angucompleteAlt', ['$parse', '$http', '$sce', '$timeout', function ($parse, $http, $sce, $timeout) {
+ var KEY_DW = 40,
+ KEY_UP = 38,
+ KEY_ES = 27,
+ KEY_EN = 13,
+ KEY_BS = 8,
+ MIN_LENGTH = 3,
+ PAUSE = 500;
+
+ return {
+ restrict: 'EA',
+ scope: {
+ selectedObject: '=',
+ localData: '=',
+ remoteUrlRequestFormatter: '=',
+ id: '@',
+ placeholder: '@',
+ remoteUrl: '@',
+ remoteUrlDataField: '@',
+ titleField: '@',
+ descriptionField: '@',
+ imageField: '@',
+ inputClass: '@',
+ pause: '@',
+ searchFields: '@',
+ minlength: '@',
+ matchClass: '@',
+ clearSelected: '@'
+ },
+ template: '