From 1bd22e065e4f51869118afbf3ce1dfe4e2ce519f Mon Sep 17 00:00:00 2001 From: Daniel Termin Date: Tue, 7 Feb 2012 11:53:51 +0100 Subject: [PATCH 1/2] Added public method clearSpecificFriend( withID ). Use this if you want to deselect a friend from outside the jfmfs. Just provide the Facebook user-ID. --- jquery.facebook.multifriend.select.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jquery.facebook.multifriend.select.js b/jquery.facebook.multifriend.select.js index 62e9de0..cfce3d4 100644 --- a/jquery.facebook.multifriend.select.js +++ b/jquery.facebook.multifriend.select.js @@ -124,6 +124,10 @@ all_friends.removeClass("selected"); }; + this.clearSpecificFriend = function( withID ) { + $( '#' + withID ).removeClass( "selected" ); + }; + // ----------+----------+----------+----------+----------+----------+----------+ // Private functions // ----------+----------+----------+----------+----------+----------+----------+ From 951dfb9f33d055870fb5a1d8ad3473d598514497 Mon Sep 17 00:00:00 2001 From: Daniel Termin Date: Tue, 7 Feb 2012 11:57:35 +0100 Subject: [PATCH 2/2] Update jquery.facebook.multifriend.select.min.js --- jquery.facebook.multifriend.select.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jquery.facebook.multifriend.select.min.js b/jquery.facebook.multifriend.select.min.js index f9efdf8..d262990 100644 --- a/jquery.facebook.multifriend.select.min.js +++ b/jquery.facebook.multifriend.select.min.js @@ -13,4 +13,4 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -(function(a){var b=function(b,c){var d=a(b),e=this,f=[],g,h=0,i=0,j,k=a.extend({max_selected:-1,max_selected_message:"{0} of {1} selected",pre_selected_friends:[],exclude_friends:[],friend_fields:"id,name",sorter:function(a,b){var c=a.name.toLowerCase(),d=b.name.toLowerCase();return cd?1:0},labels:{selected:"Selected",filter_default:"Start typing a name",filter_title:"Find Friends:",all:"All",max_selected_message:"{0} of {1} selected"}},c||{}),l,m=function(a){var b={};for(var c=0,d=a.length;c
"+k.labels.filter_title+" "+" "+k.labels.all+""+" "+k.labels.selected+" (0)"+(k.max_selected>0?"
":"")+"
"+"
"+"");var n=a("#jfmfs-friend-container"),o=a("#jfmfs-friend-selector"),p=m(k.pre_selected_friends),q=m(k.exclude_friends),r;FB.api("/me/friends?fields="+k.friend_fields,function(b){var c=b.data.sort(k.sorter),e={},g=[],h="";a.each(c,function(a,b){b.id in q||(h=b.id in p?"selected":"",g.push("
"+b.name+"
"))}),n.append(g.join("")),f=a(".jfmfs-friend",d),f.bind("inview",function(b,c){a(this).attr("src")===undefined&&a("img",a(this)).attr("src","//graph.facebook.com/"+this.id+"/picture"),a(this).unbind("inview")}),s()}),this.getSelectedIds=function(){var b=[];return a.each(d.find(".jfmfs-friend.selected"),function(c,d){b.push(a(d).attr("id"))}),b},this.getSelectedIdsAndNames=function(){var b=[];return a.each(d.find(".jfmfs-friend.selected"),function(c,d){b.push({id:a(d).attr("id"),name:a(d).find(".friend-name").text()})}),b},this.clearSelected=function(){r.removeClass("selected")};var s=function(){r=a(".jfmfs-friend",d),j=r.first().offset().top;for(var b=0,c=r.length;b=k.max_selected,h=n.find(".selected").attr("id")===a(this).attr("id");if(!c&&!f&&u()&&g)return;c&&!h&&n.find(".selected").removeClass("selected"),a(this).toggleClass("selected"),a(this).removeClass("hover");if(a(this).hasClass("selected"))if(!l)l=a(this);else if(b.shiftKey){var i=a(this).index(),j=l.index(),m=Math.max(i,j),o=Math.min(i,j);for(var q=o;q<=m;q++){var s=a(r[q]);!s.hasClass("hide-non-selected")&&!s.hasClass("hide-filtered")&&u()&&a(".jfmfs-friend.selected").length=-10&&f-i0},v=function(){var b=k.labels.max_selected_message.replace("{0}",t()).replace("{1}",k.max_selected);a("#jfmfs-max-selected-wrapper").html(b)}};a.fn.jfmfs=function(c){return this.each(function(){var d=a(this);if(d.data("jfmfs"))return;var e=new b(this,c);d.data("jfmfs",e)})},a.expr[":"].Contains=function(b,c,d){return a(b).text().toUpperCase().indexOf(d[3].toUpperCase())>=0}})(jQuery),$.debounce===undefined&&function(a,b){var c=a.jQuery||a.Cowboy||(a.Cowboy={}),d;c.throttle=d=function(a,d,e,f){function i(){function l(){h=+(new Date),e.apply(c,k)}function m(){g=b}var c=this,i=+(new Date)-h,k=arguments;f&&!g&&l(),g&&clearTimeout(g),f===b&&i>a?l():d!==!0&&(g=setTimeout(f?m:l,f===b?a-i:a))}var g,h=0;return typeof d!="boolean"&&(f=e,e=d,d=b),c.guid&&(i.guid=e.guid=e.guid||c.guid++),i},c.debounce=function(a,c,e){return e===b?d(a,c,!1):d(a,e,c!==!1)}}(this); \ No newline at end of file +(function(a){var b=function(b,c){var d=a(b),e=this,f=[],g,h=0,i=0,j,k=a.extend({max_selected:-1,max_selected_message:"{0} of {1} selected",pre_selected_friends:[],exclude_friends:[],friend_fields:"id,name",sorter:function(a,b){var c=a.name.toLowerCase(),d=b.name.toLowerCase();return cd?1:0},labels:{selected:"Selected",filter_default:"Start typing a name",filter_title:"Find Friends:",all:"All",max_selected_message:"{0} of {1} selected"}},c||{}),l,m=function(a){var b={};for(var c=0,d=a.length;c
"+k.labels.filter_title+" "+" "+k.labels.all+""+" "+k.labels.selected+" (0)"+(k.max_selected>0?"
":"")+"
"+"
"+"");var n=a("#jfmfs-friend-container"),o=a("#jfmfs-friend-selector"),p=m(k.pre_selected_friends),q=m(k.exclude_friends),r;FB.api("/me/friends?fields="+k.friend_fields,function(b){var c=b.data.sort(k.sorter),e={},g=[],h="";a.each(c,function(a,b){b.id in q||(h=b.id in p?"selected":"",g.push("
"+b.name+"
"))}),n.append(g.join("")),f=a(".jfmfs-friend",d),f.bind("inview",function(b,c){a(this).attr("src")===undefined&&a("img",a(this)).attr("src","//graph.facebook.com/"+this.id+"/picture"),a(this).unbind("inview")}),s()}),this.getSelectedIds=function(){var b=[];return a.each(d.find(".jfmfs-friend.selected"),function(c,d){b.push(a(d).attr("id"))}),b},this.getSelectedIdsAndNames=function(){var b=[];return a.each(d.find(".jfmfs-friend.selected"),function(c,d){b.push({id:a(d).attr("id"),name:a(d).find(".friend-name").text()})}),b},this.clearSelected=function(){r.removeClass("selected")};this.clearSpecificFriend(id){$('#'+id).removeClass("selected")};var s=function(){r=a(".jfmfs-friend",d),j=r.first().offset().top;for(var b=0,c=r.length;b=k.max_selected,h=n.find(".selected").attr("id")===a(this).attr("id");if(!c&&!f&&u()&&g)return;c&&!h&&n.find(".selected").removeClass("selected"),a(this).toggleClass("selected"),a(this).removeClass("hover");if(a(this).hasClass("selected"))if(!l)l=a(this);else if(b.shiftKey){var i=a(this).index(),j=l.index(),m=Math.max(i,j),o=Math.min(i,j);for(var q=o;q<=m;q++){var s=a(r[q]);!s.hasClass("hide-non-selected")&&!s.hasClass("hide-filtered")&&u()&&a(".jfmfs-friend.selected").length=-10&&f-i0},v=function(){var b=k.labels.max_selected_message.replace("{0}",t()).replace("{1}",k.max_selected);a("#jfmfs-max-selected-wrapper").html(b)}};a.fn.jfmfs=function(c){return this.each(function(){var d=a(this);if(d.data("jfmfs"))return;var e=new b(this,c);d.data("jfmfs",e)})},a.expr[":"].Contains=function(b,c,d){return a(b).text().toUpperCase().indexOf(d[3].toUpperCase())>=0}})(jQuery),$.debounce===undefined&&function(a,b){var c=a.jQuery||a.Cowboy||(a.Cowboy={}),d;c.throttle=d=function(a,d,e,f){function i(){function l(){h=+(new Date),e.apply(c,k)}function m(){g=b}var c=this,i=+(new Date)-h,k=arguments;f&&!g&&l(),g&&clearTimeout(g),f===b&&i>a?l():d!==!0&&(g=setTimeout(f?m:l,f===b?a-i:a))}var g,h=0;return typeof d!="boolean"&&(f=e,e=d,d=b),c.guid&&(i.guid=e.guid=e.guid||c.guid++),i},c.debounce=function(a,c,e){return e===b?d(a,c,!1):d(a,e,c!==!1)}}(this); \ No newline at end of file