Skip to content

Commit ced7662

Browse files
authored
Merge pull request #13 from ideal-postcodes/3.0.5
3.0.5
2 parents 8bf69c3 + 3da988b commit ced7662

26 files changed

Lines changed: 230 additions & 61 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

.npmignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
examples/
2+
test/
3+
libs/

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
language: node_js
22
node_js:
3-
- 0.10
3+
- 6.9
44
before_install: npm install -g grunt-cli

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [3.0.5] 2017-11-02
4+
- Added placeholder to input field. The placeholder is determined by the `placeholder_label` attribute
5+
- Added `onDropdownDestroyed` destroyed callback, invoked when dropdown is removed from DOM following a new search
6+
37
## [3.0.4] 2016-07-29
48
- Added shouldLookupTrigger callback
59

Gruntfile.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ module.exports = function(grunt) {
3939
'<%= grunt.template.today("yyyy-mm-dd") %>\n' +
4040
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
4141
'<%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
42-
' Licensed <%= _.pluck(pkg.licenses, "type").join(", ") %> */\n',
42+
' Licensed <%= _.map(pkg.licenses, "type").join(", ") %> */\n',
4343
// Task configuration.
4444
clean: {
4545
files: ['dist']

README.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@ Run automated tests with
6464
grunt test
6565
```
6666

67-
Please use jQuery 1.9.x or higher. This plugin has been tested against jQuery 1.9.x, 1.10.x, 1.11.x, 2.0.x, 2.1.x, 2.2.x and 3.0.x
67+
Please use jQuery 1.9.x or higher. This plugin has been tested against jQuery 1.9.x, 1.10.x, 1.11.x, 2.0.x, 2.1.x, 2.2.x, 3.0.x. 3.1.x and 3.2.x
68+
69+
You may run the plugin locally and test in your browser
70+
71+
```bash
72+
$ npm start # starts a HTTP server
73+
74+
# Navigate to the `examples` folder and select an example in a *.html file
75+
```
6876

6977
Our test postcodes are:
7078
- **ID1 1QD** Returns a successful postcode lookup response (2000)

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jquery.postcodes",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"authors": [
55
"support@ideal-postcodes.co.uk"
66
],

dist/postcodes.js

Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
/*! Ideal Postcodes jQuery Plugin - v3.0.4 - 2016-07-29
1+
/*! Ideal Postcodes jQuery Plugin - v3.0.5 - 2017-11-16
22
* https://github.com/ideal-postcodes/jquery.postcodes
3-
2016 Ideal Postcodes; Licensed MIT */
3+
2017 Ideal Postcodes; Licensed MIT */
44
(function($) {
55
"use strict";
66
// Cache for all new instances of the plugin
@@ -52,6 +52,7 @@
5252
input: undefined,
5353
$input: undefined,
5454
input_label: "Please enter your postcode",
55+
placeholder_label: "",
5556
input_muted_style: "color:#CBCBCB;",
5657
input_class: "",
5758
input_id: "idpc_input",
@@ -130,6 +131,7 @@
130131
onAddressesRetrieved: undefined, // When a lookup succeeds with a list of addresses
131132
onAddressSelected: undefined, // User has clicked an address in dropdown
132133
onDropdownCreated: undefined, // When the address selection dropdown is inserted to DOM
134+
onDropdownDestroyed: undefined, // When the address selection dropdown is removed (following new search)
133135
onLookupTriggered: undefined, // When user clicks the button to trigger a lookup
134136
shouldLookupTrigger: undefined, //
135137
onSearchError: undefined, // When a request succeeds but the API returns an error code
@@ -138,6 +140,22 @@
138140
tags: undefined
139141
};
140142

143+
/*
144+
* Utility method to remove organisation from Address result
145+
*
146+
* All organisations will have their name as first line
147+
*/
148+
var removeOrganisation = function (address) {
149+
if (address.organisation_name.length !== 0 &&
150+
(address.line_1 === address.organisation_name)) {
151+
// Shift addresses up
152+
address.line_1 = address.line_2;
153+
address.line_2 = address.line_3;
154+
address.line_3 = "";
155+
}
156+
return address;
157+
};
158+
141159
function AddressFinderController (options) {
142160
// Load in defaults
143161
this.config = {};
@@ -183,7 +201,8 @@
183201
this.$input = $('<input />', {
184202
type: "text",
185203
id: this.input_id,
186-
value: this.input_label
204+
value: this.input_label,
205+
placeholder: this.placeholder_label
187206
})
188207
.appendTo(this.$context)
189208
.addClass(this.input_class)
@@ -443,6 +462,9 @@
443462
if (this.$dropdown && this.$dropdown.length) {
444463
this.$dropdown.remove();
445464
delete this.$dropdown;
465+
if (this.onDropdownDestroyed) {
466+
this.onDropdownDestroyed.call(this);
467+
}
446468
}
447469

448470
if (!data) {
@@ -548,23 +570,6 @@
548570
}
549571
};
550572

551-
/*
552-
* Utility method to remove organisation from Address result
553-
*
554-
* All organisations will have their name as first line
555-
*/
556-
557-
var removeOrganisation = function (address) {
558-
if (address.organisation_name.length !== 0 &&
559-
(address.line_1 === address.organisation_name)) {
560-
// Shift addresses up
561-
address.line_1 = address.line_2;
562-
address.line_2 = address.line_3;
563-
address.line_3 = "";
564-
}
565-
return address;
566-
};
567-
568573
var extractError = function (data) {
569574
return data.code + " - " + data.message;
570575
};

dist/postcodes.min.js

Lines changed: 4 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/address_search_fallback.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
<head>
44
<meta charset="utf-8">
55
<title>Ideal Postcodes Example</title>
6+
<LINK href="styling.css" rel="stylesheet" type="text/css">
67
<LINK href="bootstrap.css" rel="stylesheet" type="text/css">
78
<LINK href="bootstrap-theme.css" rel="stylesheet" type="text/css">
89
<script src="//code.jquery.com/jquery-1.9.1.min.js"></script>

0 commit comments

Comments
 (0)