Coder Social home page Coder Social logo

mdomygit / flagstrap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from blazeworx/flagstrap

0.0 0.0 0.0 131 KB

A lightwieght jQuery plugin for creating Bootstrap 3 compatible country select boxes with flags

Home Page: http://blazeworx.github.io/flagstrap

License: MIT License

JavaScript 100.00%

flagstrap's Introduction

Flagstrap

A lightwieght jQuery plugin for creating Bootstrap 3 compatible country select boxes with flags.

Flagstrap Demo

Demo

http://blazeworx.github.io/flagstrap

Usage

Basic

<form class="form-horizontal">
	<div class="form-group">
        <label>Select Country</label><br>
        <div class="flagstrap" data-input-name="country"></div>
    </div>
</form>
<script>
    $('.flagstrap').flagStrap();
</script>

Options

Using Data Attributes

This example will create a Flagstrap Dropdown giving the input field the name of country with all countries available and Germany pre selected and in a scrollable dropdown with max-height of 250px.

<form>
    <div class="form-group">
        <label>Select Country</label><br>
        <div id="flagstrap2"
             data-input-name="country2"
             data-selected-country="DE"
             data-button-size="btn-md"
             data-button-type="btn-default"
             data-scrollable-height="250px"
             data-scrollable="true">
        </div>
    </div>
</form>
<script>
    $('#flagstrap2').flagStrap();
</script>
Using Instance Options

This example will create a Flagstrap Dropdown giving the input field the name of country with only Australia, USA and Canada as available options and no pre selection.

<form class="form-horizontal">
    <div class="form-group">
        <label>Select Country</label><br>
        <div id="flagstrap3"></div>
    </div>
</form>
<script>
    $('#flagstrap3').flagStrap({
        countries: {
            "AU": "Australia",
            "GB": "United Kingdom",
            "US": "United States"
        },
        inputName: 'country',
        buttonSize: "btn-lg",
        buttonType: "btn-primary",
        labelMargin: "20px",
        scrollable: false,
        scrollableHeight: "350px",
        onSelect: function(value, element) {
            //
        },
        placeholder: {
            value: "",
            text: "Please select a country"
        }
    });
</script>

Options

Name Type Default Description
inputName string uniquely generated the `name` attribute for the actual `select` input
inputId string uniquely generated the `id` attribute for the actual `select` input
buttonSize string "btn-md" The bootstrap button size `class` for this drop down
buttonType string "btn-default" The bootstrap button type `class` for this drop down
labelMargin string "20px" The `margin` between `flag` and `text label`
scrollable boolean false Scrollable or full height drop down
scrollableHeight string "250px" `max-height` for the scrollable drop down
countries (optional) object (all) Only show specific countries
Example:

{"GB": "United Kingdom", "US": "United States"}

will only show the USA and UK.
onSelect (optional) function null This callback gets called each time the select is changed. It receives two parameters, the new value, and the select element.
placeholder bool|object {value: "", text: "Please select a country"} Set the placeholder value and text. To disable the placeholder define as (boolean) false.

Contributors

This project was created by Alex Carter. I owe many thanks to the following people who have helped make flagstrap even better.

flagstrap's People

Contributors

blazeworx avatar sixlive avatar haruair avatar jriquelmeit avatar 0xrnato avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.