|
13 | 13 | })(function($, window, document, undefined) { |
14 | 14 | "use strict"; |
15 | 15 | var pluginName = "countrySelect", id = 1, // give each instance its own ID for namespaced event handling |
16 | | - defaults = { |
17 | | - // Default country |
18 | | - defaultCountry: "", |
19 | | - // Position the selected flag inside or outside of the input |
20 | | - defaultStyling: "inside", |
21 | | - // Display only these countries |
22 | | - onlyCountries: [], |
23 | | - // The countries at the top of the list. Defaults to United States and United Kingdom |
24 | | - preferredCountries: [ "us", "gb" ] |
25 | | - }, keys = { |
26 | | - UP: 38, |
27 | | - DOWN: 40, |
28 | | - ENTER: 13, |
29 | | - ESC: 27, |
30 | | - PLUS: 43, |
31 | | - A: 65, |
32 | | - Z: 90 |
33 | | - }, windowLoaded = false; |
| 16 | + defaults = { |
| 17 | + // Default country |
| 18 | + defaultCountry: "", |
| 19 | + // Position the selected flag inside or outside of the input |
| 20 | + defaultStyling: "inside", |
| 21 | + // Display only these countries |
| 22 | + onlyCountries: [], |
| 23 | + // The countries at the top of the list. Defaults to United States and United Kingdom |
| 24 | + preferredCountries: [ "us", "gb" ] |
| 25 | + }, keys = { |
| 26 | + UP: 38, |
| 27 | + DOWN: 40, |
| 28 | + ENTER: 13, |
| 29 | + ESC: 27, |
| 30 | + PLUS: 43, |
| 31 | + A: 65, |
| 32 | + Z: 90 |
| 33 | + }, windowLoaded = false; |
34 | 34 | // keep track of if the window.load event has fired as impossible to check after the fact |
35 | | - $(window).load(function() { |
| 35 | + $(window).on('load', function() { |
36 | 36 | windowLoaded = true; |
37 | 37 | }); |
38 | 38 | function Plugin(element, options) { |
|
249 | 249 | // decide where to position dropdown (depends on position within viewport, and scroll) |
250 | 250 | _setDropdownPosition: function() { |
251 | 251 | var inputTop = this.countryInput.offset().top, windowTop = $(window).scrollTop(), |
252 | | - dropdownFitsBelow = inputTop + this.countryInput.outerHeight() + this.dropdownHeight < windowTop + $(window).height(), dropdownFitsAbove = inputTop - this.dropdownHeight > windowTop; |
| 252 | + dropdownFitsBelow = inputTop + this.countryInput.outerHeight() + this.dropdownHeight < windowTop + $(window).height(), dropdownFitsAbove = inputTop - this.dropdownHeight > windowTop; |
253 | 253 | // dropdownHeight - 1 for border |
254 | 254 | var cssTop = !dropdownFitsBelow && dropdownFitsAbove ? "-" + (this.dropdownHeight - 1) + "px" : ""; |
255 | 255 | this.countryList.css("top", cssTop); |
|
517 | 517 | } |
518 | 518 | }; |
519 | 519 | /******************** |
520 | | - * STATIC METHODS |
521 | | - ********************/ |
| 520 | + * STATIC METHODS |
| 521 | + ********************/ |
522 | 522 | // get the country data object |
523 | 523 | $.fn[pluginName].getCountryData = function() { |
524 | 524 | return allCountries; |
|
0 commit comments