function doSearchAudios() { $('.isAudio').each(function () { var me = $(this); var file = $(me).attr('data-audio'); $(this).find('a.srchMain').click(function (e) { e.preventDefault(); var audioTag = $(me).find('.sch-audio').html(); if (audioTag == '') { $(me).find('.sch-audio').html(''); $(me).find('audio').trigger('play'); } return false; }); }); } $(document).ready(function () { $('.isAudio a.srchMain').each(function () { $(this).attr('href', ''); }); doSearchAudios(); }); function GetSearchResults(count) { var searchedText = $('#searchtxt').val(); var pageNumber = parseInt($('#hdnPageNo').val()) + 1; $.ajax({ type: "GET", url: "/Search", data: { searchedText: searchedText, pageNumber: pageNumber, getPartial: true }, dataType: "html", beforeSend: function () { $("#searchResults").append("
"); }, success: function (response) { $("#searchResults .imagesLoader").remove(); if (response != "") { $('#searchResults').append(response); $('#hdnPageNo').val(pageNumber); } UpdateSearchFilter(); BindSearchDDLEvent(); $('.isAudio a.srchMain').each(function () { $(this).attr('href', ''); }); doSearchAudios(); $('#resultsCount').html($("#searchResults>article").length + " نتيجة "); var totalRecords = parseInt($('#hdnTotal').val()); var currentRecords = pageNumber * count; if (totalRecords <= currentRecords) { $('#btnMoreResults').hide(); } } }); } function UpdateSearchFilter() { $('#searchResults>article').each(function (i, element) { if ($('#sectionsDDL>span[id="' + $(element).attr("section_id") + '"]').length <= 0) { $('#sectionsDDL').append('' + $(element).attr("section") + ''); } }); } function BindSearchDDLEvent() { $("#sectionsDDL").find("span").click(function () { $(".search_select").text($(this).text()); $("#sectionsDDL").slideUp(); $("#searchResults>article").hide(); var articles = $("#searchResults>article[section_id='" + $(this).attr("id") + "']"); $(articles).each(function (i, elemnt) { $(elemnt).fadeIn(); }); $('#resultsCount').html(articles.length + " نتيجة "); if ($(this).text() == "جميع النتائج") { $("#searchResults>article").show(); $('#resultsCount').html($("#searchResults>article").length + " نتيجة "); } }); }