2011-07-27 22:59:48 +00:00
|
|
|
|
jQuery(document).ready(function () {
|
|
|
|
|
$.ajaxSetup({
|
|
|
|
|
cache: false
|
|
|
|
|
});
|
2011-06-30 06:15:06 +00:00
|
|
|
|
|
2011-09-09 03:26:48 +00:00
|
|
|
|
bindFolderAutoComplete(".folderLookup");
|
|
|
|
|
bindSeriesAutoComplete(".seriesLookup");
|
2011-10-20 23:36:47 +00:00
|
|
|
|
bindLocalSeriesAutoComplete(".localSeriesLookup");
|
2011-07-27 22:59:48 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
function bindFolderAutoComplete(selector) {
|
2011-09-09 03:26:48 +00:00
|
|
|
|
|
2011-07-27 22:59:48 +00:00
|
|
|
|
$(selector).each(function (index, element) {
|
2011-09-09 03:26:48 +00:00
|
|
|
|
$(element).autocomplete({
|
|
|
|
|
//source: "/Directory/GetDirectories",
|
|
|
|
|
source: function (request, response) {
|
|
|
|
|
$.ajax({
|
|
|
|
|
url: "/Directory/GetDirectories",
|
|
|
|
|
dataType: "json",
|
|
|
|
|
data: {
|
|
|
|
|
term: request.term
|
|
|
|
|
},
|
|
|
|
|
success: function (data) {
|
|
|
|
|
var re = $.ui.autocomplete.escapeRegex(request.term);
|
|
|
|
|
var matcher = new RegExp("^" + re, "i");
|
|
|
|
|
response($.grep(data, function (item) { return matcher.test(item); }));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
minLength: 3
|
2011-06-30 06:15:06 +00:00
|
|
|
|
});
|
2011-07-27 22:59:48 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindSeriesAutoComplete(selector) {
|
|
|
|
|
|
|
|
|
|
$(selector).each(function (index, element) {
|
2011-09-09 03:26:48 +00:00
|
|
|
|
$(element).autocomplete({
|
|
|
|
|
source: "/AddSeries/LookupSeries",
|
|
|
|
|
minLength: 3,
|
|
|
|
|
delay: 500,
|
|
|
|
|
select: function (event, ui) {
|
|
|
|
|
$(this).val(ui.item.Title);
|
2011-09-09 03:52:25 +00:00
|
|
|
|
$(this).siblings('.seriesId').val(ui.item.Id);
|
2011-09-09 03:26:48 +00:00
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.data("autocomplete")._renderItem = function (ul, item) {
|
|
|
|
|
return $("<li></li>")
|
|
|
|
|
.data("item.autocomplete", item)
|
|
|
|
|
.append("<a><strong>" + item.Title + "</strong><br>" + item.FirstAired + "</a>")
|
|
|
|
|
.appendTo(ul);
|
|
|
|
|
};
|
2011-07-27 22:59:48 +00:00
|
|
|
|
});
|
2011-10-20 23:36:47 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function bindLocalSeriesAutoComplete(selector) {
|
|
|
|
|
|
|
|
|
|
$(selector).each(function (index, element) {
|
|
|
|
|
$(element).autocomplete({
|
|
|
|
|
source: "/Series/LocalSearch",
|
|
|
|
|
minLength: 3,
|
|
|
|
|
delay: 500,
|
|
|
|
|
select: function (event, ui) {
|
|
|
|
|
window.location = "../Series/Details?seriesId=" + ui.item.Id;
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.data("autocomplete")._renderItem = function (ul, item) {
|
|
|
|
|
return $("<li></li>")
|
|
|
|
|
.data("item.autocomplete", item)
|
|
|
|
|
.append("<a><strong>" + item.Title + "</strong><br>" + "</a>")
|
|
|
|
|
.appendTo(ul);
|
|
|
|
|
};
|
|
|
|
|
});
|
2011-06-30 06:15:06 +00:00
|
|
|
|
}
|