266 lines
9.2 KiB
HTML
266 lines
9.2 KiB
HTML
<html>
|
|
<head>
|
|
|
|
<script src="js/jquery-1.8.1.js"></script>
|
|
<script src="select2-master/select2.js"></script>
|
|
<link href="select2-master/select2.css" rel="stylesheet"/>
|
|
<style>img.flag { height: 10px; width: 15px; padding-right: 10px; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<!-- <div style="height:200px;"></div> -->
|
|
<div style="padding: 10px; margin: 10px;">
|
|
<br/><br/><br/>
|
|
|
|
|
|
|
|
<select id="tst">
|
|
<option value="" selected="selected">Should-be-active option</option>
|
|
<option value="1">Second option</option>
|
|
</select>
|
|
<script>$(function() { $("#tst").select2(); });</script>
|
|
<br/><br/><br/>
|
|
|
|
<input type="text" value="tab!" autofocus>
|
|
<input type="text" id="input">
|
|
<input type="text" value="ooops! skipped selector">
|
|
|
|
<script>
|
|
$("#input").select2({data:[]});
|
|
$("#input").select2({data:[]});
|
|
</script>
|
|
|
|
<br/>
|
|
|
|
<input type="text" size="30"/><br/>
|
|
<label for="e4">Label: </label>
|
|
<div style="white-space: nowrap">
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<select id="e4" style="width:300px" >
|
|
<optgroup label="Alaskan/Hawaiian Time Zone">
|
|
<option value="AK">Alaska</option>
|
|
<option value="HI">Hawaii</option>
|
|
</optgroup>
|
|
<optgroup label="Pacific Time Zone">
|
|
<option value="CA">California</option>
|
|
<option value="NV">Nevada</option>
|
|
<option value="OR">Oregon</option>
|
|
<option value="WA">Washington</option>
|
|
</optgroup>
|
|
<optgroup label="Mountain Time Zone">
|
|
<option value="AZ">Arizona</option>
|
|
<option value="CO">Colorado</option>
|
|
<option value="ID">Idaho</option>
|
|
<option value="MT">Montana</option><option value="NE" selected="selected">Nebraska</option>
|
|
<option value="NM">New Mexico</option>
|
|
<option value="ND">North Dakota</option>
|
|
<option value="UT">Utah</option>
|
|
<option value="WY">Wyoming</option>
|
|
</optgroup>
|
|
<optgroup label="Central Time Zone">
|
|
<option value="AL">Alabama</option>
|
|
<option value="AR">Arkansas</option>
|
|
<option value="IL">Illinois</option>
|
|
<option value="IA">Iowa</option>
|
|
<option value="KS">Kansas</option>
|
|
<option value="KY">Kentucky</option>
|
|
<option value="LA">Louisiana</option>
|
|
<option value="MN">Minnesota</option>
|
|
<option value="MS">Mississippi</option>
|
|
<option value="MO">Missouri</option>
|
|
<option value="OK">Oklahoma</option>
|
|
<option value="SD">South Dakota</option>
|
|
<option value="TX">Texas</option>
|
|
<option value="TN">Tennessee</option>
|
|
<option value="WI">Wisconsin</option>
|
|
</optgroup>
|
|
<optgroup label="Eastern Time Zone">
|
|
<option value="CT">Connecticut</option>
|
|
<option value="DE">Delaware</option>
|
|
<option value="FL">Florida</option>
|
|
<option value="GA">Georgia</option>
|
|
<option value="IN">Indiana</option>
|
|
<option value="ME">Maine</option>
|
|
<option value="MD">Maryland</option>
|
|
<option value="MA">Massachusetts</option>
|
|
<option value="MI">Michigan</option>
|
|
<option value="NH">New Hampshire</option><option value="NJ">New Jersey</option>
|
|
<option value="NY">New York</option>
|
|
<option value="NC">North Carolina</option>
|
|
<option value="OH">Ohio</option>
|
|
<option value="PA">Pennsylvania</option><option value="RI">Rhode Island</option><option value="SC">South Carolina</option>
|
|
<option value="VT">Vermont</option><option value="VA">Virginia</option>
|
|
<option value="WV">West Virginia</option>
|
|
</optgroup>
|
|
</select></div><br/>
|
|
<input type="text" size="30"/><br/>
|
|
<select id="e5" style="width:300px" multiple>
|
|
<option value="AK">Alaska</option>
|
|
<option value="HI">Hawaii</option>
|
|
<option value="CA">California</option>
|
|
<option value="NV">Nevada</option>
|
|
<option value="OR">Oregon</option>
|
|
<option value="WA">Washington</option>
|
|
</select><br/>
|
|
<input type="text" size="30"/><br/>
|
|
|
|
<!--
|
|
<div class="a">INSIDE A</div>
|
|
<div class="b">INSIDE B<input type="text" value="hello" class="c"/></div>
|
|
<script>
|
|
$(function() {
|
|
$(".c").on("focus", function() {
|
|
$(this).detach().appendTo($(".a"));
|
|
this.focus();
|
|
});
|
|
});
|
|
</script>
|
|
-->
|
|
</div>
|
|
|
|
|
|
<input id="filter" multiple style="width: 250px;">
|
|
|
|
<button id='reset' class='btn'>Reset</button>
|
|
|
|
<script>
|
|
$(document).ready(function() {
|
|
|
|
|
|
$('#filter').select2({
|
|
multiple: true,
|
|
data:[{id:0,text:'enhancement'},{id:1,text:'bug'}]
|
|
});
|
|
$('#reset').on('click', function() {
|
|
$('#filter').select2('val','');
|
|
});
|
|
|
|
|
|
function format(state) {
|
|
if (!state.id) return state.text; // optgroup
|
|
return "<img class='flag' src='images/flags/" + state.id.toLowerCase() + ".png'/>" + state.text;
|
|
}
|
|
$("#e5").select2();
|
|
$("#e4").select2({
|
|
formatResult: format,
|
|
formatSelection: format,
|
|
escapeMarkup: function(m) { return m; },
|
|
allowClear:true,
|
|
placeholder: "select a state",
|
|
maximumInputLength:3,
|
|
minimumResultsForSearch: 2
|
|
|
|
});
|
|
});
|
|
</script>
|
|
|
|
<!--
|
|
<label for="e6">Label: </label>
|
|
|
|
<input type="hidden" class="bigdrop" id="e6" style="width:600px" value="16340"/>
|
|
|
|
|
|
|
|
|
|
<script id="script_e6">
|
|
|
|
function movieFormatResult(movie) {
|
|
var markup = "<table class='movie-result'><tr>";
|
|
if (movie.posters !== undefined && movie.posters.thumbnail !== undefined) {
|
|
markup += "<td class='movie-image'><img src='" + movie.posters.thumbnail + "'/></td>";
|
|
}
|
|
markup += "<td class='movie-info'><div class='movie-title'>" + movie.title + "</div>";
|
|
if (movie.critics_consensus !== undefined) {
|
|
markup += "<div class='movie-synopsis'>" + movie.critics_consensus + "</div>";
|
|
}
|
|
else if (movie.synopsis !== undefined) {
|
|
markup += "<div class='movie-synopsis'>" + movie.synopsis + "</div>";
|
|
}
|
|
markup += "</td></tr></table>"
|
|
return markup;
|
|
}
|
|
|
|
function movieFormatSelection(movie) {
|
|
return movie.title;
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$("#e6").select2({
|
|
placeholder: "Search for a movie",
|
|
minimumInputLength: 3,
|
|
ajax: {
|
|
url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
|
|
dataType: 'jsonp',
|
|
quietMillis: 100,
|
|
data: function (term, page) { // page is the one-based page number tracked by Select2
|
|
return {
|
|
q: term, //search term
|
|
page_limit: 10, // page size
|
|
page: page, // page number
|
|
apikey: "ju6z9mjyajq2djue3gbvv26t" // please do not use so this example keeps working
|
|
};
|
|
},
|
|
results: function (data, page) {
|
|
console.log("loaded page: ", page, "with total: ", data.total);
|
|
var more = (page * 10) < data.total; // whether or not there are more results available
|
|
|
|
// notice we return the value of more so Select2 knows if more results can be loaded
|
|
return {results: data.movies, more: more};
|
|
}
|
|
},
|
|
formatResult: movieFormatResult, // omitted for brevity, see the source of this page
|
|
formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
|
|
dropdownCssClass: "bigdrop", // apply css that makes the dropdown taller
|
|
escapeMarkup: function (m) { return m; } // we do not want to escape markup since we are displaying html in results
|
|
,loadMorePadding:400
|
|
});
|
|
});
|
|
</script>
|
|
|
|
|
|
<form>
|
|
<select id="select7">
|
|
<option value=""></option>
|
|
<option value="1" selected="selected">Foo</option>
|
|
<option value="2">Bar</option>
|
|
<option value="3">Baaaaaaaaaaaaaaz</option>
|
|
</select>
|
|
</form>
|
|
<script>
|
|
|
|
$(function () {
|
|
$('#select7').select2({
|
|
allowClear: true,
|
|
placeholder: 'Loooooong string',
|
|
width: 'off'
|
|
});
|
|
});
|
|
|
|
</script>
|
|
-->
|
|
<div style="position: absolute; left:0; top:0; background: white; border: 1px solid red;" id="focus-spy">hello there</div>
|
|
<script>
|
|
$(document).ready(function() {
|
|
var el=$("#focus-spy");
|
|
$(window).bind("scroll", function(){ el.css({top:$(window).scrollTop()}); });
|
|
var update=function() {
|
|
var a=document.activeElement;
|
|
var b=$(a);
|
|
el.html("tag: "+a.tagName+" id:"+a.id+" class:"+b.attr("class")+" val:"+b.val());
|
|
window.setTimeout(update, 100);
|
|
};
|
|
update();
|
|
|
|
|
|
});
|
|
</script>
|
|
|
|
|
|
<input type="text" size="width:300px" id="tags"/>
|
|
<script>
|
|
$(function() {
|
|
$("#tags").select2({tags:["one","two","three"]})
|
|
})
|
|
</script>
|
|
|
|
</body>
|
|
</html> |