aboutsummaryrefslogblamecommitdiffstats
path: root/library/stylish_select/index.html
blob: b711c09f68bcf009f0858c545cb7b3d01575458c (plain) (tree)

























































































































































































































































































































                                                                                                                                                                                                     
<!DOCTYPE html>
<html>
    <head>
        <title>jQuery Stylish Select 0.4.9 plugin examples</title>
        <meta http-equiv="content-type" content="text/html;charset=utf-8" />
        <link rel="stylesheet" type="text/css" href="stylish-select.css" />

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
        <script src="jquery.stylish-select.js" type="text/javascript"></script>

        <script type="text/javascript">
            $(function(){

                $('#my-dropdown, #my-dropdown2, #my-dropdown3, #my-dropdown4, #my-dropdown5, #my-dropdown6, #my-dropdown7, #my-dropdown8, #my-dropdown9').sSelect();

                //set max height
                $('#my-dropdownCountries').sSelect({ddMaxHeight: '300px'});

                //set value on click
                $('#setVal').click(function(){
                    $('#my-dropdown5').getSetSSValue('4');
                });

                //get value on click
                $('#getVal').click(function(){
                    alert('The value is: '+$('#my-dropdown5').getSetSSValue());
                });

                //alert change event
                $('#my-dropdownChange').sSelect().change(function(){alert('changed')});

                //add options to select and update
                $('#addOptions').click(function(){
                    $('#my-dropdown6').append('<option value="newOpt">New Option</option>').resetSS();
                    return false;
                });

            });
        </script>

        <style type="text/css">
            body {font-family:Arial, Helvetica, sans-serif; font-size:12px;}
            .selCont {clear:both; margin-bottom:20px; padding-bottom:40px; float:left; border-bottom:dotted 1px #000; width:600px;}
        </style>

    </head>
    <body>
        <form action="" method="post">
            <h1>Stylish Select 0.4.9</h1>
            <h2>A cross-browser, accessible alternative to the standard form element which can be fully customised with CSS</h2>
            <p>Stylish Select attempts to replicate the functionality of the browser default select box as closely as possible with support for keyboard navigation, and intelligent positioning.</p>
            <p>Stylish Select aims to have a minimal code footprint and weighs in at just over 3KB when minified.</p>
            <a href="http://github.com/scottdarby/Stylish-Select">Get latest source code from GitHub</a>
            <h2>Usage</h2>
            <p>First, include the stylesheet, jQuery and the stylish select .js file in your html head tag.</p>
            <p>The plugin can be used to replace any select with the following:</p>
            <pre class="brush: javascript">
$(document).ready(function(){
$('#my-dropdown').sSelect();
});
            </pre>
            <div class="selCont">
                <h2>Simplest example, option selected by default</h2>
                <p>You can use the alphabetical and arrow keys to navigate the list as you would a browser default select.</p>
                <select id="my-dropdown" name="my-dropdown">
                    <option value="1">A cappella</option>
                    <option value="test">Acid Jazz</option>
                    <option value="3">Big Band</option>
                    <option value="4">Big Beat</option>
                    <option value="5">Cakewalk</option>
                    <option value="6">Calenda</option>
                    <option value="7">Dark ambient</option>
                    <option value="8">Dark cabaret</option>
                    <option value="9">Chalk &amp; Cheese</option>
                </select>
            </div>
            <div class="selCont">
                <h2>Change event</h2>
                <p>Stylish Select alters the original select on the page, so you can access it's change event:</p>
                <pre class="brush: javascript">
//change event
$('#my-dropdownChange').sSelect().change(function(){alert('changed')});
                </pre>
                <select id="my-dropdownChange" name="my-dropdown">
                    <option value="1">A cappella</option>
                    <option value="test">Acid Jazz</option>
                    <option value="3" selected="selected">Big Band</option>
                    <option value="4">Big Beat</option>
                    <option value="5">Cakewalk</option>
                    <option value="6">Calenda</option>
                    <option value="7">Dark ambient</option>
                    <option value="8">Dark cabaret</option>
                </select>
            </div>
            <div class="selCont">
                <h2>Grouped options</h2>
                <p>Stylish Select supports optgroups and also optgroups and options together.</p>
                <select id="my-dropdown2" name="my-dropdown">
                    <option>Please select</option>
                    <optgroup label="Tool">
                        <option value="1">Opiate</option>
                        <option value="2">Undertow</option>
                        <option value="3">Aenima</option>
                        <option value="4">Lateralus</option>
                    </optgroup>
                    <optgroup label="A Tribe Called Quest">
                        <option value="5">People's Instinctive Travels and the Paths of Rhythm</option>
                        <option value="6">The Low End Theory</option>
                        <option selected="selected" value="7">Midnight Marauders</option>
                        <option value="8">Beats, Rhymes and Life</option>
                        <option value="9">The Love Movement</option>
                    </optgroup>
                </select>
            </div>
            <div id="get-set" class="selCont">
                <h2>Getting/setting the value</h2>
                <pre class="brush: javascript">
//set value
$('#setVal').click(function(){
$('#my-dropdown5').getSetSSValue(4);
});

//get value
$('#getVal').click(function(){
alert('The value is: '+$('#my-dropdown5').getSetSSValue());
});
                </pre>
                <p><a id="setVal" href="javascript:void(0)">Set value to 4</a></p>
                <p><a id="getVal" href="javascript:void(0)">Get value</a></p>
                <select id="my-dropdown5" name="my-dropdown">
                    <option value="1">Lorem</option>
                    <option value="2">Ipsum</option>
                    <option value="3">Dolor</option>
                    <option value="4">Sit</option>
                    <option value="5">Amet</option>
                    <option value="6">Consectetuer</option>
                    <option value="7">Adipiscing</option>
                </select>
            </div>
            <div id="update" class="selCont">
                <h2>Add new options to Stylish Select</h2>
                <pre class="brush: javascript">
//add options to select and update
$('#addOptions').click(function(){
$('#my-dropdown6').append('&lt;option value="newOpt">New Option&lt;/option&gt;').resetSS();
});
                </pre>
                <p>If you add or remove options from the initial select element on the page, be sure to call the .resetSS() method on the select to update the Stylish Select replacement.</p>

                <p><a id="addOptions" href="javascript:void(0)">Add new options to select and update</a></p>
                <select id="my-dropdown6" name="my-dropdown">
                    <option value="1">Lorem</option>
                    <option value="2">Ipsum</option>
                    <option value="3">Dolor</option>
                    <option value="4">Sit</option>
                    <option value="5">Amet</option>
                    <option value="6">Consectetuer</option>
                    <option value="7">Adipiscing</option>
                    <option value="7">Adipiscing</option>
                    <option value="7">Adipiscing</option>
                    <option value="7">Adipiscing</option>
                </select>
            </div>
            <div class="selCont">
                <h2>Max-height for large lists</h2>
                <pre class="brush: javascript">
$('#my-dropdown').sSelect({ddMaxHeight: '300px'});
                </pre>
                <select id="my-dropdownCountries" name="my-dropdown">
                    <option value="1">Afghanistan</option>
                    <option value="1">Akrotiri</option>
                    <option value="1">Albania</option>
                    <option value="1">Algeria</option>
                    <option value="1">American Samoa</option>
                    <option value="1">Andorra</option>
                    <option value="1">Angola</option>
                    <option value="1">Anguilla</option>
                    <option value="1">Antarctica</option>
                    <option value="1">Antigua and Barbuda</option>
                    <option value="1">Argentina</option>
                    <option value="1">Armenia</option>
                    <option value="1">Aruba</option>
                    <option value="1">Ashmore and Cartier Islands</option>
                    <option value="1">Australia</option>
                    <option value="1">Austria</option>
                    <option value="1">Azerbaijan</option>
                    <option value="1">Bahamas, The</option>
                    <option value="1">Bahrain</option>
                    <option value="1">Bangladesh</option>
                    <option value="1">Barbados</option>
                    <option value="1">Bassas da India</option>
                    <option value="1">Belarus</option>
                    <option value="1">Belgium</option>
                    <option value="1">Belize</option>
                    <option value="1">Benin</option>
                    <option value="1">Bermuda</option>
                    <option value="1">Bhutan</option>
                    <option value="1">Bolivia</option>
                    <option value="1">Bosnia and Herzegovina</option>
                    <option value="1">Botswana</option>
                    <option value="1">Bouvet Island</option>
                    <option value="1">Brazil</option>
                    <option value="1">British Indian Ocean Territory</option>
                    <option value="1">British Virgin Islands</option>
                    <option value="1">Brunei</option>
                    <option value="1">Bulgaria</option>
                    <option value="1">Burkina Faso</option>
                    <option value="1">Burma</option>
                    <option value="1">Burundi</option>
                    <option value="1">Cambodia</option>
                    <option value="1">Cameroon</option>
                    <option value="1">Canada</option>
                    <option value="1">Cape Verde</option>
                    <option value="1">Cayman Islands</option>
                    <option value="1">Central African Republic</option>
                    <option value="1">Chad</option>
                    <option value="1">Chile</option>
                    <option value="1">China</option>
                    <option value="1">Christmas Island</option>
                    <option value="1">Clipperton Island</option>
                    <option value="1">Cocos (Keeling) Islands</option>
                    <option value="1">Colombia</option>
                    <option value="1">Comoros</option>
                    <option value="1">Congo, Democratic Republic of the</option>
                    <option value="1">Congo, Republic of the</option>
                    <option value="1">Cook Islands</option>
                    <option value="1">Coral Sea Islands</option>
                    <option value="1">Costa Rica</option>
                    <option value="1">Cote d'Ivoire</option>
                    <option value="1">Croatia</option>
                    <option value="1">Cuba</option>
                    <option value="1">Cyprus</option>
                    <option value="1">Czech Republic</option>
                    <option value="1">Denmark</option>
                    <option value="1">Dhekelia</option>
                    <option value="1">Djibouti</option>
                    <option value="1">Dominica</option>
                    <option value="1">Dominican Republic</option>
                    <option value="1">Ecuador</option>
                    <option value="1">Egypt</option>
                    <option value="1">El Salvador</option>
                    <option value="1">Equatorial Guinea</option>
                    <option value="1">Eritrea</option>
                    <option value="1">Estonia</option>
                    <option value="1">Ethiopia</option>
                    <option value="1">Europa Island</option>
                    <option value="1">Falkland Islands (Islas Malvinas)</option>
                    <option value="1">Faroe Islands</option>
                    <option value="1">Fiji</option>
                    <option value="1">Finland</option>
                    <option value="1">France</option>
                    <option value="1">French Guiana</option>
                </select>
            </div>
            <div class="selCont">
                <h2>Intelligent positioning</h2>
                <p>Stylish Select will always remain visible on the page.</p>
                <select id="my-dropdown4" name="my-dropdown">
                    <optgroup label="Tool">
                        <option value="1">Opiate</option>
                        <option value="2">Undertow</option>
                        <option value="3">Aenima</option>
                        <option value="4">Lateralus</option>
                    </optgroup>
                    <optgroup label="A Tribe Called Quest">
                        <option value="5">People's Instinctive Travels and the Paths of Rhythm</option>
                        <option value="6">The Low End Theory</option>
                        <option value="7" selected="selected">Midnight Marauders</option>
                        <option value="8">Beats, Rhymes and Life</option>
                        <option value="9">The Love Movement</option>
                    </optgroup>
                </select>
            </div>
            <div class="selCont">
                <h2>Disabled Select</h2>
                <select disabled="disabled" id="my-dropdown7" name="my-dropdown">
                    <option value="1">Opiate</option>
                    <option value="2">Undertow</option>
                    <option value="3">Aenima</option>
                    <option value="4">Lateralus</option>
                    <option value="9">The Love Movement</option>
                </select>
            </div>
            <div class="selCont">
                <h2>Disabled Options</h2>
                <select id="my-dropdown8" name="my-dropdown">
                    <option value="1">Opiate</option>
                    <option disabled="disabled" value="2">Undertow</option>
                    <option value="3">Aenima</option>
                    <option selected="selected" value="4">Lateralus</option>
                    <option value="9">The Love Movement</option>
                </select>
            </div>
            <div class="selCont">
                <h2>Disabled Grouped options</h2>
                <select id="my-dropdown9" name="my-dropdown">
                    <optgroup label="Tool" disabled="disabled">
                        <option value="1">Opiate</option>
                        <option value="2">Undertow</option>
                        <option value="3">Aenima</option>
                        <option value="4">Lateralus</option>
                    </optgroup>
                    <optgroup label="A Tribe Called Quest">
                        <option value="5">People's Instinctive Travels and the Paths of Rhythm</option>
                        <option value="6">The Low End Theory</option>
                        <option value="7" selected="selected">Midnight Marauders</option>
                        <option value="8">Beats, Rhymes and Life</option>
                        <option value="9">The Love Movement</option>
                    </optgroup>
                </select>
            </div>
        </form>
    </body>
</html>