<!DOCTYPE html>
<html>
<head>
<meta content="initial-scale=1.0, user-scalable=no" name="viewport"/>
<meta charset="UTF-8"/>
<title>Fusion Tables Layer Example: Autocomplete Text Search</title>
<link data-require="bootstrap-css@3.1.1" data-semver="3.1.1" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" rel="stylesheet"/>
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.1.0/css/font-awesome.min.css" rel="stylesheet">
<link href="typeahead.css" rel="stylesheet" type="text/css"/>
<link href="bootstrap-tokenfield.css" rel="stylesheet" type="text/css"/>
<link href="animate.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div class="container">
<div class="page-header">
<h1>twitter typeahead</h1>
</div>
<label for="bootstrap-typeahead">tokenfield-typeahead</label>
<div class="input-group">
<input class="form-control" name="bootstrap-typeahead" id="architect" placeholder="typeahead" type="text">
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="go">Go</button>
</span>
</div>
<hr>
<label for="tokenfield-typeahead">tokenfield-typeahead</label>
<input name="tokenfield-typeahead" id="tokenfield-typeahead" type="text">
</div>
<!--[if lt IE 9]>
<script type="text/javascript" src='//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js'></script>
<![endif]-->
<!--[if gte IE 9]><!-->
<script type="text/javascript" src='//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'></script>
<!--<![endif]-->
<script type="text/javascript" src="//cdn.jsdelivr.net/typeahead.js/0.10.5/typeahead.bundle.min.js"></script>
<script type="text/javascript" src="bootstrap-tokenfield.js"></script>
<script src="growl.js"></script>
<script type="text/javascript" src="script.js"></script>
</body>
</html>
(function () {
var $input,
list,
showMessage;
showMessage = function (message) {
if (message) {
$.growl({
message: message
}, {
type : "success",
allow_dismiss: true,
delay : 5000,
timer : 1000,
mouse_over : false,
animate : {
enter: 'animated fadeInDown',
exit : 'animated fadeOutUp'
}
});
}
};
$input = $('#architect');
list = new Bloodhound({
datumTokenizer: function (d) {
if (d) {
return Bloodhound.tokenizers.whitespace(d.name);
} else {
return "";
}
},
queryTokenizer: Bloodhound.tokenizers.whitespace,
prefetch : {
url: 'arki.json'
}
});
// initialize the bloodhound suggestion engine
list.initialize();
// instantiate the typeahead UI
$input.typeahead({
highlight: true,
minLength: 0
}, {
displayKey: 'name',
source : list.ttAdapter()
}).on("keydown", function (e) {
if (e.keyCode === 13) {
showMessage($input.val() + "<br>" + $('#tokenfield-typeahead').val());
}
});
$('#go').click(function () {
showMessage($input.val() + "<br>" + $('#tokenfield-typeahead').val());
});
$('#tokenfield-typeahead').tokenfield({
typeahead: [
null, {
displayKey: 'name',
source : list.ttAdapter()
}
]
});
})($);
/*
* typehead.js-bootstrap3.less
* @version 0.2.2
* https://github.com/hyspace/typeahead.js-bootstrap3.less
*
* Licensed under the MIT license:
* http://www.opensource.org/licenses/MIT
*/
.has-warning .twitter-typeahead .tt-input,
.has-warning .twitter-typeahead .tt-hint {
border-color: #8a6d3b;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.has-warning .twitter-typeahead .tt-input:focus,
.has-warning .twitter-typeahead .tt-hint:focus {
border-color: #66512c;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
}
.has-error .twitter-typeahead .tt-input,
.has-error .twitter-typeahead .tt-hint {
border-color: #a94442;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.has-error .twitter-typeahead .tt-input:focus,
.has-error .twitter-typeahead .tt-hint:focus {
border-color: #843534;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
}
.has-success .twitter-typeahead .tt-input,
.has-success .twitter-typeahead .tt-hint {
border-color: #3c763d;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075);
}
.has-success .twitter-typeahead .tt-input:focus,
.has-success .twitter-typeahead .tt-hint:focus {
border-color: #2b542c;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
}
.input-group .twitter-typeahead:first-child .tt-input,
.input-group .twitter-typeahead:first-child .tt-hint {
border-bottom-left-radius: 4px;
border-top-left-radius: 4px;
}
.input-group .twitter-typeahead:last-child .tt-input,
.input-group .twitter-typeahead:last-child .tt-hint {
border-bottom-right-radius: 4px;
border-top-right-radius: 4px;
}
.input-group.input-group-sm .twitter-typeahead .tt-input,
.input-group.input-group-sm .twitter-typeahead .tt-hint {
height: 30px;
padding: 5px 10px;
font-size: 12px;
line-height: 1.5;
border-radius: 3px;
}
select.input-group.input-group-sm .twitter-typeahead .tt-input,
select.input-group.input-group-sm .twitter-typeahead .tt-hint {
height: 30px;
line-height: 30px;
}
textarea.input-group.input-group-sm .twitter-typeahead .tt-input,
textarea.input-group.input-group-sm .twitter-typeahead .tt-hint,
select[multiple].input-group.input-group-sm .twitter-typeahead .tt-input,
select[multiple].input-group.input-group-sm .twitter-typeahead .tt-hint {
height: auto;
}
.input-group.input-group-sm .twitter-typeahead:not(:first-child):not(:last-child) .tt-input,
.input-group.input-group-sm .twitter-typeahead:not(:first-child):not(:last-child) .tt-hint {
border-radius: 0;
}
.input-group.input-group-sm .twitter-typeahead:first-child .tt-input,
.input-group.input-group-sm .twitter-typeahead:first-child .tt-hint {
border-bottom-left-radius: 3px;
border-top-left-radius: 3px;
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
.input-group.input-group-sm .twitter-typeahead:last-child .tt-input,
.input-group.input-group-sm .twitter-typeahead:last-child .tt-hint {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-bottom-right-radius: 3px;
border-top-right-radius: 3px;
}
.input-group.input-group-lg .twitter-typeahead .tt-input,
.input-group.input-group-lg .twitter-typeahead .tt-hint {
height: 46px;
padding: 10px 16px;
font-size: 18px;
line-height: 1.33;
border-radius: 6px;
}
select.input-group.input-group-lg .twitter-typeahead .tt-input,
select.input-group.input-group-lg .twitter-typeahead .tt-hint {
height: 46px;
line-height: 46px;
}
textarea.input-group.input-group-lg .twitter-typeahead .tt-input,
textarea.input-group.input-group-lg .twitter-typeahead .tt-hint,
select[multiple].input-group.input-group-lg .twitter-typeahead .tt-input,
select[multiple].input-group.input-group-lg .twitter-typeahead .tt-hint {
height: auto;
}
.input-group.input-group-lg .twitter-typeahead:not(:first-child):not(:last-child) .tt-input,
.input-group.input-group-lg .twitter-typeahead:not(:first-child):not(:last-child) .tt-hint {
border-radius: 0;
}
.input-group.input-group-lg .twitter-typeahead:first-child .tt-input,
.input-group.input-group-lg .twitter-typeahead:first-child .tt-hint {
border-bottom-left-radius: 6px;
border-top-left-radius: 6px;
border-bottom-right-radius: 0;
border-top-right-radius: 0;
}
.input-group.input-group-lg .twitter-typeahead:last-child .tt-input,
.input-group.input-group-lg .twitter-typeahead:last-child .tt-hint {
border-bottom-left-radius: 0;
border-top-left-radius: 0;
border-bottom-right-radius: 6px;
border-top-right-radius: 6px;
}
.twitter-typeahead {
width: 100%;
}
.input-group .twitter-typeahead {
display: table-cell !important;
}
.twitter-typeahead .tt-hint {
color: #999999;
}
.twitter-typeahead .tt-input {
z-index: 2;
}
.twitter-typeahead .tt-input[disabled],
.twitter-typeahead .tt-input[readonly],
fieldset[disabled] .twitter-typeahead .tt-input {
cursor: not-allowed;
background-color: #eeeeee !important;
}
.tt-dropdown-menu {
position: absolute;
top: 100%;
left: 0;
z-index: 1000;
min-width: 160px;
width: 100%;
padding: 5px 0;
margin: 2px 0 0;
list-style: none;
font-size: 14px;
background-color: #ffffff;
border: 1px solid #cccccc;
border: 1px solid rgba(0, 0, 0, 0.15);
border-radius: 4px;
-webkit-box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.175);
background-clip: padding-box;
*border-right-width: 2px;
*border-bottom-width: 2px;
}
.tt-dropdown-menu .tt-suggestion {
display: block;
padding: 3px 20px;
clear: both;
font-weight: normal;
line-height: 1.42857143;
color: #333333;
white-space: nowrap;
}
.tt-dropdown-menu .tt-suggestion.tt-cursor {
text-decoration: none;
outline: 0;
background-color: #444;
color: #ffffff;
cursor:pointer;
-webkit-appearance:textfield;
}
.tt-dropdown-menu .tt-suggestion.tt-cursor a {
color: #ffffff;
}
.tt-dropdown-menu .tt-suggestion p {
margin: 0;
}
[{ "nm" : "A 595959"},
{ "nm" : "A 595859"},
{ "nm" : "B 59595 infor-macion"},
{ "nm" : "a 565775"},
{ "nm" : "c 59859"},
{ "nm" : "1234 Ul-tima Hora Mallorca Palma De Mallorca Spain"},
{ "nm" : "567Ultima Hora Menorca Menorca Spain"},
{ "nm" : "Gazet van Antwerpen Antwerpen Belgium"},
{ "nm" : "20 Minutos Alicante Alicante Spain"},
{ "nm" : "20 Minutos Barcelona Barcelona Spain"},
{ "nm" : "b 6786854"},
{ "nm" : "x43-2 59595"},
{ "nm" : "20 Minutos Granada Granada Spain"}]
[
{
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 450037,
"vin" : "1 YV2VBN0CX6B450037",
"longModel" : null,
"regNo" : "651KBB",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 475515,
"vin" : "2 YV2VBN0C07B475515",
"longModel" : null,
"regNo" : "765KMQ",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 475966,
"vin" : "3 YV2VBN0C07B475966",
"longModel" : null,
"regNo" : "763KMQ",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 483840,
"vin" : "10 YV2VBL0C17B483840",
"longModel" : null,
"regNo" : "793KMQ",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 483872,
"vin" : "20 YV2VBL0C37B483872",
"longModel" : null,
"regNo" : "792KMQ",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 487620,
"vin" : "30 YV2VBN0C08B487620",
"longModel" : null,
"regNo" : "989KSD",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 487844,
"vin" : "40 YV2VBN0C08B487844",
"longModel" : null,
"regNo" : "WWN436",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FE",
"chassisSeries" : "B",
"chassisNo" : 488782,
"vin" : "YV2VBL0C38B488782",
"longModel" : null,
"regNo" : "XFV159",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FM",
"chassisSeries" : "D",
"chassisNo" : 129042,
"vin" : "YV5JSW0D17D129042",
"longModel" : null,
"regNo" : "XEX083",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FM",
"chassisSeries" : "D",
"chassisNo" : 129856,
"vin" : "YV5JSW0D07D129856",
"longModel" : null,
"regNo" : "981KSD",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "VTB",
"productClass" : null,
"model" : "FM",
"chassisSeries" : "D",
"chassisNo" : 129927,
"vin" : "YV5JSW0D87D129927",
"longModel" : null,
"regNo" : "982KSD",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CH",
"chassisSeries" : "MA1",
"chassisNo" : 7442,
"vin" : "6FMJ27J28A1B07442",
"longModel" : null,
"regNo" : "XRD332",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CH",
"chassisSeries" : "MA1",
"chassisNo" : 7470,
"vin" : "6FMJ27J28A1B07470",
"longModel" : null,
"regNo" : "XRD345",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CH",
"chassisSeries" : "MA1",
"chassisNo" : 7494,
"vin" : "6FMJ27J53A1B07494",
"longModel" : null,
"regNo" : "XRD318",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CH",
"chassisSeries" : "MA1",
"chassisNo" : 7496,
"vin" : "6FMJ27J53A1B07496",
"longModel" : null,
"regNo" : "671LJK",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CH",
"chassisSeries" : "MA1",
"chassisNo" : 7508,
"vin" : "6FMJ27J53A1B07508",
"longModel" : null,
"regNo" : "XRD333",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "QH",
"chassisSeries" : "MA1",
"chassisNo" : 7514,
"vin" : "6FMP27J38A1B07514",
"longModel" : null,
"regNo" : "WSP407",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CH",
"chassisSeries" : "MA1",
"chassisNo" : 7517,
"vin" : "6FMJ27J53A1B07517",
"longModel" : null,
"regNo" : "XRD340",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 707884,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 707950,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 707963,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 708537,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709787,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709794,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709802,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709820,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709829,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709839,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709852,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709855,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709857,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709859,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709863,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709866,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709870,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709876,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709878,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709884,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709895,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 709929,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 710199,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 710271,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 710306,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 710743,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711237,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711242,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711264,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711288,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711350,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711372,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711487,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711489,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711506,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711575,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711678,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711685,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711720,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711740,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 711967,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 712228,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 712426,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 712493,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 712682,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 712703,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 712733,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 712978,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 713227,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 713284,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 713570,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CX",
"chassisSeries" : "MA1",
"chassisNo" : 713573,
"vin" : "6FMJ10F557D713573",
"longModel" : null,
"regNo" : "BV50AP",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA1",
"chassisNo" : 714053,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 10511,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 11517,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 11554,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 12479,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 12498,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 12519,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 12600,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 16623,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : null,
"productClass" : null,
"model" : null,
"chassisSeries" : "MA2",
"chassisNo" : 18369,
"vin" : null,
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 800060,
"vin" : "6FMN12G028D800060",
"longModel" : null,
"regNo" : "831LBF",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 800110,
"vin" : "6FMN12G028D800110",
"longModel" : null,
"regNo" : "832LBF",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 800129,
"vin" : "6FMN12F028D800129",
"longModel" : null,
"regNo" : "BB58YF",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 800135,
"vin" : "6FMN12F738D800135",
"longModel" : null,
"regNo" : "997LDG",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 800253,
"vin" : "6FMN12F738D800253",
"longModel" : null,
"regNo" : "XDO380",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 800404,
"vin" : "6FMN12F738D800404",
"longModel" : null,
"regNo" : "XCV663",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 800422,
"vin" : "6FMN12F028D800422",
"longModel" : null,
"regNo" : "055LYP",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 801201,
"vin" : "6FMN12G569D801201",
"longModel" : null,
"regNo" : "320MVG",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 801391,
"vin" : "6FMN12F73AD801391",
"longModel" : null,
"regNo" : "SB94DN",
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 804502,
"vin" : "6FMN12H73DD804502",
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 804509,
"vin" : "6FMN12H73DD804509",
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}, {
"brand" : "MACK",
"productClass" : null,
"model" : "CMM",
"chassisSeries" : "MA5",
"chassisNo" : 804674,
"vin" : "6FMN12H02DD804674",
"longModel" : null,
"regNo" : null,
"unitNo" : null,
"marketingType" : null,
"vehicleExplorerLink": null,
"buildDate" : null
}
]
/*!
* typeahead.js 0.10.1
* https://github.com/twitter/typeahead.js
* Copyright 2013 Twitter, Inc. and other contributors; Licensed MIT
*/
(function($) {
var _ = {
isMsie: function() {
return /(msie|trident)/i.test(navigator.userAgent) ? navigator.userAgent.match(/(msie |rv:)(\d+(.\d+)?)/i)[2] : false;
},
isBlankString: function(str) {
return !str || /^\s*$/.test(str);
},
escapeRegExChars: function(str) {
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
},
isString: function(obj) {
return typeof obj === "string";
},
isNumber: function(obj) {
return typeof obj === "number";
},
isArray: $.isArray,
isFunction: $.isFunction,
isObject: $.isPlainObject,
isUndefined: function(obj) {
return typeof obj === "undefined";
},
bind: $.proxy,
each: function(collection, cb) {
$.each(collection, reverseArgs);
function reverseArgs(index, value) {
return cb(value, index);
}
},
map: $.map,
filter: $.grep,
every: function(obj, test) {
var result = true;
if (!obj) {
return result;
}
$.each(obj, function(key, val) {
if (!(result = test.call(null, val, key, obj))) {
return false;
}
});
return !!result;
},
some: function(obj, test) {
var result = false;
if (!obj) {
return result;
}
$.each(obj, function(key, val) {
if (result = test.call(null, val, key, obj)) {
return false;
}
});
return !!result;
},
mixin: $.extend,
getUniqueId: function() {
var counter = 0;
return function() {
return counter++;
};
}(),
templatify: function templatify(obj) {
return $.isFunction(obj) ? obj : template;
function template() {
return String(obj);
}
},
defer: function(fn) {
setTimeout(fn, 0);
},
debounce: function(func, wait, immediate) {
var timeout, result;
return function() {
var context = this, args = arguments, later, callNow;
later = function() {
timeout = null;
if (!immediate) {
result = func.apply(context, args);
}
};
callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) {
result = func.apply(context, args);
}
return result;
};
},
throttle: function(func, wait) {
var context, args, timeout, result, previous, later;
previous = 0;
later = function() {
previous = new Date();
timeout = null;
result = func.apply(context, args);
};
return function() {
var now = new Date(), remaining = wait - (now - previous);
context = this;
args = arguments;
if (remaining <= 0) {
clearTimeout(timeout);
timeout = null;
previous = now;
result = func.apply(context, args);
} else if (!timeout) {
timeout = setTimeout(later, remaining);
}
return result;
};
},
noop: function() {}
};
var VERSION = "0.10.1";
var LruCache = function(root, undefined) {
function LruCache(maxSize) {
this.maxSize = maxSize || 100;
this.size = 0;
this.hash = {};
this.list = new List();
}
_.mixin(LruCache.prototype, {
set: function set(key, val) {
var tailItem = this.list.tail, node;
if (this.size >= this.maxSize) {
this.list.remove(tailItem);
delete this.hash[tailItem.key];
}
if (node = this.hash[key]) {
node.val = val;
this.list.moveToFront(node);
} else {
node = new Node(key, val);
this.list.add(node);
this.hash[key] = node;
this.size++;
}
},
get: function get(key) {
var node = this.hash[key];
if (node) {
this.list.moveToFront(node);
return node.val;
}
}
});
function List() {
this.head = this.tail = null;
}
_.mixin(List.prototype, {
add: function add(node) {
if (this.head) {
node.next = this.head;
this.head.prev = node;
}
this.head = node;
this.tail = this.tail || node;
},
remove: function remove(node) {
node.prev ? node.prev.next = node.next : this.head = node.next;
node.next ? node.next.prev = node.prev : this.tail = node.prev;
},
moveToFront: function(node) {
this.remove(node);
this.add(node);
}
});
function Node(key, val) {
this.key = key;
this.val = val;
this.prev = this.next = null;
}
return LruCache;
}(this);
var PersistentStorage = function() {
var ls, methods;
try {
ls = window.localStorage;
ls.setItem("~~~", "!");
ls.removeItem("~~~");
} catch (err) {
ls = null;
}
function PersistentStorage(namespace) {
this.prefix = [ "__", namespace, "__" ].join("");
this.ttlKey = "__ttl__";
this.keyMatcher = new RegExp("^" + this.prefix);
}
if (ls && window.JSON) {
methods = {
_prefix: function(key) {
return this.prefix + key;
},
_ttlKey: function(key) {
return this._prefix(key) + this.ttlKey;
},
get: function(key) {
if (this.isExpired(key)) {
this.remove(key);
}
return decode(ls.getItem(this._prefix(key)));
},
set: function(key, val, ttl) {
if (_.isNumber(ttl)) {
ls.setItem(this._ttlKey(key), encode(now() + ttl));
} else {
ls.removeItem(this._ttlKey(key));
}
return ls.setItem(this._prefix(key), encode(val));
},
remove: function(key) {
ls.removeItem(this._ttlKey(key));
ls.removeItem(this._prefix(key));
return this;
},
clear: function() {
var i, key, keys = [], len = ls.length;
for (i = 0; i < len; i++) {
if ((key = ls.key(i)).match(this.keyMatcher)) {
keys.push(key.replace(this.keyMatcher, ""));
}
}
for (i = keys.length; i--; ) {
this.remove(keys[i]);
}
return this;
},
isExpired: function(key) {
var ttl = decode(ls.getItem(this._ttlKey(key)));
return _.isNumber(ttl) && now() > ttl ? true : false;
}
};
} else {
methods = {
get: _.noop,
set: _.noop,
remove: _.noop,
clear: _.noop,
isExpired: _.noop
};
}
_.mixin(PersistentStorage.prototype, methods);
return PersistentStorage;
function now() {
return new Date().getTime();
}
function encode(val) {
return JSON.stringify(_.isUndefined(val) ? null : val);
}
function decode(val) {
return JSON.parse(val);
}
}();
var Transport = function() {
var pendingRequestsCount = 0, pendingRequests = {}, maxPendingRequests = 6, requestCache = new LruCache(10);
function Transport(o) {
o = o || {};
this._send = o.transport ? callbackToDeferred(o.transport) : $.ajax;
this._get = o.rateLimiter ? o.rateLimiter(this._get) : this._get;
}
Transport.setMaxPendingRequests = function setMaxPendingRequests(num) {
maxPendingRequests = num;
};
Transport.resetCache = function clearCache() {
requestCache = new LruCache(10);
};
_.mixin(Transport.prototype, {
_get: function(url, o, cb) {
var that = this, jqXhr;
if (jqXhr = pendingRequests[url]) {
jqXhr.done(done);
} else if (pendingRequestsCount < maxPendingRequests) {
pendingRequestsCount++;
pendingRequests[url] = this._send(url, o).done(done).always(always);
} else {
this.onDeckRequestArgs = [].slice.call(arguments, 0);
}
function done(resp) {
cb && cb(resp);
requestCache.set(url, resp);
}
function always() {
pendingRequestsCount--;
delete pendingRequests[url];
if (that.onDeckRequestArgs) {
that._get.apply(that, that.onDeckRequestArgs);
that.onDeckRequestArgs = null;
}
}
},
get: function(url, o, cb) {
var that = this, resp;
if (_.isFunction(o)) {
cb = o;
o = {};
}
if (resp = requestCache.get(url)) {
_.defer(function() {
cb && cb(resp);
});
} else {
this._get(url, o, cb);
}
return !!resp;
}
});
return Transport;
function callbackToDeferred(fn) {
return function customSendWrapper(url, o) {
var deferred = $.Deferred();
fn(url, o, onSuccess, onError);
return deferred;
function onSuccess(resp) {
_.defer(function() {
deferred.resolve(resp);
});
}
function onError(err) {
_.defer(function() {
deferred.reject(err);
});
}
};
}
}();
var SearchIndex = function() {
function SearchIndex(o) {
o = o || {};
if (!o.datumTokenizer || !o.queryTokenizer) {
$.error("datumTokenizer and queryTokenizer are both required");
}
this.datumTokenizer = o.datumTokenizer;
this.queryTokenizer = o.queryTokenizer;
this.datums = [];
this.trie = newNode();
}
_.mixin(SearchIndex.prototype, {
bootstrap: function bootstrap(o) {
this.datums = o.datums;
this.trie = o.trie;
},
add: function(data) {
var that = this;
data = _.isArray(data) ? data : [ data ];
_.each(data, function(datum) {
var id, tokens;
id = that.datums.push(datum) - 1;
tokens = normalizeTokens(that.datumTokenizer(datum));
_.each(tokens, function(token) {
var node, chars, ch, ids;
node = that.trie;
chars = token.split("");
while (ch = chars.shift()) {
node = node.children[ch] || (node.children[ch] = newNode());
node.ids.push(id);
}
});
});
},
get: function get(query) {
var that = this, tokens, matches;
tokens = normalizeTokens(this.queryTokenizer(query));
_.each(tokens, function(token) {
var node, chars, ch, ids;
if (matches && matches.length === 0) {
return false;
}
node = that.trie;
chars = token.split("");
while (node && (ch = chars.shift())) {
node = node.children[ch];
}
if (node && chars.length === 0) {
ids = node.ids.slice(0);
matches = matches ? getIntersection(matches, ids) : ids;
} else {
matches = [];
return false;
}
});
return matches ? _.map(unique(matches), function(id) {
return that.datums[id];
}) : [];
},
serialize: function serialize() {
return {
datums: this.datums,
trie: this.trie
};
}
});
return SearchIndex;
function normalizeTokens(tokens) {
tokens = _.filter(tokens, function(token) {
return !!token;
});
tokens = _.map(tokens, function(token) {
return token.toLowerCase();
});
return tokens;
}
function newNode() {
return {
ids: [],
children: {}
};
}
function unique(array) {
var seen = {}, uniques = [];
for (var i = 0; i < array.length; i++) {
if (!seen[array[i]]) {
seen[array[i]] = true;
uniques.push(array[i]);
}
}
return uniques;
}
function getIntersection(arrayA, arrayB) {
var ai = 0, bi = 0, intersection = [];
arrayA = arrayA.sort(compare);
arrayB = arrayB.sort(compare);
while (ai < arrayA.length && bi < arrayB.length) {
if (arrayA[ai] < arrayB[bi]) {
ai++;
} else if (arrayA[ai] > arrayB[bi]) {
bi++;
} else {
intersection.push(arrayA[ai]);
ai++;
bi++;
}
}
return intersection;
function compare(a, b) {
return a - b;
}
}
}();
var oParser = function() {
return {
local: getLocal,
prefetch: getPrefetch,
remote: getRemote
};
function getLocal(o) {
var local = o.local || null;
if (_.isFunction(local)) {
local = local.call(null);
}
return local;
}
function getPrefetch(o) {
var prefetch, defaults;
defaults = {
url: null,
thumbprint: "",
ttl: 24 * 60 * 60 * 1e3,
filter: null,
ajax: {}
};
if (prefetch = o.prefetch || null) {
prefetch = _.isString(prefetch) ? {
url: prefetch
} : prefetch;
prefetch = _.mixin(defaults, prefetch);
prefetch.thumbprint = VERSION + prefetch.thumbprint;
prefetch.ajax.type = prefetch.ajax.type || "GET";
prefetch.ajax.dataType = prefetch.ajax.dataType || "json";
!prefetch.url && $.error("prefetch requires url to be set");
}
return prefetch;
}
function getRemote(o) {
var remote, defaults;
defaults = {
url: null,
wildcard: "%QUERY",
replace: null,
rateLimitBy: "debounce",
rateLimitWait: 300,
send: null,
filter: null,
ajax: {}
};
if (remote = o.remote || null) {
remote = _.isString(remote) ? {
url: remote
} : remote;
remote = _.mixin(defaults, remote);
remote.rateLimiter = /^throttle$/i.test(remote.rateLimitBy) ? byThrottle(remote.rateLimitWait) : byDebounce(remote.rateLimitWait);
remote.ajax.type = remote.ajax.type || "GET";
remote.ajax.dataType = remote.ajax.dataType || "json";
delete remote.rateLimitBy;
delete remote.rateLimitWait;
!remote.url && $.error("remote requires url to be set");
}
return remote;
function byDebounce(wait) {
return function(fn) {
return _.debounce(fn, wait);
};
}
function byThrottle(wait) {
return function(fn) {
return _.throttle(fn, wait);
};
}
}
}();
var Bloodhound = window.Bloodhound = function() {
var keys;
keys = {
data: "data",
protocol: "protocol",
thumbprint: "thumbprint"
};
function Bloodhound(o) {
if (!o || !o.local && !o.prefetch && !o.remote) {
$.error("one of local, prefetch, or remote is required");
}
this.limit = o.limit || 5;
this.sorter = getSorter(o.sorter);
this.dupDetector = o.dupDetector || ignoreDuplicates;
this.local = oParser.local(o);
this.prefetch = oParser.prefetch(o);
this.remote = oParser.remote(o);
this.cacheKey = this.prefetch ? this.prefetch.cacheKey || this.prefetch.url : null;
this.index = new SearchIndex({
datumTokenizer: o.datumTokenizer,
queryTokenizer: o.queryTokenizer
});
this.storage = this.cacheKey ? new PersistentStorage(this.cacheKey) : null;
}
Bloodhound.tokenizers = {
whitespace: function whitespaceTokenizer(s) {
return s.split(/\s+/);
},
nonword: function nonwordTokenizer(s) {
return s.split(/\W+/);
}
};
_.mixin(Bloodhound.prototype, {
_loadPrefetch: function loadPrefetch(o) {
var that = this, serialized, deferred;
if (serialized = this._readFromStorage(o.thumbprint)) {
this.index.bootstrap(serialized);
deferred = $.Deferred().resolve();
} else {
deferred = $.ajax(o.url, o.ajax).done(handlePrefetchResponse);
}
return deferred;
function handlePrefetchResponse(resp) {
var filtered;
filtered = o.filter ? o.filter(resp) : resp;
that.add(filtered);
that._saveToStorage(that.index.serialize(), o.thumbprint, o.ttl);
}
},
_getFromRemote: function getFromRemote(query, cb) {
var that = this, url, uriEncodedQuery;
query = query || "";
uriEncodedQuery = encodeURIComponent(query);
url = this.remote.replace ? this.remote.replace(this.remote.url, query) : this.remote.url.replace(this.remote.wildcard, uriEncodedQuery);
return this.transport.get(url, this.remote.ajax, handleRemoteResponse);
function handleRemoteResponse(resp) {
var filtered = that.remote.filter ? that.remote.filter(resp) : resp;
cb(filtered);
}
},
_saveToStorage: function saveToStorage(data, thumbprint, ttl) {
if (this.storage) {
this.storage.set(keys.data, data, ttl);
this.storage.set(keys.protocol, location.protocol, ttl);
this.storage.set(keys.thumbprint, thumbprint, ttl);
}
},
_readFromStorage: function readFromStorage(thumbprint) {
var stored = {}, isExpired;
if (this.storage) {
stored.data = this.storage.get(keys.data);
stored.protocol = this.storage.get(keys.protocol);
stored.thumbprint = this.storage.get(keys.thumbprint);
}
isExpired = stored.thumbprint !== thumbprint || stored.protocol !== location.protocol;
return stored.data && !isExpired ? stored.data : null;
},
initialize: function initialize() {
var that = this, deferred;
deferred = this.prefetch ? this._loadPrefetch(this.prefetch) : $.Deferred().resolve();
this.local && deferred.done(addLocalToIndex);
this.transport = this.remote ? new Transport(this.remote) : null;
this.initialize = function initialize() {
return deferred.promise();
};
return deferred.promise();
function addLocalToIndex() {
that.add(that.local);
}
},
add: function add(data) {
this.index.add(data);
},
get: function get(query, cb) {
var that = this, matches, cacheHit = false;
matches = this.index.get(query);
matches = this.sorter(matches).slice(0, this.limit);
if (matches.length < this.limit && this.transport) {
cacheHit = this._getFromRemote(query, returnRemoteMatches);
}
!cacheHit && cb && cb(matches);
function returnRemoteMatches(remoteMatches) {
var matchesWithBackfill = matches.slice(0);
_.each(remoteMatches, function(remoteMatch) {
var isDuplicate;
isDuplicate = _.some(matchesWithBackfill, function(match) {
return that.dupDetector(remoteMatch, match);
});
!isDuplicate && matchesWithBackfill.push(remoteMatch);
return matchesWithBackfill.length < that.limit;
});
cb && cb(that.sorter(matchesWithBackfill));
}
},
ttAdapter: function ttAdapter() {
return _.bind(this.get, this);
}
});
return Bloodhound;
function getSorter(sortFn) {
return _.isFunction(sortFn) ? sort : noSort;
function sort(array) {
return array.sort(sortFn);
}
function noSort(array) {
return array;
}
}
function ignoreDuplicates() {
return false;
}
}();
var html = {
wrapper: '<span class="twitter-typeahead"></span>',
dropdown: '<span class="tt-dropdown-menu"></span>',
dataset: '<div class="tt-dataset-%CLASS%"></div>',
suggestions: '<span class="tt-suggestions"></span>',
suggestion: '<div class="tt-suggestion">%BODY%</div>'
};
var css = {
wrapper: {
position: "relative",
display: "inline-block"
},
hint: {
position: "absolute",
top: "0",
left: "0",
borderColor: "transparent",
boxShadow: "none"
},
input: {
position: "relative",
verticalAlign: "top",
backgroundColor: "transparent"
},
inputWithNoHint: {
position: "relative",
verticalAlign: "top"
},
dropdown: {
position: "absolute",
top: "100%",
left: "0",
zIndex: "100",
display: "none"
},
suggestions: {
display: "block"
},
suggestion: {
whiteSpace: "nowrap",
cursor: "pointer"
},
suggestionChild: {
whiteSpace: "normal"
},
ltr: {
left: "0",
right: "auto"
},
rtl: {
left: "auto",
right: " 0"
}
};
if (_.isMsie()) {
_.mixin(css.input, {
backgroundImage: "url(data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7)"
});
}
if (_.isMsie() && _.isMsie() <= 7) {
_.mixin(css.input, {
marginTop: "-1px"
});
}
var EventBus = function() {
var namespace = "typeahead:";
function EventBus(o) {
if (!o || !o.el) {
$.error("EventBus initialized without el");
}
this.$el = $(o.el);
}
_.mixin(EventBus.prototype, {
trigger: function(type) {
var args = [].slice.call(arguments, 1);
this.$el.trigger(namespace + type, args);
}
});
return EventBus;
}();
var EventEmitter = function() {
var splitter = /\s+/, nextTick = getNextTick();
return {
onSync: onSync,
onAsync: onAsync,
off: off,
trigger: trigger
};
function on(method, types, cb, context) {
var type;
if (!cb) {
return this;
}
types = types.split(splitter);
cb = context ? bindContext(cb, context) : cb;
this._callbacks = this._callbacks || {};
while (type = types.shift()) {
this._callbacks[type] = this._callbacks[type] || {
sync: [],
async: []
};
this._callbacks[type][method].push(cb);
}
return this;
}
function onAsync(types, cb, context) {
return on.call(this, "async", types, cb, context);
}
function onSync(types, cb, context) {
return on.call(this, "sync", types, cb, context);
}
function off(types) {
var type;
if (!this._callbacks) {
return this;
}
types = types.split(splitter);
while (type = types.shift()) {
delete this._callbacks[type];
}
return this;
}
function trigger(types) {
var that = this, type, callbacks, args, syncFlush, asyncFlush;
if (!this._callbacks) {
return this;
}
types = types.split(splitter);
args = [].slice.call(arguments, 1);
while ((type = types.shift()) && (callbacks = this._callbacks[type])) {
syncFlush = getFlush(callbacks.sync, this, [ type ].concat(args));
asyncFlush = getFlush(callbacks.async, this, [ type ].concat(args));
syncFlush() && nextTick(asyncFlush);
}
return this;
}
function getFlush(callbacks, context, args) {
return flush;
function flush() {
var cancelled;
for (var i = 0; !cancelled && i < callbacks.length; i += 1) {
cancelled = callbacks[i].apply(context, args) === false;
}
return !cancelled;
}
}
function getNextTick() {
var nextTickFn, messageChannel;
if (window.setImmediate) {
nextTickFn = function nextTickSetImmediate(fn) {
setImmediate(function() {
fn();
});
};
} else {
nextTickFn = function nextTickSetTimeout(fn) {
setTimeout(function() {
fn();
}, 0);
};
}
return nextTickFn;
}
function bindContext(fn, context) {
return fn.bind ? fn.bind(context) : function() {
fn.apply(context, [].slice.call(arguments, 0));
};
}
}();
var highlight = function(doc) {
var defaults = {
node: null,
pattern: null,
tagName: "strong",
className: null,
wordsOnly: false,
caseSensitive: false
};
return function hightlight(o) {
var regex;
o = _.mixin({}, defaults, o);
if (!o.node || !o.pattern) {
return;
}
o.pattern = _.isArray(o.pattern) ? o.pattern : [ o.pattern ];
regex = getRegex(o.pattern, o.caseSensitive, o.wordsOnly);
traverse(o.node, hightlightTextNode);
function hightlightTextNode(textNode) {
var match, patternNode;
if (match = regex.exec(textNode.data)) {
wrapperNode = doc.createElement(o.tagName);
o.className && (wrapperNode.className = o.className);
patternNode = textNode.splitText(match.index);
patternNode.splitText(match[0].length);
wrapperNode.appendChild(patternNode.cloneNode(true));
textNode.parentNode.replaceChild(wrapperNode, patternNode);
}
return !!match;
}
function traverse(el, hightlightTextNode) {
var childNode, TEXT_NODE_TYPE = 3;
for (var i = 0; i < el.childNodes.length; i++) {
childNode = el.childNodes[i];
if (childNode.nodeType === TEXT_NODE_TYPE) {
i += hightlightTextNode(childNode) ? 1 : 0;
} else {
traverse(childNode, hightlightTextNode);
}
}
}
};
function getRegex(patterns, caseSensitive, wordsOnly) {
var escapedPatterns = [], regexStr;
for (var i = 0; i < patterns.length; i++) {
escapedPatterns.push(_.escapeRegExChars(patterns[i]));
}
regexStr = wordsOnly ? "\\b(" + escapedPatterns.join("|") + ")\\b" : "(" + escapedPatterns.join("|") + ")";
return caseSensitive ? new RegExp(regexStr) : new RegExp(regexStr, "i");
}
}(window.document);
var Input = function() {
var specialKeyCodeMap;
specialKeyCodeMap = {
9: "tab",
27: "esc",
37: "left",
39: "right",
13: "enter",
38: "up",
40: "down"
};
function Input(o) {
var that = this, onBlur, onFocus, onKeydown, onInput;
o = o || {};
if (!o.input) {
$.error("input is missing");
}
onBlur = _.bind(this._onBlur, this);
onFocus = _.bind(this._onFocus, this);
onKeydown = _.bind(this._onKeydown, this);
onInput = _.bind(this._onInput, this);
this.$hint = $(o.hint);
this.$input = $(o.input).on("blur.tt", onBlur).on("focus.tt", onFocus).on("keydown.tt", onKeydown);
if (this.$hint.length === 0) {
this.setHintValue = this.getHintValue = this.clearHint = _.noop;
}
if (!_.isMsie()) {
this.$input.on("input.tt", onInput);
} else {
this.$input.on("keydown.tt keypress.tt cut.tt paste.tt", function($e) {
if (specialKeyCodeMap[$e.which || $e.keyCode]) {
return;
}
_.defer(_.bind(that._onInput, that, $e));
});
}
this.query = this.$input.val();
this.$overflowHelper = buildOverflowHelper(this.$input);
}
Input.normalizeQuery = function(str) {
return (str || "").replace(/^\s*/g, "").replace(/\s{2,}/g, " ");
};
_.mixin(Input.prototype, EventEmitter, {
_onBlur: function onBlur($e) {
this.resetInputValue();
this.trigger("blurred");
},
_onFocus: function onFocus($e) {
this.trigger("focused");
},
_onKeydown: function onKeydown($e) {
var keyName = specialKeyCodeMap[$e.which || $e.keyCode];
this._managePreventDefault(keyName, $e);
if (keyName && this._shouldTrigger(keyName, $e)) {
this.trigger(keyName + "Keyed", $e);
}
},
_onInput: function onInput($e) {
this._checkInputValue();
},
_managePreventDefault: function managePreventDefault(keyName, $e) {
var preventDefault, hintValue, inputValue;
switch (keyName) {
case "tab":
hintValue = this.getHintValue();
inputValue = this.getInputValue();
preventDefault = hintValue && hintValue !== inputValue && !withModifier($e);
break;
case "up":
case "down":
preventDefault = !withModifier($e);
break;
default:
preventDefault = false;
}
preventDefault && $e.preventDefault();
},
_shouldTrigger: function shouldTrigger(keyName, $e) {
var trigger;
switch (keyName) {
case "tab":
trigger = !withModifier($e);
break;
default:
trigger = true;
}
return trigger;
},
_checkInputValue: function checkInputValue() {
var inputValue, areEquivalent, hasDifferentWhitespace;
inputValue = this.getInputValue();
areEquivalent = areQueriesEquivalent(inputValue, this.query);
hasDifferentWhitespace = areEquivalent ? this.query.length !== inputValue.length : false;
if (!areEquivalent) {
this.trigger("queryChanged", this.query = inputValue);
} else if (hasDifferentWhitespace) {
this.trigger("whitespaceChanged", this.query);
}
},
focus: function focus() {
this.$input.focus();
},
blur: function blur() {
this.$input.blur();
},
getQuery: function getQuery() {
return this.query;
},
setQuery: function setQuery(query) {
this.query = query;
},
getInputValue: function getInputValue() {
return this.$input.val();
},
setInputValue: function setInputValue(value, silent) {
this.$input.val(value);
!silent && this._checkInputValue();
},
getHintValue: function getHintValue() {
return this.$hint.val();
},
setHintValue: function setHintValue(value) {
this.$hint.val(value);
},
resetInputValue: function resetInputValue() {
this.$input.val(this.query);
},
clearHint: function clearHint() {
this.$hint.val("");
},
getLanguageDirection: function getLanguageDirection() {
return (this.$input.css("direction") || "ltr").toLowerCase();
},
hasOverflow: function hasOverflow() {
var constraint = this.$input.width() - 2;
this.$overflowHelper.text(this.getInputValue());
return this.$overflowHelper.width() >= constraint;
},
isCursorAtEnd: function() {
var valueLength, selectionStart, range;
valueLength = this.$input.val().length;
selectionStart = this.$input[0].selectionStart;
if (_.isNumber(selectionStart)) {
return selectionStart === valueLength;
} else if (document.selection) {
range = document.selection.createRange();
range.moveStart("character", -valueLength);
return valueLength === range.text.length;
}
return true;
},
destroy: function destroy() {
this.$hint.off(".tt");
this.$input.off(".tt");
this.$hint = this.$input = this.$overflowHelper = null;
}
});
return Input;
function buildOverflowHelper($input) {
return $('<pre aria-hidden="true"></pre>').css({
position: "absolute",
visibility: "hidden",
whiteSpace: "nowrap",
fontFamily: $input.css("font-family"),
fontSize: $input.css("font-size"),
fontStyle: $input.css("font-style"),
fontVariant: $input.css("font-variant"),
fontWeight: $input.css("font-weight"),
wordSpacing: $input.css("word-spacing"),
letterSpacing: $input.css("letter-spacing"),
textIndent: $input.css("text-indent"),
textRendering: $input.css("text-rendering"),
textTransform: $input.css("text-transform")
}).insertAfter($input);
}
function areQueriesEquivalent(a, b) {
return Input.normalizeQuery(a) === Input.normalizeQuery(b);
}
function withModifier($e) {
return $e.altKey || $e.ctrlKey || $e.metaKey || $e.shiftKey;
}
}();
var Dataset = function() {
var datasetKey = "ttDataset", valueKey = "ttValue", datumKey = "ttDatum";
function Dataset(o) {
o = o || {};
o.templates = o.templates || {};
if (!o.source) {
$.error("missing source");
}
if (o.name && !isValidName(o.name)) {
$.error("invalid dataset name: " + o.name);
}
this.query = null;
this.highlight = !!o.highlight;
this.name = o.name || _.getUniqueId();
this.source = o.source;
this.displayFn = getDisplayFn(o.display || o.displayKey);
this.templates = getTemplates(o.templates, this.displayFn);
this.$el = $(html.dataset.replace("%CLASS%", this.name));
}
Dataset.extractDatasetName = function extractDatasetName(el) {
return $(el).data(datasetKey);
};
Dataset.extractValue = function extractDatum(el) {
return $(el).data(valueKey);
};
Dataset.extractDatum = function extractDatum(el) {
return $(el).data(datumKey);
};
_.mixin(Dataset.prototype, EventEmitter, {
_render: function render(query, suggestions) {
if (!this.$el) {
return;
}
var that = this, hasSuggestions;
this.$el.empty();
hasSuggestions = suggestions && suggestions.length;
if (!hasSuggestions && this.templates.empty) {
this.$el.html(getEmptyHtml()).prepend(that.templates.header ? getHeaderHtml() : null).append(that.templates.footer ? getFooterHtml() : null);
} else if (hasSuggestions) {
this.$el.html(getSuggestionsHtml()).prepend(that.templates.header ? getHeaderHtml() : null).append(that.templates.footer ? getFooterHtml() : null);
}
this.trigger("rendered");
function getEmptyHtml() {
return that.templates.empty({
query: query,
isEmpty: true
});
}
function getSuggestionsHtml() {
var $suggestions, nodes;
$suggestions = $(html.suggestions).css(css.suggestions);
nodes = _.map(suggestions, getSuggestionNode);
$suggestions.append.apply($suggestions, nodes);
that.highlight && highlight({
node: $suggestions[0],
pattern: query
});
return $suggestions;
function getSuggestionNode(suggestion) {
var $el, innerHtml, outerHtml;
innerHtml = that.templates.suggestion(suggestion);
outerHtml = html.suggestion.replace("%BODY%", innerHtml);
$el = $(outerHtml).data(datasetKey, that.name).data(valueKey, that.displayFn(suggestion)).data(datumKey, suggestion);
$el.children().each(function() {
$(this).css(css.suggestionChild);
});
return $el;
}
}
function getHeaderHtml() {
return that.templates.header({
query: query,
isEmpty: !hasSuggestions
});
}
function getFooterHtml() {
return that.templates.footer({
query: query,
isEmpty: !hasSuggestions
});
}
},
getRoot: function getRoot() {
return this.$el;
},
update: function update(query) {
var that = this;
this.query = query;
this.source(query, renderIfQueryIsSame);
function renderIfQueryIsSame(suggestions) {
query === that.query && that._render(query, suggestions);
}
},
clear: function clear() {
this._render(this.query || "");
},
isEmpty: function isEmpty() {
return this.$el.is(":empty");
},
destroy: function destroy() {
this.$el = null;
}
});
return Dataset;
function getDisplayFn(display) {
display = display || "value";
return _.isFunction(display) ? display : displayFn;
function displayFn(obj) {
return obj[display];
}
}
function getTemplates(templates, displayFn) {
return {
empty: templates.empty && _.templatify(templates.empty),
header: templates.header && _.templatify(templates.header),
footer: templates.footer && _.templatify(templates.footer),
suggestion: templates.suggestion || suggestionTemplate
};
function suggestionTemplate(context) {
return "<p>" + displayFn(context) + "</p>";
}
}
function isValidName(str) {
return /^[_a-zA-Z0-9-]+$/.test(str);
}
}();
var Dropdown = function() {
function Dropdown(o) {
var that = this, onSuggestionClick, onSuggestionMouseEnter, onSuggestionMouseLeave;
o = o || {};
if (!o.menu) {
$.error("menu is required");
}
this.isOpen = false;
this.isEmpty = true;
this.datasets = _.map(o.datasets, initializeDataset);
onSuggestionClick = _.bind(this._onSuggestionClick, this);
onSuggestionMouseEnter = _.bind(this._onSuggestionMouseEnter, this);
onSuggestionMouseLeave = _.bind(this._onSuggestionMouseLeave, this);
this.$menu = $(o.menu).on("click.tt", ".tt-suggestion", onSuggestionClick).on("mouseenter.tt", ".tt-suggestion", onSuggestionMouseEnter).on("mouseleave.tt", ".tt-suggestion", onSuggestionMouseLeave);
_.each(this.datasets, function(dataset) {
that.$menu.append(dataset.getRoot());
dataset.onSync("rendered", that._onRendered, that);
});
}
_.mixin(Dropdown.prototype, EventEmitter, {
_onSuggestionClick: function onSuggestionClick($e) {
this.trigger("suggestionClicked", $($e.currentTarget));
},
_onSuggestionMouseEnter: function onSuggestionMouseEnter($e) {
this._removeCursor();
this._setCursor($($e.currentTarget), true);
},
_onSuggestionMouseLeave: function onSuggestionMouseLeave($e) {
this._removeCursor();
},
_onRendered: function onRendered() {
this.isEmpty = _.every(this.datasets, isDatasetEmpty);
this.isEmpty ? this._hide() : this.isOpen && this._show();
this.trigger("datasetRendered");
function isDatasetEmpty(dataset) {
return dataset.isEmpty();
}
},
_hide: function() {
this.$menu.hide();
},
_show: function() {
this.$menu.css("display", "block");
},
_getSuggestions: function getSuggestions() {
return this.$menu.find(".tt-suggestion");
},
_getCursor: function getCursor() {
return this.$menu.find(".tt-cursor").first();
},
_setCursor: function setCursor($el, silent) {
$el.first().addClass("tt-cursor");
!silent && this.trigger("cursorMoved");
},
_removeCursor: function removeCursor() {
this._getCursor().removeClass("tt-cursor");
},
_moveCursor: function moveCursor(increment) {
var $suggestions, $oldCursor, newCursorIndex, $newCursor;
if (!this.isOpen) {
return;
}
$oldCursor = this._getCursor();
$suggestions = this._getSuggestions();
this._removeCursor();
newCursorIndex = $suggestions.index($oldCursor) + increment;
newCursorIndex = (newCursorIndex + 1) % ($suggestions.length + 1) - 1;
if (newCursorIndex === -1) {
this.trigger("cursorRemoved");
return;
} else if (newCursorIndex < -1) {
newCursorIndex = $suggestions.length - 1;
}
this._setCursor($newCursor = $suggestions.eq(newCursorIndex));
this._ensureVisible($newCursor);
},
_ensureVisible: function ensureVisible($el) {
var elTop, elBottom, menuScrollTop, menuHeight;
elTop = $el.position().top;
elBottom = elTop + $el.outerHeight(true);
menuScrollTop = this.$menu.scrollTop();
menuHeight = this.$menu.height() + parseInt(this.$menu.css("paddingTop"), 10) + parseInt(this.$menu.css("paddingBottom"), 10);
if (elTop < 0) {
this.$menu.scrollTop(menuScrollTop + elTop);
} else if (menuHeight < elBottom) {
this.$menu.scrollTop(menuScrollTop + (elBottom - menuHeight));
}
},
close: function close() {
if (this.isOpen) {
this.isOpen = false;
this._removeCursor();
this._hide();
this.trigger("closed");
}
},
open: function open() {
if (!this.isOpen) {
this.isOpen = true;
!this.isEmpty && this._show();
this.trigger("opened");
}
},
setLanguageDirection: function setLanguageDirection(dir) {
this.$menu.css(dir === "ltr" ? css.ltr : css.rtl);
},
moveCursorUp: function moveCursorUp() {
this._moveCursor(-1);
},
moveCursorDown: function moveCursorDown() {
this._moveCursor(+1);
},
getDatumForSuggestion: function getDatumForSuggestion($el) {
var datum = null;
if ($el.length) {
datum = {
raw: Dataset.extractDatum($el),
value: Dataset.extractValue($el),
datasetName: Dataset.extractDatasetName($el)
};
}
return datum;
},
getDatumForCursor: function getDatumForCursor() {
return this.getDatumForSuggestion(this._getCursor().first());
},
getDatumForTopSuggestion: function getDatumForTopSuggestion() {
return this.getDatumForSuggestion(this._getSuggestions().first());
},
update: function update(query) {
_.each(this.datasets, updateDataset);
function updateDataset(dataset) {
dataset.update(query);
}
},
empty: function empty() {
_.each(this.datasets, clearDataset);
this.isEmpty = true;
function clearDataset(dataset) {
dataset.clear();
}
},
isVisible: function isVisible() {
return this.isOpen && !this.isEmpty;
},
destroy: function destroy() {
this.$menu.off(".tt");
this.$menu = null;
_.each(this.datasets, destroyDataset);
function destroyDataset(dataset) {
dataset.destroy();
}
}
});
return Dropdown;
function initializeDataset(oDataset) {
return new Dataset(oDataset);
}
}();
var Typeahead = function() {
var attrsKey = "ttAttrs";
function Typeahead(o) {
var $menu, $input, $hint, datasets;
o = o || {};
if (!o.input) {
$.error("missing input");
}
this.autoselect = !!o.autoselect;
this.minLength = _.isNumber(o.minLength) ? o.minLength : 1;
this.$node = buildDomStructure(o.input, o.withHint);
$menu = this.$node.find(".tt-dropdown-menu");
$input = this.$node.find(".tt-input");
$hint = this.$node.find(".tt-hint");
this.eventBus = o.eventBus || new EventBus({
el: $input
});
this.dropdown = new Dropdown({
menu: $menu,
datasets: o.datasets
}).onSync("suggestionClicked", this._onSuggestionClicked, this).onSync("cursorMoved", this._onCursorMoved, this).onSync("cursorRemoved", this._onCursorRemoved, this).onSync("opened", this._onOpened, this).onSync("closed", this._onClosed, this).onAsync("datasetRendered", this._onDatasetRendered, this);
this.input = new Input({
input: $input,
hint: $hint
}).onSync("focused", this._onFocused, this).onSync("blurred", this._onBlurred, this).onSync("enterKeyed", this._onEnterKeyed, this).onSync("tabKeyed", this._onTabKeyed, this).onSync("escKeyed", this._onEscKeyed, this).onSync("upKeyed", this._onUpKeyed, this).onSync("downKeyed", this._onDownKeyed, this).onSync("leftKeyed", this._onLeftKeyed, this).onSync("rightKeyed", this._onRightKeyed, this).onSync("queryChanged", this._onQueryChanged, this).onSync("whitespaceChanged", this._onWhitespaceChanged, this);
$menu.on("mousedown.tt", function($e) {
if (_.isMsie() && _.isMsie() < 9) {
$input[0].onbeforedeactivate = function() {
window.event.returnValue = false;
$input[0].onbeforedeactivate = null;
};
}
$e.preventDefault();
});
}
_.mixin(Typeahead.prototype, {
_onSuggestionClicked: function onSuggestionClicked(type, $el) {
var datum;
if (datum = this.dropdown.getDatumForSuggestion($el)) {
this._select(datum);
}
},
_onCursorMoved: function onCursorMoved() {
var datum = this.dropdown.getDatumForCursor();
this.input.clearHint();
this.input.setInputValue(datum.value, true);
this.eventBus.trigger("cursorchanged", datum.raw, datum.datasetName);
},
_onCursorRemoved: function onCursorRemoved() {
this.input.resetInputValue();
this._updateHint();
},
_onDatasetRendered: function onDatasetRendered() {
this._updateHint();
},
_onOpened: function onOpened() {
this._updateHint();
this.eventBus.trigger("opened");
},
_onClosed: function onClosed() {
this.input.clearHint();
this.eventBus.trigger("closed");
},
_onFocused: function onFocused() {
this.dropdown.empty();
this.dropdown.open();
},
_onBlurred: function onBlurred() {
this.dropdown.close();
},
_onEnterKeyed: function onEnterKeyed(type, $e) {
var cursorDatum, topSuggestionDatum;
cursorDatum = this.dropdown.getDatumForCursor();
topSuggestionDatum = this.dropdown.getDatumForTopSuggestion();
if (cursorDatum) {
this._select(cursorDatum);
$e.preventDefault();
} else if (this.autoselect && topSuggestionDatum) {
this._select(topSuggestionDatum);
$e.preventDefault();
}
},
_onTabKeyed: function onTabKeyed(type, $e) {
var datum;
if (datum = this.dropdown.getDatumForCursor()) {
this._select(datum);
$e.preventDefault();
} else {
this._autocomplete();
}
},
_onEscKeyed: function onEscKeyed() {
this.dropdown.close();
this.input.resetInputValue();
},
_onUpKeyed: function onUpKeyed() {
var query = this.input.getQuery();
if (!this.dropdown.isOpen && query.length >= this.minLength) {
this.dropdown.update(query);
}
this.dropdown.open();
this.dropdown.moveCursorUp();
},
_onDownKeyed: function onDownKeyed() {
var query = this.input.getQuery();
if (!this.dropdown.isOpen && query.length >= this.minLength) {
this.dropdown.update(query);
}
this.dropdown.open();
this.dropdown.moveCursorDown();
},
_onLeftKeyed: function onLeftKeyed() {
this.dir === "rtl" && this._autocomplete();
},
_onRightKeyed: function onRightKeyed() {
this.dir === "ltr" && this._autocomplete();
},
_onQueryChanged: function onQueryChanged(e, query) {
this.input.clearHint();
this.dropdown.empty();
query.length >= this.minLength && this.dropdown.update(query);
this.dropdown.open();
this._setLanguageDirection();
},
_onWhitespaceChanged: function onWhitespaceChanged() {
this._updateHint();
this.dropdown.open();
},
_setLanguageDirection: function setLanguageDirection() {
var dir;
if (this.dir !== (dir = this.input.getLanguageDirection())) {
this.dir = dir;
this.$node.css("direction", dir);
this.dropdown.setLanguageDirection(dir);
}
},
_updateHint: function updateHint() {
var datum, inputValue, query, escapedQuery, frontMatchRegEx, match;
datum = this.dropdown.getDatumForTopSuggestion();
if (datum && this.dropdown.isVisible() && !this.input.hasOverflow()) {
inputValue = this.input.getInputValue();
query = Input.normalizeQuery(inputValue);
escapedQuery = _.escapeRegExChars(query);
frontMatchRegEx = new RegExp("^(?:" + escapedQuery + ")(.*$)", "i");
match = frontMatchRegEx.exec(datum.value);
this.input.setHintValue(inputValue + (match ? match[1] : ""));
}
},
_autocomplete: function autocomplete() {
var hint, query, datum;
hint = this.input.getHintValue();
query = this.input.getQuery();
if (hint && query !== hint && this.input.isCursorAtEnd()) {
datum = this.dropdown.getDatumForTopSuggestion();
datum && this.input.setInputValue(datum.value);
this.eventBus.trigger("autocompleted", datum.raw, datum.datasetName);
}
},
_select: function select(datum) {
this.input.clearHint();
this.input.setQuery(datum.value);
this.input.setInputValue(datum.value, true);
this._setLanguageDirection();
this.eventBus.trigger("selected", datum.raw, datum.datasetName);
this.dropdown.close();
_.defer(_.bind(this.dropdown.empty, this.dropdown));
},
open: function open() {
this.dropdown.open();
},
close: function close() {
this.dropdown.close();
},
getQuery: function getQuery() {
return this.input.getQuery();
},
setQuery: function setQuery(val) {
this.input.setInputValue(val);
},
destroy: function destroy() {
this.input.destroy();
this.dropdown.destroy();
destroyDomStructure(this.$node);
this.$node = null;
}
});
return Typeahead;
function buildDomStructure(input, withHint) {
var $input, $wrapper, $dropdown, $hint;
$input = $(input);
$wrapper = $(html.wrapper).css(css.wrapper);
$dropdown = $(html.dropdown).css(css.dropdown);
$hint = $input.clone().css(css.hint).css(getBackgroundStyles($input));
$hint.val("").removeData().addClass("tt-hint").removeAttr("id name placeholder").prop("disabled", true).attr({
autocomplete: "off",
spellcheck: "false"
});
$input.data(attrsKey, {
dir: $input.attr("dir"),
autocomplete: $input.attr("autocomplete"),
spellcheck: $input.attr("spellcheck"),
style: $input.attr("style")
});
$input.addClass("tt-input").attr({
autocomplete: "off",
spellcheck: false
}).css(withHint ? css.input : css.inputWithNoHint);
try {
!$input.attr("dir") && $input.attr("dir", "auto");
} catch (e) {}
return $input.wrap($wrapper).parent().prepend(withHint ? $hint : null).append($dropdown);
}
function getBackgroundStyles($el) {
return {
backgroundAttachment: $el.css("background-attachment"),
backgroundClip: $el.css("background-clip"),
backgroundColor: $el.css("background-color"),
backgroundImage: $el.css("background-image"),
backgroundOrigin: $el.css("background-origin"),
backgroundPosition: $el.css("background-position"),
backgroundRepeat: $el.css("background-repeat"),
backgroundSize: $el.css("background-size")
};
}
function destroyDomStructure($node) {
var $input = $node.find(".tt-input");
_.each($input.data(attrsKey), function(val, key) {
_.isUndefined(val) ? $input.removeAttr(key) : $input.attr(key, val);
});
$input.detach().removeData(attrsKey).removeClass("tt-input").insertAfter($node);
$node.remove();
}
}();
(function() {
var old, typeaheadKey, methods;
old = $.fn.typeahead;
typeaheadKey = "ttTypeahead";
methods = {
initialize: function initialize(o, datasets) {
datasets = _.isArray(datasets) ? datasets : [].slice.call(arguments, 1);
o = o || {};
return this.each(attach);
function attach() {
var $input = $(this), eventBus, typeahead;
_.each(datasets, function(d) {
d.highlight = !!o.highlight;
});
typeahead = new Typeahead({
input: $input,
eventBus: eventBus = new EventBus({
el: $input
}),
withHint: _.isUndefined(o.hint) ? true : !!o.hint,
minLength: o.minLength,
autoselect: o.autoselect,
datasets: datasets
});
$input.data(typeaheadKey, typeahead);
}
},
open: function open() {
return this.each(openTypeahead);
function openTypeahead() {
var $input = $(this), typeahead;
if (typeahead = $input.data(typeaheadKey)) {
typeahead.open();
}
}
},
close: function close() {
return this.each(closeTypeahead);
function closeTypeahead() {
var $input = $(this), typeahead;
if (typeahead = $input.data(typeaheadKey)) {
typeahead.close();
}
}
},
val: function val(newVal) {
return !arguments.length ? getQuery(this.first()) : this.each(setQuery);
function setQuery() {
var $input = $(this), typeahead;
if (typeahead = $input.data(typeaheadKey)) {
typeahead.setQuery(newVal);
}
}
function getQuery($input) {
var typeahead, query;
if (typeahead = $input.data(typeaheadKey)) {
query = typeahead.getQuery();
}
return query;
}
},
destroy: function destroy() {
return this.each(unattach);
function unattach() {
var $input = $(this), typeahead;
if (typeahead = $input.data(typeaheadKey)) {
typeahead.destroy();
$input.removeData(typeaheadKey);
}
}
}
};
$.fn.typeahead = function(method) {
if (methods[method]) {
return methods[method].apply(this, [].slice.call(arguments, 1));
} else {
return methods.initialize.apply(this, arguments);
}
};
$.fn.typeahead.noConflict = function noConflict() {
$.fn.typeahead = old;
return this;
};
})();
})(window.jQuery);
[{"name":"Tore Abrahamsson"}, {"name":"Johan Christian Ackermann (arkitekt)"}, {"name":"Carl-Axel Acking"}, {"name":"Carl Fredrik Adelcrantz"}, {"name":"G\u00f6ran Josu\u00e6 Adelcrantz"}, {"name":"Claes Adelsk\u00f6ld"}, {"name":"Bror Viktor Adler"}, {"name":"Jean Adrian"}, {"name":"Hakon Ahlberg"}, {"name":"Sven Ahlbom"}, {"name":"Yngve Ahlbom"}, {"name":"Magnus Ahlgren"}, {"name":"Erik och Tore Ahls\u00e9n"}, {"name":"\u00c5ke Ahlstr\u00f6m"}, {"name":"Erik Ahnborg"}, {"name":"Arvid Ahrnborg"},
{"name":"Lorens Axel Fredrik Almfelt"}, {"name":"Bror Almquist"}, {"name":"Osvald Almqvist"}, {"name":"Jerk Alton"}, {"name":"Gustaf Am\u00e9en"}, {"name":"John Anchert"}, {"name":"Theodor Anckarsv\u00e4rd"}, {"name":"Stig Ancker"}, {"name":"Axel Anderberg"}, {"name":"Anders m\u00e5lare"}, {"name":"Ola Anderson"}, {"name":"Olle Anderson"}, {"name":"Carl Andersson (arkitekt)"}, {"name":"Henrik O. Andersson"}, {"name":"Harald Andr\u00e9 (arkitekt)"}, {"name":"Stig Annerfelt"}, {"name":"Klas Anshelm"},
{"name":"Per Appelberg (arkitekt)"}, {"name":"Christina von Arbin"}, {"name":"Rudolf Arborelius"}, {"name":"ARES (arkitekter)"}, {"name":"Georg Arn"}, {"name":"Alfred Arwidius"}, {"name":"Lars Asklund"}, {"name":"Gunnar Asplund"}, {"name":"Hans Asplund"}, {"name":"Uno Asplund"}, {"name":"August Atterstr\u00f6m"}, {"name":"Tore Ax\u00e9n"}, {"name":"Adam Backstr\u00f6m"}, {"name":"Sven Backstr\u00f6m"}, {"name":"John Bagger"}, {"name":"Kerstin Barup"}, {"name":"Knut Beckeman"}, {"name":"Zolt\u00e1n Bedecs"},
{"name":"Emil Befwe"}, {"name":"Rahel Belatchew Lerdell"}, {"name":"Elis Benckert"}, {"name":"Karl M. Bengtson"}, {"name":"Per Benson"}, {"name":"Folke Bensow"}, {"name":"Anders Berg (arkitekt)"}, {"name":"Thure Bergentz"}, {"name":"Edvin Bergenudd"}, {"name":"Gottfrid Bergenudd"}, {"name":"Ulf Bergfjord"}, {"name":"Elis Bergh"}, {"name":"Rolf Bergh"}, {"name":"Robert Berghagen"}, {"name":"Harald Berglin"}, {"name":"Axel Bergman (arkitekt)"}, {"name":"Carl Bergsten"}, {"name":"Anders Wilhelm Bergstr\u00f6m"},
{"name":"Lennart Bergstr\u00f6m"}, {"name":"Karl Berlin"}, {"name":"Edvard Bernhard"}, {"name":"Emil Billing"}, {"name":"Gustaf Birch-Lindgren"}, {"name":"Arvid Bjerke"}, {"name":"Folke Bj\u00f6rck"}, {"name":"Curt Bj\u00f6rklund"}, {"name":"Axel Bj\u00f6rkman"}, {"name":"Karl-Axel Bladh"}, {"name":"Nils A. Blanck"}, {"name":"Maria Block"}, {"name":"Carl Gustaf Blom Carlsson"}, {"name":"Fredrik Blom"}, {"name":"Gustav Adolf Blom"}, {"name":"Holger Blom"}, {"name":"David Blomberg"}, {"name":"Ferdinand Boberg"},
{"name":"Paul Boberg"}, {"name":"Anders Bodin (arkitekt)"}, {"name":"Victor Bodin"}, {"name":"Peter Boisen (arkitekt)"}, {"name":"Varis Bokalders"}, {"name":"Harald Boklund"}, {"name":"Rolf Bolin (arkitekt)"}, {"name":"Klas Boman"}, {"name":"Anna Borelius-Brodd"}, {"name":"Oscar Borgman"}, {"name":"Martin Borgstedt"}, {"name":"Birger Borgstr\u00f6m"}, {"name":"Hans Borgstr\u00f6m"}, {"name":"Per Borgstr\u00f6m"}, {"name":"Erik Bostr\u00f6m (arkitekt)"}, {"name":"Willem Boy"}, {"name":"Albin Brag"},
{"name":"Madeleine Brandin"}, {"name":"Anna Branzell"}, {"name":"Arne Branzell"}, {"name":"Sten Branzell"}, {"name":"Arthur Brattberg"}, {"name":"Sven Brolid"}, {"name":"Fleming Broman"}, {"name":"Carl Georg Brunius"}, {"name":"Hans Brunnberg"}, {"name":"Axel Brunskog"}, {"name":"Lars Bryde"}, {"name":"Joachim van Bulgerin"}, {"name":"Alf Byd\u00e9n"}, {"name":"Lars B\u00e4ckvall"}, {"name":"Hillevi Callander"}, {"name":"Ivar Callmander"}, {"name":"Carl Hampus Bergman"}, {"name":"Bengt Wilhelm Carlberg"},
{"name":"Carl Wilhelm Carlberg"}, {"name":"Johan Eberhard Carlberg"}, {"name":"Haqvin Carlheim-Gyllensk\u00f6ld"}, {"name":"Hjalmar Cederstr\u00f6m"}, {"name":"Johan Celsing"}, {"name":"Peter Celsing"}, {"name":"William Chambers (arkitekt)"}, {"name":"Georg Theodor Chiewitz"}, {"name":"Gustaf Clason"}, {"name":"Peder Clason"}, {"name":"Lennart Clemens"}, {"name":"Hjalmar Cornilsen"}, {"name":"Carl Crispin"}, {"name":"Sigge Cronstedt"}, {"name":"Carl Johan Cronstedt"}, {"name":"J\u00f6ran CurmanD"},
{"name":"David Dahl"}, {"name":"Gustaf Dahl"}, {"name":"Theodor Dahl"}, {"name":"Magnus Dahlander"}, {"name":"Birger Dahlberg"}, {"name":"Erik Dahlberg (arkitekt)"}, {"name":"Fredrik Dahlberg"}, {"name":"Mauritz Dahlberg"}, {"name":"Erik Dahlbergh"}, {"name":"Olle Dahl\u00e9n (arkitekt)"}, {"name":"Greger Dahlstr\u00f6m"}, {"name":"Kjell Dahlstr\u00f6m"}, {"name":"Rudolph Matthias Dallin"}, {"name":"Birger Damstedt"}, {"name":"G\u00f6sta Danielson (arkitekt)"}, {"name":"Alfred Danielsson-B\u00e5\u00e5k"},
{"name":"Gerard de Besche"}, {"name":"Gustaf de Frumerie"}, {"name":"Christoffer de la Vall\u00e9e"}, {"name":"Olof Deas-Olsson"}, {"name":"Igor Dergalin"}, {"name":"Louis Jean Desprez"}, {"name":"Gustaf Detthoff"}, {"name":"Peter Dionisius"}, {"name":"Gunnar Djurberg"}, {"name":"Per Dockson"}, {"name":"Victor Dorph"}, {"name":"Stig Dranger"}, {"name":"Svante Dyhl\u00e9n"}, {"name":"Otto DymlingE"}, {"name":"Fritz Eckert"}, {"name":"Birgitta Edberg"}, {"name":"Carl Albert Edelfelt"}, {"name":"Adolf W. Edelsv\u00e4rd"},
{"name":"Bengt Edman"}, {"name":"Harry Egler"}, {"name":"Hans Ehrlin"}, {"name":"Fredrik Ekberg"}, {"name":"Frans Ekelund"}, {"name":"Lennart Ekenger"}, {"name":"Carl Axel Ekholm"}, {"name":"Carl Fredrik Ekholm"}, {"name":"Frithiof Ekman"}, {"name":"Pehr Johan Ekman"}, {"name":"Yngve Ekstr\u00f6m"}, {"name":"Elding Oscarson"}, {"name":"Claes Eliander"}, {"name":"Konrad Elm\u00e9us"}, {"name":"Samuel Enander (arkitekt)"}, {"name":"Rudolf S. Enblom"}, {"name":"Louis Enders"}, {"name":"Edvin Engstr\u00f6m"},
{"name":"Ivar Engstr\u00f6m"}, {"name":"Rolf Engstr\u00f6mer"}, {"name":"Johann Friedrich Eosander von G\u00f6the"}, {"name":"Estrid Ericson"}, {"name":"Harald Ericson"}, {"name":"Sigfrid Ericson"}, {"name":"Oskar Erikson"}, {"name":"Annika Eriksson (arkitekt)"}, {"name":"Axel Eriksson"}, {"name":"Nils Einar Eriksson"}, {"name":"Ralph Erskine"}, {"name":"Arre Ess\u00e9n"}, {"name":"Per Estenberg"}, {"name":"August Ewe"}, {"name":"Victor Fagerstr\u00f6m"}, {"name":"Carl Fahlstr\u00f6m"}, {"name":"Gustav Adolf Falk"},
{"name":"Rune Falk"}, {"name":"Arvid Falkenberg"}, {"name":"Fredrik Falkenberg"}, {"name":"Harald Falkman"}, {"name":"Erik Fant"}, {"name":"Erik Fehling"}, {"name":"Johan Fredric Fehmer"}, {"name":"Janne Feldt"}, {"name":"Hans Fleming"}, {"name":"Sune Fl\u00f6k"}, {"name":"Fred Forbat"}, {"name":"Anders Gustaf Forsberg"}, {"name":"Axel Herman Forsberg"}, {"name":"Axel Viktor Forsberg"}, {"name":"Axel Forss\u00e9n"}, {"name":"Gunnar Forsz\u00e9n"}, {"name":"S Uno Forthmeiier"}, {"name":"Albert France-Lanord"},
{"name":"Josef Frank"}, {"name":"Daniel Franz\u00e9n"}, {"name":"Yngve Fredriks\u00e9n"}, {"name":"Nils G:son Friberg"}, {"name":"Per Friberg"}, {"name":"Erik Friberger"}, {"name":"Archibald Frid"}, {"name":"Karin Fridell Anter"}, {"name":"Bertil Fridhagen"}, {"name":"Casper Christian Friese"}, {"name":"Johan Wilhelm Friese"}, {"name":"Christian Frisenstam"}, {"name":"Gustaf Adolf Fristedt"}, {"name":"Fredrik Fritzson"}, {"name":"Mauritz Frohm"}, {"name":"Sture Fr\u00f6l\u00e9n"}, {"name":"Arvid FuhreG"},
{"name":"Eva Gabrielsson"}, {"name":"Hans Gade"}, {"name":"Wolter Gahn"}, {"name":"Roland Gandvik"}, {"name":"Bengt Gate"}, {"name":"Jacob J:son Gate"}, {"name":"Victor von Gegerfelt"}, {"name":"Charles-Edouard Geisendorf"}, {"name":"L\u00e9onie Geisendorf"}, {"name":"Jacob Wilhelm Gerss"}, {"name":"Jan Gezelius"}, {"name":"Lars Magnus Giertz"}, {"name":"Petra Gipp"}, {"name":"Carl Christoffer Gj\u00f6rwell den yngre"}, {"name":"Erik Glemme"}, {"name":"Carl Theodor Glosemeyer"}, {"name":"Lars Gram\u00e9n"},
{"name":"Sven Gratz"}, {"name":"Bo Grefberg"}, {"name":"Alfred Grenander"}, {"name":"Claes Grundstr\u00f6m"}, {"name":"Torben Grut"}, {"name":"Eiler Gr\u00e6be"}, {"name":"Ernst Gr\u00f6nwall"}, {"name":"Karl G\u00fcettler"}, {"name":"Pehr Johan Gylich"}, {"name":"Kenneth G\u00e4rdestad"}, {"name":"Kjerstin G\u00f6ransson-Ljungman"}, {"name":"Viking G\u00f6ranssonH"}, {"name":"Ernst Haegglund"}, {"name":"Jonas Hagberg"}, {"name":"Carl Axel Hagelberg"}, {"name":"Daniel Hagman"}, {"name":"Rolf Hagstrand"},
{"name":"Erik Hahr"}, {"name":"Margit Hall"}, {"name":"Rudolf Hall (arkitekt)"}, {"name":"Per Olof Hallman"}, {"name":"Carl-Otto Hallstr\u00f6m"}, {"name":"Ludvig Hammar"}, {"name":"Hjalmar Hammarling"}, {"name":"Ingeborg Hammarskj\u00f6ld-Reiz"}, {"name":"Albin Hamrin"}, {"name":"Tomas Hansen"}, {"name":"Jack Hanson"}, {"name":"Torsten Hansson"}, {"name":"Elizabeth Hatz"}, {"name":"Immanuel H\u00e4usler"}, {"name":"Ernst Hawerman"}, {"name":"Johan Adolf Hawerman"}, {"name":"Ludvig Hawerman"}, {"name":"Abraham Ludvig Hedin"},
{"name":"Erik Alfred Hedin"}, {"name":"Bj\u00f6rner Hedlund"}, {"name":"Hedvig Hedqvist"}, {"name":"Paul Hedqvist"}, {"name":"G\u00f6sta Hedstr\u00f6m"}, {"name":"Bj\u00f6rn Hedvall"}, {"name":"Frans Jacob Heilborn"}, {"name":"Hans-Erland Heineman"}, {"name":"David Helld\u00e9n"}, {"name":"Alfred Hellerstr\u00f6m"}, {"name":"Jan Henriksson"}, {"name":"Staffan Henriksson"}, {"name":"Gustaf Hermansson"}, {"name":"Tage Hertzell"}, {"name":"Sven Hesselgren"}, {"name":"Erland Heurlin"}, {"name":"Bengt Hidemark"},
{"name":"Carl Fredrik Hjelm"}, {"name":"Ragnar Hjorth"}, {"name":"Lennart Holm"}, {"name":"Oscar Holm"}, {"name":"Gustav Holmdahl"}, {"name":"Erik Holmdal"}, {"name":"Carl-Fredrik Holmer"}, {"name":"Herman Holmgren"}, {"name":"Victor Holmgren"}, {"name":"Gunnar Hoving"}, {"name":"Johan Huldt"}, {"name":"Olof Hult (arkitekt)"}, {"name":"Olof Hultin"}, {"name":"Bengt Hultmark"}, {"name":"Gustaf Hultquist"}, {"name":"Sten Hummel-Gumaelius"}, {"name":"Hendrik van Huwen"}, {"name":"Bertil H\u00e5kansson"},
{"name":"Carl H\u00e5rleman"}, {"name":"Axel Herman H\u00e4gg"}, {"name":"Mia H\u00e4gg"}, {"name":"Oscar H\u00e4gg"}, {"name":"Theodor H\u00f6gstr\u00f6m"}, {"name":"Jon H\u00f6jer"}, {"name":"Otar H\u00f6kerberg"}, {"name":"Hugo H\u00f6rlin"}, {"name":"Carl H\u00f6rvik"}, {"name":"Anders H\u00f6\u00f6g"}, {"name":"Bertil H\u00f6\u00f6kI"}, {"name":"Hermann Imh\u00e4user"}, {"name":"Jan Inghe-Hagstr\u00f6m"}, {"name":"Carmen IzquierdoJ"}, {"name":"Gunnar Jacobson"}, {"name":"Fritz Jaenecke"}, {"name":"Hugo Jahnke"},
{"name":"Henrik Jais-Nielsen"}, {"name":"August Jakobsson"}, {"name":"Bristol Jald\u00e9n"}, {"name":"Johan Jarl\u00e9n"}, {"name":"Aron Johansson"}, {"name":"Cyrillus Johansson"}, {"name":"Waldemar Johansson"}, {"name":"Bengt H. Jonson"}, {"name":"Birger Jonson"}, {"name":"Koj Jonsson"}, {"name":"Olof Jonsson (arkitekt)"}, {"name":"Erik Josephson"}, {"name":"Axel Jul\u00e9n"}, {"name":"Stefan JunestrandK"}, {"name":"Per Kallstenius"}, {"name":"Hack Kampmann"}, {"name":"Axel Kandell"}, {"name":"John Kandell"},
{"name":"Valfrid Karlson"}, {"name":"Karl Karlstr\u00f6m"}, {"name":"Gustaf Kaunitz"}, {"name":"Theodor Kellgren"}, {"name":"Lars Kellman"}, {"name":"Carl Kempendahl"}, {"name":"Karolina Keyzer"}, {"name":"Carl August Kihlberg"}, {"name":"Sam Kjellberg"}, {"name":"Adolf Kjellstr\u00f6m"}, {"name":"William Klein"}, {"name":"Carl Kleitz"}, {"name":"Wilhelm Klemming"}, {"name":"Frej Klemming"}, {"name":"Hjalmar Klemming"}, {"name":"Fredrik Filip Klingspor"}, {"name":"Lennart Kolte"}, {"name":"Christo Kouzmanov"},
{"name":"Heino Krabu"}, {"name":"Axel Kumlien"}, {"name":"Hjalmar Kumlien"}, {"name":"Lennart Kvarnstr\u00f6m"}, {"name":"Natanael K\u00e4llander"}, {"name":"Margareta K\u00e4llstr\u00f6m"}, {"name":"Carl Henrik K\u00f6nigL"}, {"name":"Olle Lagergren"}, {"name":"Per Lagergren"}, {"name":"Lars-Erik Lallerstedt"}, {"name":"Alf Land\u00e9n"}, {"name":"Rudolf Lange (arkitekt)"}, {"name":"Adrian Langendal"}, {"name":"Emil Viktor Langlet"}, {"name":"Erik Langlet"}, {"name":"Gustaf Larson (arkitekt)"},
{"name":"Lena Larsson"}, {"name":"M\u00e5rten Larsson"}, {"name":"Curt Laudon"}, {"name":"Gustaf Laurelius"}, {"name":"Claes Laurent"}, {"name":"Johan Laurentz"}, {"name":"Gunnar Leche"}, {"name":"Lars Johan Lehming"}, {"name":"Lennart van Leipzig"}, {"name":"Gunnar Len\u00e9"}, {"name":"Torsten Leon-Nilson"}, {"name":"Gustaf Lettstr\u00f6m"}, {"name":"Sigurd Lewerentz"}, {"name":"Ebbe Lidemark"}, {"name":"Fredrik Lidvall"}, {"name":"Albert Lilienberg"}, {"name":"Fredrik Lilljekvist"}, {"name":"Sven Ivar Lind"},
{"name":"Birger Lindberg"}, {"name":"Oskar Lindberg (formgivare)"}, {"name":"Sune Linde"}, {"name":"Sten Lindeberg"}, {"name":"Agi Lindegren"}, {"name":"Axel Lindegren"}, {"name":"Sten Lindegren"}, {"name":"Gustav Linden"}, {"name":"Anders Linder"}, {"name":"Gustaf Lindgren"}, {"name":"Ingela Lindh"}, {"name":"Tore E:son Lindhberg"}, {"name":"Charles Lindholm"}, {"name":"Gunnar Lindman"}, {"name":"Carl Adam Lindmark"}, {"name":"R. L. Lindquist"}, {"name":"Ossian Lindqvist"}, {"name":"\u00c5ke E. Lindqvist"},
{"name":"Bengt Lindroos"}, {"name":"John Lindros"}, {"name":"Frans Lindskog"}, {"name":"Carl-Robert Lindstr\u00f6m"}, {"name":"Fredrik Olaus Lindstr\u00f6m"}, {"name":"August Lindvall"}, {"name":"Jan Lisinski"}, {"name":"Pontus Ljungberg"}, {"name":"Gottfrid Ljunggren"}, {"name":"Sture Ljungqvist"}, {"name":"Einar Lov\u00e9n"}, {"name":"Erik Lundberg (arkitekt)"}, {"name":"David Lundeg\u00e5rdh"}, {"name":"Joel Lundeqvist"}, {"name":"Filip Lundgren"}, {"name":"Olof Lundgren"}, {"name":"Sven Erik Lundqvist"},
{"name":"Erik Lundroth"}, {"name":"\u00d6rjan L\u00fcning"}, {"name":"Folke L\u00f6fstr\u00f6m"}, {"name":"Charles Emil L\u00f6fvenski\u00f6ldM"}, {"name":"Agnes Magnell"}, {"name":"Greta Magnusson-Grossman"}, {"name":"Carl Theodor Malm"}, {"name":"Sven Malm (arkitekt)"}, {"name":"Bror Malmberg"}, {"name":"Olof Malmgren"}, {"name":"Sune Malmquist"}, {"name":"Carl Malmstr\u00f6m (arkitekt)"}, {"name":"Folke Mandelius"}, {"name":"Mandus Mandelius"}, {"name":"Otto August Mankell"}, {"name":"Sven Markelius"},
{"name":"Laszlo Marko"}, {"name":"Bruno Mathsson"}, {"name":"Gunnar Mattsson (arkitekt)"}, {"name":"Thor Medelplan"}, {"name":"Edvard Med\u00e9n"}, {"name":"Carl Fredrik Meijer"}, {"name":"Johan Mel"}, {"name":"Adolf Emil Melander"}, {"name":"Bengt-Olof Melin"}, {"name":"Carl Melin"}, {"name":"Dag Melin"}, {"name":"Johan August Mesch"}, {"name":"Evert Milles"}, {"name":"Jan Mizerski"}, {"name":"Harald Mj\u00f6berg"}, {"name":"Mogens Mogensen"}, {"name":"Mats Erik Molander"}, {"name":"Ragnar Molin"},
{"name":"Harald Mores"}, {"name":"Gunnar Morssing"}, {"name":"Hans Murman"}, {"name":"Lars Myrenberg"}, {"name":"Magnus M\u00e5nsson"}, {"name":"Carl M\u00f6ller"}, {"name":"Tage M\u00f8ller (arkitekt)"}, {"name":"Wilhelm Nerman"}, {"name":"Hans Neum\u00fcller"}, {"name":"Carl Nissen"}, {"name":"Immanuel Nobel den yngre"}, {"name":"Joel Norborg"}, {"name":"Berndt Nordberg"}, {"name":"Nils Nord\u00e9n"}, {"name":"Knut Nordenskj\u00f6ld"}, {"name":"Johan Nordquist"}, {"name":"Sven Nordqvist"}, {"name":"Johan Albert Nordstr\u00f6m"},
{"name":"\u00c4rland Noreen"}, {"name":"Johannes Norlander"}, {"name":"Verner Northun"}, {"name":"Bernt Nyberg"}, {"name":"Peder Nyblom"}, {"name":"Bitte Nygren"}, {"name":"Oskar Nygren"}, {"name":"Ola Nylander"}, {"name":"Conny Nyquist"}, {"name":"Ivar Nyqvist"}, {"name":"Carl Nyr\u00e9n"}, {"name":"August och Johan Robert Nystr\u00f6m"}, {"name":"Axel Nystr\u00f6m (1793\u20131868)"}, {"name":"Axel Fredrik Nystr\u00f6m"}, {"name":"Nils Oelrich"}, {"name":"Edward Ohlsson"}, {"name":"Carl Olinder"},
{"name":"Johannes Olivegren"}, {"name":"G\u00f6sta Olson"}, {"name":"J Fred Olson"}, {"name":"Kerstin Olson"}, {"name":"John Olsson (arkitekt)"}, {"name":"Nils Olsson (arkitekt)"}, {"name":"Per-Olof Olsson"}, {"name":"Torbj\u00f6rn Olsson"}, {"name":"Birger Oppman"}, {"name":"Henning Orlando"}, {"name":"Ernst Evald Otterstr\u00f6m"}, {"name":"Karl W. Ottesen"}, {"name":"Dominicus Pahr"}, {"name":"Johan Baptista Pahr"}, {"name":"Kristoffer Pahr"}, {"name":"August Palm\u00e9r"}, {"name":"Per Wilhelm Palmroth"},
{"name":"Erik Palmstedt"}, {"name":"Gerhard Paulson"}, {"name":"Mats Pemer"}, {"name":"Carl Johan Perne"}, {"name":"Knut Perno"}, {"name":"Alfred Persson (arkitekt)"}, {"name":"Per Persson (arkitekt)"}, {"name":"Adrian C. Peterson"}, {"name":"Ludwig Peterson"}, {"name":"Gustaf Petterson"}, {"name":"Gustaf Pettersson"}, {"name":"Fredrik Magnus Piper"}, {"name":"G\u00f6sta Planck"}, {"name":"Gunnar Pleijel"}, {"name":"Ervin P\u00fctsep"}, {"name":"Gunnar P\u00e5hlman"}, {"name":"Erik Ragndal"}, {"name":"Hugo Rahm"},
{"name":"Sten Ramel"}, {"name":"Ariana Ramhage"}, {"name":"Yngve Rasmussen"}, {"name":"Ilmar Reepalu"}, {"name":"Jean Eric Rehn"}, {"name":"Rolf Reimers"}, {"name":"Leif Reinius"}, {"name":"Vilhelm Renhult"}, {"name":"Dag Ribbing"}, {"name":"Jakob Richter"}, {"name":"Lars Ridderstedt"}, {"name":"Jacob Rijf"}, {"name":"Victor Ringheim"}, {"name":"Carl-Ivar Ringmar"}, {"name":"Georg Ringstr\u00f6m"}, {"name":"Alessandro Ripellino"}, {"name":"Eric Rockstr\u00f6m"}, {"name":"Anders Roland"}, {"name":"Bengt Romare"},
{"name":"Thorsten Roos"}, {"name":"Carl Rosell"}, {"name":"Gustaf Rosenberg"}, {"name":"Rosenbergs Arkitekter"}, {"name":"Carl E. Rosenius"}, {"name":"P\u00e5l Ross"}, {"name":"Edvard von Rothstein"}, {"name":"Eva Rudberg"}, {"name":"Per Rudenstam"}, {"name":"Einar Rudskog"}, {"name":"Ture Ryberg"}, {"name":"Johan R\u00e5dberg"}, {"name":"Jan R\u00e4ntfors"}, {"name":"Holger R\u00f6ssborn"}, {"name":"Lars Jacob von R\u00f6\u00f6k"}, {"name":"Kasper Salin"}, {"name":"Arnold Salomon-S\u00f6rensen"},
{"name":"SAMARK"}, {"name":"Sten Samuelson"}, {"name":"Karl Samuelsson"}, {"name":"Carl Sandahl"}, {"name":"Carl-Evin Sandberg"}, {"name":"Gustaf Hugo Sandberg"}, {"name":"Thomas Sandell"}, {"name":"Ulrika Sax"}, {"name":"Ture Schaar"}, {"name":"Georg Scherman"}, {"name":"Hans Schlyter"}, {"name":"Artur von Schmalensee"}, {"name":"Kurt von Schmalensee"}, {"name":"Fredrik Wilhelm Scholander"}, {"name":"Bertil Schr\u00f6der"}, {"name":"Eric Schuwert"}, {"name":"Ture Sellman"}, {"name":"Carl Axel Setterberg"},
{"name":"John Settergren"}, {"name":"G\u00f6ran Sidenbladh"}, {"name":"Bj\u00f6rn Siesj\u00f6"}, {"name":"Gustaf af Sill\u00e9n"}, {"name":"Sven Silow"}, {"name":"Per-Olav Sivertzen"}, {"name":"Bror Albert Si\u00f6steen"}, {"name":"Gustaf Sj\u00f6berg (arkitekt)"}, {"name":"Axel Sj\u00f6gren"}, {"name":"Arvid Sj\u00f6qvist"}, {"name":"Guy Sj\u00f6wall"}, {"name":"John Smedberg"}, {"name":"Karl August Smith"}, {"name":"Brita Snellman"}, {"name":"Ulf Snellman"}, {"name":"Ingegerd Snis"}, {"name":"John Snis"},
{"name":"Hans Speek"}, {"name":"Mathias Spieler"}, {"name":"Ernst Spol\u00e9n"}, {"name":"Cyril Stackell"}, {"name":"Poul Stampe"}, {"name":"Albin Stark"}, {"name":"Magnus Steendorff"}, {"name":"Axel Stenberg"}, {"name":"Johan Erik Stenberg"}, {"name":"Ture Stenberg"}, {"name":"Bengt Steneby"}, {"name":"Ernst Stenhammar"}, {"name":"Per Ulrik Stenhammar"}, {"name":"Nils Sterner"}, {"name":"Arvid Stille"}, {"name":"August Stoltz"}, {"name":"Carl-Axel Stoltz"}, {"name":"August Strehlenert"}, {"name":"Curt Strehlenert"},
{"name":"Staffan Strindberg"}, {"name":"Nils Strinning"}, {"name":"Hans Jakob Str\u00f6mberg"}, {"name":"Torsten Stubelius"}, {"name":"Carl St\u00e5l (milit\u00e4r)"}, {"name":"Ivar St\u00e5l"}, {"name":"Josef St\u00e4ck"}, {"name":"Kaj Sucksdorff"}, {"name":"Eskil Sundahl"}, {"name":"Jonas Eriksson Sundahl"}, {"name":"Fredrik Sundb\u00e4rg"}, {"name":"Gunnar Sundb\u00e4rg"}, {"name":"Petter Georg Sundius"}, {"name":"Per Sundstedt"}, {"name":"Kristian Sundstrand"}, {"name":"Carl Fredrik Sundvall"},
{"name":"Elias Svedberg"}, {"name":"Hillevi Svedberg"}, {"name":"August Svensson"}, {"name":"Simon Svensson (byggnadsingenj\u00f6r)"}, {"name":"Ragnar Ossian Swensson"}, {"name":"Zander S\u00e4fverstam"}, {"name":"Gustaf S\u00e4llstr\u00f6m"}, {"name":"Carl Nestor S\u00f6derberg"}, {"name":"Johan Erik S\u00f6derlund"}, {"name":"Salomon S\u00f6rensen"}, {"name":"Louis Gustave Taraval"}, {"name":"Yngve Tegn\u00e9r"}, {"name":"Olof Tempelman"}, {"name":"Anders Tengbom"}, {"name":"Ivar Tengbom"}, {"name":"\u00c5ke Tengelin"},
{"name":"Nils Tesch"}, {"name":"Nicodemus Tessin den \u00e4ldre"}, {"name":"Nicodemus Tessin den yngre"}, {"name":"Harald Thafvelin"}, {"name":"Bolle Tham"}, {"name":"Klas Tham"}, {"name":"Lennart Tham"}, {"name":"Erik Thelaus"}, {"name":"Alice Thiberg"}, {"name":"Thomas Thieme"}, {"name":"Johan Thom\u00e9"}, {"name":"Eugen Thorburn"}, {"name":"Thor Thor\u00e9n"}, {"name":"Bror Thornberg"}, {"name":"Jan Lunding"}, {"name":"Olof Thunstr\u00f6m"}, {"name":"Albert Thurdin"}, {"name":"Jan Thurfjell"},
{"name":"Ville Tommos"}, {"name":"Ernst Torulf"}, {"name":"Claes Tottie"}, {"name":"Erik Lund (arkitekt)"}, {"name":"Erik Trana (arkitekt)"}, {"name":"Erik Hugo Tryggelin"}, {"name":"Johan Tuvert"}, {"name":"Tyke Tykesson"}, {"name":"Sven Tynelius"}, {"name":"Albert T\u00f6rnqvistU"}, {"name":"Hans Uddenberg"}, {"name":"Ingrid Uddenberg"}, {"name":"Lennart Uhlin"}, {"name":"Erik UlrichV"}, {"name":"Jean de la Vall\u00e9e"}, {"name":"Simon de la Vall\u00e9e"}, {"name":"Inga Varg"}, {"name":"Georg Varhelyi"},
{"name":"Hanna Victorson"}, {"name":"Martin Videg\u00e5rd"}, {"name":"Justus Vingboons"}, {"name":"Tore Virke"}, {"name":"Fritz Voigt"}, {"name":"Ludvig Vold"}, {"name":"Harald Wadsj\u00f6"}, {"name":"Ingeborg W\u00e6rn Bugge"}, {"name":"Jan Wahlman"}, {"name":"Lars Israel Wahlman"}, {"name":"Lars Niklas Wahrgren"}, {"name":"Sven Wallander"}, {"name":"Frans Bertil Wallberg"}, {"name":"Ingrid Wallberg"}, {"name":"Anton Wallby"}, {"name":"Peder Wallenberg"}, {"name":"Oskar Waller"}, {"name":"Bj\u00f6rn Wallgren"},
{"name":"Jan Wallinder"}, {"name":"Clas Wallman"}, {"name":"Bengt Warne"}, {"name":"Gunnar Wejke"}, {"name":"Thure Wennberg"}, {"name":"Ture Wennerholm"}, {"name":"Per Emanuel Werming"}, {"name":"Melchior Wernstedt"}, {"name":"Johan August Westerberg"}, {"name":"Karl Martin Westerberg"}, {"name":"Hjalmar Westerlund"}, {"name":"Sigurd Westholm"}, {"name":"Sten Westholm"}, {"name":"Carl Westman"}, {"name":"Hans Westman"}, {"name":"Torsten Westman"}, {"name":"Axel Wetterberg"}, {"name":"Gunnar Wetterling"},
{"name":"Gustaf Wickman"}, {"name":"Gustav Wilhelmsson Widmark"}, {"name":"Carl Wijnbladh"}, {"name":"Fridolf Wijnbladh (arkitekt)"}, {"name":"Erik Wikerst\u00e5l"}, {"name":"G\u00f6sta Wikforss"}, {"name":"\u00d6rjan Wikforss"}, {"name":"Anders Wilhelmson"}, {"name":"Anders William-Olsson"}, {"name":"Tage William-Olsson"}, {"name":"Abraham Winantz Svansk\u00f6ld"}, {"name":"Gabriel Winge"}, {"name":"Gert Wing\u00e5rdh"}, {"name":"Mats Winsa"}, {"name":"Hans Wohlin"}, {"name":"Sven Wran\u00e9r"},
{"name":"Kjell Wretling"}, {"name":"Theodor W\u00e5hlin"}, {"name":"Karl Erik Ydeskog"}, {"name":"Per Zakrisson"}, {"name":"Olle Zetterberg (arkitekt)"}, {"name":"Folke Zettervall"}, {"name":"Helgo Zettervall"}, {"name":"Akke Zimdal"}, {"name":"Henrik \u00c5berg (arkitekt)"}, {"name":"G\u00f6sta \u00c5bergh"}, {"name":"Johan Fredrik \u00c5bom"}, {"name":"Lars \u00c5gren"}, {"name":"Uno \u00c5hr\u00e9n"}, {"name":"Carl \u00c5kerblad"}, {"name":"Hans \u00c5kerblad"}, {"name":"John \u00c5kerlund"},
{"name":"Sven-Ingvar \u00c5kesson"}, {"name":"Kell \u00c5str\u00f6m"}, {"name":"Viktor \u00c5str\u00f6m"}, {"name":"Oskar \u00d6berg"}, {"name":"Kjell \u00d6deen"}, {"name":"Ragnar \u00d6stberg"}, {"name":"Yngve \u00d6stborn"}, {"name":"Fritz \u00d6sterlind"}, {"name":"Carl \u00d6sterman"}, {"name":"Josef \u00d6stlihn"}, {"name":"Endel \u00d6unapuu"}]
/*!
* bootstrap-tokenfield
* https://github.com/sliptree/bootstrap-tokenfield
* Copyright 2013-2014 Sliptree and other contributors; Licensed MIT
*/
@-webkit-keyframes 'blink' {
0% {
border-color: #ededed;
}
100% {
border-color: #b94a48;
}
}
@-moz-keyframes 'blink' {
0% {
border-color: #ededed;
}
100% {
border-color: #b94a48;
}
}
@keyframes 'blink' {
0% {
border-color: #ededed;
}
100% {
border-color: #b94a48;
}
}
.tokenfield {
height: auto;
min-height: 34px;
padding-bottom: 0px;
}
.tokenfield.focus {
border-color: #66afe9;
outline: 0;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
box-shadow: inset 0 1px 1px rgba(0, 0, 0, .075), 0 0 8px rgba(102, 175, 233, 0.6);
}
.tokenfield .token {
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
display: inline-block;
border: 1px solid #d9d9d9;
background-color: #ededed;
white-space: nowrap;
margin: -1px 5px 5px 0;
height: 22px;
vertical-align: top;
cursor: default;
}
.tokenfield .token:hover {
border-color: #b9b9b9;
}
.tokenfield .token.active {
border-color: #52a8ec;
border-color: rgba(82, 168, 236, 0.8);
}
.tokenfield .token.duplicate {
border-color: #ebccd1;
-webkit-animation-name: blink;
animation-name: blink;
-webkit-animation-duration: 0.1s;
animation-duration: 0.1s;
-webkit-animation-direction: normal;
animation-direction: normal;
-webkit-animation-timing-function: ease;
animation-timing-function: ease;
-webkit-animation-iteration-count: infinite;
animation-iteration-count: infinite;
}
.tokenfield .token.invalid {
background: none;
border: 1px solid transparent;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
border-bottom: 1px dotted #d9534f;
}
.tokenfield .token.invalid.active {
background: #ededed;
border: 1px solid #ededed;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.tokenfield .token .token-label {
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
padding-left: 4px;
vertical-align: top;
}
.tokenfield .token .close {
font-family: Arial;
display: inline-block;
line-height: 100%;
font-size: 1.1em;
line-height: 1.49em;
margin-left: 5px;
float: none;
height: 100%;
vertical-align: top;
padding-right: 4px;
}
.tokenfield .token-input {
background: none;
width: 60px;
min-width: 60px;
border: 0;
height: 20px;
padding: 0;
margin-bottom: 6px;
-webkit-box-shadow: none;
box-shadow: none;
}
.tokenfield .token-input:focus {
border-color: transparent;
outline: 0;
/* IE6-9 */
-webkit-box-shadow: none;
box-shadow: none;
}
.tokenfield.disabled {
cursor: not-allowed;
background-color: #eeeeee;
}
.tokenfield.disabled .token-input {
cursor: not-allowed;
}
.tokenfield.disabled .token:hover {
cursor: not-allowed;
border-color: #d9d9d9;
}
.tokenfield.disabled .token:hover .close {
cursor: not-allowed;
opacity: 0.2;
filter: alpha(opacity=20);
}
.has-warning .tokenfield.focus {
border-color: #66512c;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #c0a16b;
}
.has-error .tokenfield.focus {
border-color: #843534;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #ce8483;
}
.has-success .tokenfield.focus {
border-color: #2b542c;
-webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.075), 0 0 6px #67b168;
}
.tokenfield.input-sm,
.input-group-sm .tokenfield {
min-height: 30px;
padding-bottom: 0px;
}
.input-group-sm .token,
.tokenfield.input-sm .token {
height: 20px;
margin-bottom: 4px;
}
.input-group-sm .token-input,
.tokenfield.input-sm .token-input {
height: 18px;
margin-bottom: 5px;
}
.tokenfield.input-lg,
.input-group-lg .tokenfield {
min-height: 45px;
padding-bottom: 4px;
}
.input-group-lg .token,
.tokenfield.input-lg .token {
height: 25px;
}
.input-group-lg .token-label,
.tokenfield.input-lg .token-label {
line-height: 23px;
}
.input-group-lg .token .close,
.tokenfield.input-lg .token .close {
line-height: 1.3em;
}
.input-group-lg .token-input,
.tokenfield.input-lg .token-input {
height: 23px;
line-height: 23px;
margin-bottom: 6px;
vertical-align: top;
}
.tokenfield.rtl {
direction: rtl;
text-align: right;
}
.tokenfield.rtl .token {
margin: -1px 0 5px 5px;
}
.tokenfield.rtl .token .token-label {
padding-left: 0px;
padding-right: 4px;
}
/*!
* bootstrap-tokenfield
* https://github.com/sliptree/bootstrap-tokenfield
* Copyright 2013-2014 Sliptree and other contributors; Licensed MIT
*/
(function (factory) {
if (typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// For CommonJS and CommonJS-like environments where a window with jQuery
// is present, execute the factory with the jQuery instance from the window object
// For environments that do not inherently posses a window with a document
// (such as Node.js), expose a Tokenfield-making factory as module.exports
// This accentuates the need for the creation of a real window or passing in a jQuery instance
// e.g. require("bootstrap-tokenfield")(window); or require("bootstrap-tokenfield")($);
module.exports = global.window && global.window.$ ?
factory( global.window.$ ) :
function( input ) {
if ( !input.$ && !input.fn ) {
throw new Error( "Tokenfield requires a window object with jQuery or a jQuery instance" );
}
return factory( input.$ || input );
};
} else {
// Browser globals
factory(jQuery);
}
}(function ($, window) {
"use strict"; // jshint ;_;
/* TOKENFIELD PUBLIC CLASS DEFINITION
* ============================== */
var Tokenfield = function (element, options) {
var _self = this
this.$element = $(element)
this.textDirection = this.$element.css('direction');
// Extend options
this.options = $.extend(true, {}, $.fn.tokenfield.defaults, { tokens: this.$element.val() }, this.$element.data(), options)
// Setup delimiters and trigger keys
this._delimiters = (typeof this.options.delimiter === 'string') ? [this.options.delimiter] : this.options.delimiter
this._triggerKeys = $.map(this._delimiters, function (delimiter) {
return delimiter.charCodeAt(0);
});
this._firstDelimiter = this._delimiters[0];
// Check for whitespace, dash and special characters
var whitespace = $.inArray(' ', this._delimiters)
, dash = $.inArray('-', this._delimiters)
if (whitespace >= 0)
this._delimiters[whitespace] = '\\s'
if (dash >= 0) {
delete this._delimiters[dash]
this._delimiters.unshift('-')
}
var specialCharacters = ['\\', '$', '[', '{', '^', '.', '|', '?', '*', '+', '(', ')']
$.each(this._delimiters, function (index, char) {
var pos = $.inArray(char, specialCharacters)
if (pos >= 0) _self._delimiters[index] = '\\' + char;
});
// Store original input width
var elRules = (window && typeof window.getMatchedCSSRules === 'function') ? window.getMatchedCSSRules( element ) : null
, elStyleWidth = element.style.width
, elCSSWidth
, elWidth = this.$element.width()
if (elRules) {
$.each( elRules, function (i, rule) {
if (rule.style.width) {
elCSSWidth = rule.style.width;
}
});
}
// Move original input out of the way
var hidingPosition = $('body').css('direction') === 'rtl' ? 'right' : 'left',
originalStyles = { position: this.$element.css('position') };
originalStyles[hidingPosition] = this.$element.css(hidingPosition);
this.$element
.data('original-styles', originalStyles)
.data('original-tabindex', this.$element.prop('tabindex'))
.css('position', 'absolute')
.css(hidingPosition, '-10000px')
.prop('tabindex', -1)
// Create a wrapper
this.$wrapper = $('<div class="tokenfield form-control" />')
if (this.$element.hasClass('input-lg')) this.$wrapper.addClass('input-lg')
if (this.$element.hasClass('input-sm')) this.$wrapper.addClass('input-sm')
if (this.textDirection === 'rtl') this.$wrapper.addClass('rtl')
// Create a new input
var id = this.$element.prop('id') || new Date().getTime() + '' + Math.floor((1 + Math.random()) * 100)
this.$input = $('<input type="text" class="token-input" autocomplete="off" />')
.appendTo( this.$wrapper )
.prop( 'placeholder', this.$element.prop('placeholder') )
.prop( 'id', id + '-tokenfield' )
.prop( 'tabindex', this.$element.data('original-tabindex') )
// Re-route original input label to new input
var $label = $( 'label[for="' + this.$element.prop('id') + '"]' )
if ( $label.length ) {
$label.prop( 'for', this.$input.prop('id') )
}
// Set up a copy helper to handle copy & paste
this.$copyHelper = $('<input type="text" />').css('position', 'absolute').css(hidingPosition, '-10000px').prop('tabindex', -1).prependTo( this.$wrapper )
// Set wrapper width
if (elStyleWidth) {
this.$wrapper.css('width', elStyleWidth);
}
else if (elCSSWidth) {
this.$wrapper.css('width', elCSSWidth);
}
// If input is inside inline-form with no width set, set fixed width
else if (this.$element.parents('.form-inline').length) {
this.$wrapper.width( elWidth )
}
// Set tokenfield disabled, if original or fieldset input is disabled
if (this.$element.prop('disabled') || this.$element.parents('fieldset[disabled]').length) {
this.disable();
}
// Set tokenfield readonly, if original input is readonly
if (this.$element.prop('readonly')) {
this.readonly();
}
// Set up mirror for input auto-sizing
this.$mirror = $('<span style="position:absolute; top:-999px; left:0; white-space:pre;"/>');
this.$input.css('min-width', this.options.minWidth + 'px')
$.each([
'fontFamily',
'fontSize',
'fontWeight',
'fontStyle',
'letterSpacing',
'textTransform',
'wordSpacing',
'textIndent'
], function (i, val) {
_self.$mirror[0].style[val] = _self.$input.css(val);
});
this.$mirror.appendTo( 'body' )
// Insert tokenfield to HTML
this.$wrapper.insertBefore( this.$element )
this.$element.prependTo( this.$wrapper )
// Calculate inner input width
this.update()
// Create initial tokens, if any
this.setTokens(this.options.tokens, false, false)
// Start listening to events
this.listen()
// Initialize autocomplete, if necessary
if ( ! $.isEmptyObject( this.options.autocomplete ) ) {
var side = this.textDirection === 'rtl' ? 'right' : 'left'
, autocompleteOptions = $.extend({
minLength: this.options.showAutocompleteOnFocus ? 0 : null,
position: { my: side + " top", at: side + " bottom", of: this.$wrapper }
}, this.options.autocomplete )
this.$input.autocomplete( autocompleteOptions )
}
// Initialize typeahead, if necessary
if ( ! $.isEmptyObject( this.options.typeahead ) ) {
var typeaheadOptions = this.options.typeahead
, defaults = {
minLength: this.options.showAutocompleteOnFocus ? 0 : null
}
, args = $.isArray( typeaheadOptions ) ? typeaheadOptions : [typeaheadOptions, typeaheadOptions]
args[0] = $.extend( {}, defaults, args[0] )
this.$input.typeahead.apply( this.$input, args )
this.typeahead = true
}
this.$element.trigger('tokenfield:initialize')
}
Tokenfield.prototype = {
constructor: Tokenfield
, createToken: function (attrs, triggerChange) {
var _self = this
if (typeof attrs === 'string') {
attrs = { value: attrs, label: attrs }
}
if (typeof triggerChange === 'undefined') {
triggerChange = true
}
// Normalize label and value
attrs.value = $.trim(attrs.value);
attrs.label = attrs.label && attrs.label.length ? $.trim(attrs.label) : attrs.value
// Bail out if has no value or label, or label is too short
if (!attrs.value.length || !attrs.label.length || attrs.label.length <= this.options.minLength) return
// Bail out if maximum number of tokens is reached
if (this.options.limit && this.getTokens().length >= this.options.limit) return
// Allow changing token data before creating it
var createEvent = $.Event('tokenfield:createtoken', { attrs: attrs })
this.$element.trigger(createEvent)
// Bail out if there if attributes are empty or event was defaultPrevented
if (!createEvent.attrs || createEvent.isDefaultPrevented()) return
var $token = $('<div class="token" />')
.attr('data-value', attrs.value)
.append('<span class="token-label" />')
.append('<a href="#" class="close" tabindex="-1">×</a>')
// Insert token into HTML
if (this.$input.hasClass('tt-input')) {
// If the input has typeahead enabled, insert token before it's parent
this.$input.parent().before( $token )
} else {
this.$input.before( $token )
}
// Temporarily set input width to minimum
this.$input.css('width', this.options.minWidth + 'px')
var $tokenLabel = $token.find('.token-label')
, $closeButton = $token.find('.close')
// Determine maximum possible token label width
if (!this.maxTokenWidth) {
this.maxTokenWidth =
this.$wrapper.width() - $closeButton.outerWidth() -
parseInt($closeButton.css('margin-left'), 10) -
parseInt($closeButton.css('margin-right'), 10) -
parseInt($token.css('border-left-width'), 10) -
parseInt($token.css('border-right-width'), 10) -
parseInt($token.css('padding-left'), 10) -
parseInt($token.css('padding-right'), 10)
parseInt($tokenLabel.css('border-left-width'), 10) -
parseInt($tokenLabel.css('border-right-width'), 10) -
parseInt($tokenLabel.css('padding-left'), 10) -
parseInt($tokenLabel.css('padding-right'), 10)
parseInt($tokenLabel.css('margin-left'), 10) -
parseInt($tokenLabel.css('margin-right'), 10)
}
$tokenLabel
.text(attrs.label)
.css('max-width', this.maxTokenWidth)
// Listen to events on token
$token
.on('mousedown', function (e) {
if (_self._disabled || _self._readonly) return false
_self.preventDeactivation = true
})
.on('click', function (e) {
if (_self._disabled || _self._readonly) return false
_self.preventDeactivation = false
if (e.ctrlKey || e.metaKey) {
e.preventDefault()
return _self.toggle( $token )
}
_self.activate( $token, e.shiftKey, e.shiftKey )
})
.on('dblclick', function (e) {
if (_self._disabled || _self._readonly || !_self.options.allowEditing ) return false
_self.edit( $token )
})
$closeButton
.on('click', $.proxy(this.remove, this))
// Trigger createdtoken event on the original field
// indicating that the token is now in the DOM
this.$element.trigger($.Event('tokenfield:createdtoken', {
attrs: attrs,
relatedTarget: $token.get(0)
}))
// Trigger change event on the original field
if (triggerChange) {
this.$element.val( this.getTokensList() ).trigger( $.Event('change', { initiator: 'tokenfield' }) )
}
// Update tokenfield dimensions
this.update()
// Return original element
return this.$element.get(0)
}
, setTokens: function (tokens, add, triggerChange) {
if (!tokens) return
if (!add) this.$wrapper.find('.token').remove()
if (typeof triggerChange === 'undefined') {
triggerChange = true
}
if (typeof tokens === 'string') {
if (this._delimiters.length) {
// Split based on delimiters
tokens = tokens.split( new RegExp( '[' + this._delimiters.join('') + ']' ) )
} else {
tokens = [tokens];
}
}
var _self = this
$.each(tokens, function (i, attrs) {
_self.createToken(attrs, triggerChange)
})
return this.$element.get(0)
}
, getTokenData: function($token) {
var data = $token.map(function() {
var $token = $(this);
return {
value: $token.attr('data-value'),
label: $token.find('.token-label').text()
}
}).get();
if (data.length == 1) {
data = data[0];
}
return data;
}
, getTokens: function(active) {
var self = this
, tokens = []
, activeClass = active ? '.active' : '' // get active tokens only
this.$wrapper.find( '.token' + activeClass ).each( function() {
tokens.push( self.getTokenData( $(this) ) )
})
return tokens
}
, getTokensList: function(delimiter, beautify, active) {
delimiter = delimiter || this._firstDelimiter
beautify = ( typeof beautify !== 'undefined' && beautify !== null ) ? beautify : this.options.beautify
var separator = delimiter + ( beautify && delimiter !== ' ' ? ' ' : '')
return $.map( this.getTokens(active), function (token) {
return token.value
}).join(separator)
}
, getInput: function() {
return this.$input.val()
}
, listen: function () {
var _self = this
this.$element
.on('change', $.proxy(this.change, this))
this.$wrapper
.on('mousedown',$.proxy(this.focusInput, this))
this.$input
.on('focus', $.proxy(this.focus, this))
.on('blur', $.proxy(this.blur, this))
.on('paste', $.proxy(this.paste, this))
.on('keydown', $.proxy(this.keydown, this))
.on('keypress', $.proxy(this.keypress, this))
.on('keyup', $.proxy(this.keyup, this))
this.$copyHelper
.on('focus', $.proxy(this.focus, this))
.on('blur', $.proxy(this.blur, this))
.on('keydown', $.proxy(this.keydown, this))
.on('keyup', $.proxy(this.keyup, this))
// Secondary listeners for input width calculation
this.$input
.on('keypress', $.proxy(this.update, this))
.on('keyup', $.proxy(this.update, this))
this.$input
.on('autocompletecreate', function() {
// Set minimum autocomplete menu width
var $_menuElement = $(this).data('ui-autocomplete').menu.element
var minWidth = _self.$wrapper.outerWidth() -
parseInt( $_menuElement.css('border-left-width'), 10 ) -
parseInt( $_menuElement.css('border-right-width'), 10 )
$_menuElement.css( 'min-width', minWidth + 'px' )
})
.on('autocompleteselect', function (e, ui) {
if (_self.createToken( ui.item )) {
_self.$input.val('')
if (_self.$input.data( 'edit' )) {
_self.unedit(true)
}
}
return false
})
.on('typeahead:selected typeahead:autocompleted', function (e, datum, dataset) {
// Create token
if (_self.createToken( datum )) {
_self.$input.typeahead('val', '')
if (_self.$input.data( 'edit' )) {
_self.unedit(true)
}
}
})
// Listen to window resize
$(window).on('resize', $.proxy(this.update, this ))
}
, keydown: function (e) {
if (!this.focused) return
var _self = this
switch(e.keyCode) {
case 8: // backspace
if (!this.$input.is(document.activeElement)) break
this.lastInputValue = this.$input.val()
break
case 37: // left arrow
leftRight( this.textDirection === 'rtl' ? 'next': 'prev' )
break
case 38: // up arrow
upDown('prev')
break
case 39: // right arrow
leftRight( this.textDirection === 'rtl' ? 'prev': 'next' )
break
case 40: // down arrow
upDown('next')
break
case 65: // a (to handle ctrl + a)
if (this.$input.val().length > 0 || !(e.ctrlKey || e.metaKey)) break
this.activateAll()
e.preventDefault()
break
case 9: // tab
case 13: // enter
// We will handle creating tokens from autocomplete in autocomplete events
if (this.$input.data('ui-autocomplete') && this.$input.data('ui-autocomplete').menu.element.find("li:has(a.ui-state-focus)").length) break
// We will handle creating tokens from typeahead in typeahead events
if (this.$input.hasClass('tt-input') && this.$wrapper.find('.tt-cursor').length ) break
if (this.$input.hasClass('tt-input') && this.$wrapper.find('.tt-hint').val().length) break
// Create token
if (this.$input.is(document.activeElement) && this.$input.val().length || this.$input.data('edit')) {
return this.createTokensFromInput(e, this.$input.data('edit'));
}
// Edit token
if (e.keyCode === 13) {
if (!this.$copyHelper.is(document.activeElement) || this.$wrapper.find('.token.active').length !== 1) break
if (!_self.options.allowEditing) break
this.edit( this.$wrapper.find('.token.active') )
}
}
function leftRight(direction) {
if (_self.$input.is(document.activeElement)) {
if (_self.$input.val().length > 0) return
direction += 'All'
var $token = _self.$input.hasClass('tt-input') ? _self.$input.parent()[direction]('.token:first') : _self.$input[direction]('.token:first')
if (!$token.length) return
_self.preventInputFocus = true
_self.preventDeactivation = true
_self.activate( $token )
e.preventDefault()
} else {
_self[direction]( e.shiftKey )
e.preventDefault()
}
}
function upDown(direction) {
if (!e.shiftKey) return
if (_self.$input.is(document.activeElement)) {
if (_self.$input.val().length > 0) return
var $token = _self.$input.hasClass('tt-input') ? _self.$input.parent()[direction + 'All']('.token:first') : _self.$input[direction + 'All']('.token:first')
if (!$token.length) return
_self.activate( $token )
}
var opposite = direction === 'prev' ? 'next' : 'prev'
, position = direction === 'prev' ? 'first' : 'last'
_self.firstActiveToken[opposite + 'All']('.token').each(function() {
_self.deactivate( $(this) )
})
_self.activate( _self.$wrapper.find('.token:' + position), true, true )
e.preventDefault()
}
this.lastKeyDown = e.keyCode
}
, keypress: function(e) {
this.lastKeyPressCode = e.keyCode
this.lastKeyPressCharCode = e.charCode
// Comma
if ($.inArray( e.charCode, this._triggerKeys) !== -1 && this.$input.is(document.activeElement)) {
if (this.$input.val()) {
this.createTokensFromInput(e)
}
return false;
}
}
, keyup: function (e) {
this.preventInputFocus = false
if (!this.focused) return
switch(e.keyCode) {
case 8: // backspace
if (this.$input.is(document.activeElement)) {
if (this.$input.val().length || this.lastInputValue.length && this.lastKeyDown === 8) break
this.preventDeactivation = true
var $prevToken = this.$input.hasClass('tt-input') ? this.$input.parent().prevAll('.token:first') : this.$input.prevAll('.token:first')
if (!$prevToken.length) break
this.activate( $prevToken )
} else {
this.remove(e)
}
break
case 46: // delete
this.remove(e, 'next')
break
}
this.lastKeyUp = e.keyCode
}
, focus: function (e) {
this.focused = true
this.$wrapper.addClass('focus')
if (this.$input.is(document.activeElement)) {
this.$wrapper.find('.active').removeClass('active')
this.$firstActiveToken = null
if (this.options.showAutocompleteOnFocus) {
this.search()
}
}
}
, blur: function (e) {
this.focused = false
this.$wrapper.removeClass('focus')
if (!this.preventDeactivation && !this.$element.is(document.activeElement)) {
this.$wrapper.find('.active').removeClass('active')
this.$firstActiveToken = null
}
if (!this.preventCreateTokens && (this.$input.data('edit') && !this.$input.is(document.activeElement) || this.options.createTokensOnBlur )) {
this.createTokensFromInput(e)
}
this.preventDeactivation = false
this.preventCreateTokens = false
}
, paste: function (e) {
var _self = this
// Add tokens to existing ones
setTimeout(function () {
_self.createTokensFromInput(e)
}, 1)
}
, change: function (e) {
if ( e.initiator === 'tokenfield' ) return // Prevent loops
this.setTokens( this.$element.val() )
}
, createTokensFromInput: function (e, focus) {
if (this.$input.val().length < this.options.minLength)
return // No input, simply return
var tokensBefore = this.getTokensList()
this.setTokens( this.$input.val(), true )
if (tokensBefore == this.getTokensList() && this.$input.val().length)
return false // No tokens were added, do nothing (prevent form submit)
if (this.$input.hasClass('tt-input')) {
// Typeahead acts weird when simply setting input value to empty,
// so we set the query to empty instead
this.$input.typeahead('val', '')
} else {
this.$input.val('')
}
if (this.$input.data( 'edit' )) {
this.unedit(focus)
}
return false // Prevent form being submitted
}
, next: function (add) {
if (add) {
var $firstActiveToken = this.$wrapper.find('.active:first')
, deactivate = $firstActiveToken && this.$firstActiveToken ? $firstActiveToken.index() < this.$firstActiveToken.index() : false
if (deactivate) return this.deactivate( $firstActiveToken )
}
var $lastActiveToken = this.$wrapper.find('.active:last')
, $nextToken = $lastActiveToken.nextAll('.token:first')
if (!$nextToken.length) {
this.$input.focus()
return
}
this.activate($nextToken, add)
}
, prev: function (add) {
if (add) {
var $lastActiveToken = this.$wrapper.find('.active:last')
, deactivate = $lastActiveToken && this.$firstActiveToken ? $lastActiveToken.index() > this.$firstActiveToken.index() : false
if (deactivate) return this.deactivate( $lastActiveToken )
}
var $firstActiveToken = this.$wrapper.find('.active:first')
, $prevToken = $firstActiveToken.prevAll('.token:first')
if (!$prevToken.length) {
$prevToken = this.$wrapper.find('.token:first')
}
if (!$prevToken.length && !add) {
this.$input.focus()
return
}
this.activate( $prevToken, add )
}
, activate: function ($token, add, multi, remember) {
if (!$token) return
if (typeof remember === 'undefined') var remember = true
if (multi) var add = true
this.$copyHelper.focus()
if (!add) {
this.$wrapper.find('.active').removeClass('active')
if (remember) {
this.$firstActiveToken = $token
} else {
delete this.$firstActiveToken
}
}
if (multi && this.$firstActiveToken) {
// Determine first active token and the current tokens indicies
// Account for the 1 hidden textarea by subtracting 1 from both
var i = this.$firstActiveToken.index() - 2
, a = $token.index() - 2
, _self = this
this.$wrapper.find('.token').slice( Math.min(i, a) + 1, Math.max(i, a) ).each( function() {
_self.activate( $(this), true )
})
}
$token.addClass('active')
this.$copyHelper.val( this.getTokensList( null, null, true ) ).select()
}
, activateAll: function() {
var _self = this
this.$wrapper.find('.token').each( function (i) {
_self.activate($(this), i !== 0, false, false)
})
}
, deactivate: function($token) {
if (!$token) return
$token.removeClass('active')
this.$copyHelper.val( this.getTokensList( null, null, true ) ).select()
}
, toggle: function($token) {
if (!$token) return
$token.toggleClass('active')
this.$copyHelper.val( this.getTokensList( null, null, true ) ).select()
}
, edit: function ($token) {
if (!$token) return
var attrs = {
value: $token.data('value'),
label: $token.find('.token-label').text()
}
// Allow changing input value before editing
var options = { attrs: attrs, relatedTarget: $token.get(0) }
var editEvent = $.Event('tokenfield:edittoken', options)
this.$element.trigger( editEvent )
// Edit event can be cancelled if default is prevented
if (editEvent.isDefaultPrevented()) return
$token.find('.token-label').text(attrs.value)
var tokenWidth = $token.outerWidth()
var $_input = this.$input.hasClass('tt-input') ? this.$input.parent() : this.$input
$token.replaceWith( $_input )
this.preventCreateTokens = true
this.$input.val( attrs.value )
.select()
.data( 'edit', true )
.width( tokenWidth )
this.update();
// Indicate that token in snow being edited, and is replaced with an input field in the DOM
this.$element.trigger($.Event('tokenfield:editedtoken', options ))
}
, unedit: function (focus) {
var $_input = this.$input.hasClass('tt-input') ? this.$input.parent() : this.$input
$_input.appendTo( this.$wrapper )
this.$input.data('edit', false)
this.$mirror.text('')
this.update()
// Because moving the input element around in DOM
// will cause it to lose focus, we provide an option
// to re-focus the input after appending it to the wrapper
if (focus) {
var _self = this
setTimeout(function () {
_self.$input.focus()
}, 1)
}
}
, remove: function (e, direction) {
if (this.$input.is(document.activeElement) || this._disabled || this._readonly) return
var $token = (e.type === 'click') ? $(e.target).closest('.token') : this.$wrapper.find('.token.active')
if (e.type !== 'click') {
if (!direction) var direction = 'prev'
this[direction]()
// Was it the first token?
if (direction === 'prev') var firstToken = $token.first().prevAll('.token:first').length === 0
}
// Prepare events and their options
var options = { attrs: this.getTokenData( $token ), relatedTarget: $token.get(0) }
, removeEvent = $.Event('tokenfield:removetoken', options)
this.$element.trigger(removeEvent);
// Remove event can be intercepted and cancelled
if (removeEvent.isDefaultPrevented()) return
var removedEvent = $.Event('tokenfield:removedtoken', options)
, changeEvent = $.Event('change', { initiator: 'tokenfield' })
// Remove token from DOM
$token.remove()
// Trigger events
this.$element.val( this.getTokensList() ).trigger( removedEvent ).trigger( changeEvent )
// Focus, when necessary:
// When there are no more tokens, or if this was the first token
// and it was removed with backspace or it was clicked on
if (!this.$wrapper.find('.token').length || e.type === 'click' || firstToken) this.$input.focus()
// Adjust input width
this.$input.css('width', this.options.minWidth + 'px')
this.update()
// Cancel original event handlers
e.preventDefault()
e.stopPropagation()
}
/**
* Update tokenfield dimensions
*/
, update: function (e) {
var value = this.$input.val()
, inputPaddingLeft = parseInt(this.$input.css('padding-left'), 10)
, inputPaddingRight = parseInt(this.$input.css('padding-right'), 10)
, inputPadding = inputPaddingLeft + inputPaddingRight
if (this.$input.data('edit')) {
if (!value) {
value = this.$input.prop("placeholder")
}
if (value === this.$mirror.text()) return
this.$mirror.text(value)
var mirrorWidth = this.$mirror.width() + 10;
if ( mirrorWidth > this.$wrapper.width() ) {
return this.$input.width( this.$wrapper.width() )
}
this.$input.width( mirrorWidth )
}
else {
this.$input.css( 'width', this.options.minWidth + 'px' )
if (this.textDirection === 'rtl') {
return this.$input.width( this.$input.offset().left + this.$input.outerWidth() - this.$wrapper.offset().left - parseInt(this.$wrapper.css('padding-left'), 10) - inputPadding - 1 )
}
this.$input.width( this.$wrapper.offset().left + this.$wrapper.width() + parseInt(this.$wrapper.css('padding-left'), 10) - this.$input.offset().left - inputPadding )
}
}
, focusInput: function (e) {
if ( $(e.target).closest('.token').length || $(e.target).closest('.token-input').length || $(e.target).closest('.tt-dropdown-menu').length ) return
// Focus only after the current call stack has cleared,
// otherwise has no effect.
// Reason: mousedown is too early - input will lose focus
// after mousedown. However, since the input may be moved
// in DOM, there may be no click or mouseup event triggered.
var _self = this
setTimeout(function() {
_self.$input.focus()
}, 0)
}
, search: function () {
if ( this.$input.data('ui-autocomplete') ) {
this.$input.autocomplete('search')
}
}
, disable: function () {
this.setProperty('disabled', true);
}
, enable: function () {
this.setProperty('disabled', false);
}
, readonly: function () {
this.setProperty('readonly', true);
}
, writeable: function () {
this.setProperty('readonly', false);
}
, setProperty: function(property, value) {
this['_' + property] = value;
this.$input.prop(property, value);
this.$element.prop(property, value);
this.$wrapper[ value ? 'addClass' : 'removeClass' ](property);
}
, destroy: function() {
// Set field value
this.$element.val( this.getTokensList() );
// Restore styles and properties
this.$element.css( this.$element.data('original-styles') );
this.$element.prop( 'tabindex', this.$element.data('original-tabindex') );
// Re-route tokenfield labele to original input
var $label = $( 'label[for="' + this.$input.prop('id') + '"]' )
if ( $label.length ) {
$label.prop( 'for', this.$element.prop('id') )
}
// Move original element outside of tokenfield wrapper
this.$element.insertBefore( this.$wrapper );
// Remove tokenfield-related data
this.$element.removeData('original-styles')
.removeData('original-tabindex')
.removeData('bs.tokenfield');
// Remove tokenfield from DOM
this.$wrapper.remove();
var $_element = this.$element;
delete this;
return $_element;
}
}
/* TOKENFIELD PLUGIN DEFINITION
* ======================== */
var old = $.fn.tokenfield
$.fn.tokenfield = function (option, param) {
var value
, args = []
Array.prototype.push.apply( args, arguments );
var elements = this.each(function () {
var $this = $(this)
, data = $this.data('bs.tokenfield')
, options = typeof option == 'object' && option
if (typeof option === 'string' && data && data[option]) {
args.shift()
value = data[option].apply(data, args)
} else {
if (!data && typeof option !== 'string' && !param) $this.data('bs.tokenfield', (data = new Tokenfield(this, options)))
}
})
return typeof value !== 'undefined' ? value : elements;
}
$.fn.tokenfield.defaults = {
minWidth: 60,
minLength: 0,
allowEditing: true,
limit: 0,
autocomplete: {},
typeahead: {},
showAutocompleteOnFocus: false,
createTokensOnBlur: false,
delimiter: ',',
beautify: true
}
$.fn.tokenfield.Constructor = Tokenfield
/* TOKENFIELD NO CONFLICT
* ================== */
$.fn.tokenfield.noConflict = function () {
$.fn.tokenfield = old
return this
}
return Tokenfield;
}));
/*
* Project: Bootstrap Growl - v2.0.0
* Description: Turns standard Bootstrap alerts into "Growl-like" notifications.
* Author: Mouse0270 aka Robert McIntosh
* License: MIT License
* Website: https://github.com/mouse0270/bootstrap-growl
*/
;(function ( $, window, document, undefined ) {
// Create the defaults once
var pluginName = "growl",
dataKey = "plugin_" + pluginName,
defaults = {
element: 'body',
type: "info",
allow_dismiss: true,
placement: {
from: "top",
align: "right"
},
offset: 20,
spacing: 10,
z_index: 1031,
delay: 5000,
timer: 1000,
url_target: '_blank',
mouse_over: false,
animate: {
enter: 'animated fadeInDown',
exit: 'animated fadeOutUp'
},
icon_type: 'class',
template: '<div data-growl="container" class="alert" role="alert"><button type="button" class="close" data-growl="dismiss"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button><span data-growl="icon"></span><span data-growl="title"></span><span data-growl="message"></span><a href="#" data-growl="url"></a></div>'
};
// The actual plugin constructor
var setDefaults = function(element, options) {
defaults = $.extend(true, {}, defaults, options);
},
Plugin = function (element, content, options) {
var content = {
content: {
message: typeof content == 'object' ? content.message : content,
title: content.title ? content.title : null,
icon: content.icon ? content.icon : null,
url: content.url ? content.url : null
}
};
options = $.extend(true, {}, content, options);
this.settings = $.extend(true, {}, defaults, options);
plugin = this;
init(options, this.settings, plugin);
this.$template = $template;
},
init = function (options, settings, plugin) {
var base = {
settings: settings,
$element: $(settings.element),
template: settings.template
};
$template = buildGrowl(base);
addContent($template, base.settings);
placement($template, base.settings);
bindControls($template, base.settings,plugin);
},
buildGrowl = function(base) {
var $template = $(base.settings.template);
$template.addClass('alert-' + base.settings.type);
$template.attr('data-growl-position', base.settings.placement.from + '-' + base.settings.placement.align);
$template.find('[data-growl="dismiss"]').css('display', 'none');
if (base.settings.allow_dismiss) {
$template.find('[data-growl="dismiss"]').css('display', 'inline-block');
}
return $template;
},
addContent = function($template, settings) {
$template.find('[data-growl="dismiss"]').css({
'position': 'absolute',
'top': '5px',
'right': '10px',
'z-index': ((settings.z_index-1) >= 1 ? (settings.z_index-1) : 1)
});
if (settings.content.icon) {
if (settings.icon_type.toLowerCase() == 'class') {
$template.find('[data-growl="icon"]').addClass(settings.content.icon);
}else{
if ($template.find('[data-growl="icon"]').is('img')) {
$template.find('[data-growl="icon"]').attr('src', settings.content.icon);
}else{
$template.find('[data-growl="icon"]').append('<img src="'+settings.content.icon+'" />');
}
}
}
if (settings.content.title) {
$template.find('[data-growl="title"]').html(settings.content.title);
}
if (settings.content.message) {
$template.find('[data-growl="message"]').html(settings.content.message);
}
if (settings.content.url) {
$template.find('[data-growl="url"]').attr('href', settings.content.url).attr('target', settings.url_target);
$template.find('[data-growl="url"]').css({
'position': 'absolute',
'top': '0px',
'left': '0px',
'width': '100%',
'height': '100%',
'z-index': ((settings.z_index-2) >= 1 ? (settings.z_index-2) : 1)
});
}
},
placement = function($template, settings) {
var offsetAmt = settings.offset,
gCSS = {
'position': (settings.element === 'body' ? 'fixed' : 'absolute'),
'margin': 0,
'z-index': settings.z_index,
'display': 'inline-block'
}
$('[data-growl-position="' + settings.placement.from + '-' + settings.placement.align + '"]').each(function() {
return offsetAmt = Math.max(offsetAmt, parseInt($(this).css(settings.placement.from)) + $(this).outerHeight() + settings.spacing);
});
gCSS[settings.placement.from] = offsetAmt + "px";
$template.css(gCSS);
$(settings.element).append($template);
switch (settings.placement.align) {
case 'center':
$template.css({
'left': '50%',
'marginLeft': -($template.outerWidth() / 2) + 'px'
});
break;
case 'left':
$template.css('left', settings.offset + 'px');
break;
case 'right':
$template.css('right', settings.offset + 'px');
break;
}
$template.addClass('growl-animated');
},
bindControls = function($template, settings, plugin) {
$template.addClass(settings.animate.enter);
$template.find('[data-growl="dismiss"]').on('click', function() {
plugin.close();
});
$template.on('mouseover', function(e) {
$template.addClass('hovering');
}).on('mouseout', function() {
$template.removeClass('hovering');
});
if (settings.delay >= 1) {
$template.data('growl-delay', settings.delay);
var timer = setInterval(function() {
var delay = parseInt($template.data('growl-delay')) - settings.timer;
if ((!$template.hasClass('hovering') && settings.mouse_over == 'pause') || settings.mouse_over != 'pause') {
$template.data('growl-delay', delay);
}
if (delay <= 0) {
clearInterval(timer);
plugin.close();
}
}, settings.timer);
}
};
// Avoid Plugin.prototype conflicts
Plugin.prototype = {
update: function(command, update) {
switch (command) {
case 'icon':
if (this.settings.icon_type.toLowerCase() == 'class') {
this.$template.find('[data-growl="icon"]').removeClass(this.settings.content.icon);
this.$template.find('[data-growl="icon"]').addClass(update);
}else{
if (this.$template.find('[data-growl="icon"]').is('img')) {
this.$template.find('[data-growl="icon"]')
}else{
this.$template.find('[data-growl="icon"]').find('img').attr().attr('src', update);
}
}
break;
case 'url':
this.$template.find('[data-growl="url"]').attr('href', update);
break;
case 'type':
this.$template.removeClass('alert-' + this.settings.type);
this.$template.addClass('alert-' + update);
break;
default:
this.$template.find('[data-growl="' + command +'"]').html(update);
}
return this;
},
close: function() {
var base = this.$template,
settings = this.settings,
posX = base.css(settings.placement.from),
hasAnimation = false;
base.addClass(this.settings.animate.exit);
base.nextAll('[data-growl-position="' + this.settings.placement.from + '-' + this.settings.placement.align + '"]').each(function() {
$(this).css(settings.placement.from, posX);
posX = (parseInt(posX)+(settings.spacing)) + $(this).outerHeight();
});
base.one('webkitAnimationStart oanimationstart MSAnimationStart animationstart', function(event) {
hasAnimation = true;
});
base.one('webkitAnimationEnd oanimationend MSAnimationEnd animationend', function(event) {
$(this).remove();
});
setTimeout(function() {
if (!hasAnimation) {
base.remove();
}
}, 100);
return this;
}
};
// A really lightweight plugin wrapper around the constructor,
// preventing against multiple instantiations
$.growl = function ( content, options ) {
if (content == false) {
setDefaults(this, options);
return false;
}
var plugin = new Plugin( this, content, options );
return plugin;
};
})( jQuery, window, document );
.animated {
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
}
@-webkit-keyframes fadeInDown {
0% {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
100% {
opacity: 1;
-webkit-transform: none;
transform: none;
}
}
@keyframes fadeInDown {
0% {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
-ms-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
100% {
opacity: 1;
-webkit-transform: none;
-ms-transform: none;
transform: none;
}
}
.fadeInDown {
-webkit-animation-name: fadeInDown;
animation-name: fadeInDown;
}
@-webkit-keyframes fadeOutUp {
0% {
opacity: 1;
}
100% {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
}
@keyframes fadeOutUp {
0% {
opacity: 1;
}
100% {
opacity: 0;
-webkit-transform: translate3d(0, -100%, 0);
-ms-transform: translate3d(0, -100%, 0);
transform: translate3d(0, -100%, 0);
}
}
.fadeOutUp {
-webkit-animation-name: fadeOutUp;
animation-name: fadeOutUp;
}