/* ========================================================== * bootstrap-formhelpers-countries.js * https://github.com/vlamanna/BootstrapFormHelpers * ========================================================== * Copyright 2012 Vincent Lamanna * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ========================================================== */ !function ($) { "use strict"; // jshint ;_; /* COUNTRIES CLASS DEFINITION * ====================== */ var BFHCountries = function (element, options) { this.options = $.extend({}, $.fn.bfhcountries.defaults, options) this.$element = $(element) if (this.options.countrylist) { this.countryList = [] this.options.countrylist = this.options.countrylist.split(',') for (var country in BFHCountriesList) { if ($.inArray(country, this.options.countrylist) >= 0) { this.countryList[country] = BFHCountriesList[country] } } } else { this.countryList = BFHCountriesList } if (this.$element.is("select")) { this.addCountries() } if (this.$element.is("span")) { this.displayCountry() } if (this.$element.hasClass("bfh-selectbox")) { this.addBootstrapCountries() } } BFHCountries.prototype = { constructor: BFHCountries , addCountries: function () { var value = this.options.country this.$element.html('') this.$element.append('') for (var country in this.countryList) { this.$element.append('') } this.$element.val(value) } , addBootstrapCountries: function() { var $input , $toggle , $options var value = this.options.country $input = this.$element.find('input[type="hidden"]') $toggle = this.$element.find('.bfh-selectbox-option') $options = this.$element.find('[role=option]') $options.html('') $options.append('