});
},
renderItem: function (item, search){
+
search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi");
- return '<div class="autocomplete-suggestion" data-langname="'+item[0]+'" data-lang="'+item[1]+'" data-val="'+search+'">'+item.replace(re, "<b>$1</b>")+'</div>';
+ return '<div class="autocomplete-suggestion " data-langname="'+item[0]+'" data-lang="'+item[1]+'" data-val="'+search+'"><span class="member-record-name">'+item.replace(re, "<b>$1</b>")+'</span></div>';
},
- onSelect: function(e, term, item){
- let search = $(item).text();
+ // onSelect: function(e, term, item){
+ // console.log(item);
+ // let search = $(item).text();
- if(search !== "No Results Found"){
- window.location.replace(textSearchData.resultUrl+searchResults[search].entityID);
- }
- },
+ // if(search !== "No Results Found"){
+ // window.location.replace("TEST");
+ // }
+ // },
+ onSelect: function(e, term, item){
+ alert('Item "'+item.data('langname')+' ('+item.data('lang')+')" selected by '+(e.type == 'keydown' ? 'pressing enter' : 'mouse click')+'.');
+ }
+ // select: function( event, ui ) {
+ // console.log("ui:" + ui)
+ // var memberID = ui.item.id;
+ // window.location.replace("#=" + memberID );
+ // },
});
});
}
});
$(document).on("click",".member-record-name", function(){
+ console.log("HERE"); // fails
$(".edit-screen").html('');
editData.option = "manage";
editData.memberID = $(this).parent().data('id');
);
});
});
+ /*
+ * Text Search Autocomplete
+ */
+ function textSearch(textSearchData){
+ // Text Search Component
+ jQuery(function($){
+ let searchResults = {};
+ let imageUrl = `{$glmPluginMediaUrl}/images`
+ let listData = {
+ action : 'glm_members_admin_ajax',
+ glm_action : 'glmTextSearch',
+ table : textSearchData.table,
+ fields : textSearchData.fields,
+ where : textSearchData.where
+ }
+ console.log(listData);
+ $('input#'+textSearchData.slug+'-text').autoComplete({
+ minChars: 1,
+ source: function( request, response ) {
+ listData.query = request;
+ $.ajax({
+ dataType: "json",
+ type : 'POST',
+ url: '{$ajaxUrl}',
+ data: listData,
+ success: function(data) {
+ if(data.searchData){
+ let searchDropdown = [];
+ for(let i = 0;i < data.searchData.length;i++){
+ let searchTitle = Object.keys(data.searchData[i])[0];
+ let image = (data.searchData[i][searchTitle].image) ? data.searchData[i][searchTitle].image : null;
+ let memberID = data.searchData[i][searchTitle].memberID;
+ let entityID = data.searchData[i][searchTitle].entityID;
+ searchDropdown.push(searchTitle);
+ {literal} searchResults[searchTitle] = {image: image, memberID: memberID, entityID: entityID}; {/literal}
+ }
+ {literal} response(searchDropdown); {/literal}
+ }else{
+ response(['No Results Found'])
+ }
+ }
+ });
+ },
+ renderItem: function (item, search){
+
+ search = search.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
+ var re = new RegExp("(" + search.split(' ').join('|') + ")", "gi");
+ let entityID = 0;
+ //console.log(search);
+ //console.log(re);
+ if(search !== "No Results Found"){
+ entityID = searchResults[item].entityID;
+ }
+ console.log('<div data-id="'+entityID+'" class="autocomplete-suggestion" data-langname="'+item[0]+'" data-lang="'+item[1]+'" data-val="'+search+'"><div class="member-record-name">'+item.replace(re, "<b>$1</b>")+'</div></div>');
+ return '<div data-id="'+entityID+'" class="autocomplete-suggestion" data-langname="'+item[0]+'" data-lang="'+item[1]+'" data-val="'+search+'"><div class="member-record-name">'+item.replace(re, "<b>$1</b>")+'</div></div>';
+
+ },
+ });
+ });
+ }
+
+ /*
+ * Date Search Widget
+ * IF WE WANT DATE SEARCH FOR MEMBERS
+ */
+ // function dateSearch(dateSearchData){
+ // jQuery(function($){
+
+ // var date = new Date();
+ // var toDate = '', fromDate = (dateSearchData.defaultFromDate) ? '&' + dateSearchData.fromDate + '=' + dateSearchData.defaultFromDate : '';
+ // $('.fromDate').datepicker({
+ // format : 'mm/dd/yyyy',
+ // setDefaultDate : true,
+ // defaultDate : date,
+ // autoClose : true,
+ // onClose : function(){
+ // fromDate = '&' + dateSearchData.fromDate + '=' + $(this)[0].el.value;
+ // }
+ // });
+ // $('.toDate').datepicker({
+ // format : 'mm/dd/yyyy',
+ // autoClose : true,
+ // onClose: function(){
+ // toDate = '&' + dateSearchData.toDate + '=' + $(this)[0].el.value;
+ // }
+ // });
+
+ // $('#' + dateSearchData.searchBtn).on("click", function(){
+ // window.location = dateSearchData.resultUrl + fromDate + toDate;
+ // })
+ // });
+ // }
+
</script>
{include file='admin/footer.html'}
\ No newline at end of file