Skip to:
Content

BuddyPress.org

Changeset 4711


Ignore:
Timestamp:
07/18/2011 11:21:34 PM (13 years ago)
Author:
boonebgorges
Message:

Ensure that autocompleted message recipients can't be duplicated on the Compose screen. Fixes #3352

Location:
trunk/bp-messages/js/autocomplete
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-messages/js/autocomplete/jquery.autocompletefb.dev.js

    r4710 r4711  
    5353        var d = String(d).split(' (');
    5454        var un = d[1].substr(0, d[1].length-1);
    55         var ln = '#link-' + un;
    56         var l = jQuery(ln).attr('href');
    57         var v = '<li class="'+f+'" id="un-'+un+'"><span><a href="'+l+'">'+d[0]+'</a></span> <span class="p">X</span></li>';
    58         var x = jQuery(settings.inputClass,tmp).before(v);
     55       
     56        /* Don't add the same user multiple times */
     57        if( 0 === jQuery(settings.inputClass).siblings('#un-' + un).length ) {     
     58            var ln = '#link-' + un;
     59            var l = jQuery(ln).attr('href');
     60            var v = '<li class="'+f+'" id="un-'+un+'"><span><a href="'+l+'">'+d[0]+'</a></span> <span class="p">X</span></li>';
     61           
     62            var x = jQuery(settings.inputClass,tmp).before(v);
     63            jQuery('#send-to-usernames').addClass(un);
     64               
     65            jQuery('.p',x[0].previousSibling).click(function(){
     66                acfb.removeFind(this);
     67            });
     68        }
     69           
     70        jQuery(settings.inputClass,tmp).val('');
    5971
    60         jQuery('#send-to-usernames').addClass(un);
    61 
    62         jQuery('.p',x[0].previousSibling).click(function(){
    63             acfb.removeFind(this);
    64         });
    65         jQuery(settings.inputClass,tmp).val('');
    6672    });
    6773
  • trunk/bp-messages/js/autocomplete/jquery.autocompletefb.js

    r4710 r4711  
    1414 *   http://www.gnu.org/licenses/gpl.html
    1515 */
    16 jQuery.fn.autoCompletefb=function(b){var c=this;var d={ul:c,urlLookup:[""],acOptions:{},foundClass:".friend-tab",inputClass:".send-to-input"};if(b){jQuery.extend(d,b)}var a={params:d,removeFind:function(e){a.removeUsername(e);jQuery(e).unbind("click").parent().remove();jQuery(d.inputClass,c).focus();return c.acfb},removeUsername:function(f){var e=f.parentNode.id.split("-");jQuery("#send-to-usernames").removeClass(e[1])}};jQuery(d.foundClass+" img.p").click(function(){a.removeFind(this)});jQuery(d.inputClass,c).autocomplete(d.urlLookup,d.acOptions);jQuery(d.inputClass,c).result(function(n,o,m){var m=d.foundClass.replace(/\./,"");var o=String(o).split(" (");var j=o[1].substr(0,o[1].length-1);var k="#link-"+j;var h=jQuery(k).attr("href");var i='<li class="'+m+'" id="un-'+j+'"><span><a href="'+h+'">'+o[0]+'</a></span> <span class="p">X</span></li>';var g=jQuery(d.inputClass,c).before(i);jQuery("#send-to-usernames").addClass(j);jQuery(".p",g[0].previousSibling).click(function(){a.removeFind(this)});jQuery(d.inputClass,c).val("")});jQuery(d.inputClass,c).focus();return a};
     16jQuery.fn.autoCompletefb=function(b){var c=this;var d={ul:c,urlLookup:[""],acOptions:{},foundClass:".friend-tab",inputClass:".send-to-input"};if(b){jQuery.extend(d,b)}var a={params:d,removeFind:function(e){a.removeUsername(e);jQuery(e).unbind("click").parent().remove();jQuery(d.inputClass,c).focus();return c.acfb},removeUsername:function(f){var e=f.parentNode.id.split("-");jQuery("#send-to-usernames").removeClass(e[1])}};jQuery(d.foundClass+" img.p").click(function(){a.removeFind(this)});jQuery(d.inputClass,c).autocomplete(d.urlLookup,d.acOptions);jQuery(d.inputClass,c).result(function(n,o,m){var m=d.foundClass.replace(/\./,"");var o=String(o).split(" (");var j=o[1].substr(0,o[1].length-1);if(0===jQuery(d.inputClass).siblings("#un-"+j).length){var k="#link-"+j;var h=jQuery(k).attr("href");var i='<li class="'+m+'" id="un-'+j+'"><span><a href="'+h+'">'+o[0]+'</a></span> <span class="p">X</span></li>';var g=jQuery(d.inputClass,c).before(i);jQuery("#send-to-usernames").addClass(j);jQuery(".p",g[0].previousSibling).click(function(){a.removeFind(this)})}jQuery(d.inputClass,c).val("")});jQuery(d.inputClass,c).focus();return a};
Note: See TracChangeset for help on using the changeset viewer.