2013-02-06 03:24:44 +04:00
|
|
|
<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>
|
2013-05-07 07:15:10 +04:00
|
|
|
<!-- <div style="height:200px;"></div> -->
|
2013-02-06 03:24:44 +04:00
|
|
|
<div style="padding: 10px; margin: 10px;">
|
2013-02-09 00:13:59 +04:00
|
|
|
<br/><br/><br/>
|
|
|
|
<input type="text" size="30"/><br/>
|
2013-03-25 20:12:08 +04:00
|
|
|
<label for="e4">Label: </label>
|
2013-05-07 10:40:50 +04:00
|
|
|
<div style="white-space: nowrap">
|
|
|
|
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx<select id="e4" style="width:300px" class="populate" >
|
2013-02-09 00:13:59 +04:00
|
|
|
<option></option>
|
2013-02-06 03:24:44 +04:00
|
|
|
<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>
|
2013-05-07 10:40:50 +04:00
|
|
|
</select></div><br/>
|
2013-04-23 19:59:12 +04:00
|
|
|
<input type="text" size="30"/><br/>
|
2013-05-07 07:15:10 +04:00
|
|
|
<select id="e5" style="width:300px" multiple>
|
2013-04-23 19:59:12 +04:00
|
|
|
<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/>
|
2013-05-07 07:15:10 +04:00
|
|
|
<input type="text" size="30"/><br/>
|
2013-04-23 19:59:12 +04:00
|
|
|
|
2013-05-07 07:15:10 +04:00
|
|
|
<!--
|
2013-04-23 19:59:12 +04:00
|
|
|
<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>
|
2013-05-07 07:15:10 +04:00
|
|
|
-->
|
2013-02-06 03:24:44 +04:00
|
|
|
</div>
|
2013-02-12 12:13:56 +04:00
|
|
|
|
2013-04-23 19:59:12 +04:00
|
|
|
<script>
|
|
|
|
$(document).ready(function() {
|
|
|
|
function format(state) {
|
|
|
|
if (!state.id) return state.text; // optgroup
|
|
|
|
return "<img class='flag' src='images/flags/" + state.id.toLowerCase() + ".png'/>" + state.text;
|
|
|
|
}
|
2013-05-07 07:15:10 +04:00
|
|
|
$("#e5").select2();
|
2013-04-23 19:59:12 +04:00
|
|
|
$("#e4").select2({
|
|
|
|
formatResult: format,
|
|
|
|
formatSelection: format,
|
|
|
|
escapeMarkup: function(m) { return m; },
|
|
|
|
allowClear:true,
|
|
|
|
placeholder: "select a state",
|
2013-05-07 10:40:50 +04:00
|
|
|
maximumInputLength:3,
|
|
|
|
minimumResultsForSearch: 2
|
2013-04-23 19:59:12 +04:00
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<!--
|
2013-03-25 20:12:08 +04:00
|
|
|
<label for="e6">Label: </label>
|
2013-04-23 19:59:12 +04:00
|
|
|
|
2013-02-12 12:13:56 +04:00
|
|
|
<input type="hidden" class="bigdrop" id="e6" style="width:600px" value="16340"/>
|
|
|
|
|
2013-02-20 22:06:11 +04:00
|
|
|
|
2013-02-06 03:24:44 +04:00
|
|
|
|
2013-04-10 06:53:36 +04:00
|
|
|
|
2013-02-12 12:13:56 +04:00
|
|
|
<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;
|
|
|
|
}
|
2013-02-06 03:24:44 +04:00
|
|
|
|
2013-02-12 12:13:56 +04:00
|
|
|
function movieFormatSelection(movie) {
|
|
|
|
return movie.title;
|
|
|
|
}
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
$("#e6").select2({
|
|
|
|
placeholder: "Search for a movie",
|
2013-04-09 03:49:53 +04:00
|
|
|
minimumInputLength: 3,
|
|
|
|
ajax: {
|
2013-02-12 12:13:56 +04:00
|
|
|
url: "http://api.rottentomatoes.com/api/public/v1.0/movies.json",
|
|
|
|
dataType: 'jsonp',
|
2013-04-09 03:49:53 +04:00
|
|
|
quietMillis: 100,
|
|
|
|
data: function (term, page) { // page is the one-based page number tracked by Select2
|
2013-02-12 12:13:56 +04:00
|
|
|
return {
|
2013-04-09 03:49:53 +04:00
|
|
|
q: term, //search term
|
|
|
|
page_limit: 10, // page size
|
|
|
|
page: page, // page number
|
2013-02-12 12:13:56 +04:00
|
|
|
apikey: "ju6z9mjyajq2djue3gbvv26t" // please do not use so this example keeps working
|
|
|
|
};
|
|
|
|
},
|
2013-04-09 03:49:53 +04:00
|
|
|
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};
|
2013-02-12 12:13:56 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
formatResult: movieFormatResult, // omitted for brevity, see the source of this page
|
2013-04-09 03:49:53 +04:00
|
|
|
formatSelection: movieFormatSelection, // omitted for brevity, see the source of this page
|
2013-02-12 12:13:56 +04:00
|
|
|
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
|
2013-04-09 03:49:53 +04:00
|
|
|
,loadMorePadding:400
|
2013-02-12 12:13:56 +04:00
|
|
|
});
|
|
|
|
});
|
|
|
|
</script>
|
2013-04-10 06:53:36 +04:00
|
|
|
|
|
|
|
|
2013-04-12 06:15:41 +04:00
|
|
|
<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>
|
2013-04-23 19:59:12 +04:00
|
|
|
-->
|
2013-04-10 06:53:36 +04:00
|
|
|
<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();
|
2013-05-07 07:15:10 +04:00
|
|
|
|
|
|
|
|
2013-04-10 06:53:36 +04:00
|
|
|
});
|
|
|
|
</script>
|
|
|
|
|
2013-02-06 03:24:44 +04:00
|
|
|
</body>
|
|
|
|
</html>
|