Ticket #6935: 6935.01.patch
File 6935.01.patch, 2.6 KB (added by , 8 years ago) |
---|
-
src/bp-messages/js/autocomplete/jquery.autocompletefb.js
19 19 var settings = 20 20 { 21 21 ul : tmp, 22 urlLookup : [ ""],22 urlLookup : [''], 23 23 acOptions : {}, 24 foundClass : ".friend-tab",25 inputClass : ".send-to-input"26 } 24 foundClass : '.friend-tab', 25 inputClass : '.send-to-input' 26 }; 27 27 28 if(options) jQuery.extend(settings, options); 28 if (options) { 29 jQuery.extend(settings, options); 30 } 29 31 30 32 var acfb = 31 33 { … … 40 42 var newID = o.parentNode.id.substr( o.parentNode.id.indexOf('-')+1 ); 41 43 jQuery('#send-to-usernames').removeClass(newID); 42 44 } 43 } 45 }; 44 46 45 jQuery(settings.foundClass+ " img.p").click(function(){47 jQuery(settings.foundClass+' img.p').click(function(){ 46 48 acfb.removeFind(this); 47 49 }); 48 50 49 51 jQuery(settings.inputClass,tmp).autocomplete(settings.urlLookup,settings.acOptions); 50 52 jQuery(settings.inputClass,tmp).result(function(e,d,f){ 51 varf = settings.foundClass.replace(/\./,'');52 vard = String(d).split(' (');53 f = settings.foundClass.replace(/\./,''); 54 d = String(d).split(' ('); 53 55 var un = d[1].substr(0, d[1].length-1); 54 56 55 57 /* Don't add the same user multiple times */ 56 58 if( 0 === jQuery(settings.inputClass).siblings('#un-' + un).length ) { 59 // Get URL parameter function. 60 // http://stackoverflow.com/a/21903119 61 var getUrlParameter = function getUrlParameter(sParam) { 62 var sPageURL = decodeURIComponent(window.location.search.substring(1)), 63 sURLVariables = sPageURL.split('&'), 64 sParameterName, 65 i; 66 67 for (i = 0; i < sURLVariables.length; i++) { 68 sParameterName = sURLVariables[i].split('='); 69 70 if (sParameterName[0] === sParam) { 71 return sParameterName[1] === undefined ? true : sParameterName[1]; 72 } 73 } 74 }; 75 57 76 var ln = '#link-' + un; 58 77 var l = jQuery(ln).attr('href'); 59 78 var v = '<li class="'+f+'" id="un-'+un+'"><span><a href="'+l+'">'+d[0]+'</a></span> <span class="p">X</span></li>'; 60 79 61 var x = jQuery(settings.inputClass,tmp).closest('li').before(v); 80 var x; 81 // Check if we are attempting to PM a user via URL querystring. 82 if ( getUrlParameter('r') ) { 83 x = jQuery(settings.inputClass,tmp).before(v); 84 } else { 85 x = jQuery(settings.inputClass,tmp).closest('li').before(v); 86 } 87 62 88 jQuery('#send-to-usernames').addClass(un); 63 89 64 90 jQuery('.p',x[0].previousSibling).click(function(){ … … 72 98 73 99 jQuery(settings.inputClass,tmp).focus(); 74 100 return acfb; 75 } 101 };