Elgg  Version 1.9
ui.friends_picker.js
Go to the documentation of this file.
1 /*
2  elgg friendsPicker plugin
3  adapted from Niall Doherty's excellent Coda-Slider - http://www.ndoherty.com/coda-slider
4  */
5 
6 
7 jQuery.fn.friendsPicker = function(iterator) {
8 
9  var settings;
10  settings = $.extend({ easeFunc: "easeOutExpo", easeTime: 1000, toolTip: false }, settings);
11 
12  return this.each(function() {
13 
14  var container = $(this);
15  container.addClass("friends-picker");
16  // set panelwidth manually as it's hidden initially - adjust this value for different themes/pagewidths
17  var panelWidth = 730;
18 
19  // count the panels in the container
20  var panelCount = container.find("div.panel").size();
21  // calculate the width of all the panels lined up end-to-end
22  var friendsPicker_containerWidth = panelWidth*panelCount;
23  // specify width for the friendsPicker_container
24  container.find("div.friends-picker-container").css("width" , friendsPicker_containerWidth);
25 
26  // global variables for container.each function below
27  var friendsPickerNavigationWidth = 0;
28  var currentPanel = 1;
29 
30  // generate appropriate nav for each container
31  container.each(function(i) {
32  // generate Left and Right arrows
33  $(this).before("<div class='friends-picker-navigation-l' id='friends-picker-navigation-l" + iterator + "'><a href='#'>Left</a><\/div>");
34  $(this).after("<div class='friends-picker-navigation-r' id='friends-picker-navigation-r" + iterator + "'><a href='#'>Right</a><\/div>");
35 
36  // generate a-z tabs
37  $(this).before("<div class='friends-picker-navigation' id='friends-picker-navigation" + iterator + "'><ul><\/ul><\/div>");
38  $(this).find("div.panel").each(function(individualTabItemNumber) {
39  $("div#friends-picker-navigation" + iterator + " ul").append("<li class='tab" + (individualTabItemNumber+1) + "'><a href='#" + (individualTabItemNumber+1) + "'>" + $(this).attr("title") + "<\/a><\/li>");
40  });
41 
42  // tabs navigation
43  $("div#friends-picker-navigation" + iterator + " a").each(function(individualTabItemNumber) {
44  // calc friendsPickerNavigationWidth by summing width of each li
45  friendsPickerNavigationWidth += $(this).parent().width();
46  // set-up individual tab clicks
47  $(this).bind("click", function() {
48  $(this).addClass("current").parent().parent().find("a").not($(this)).removeClass("current");
49  var distanceToMoveFriendsPicker_container = - (panelWidth*individualTabItemNumber);
50  currentPanel = individualTabItemNumber + 1;
51  $(this).parent().parent().parent().next().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
52  });
53  });
54 
55  // Right arow click function
56  $("div#friends-picker-navigation-r" + iterator + " a").click(function() {
57  if (currentPanel == panelCount) {
58  var distanceToMoveFriendsPicker_container = 0;
59  currentPanel = 1;
60  $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().parent().find("a:eq(0)").addClass("current");
61  } else {
62  var distanceToMoveFriendsPicker_container = - (panelWidth*currentPanel);
63  currentPanel += 1;
64  $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().next().find("a").addClass("current");
65  };
66  $(this).parent().parent().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
67  return false;
68  });
69 
70  // Left arrow click function
71  $("div#friends-picker-navigation-l" + iterator + " a").click(function() {
72  if (currentPanel == 1) {
73  var distanceToMoveFriendsPicker_container = - (panelWidth*(panelCount - 1));
74  currentPanel = panelCount;
75  $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().parent().find("li:last a").addClass("current");
76  } else {
77  currentPanel -= 1;
78  var distanceToMoveFriendsPicker_container = - (panelWidth*(currentPanel - 1));
79  $(this).parent().parent().find("div.friends-picker-navigation a.current").removeClass("current").parent().prev().find("a").addClass("current");
80  };
81  $(this).parent().parent().find("div.friends-picker-container").animate({ left: distanceToMoveFriendsPicker_container}, settings.easeTime, settings.easeFunc);
82  return false;
83  });
84 
85  // apply 'current' class to currently selected tab link
86  $("div#friends-picker-navigation" + iterator + " a:eq(0)").addClass("current");
87  });
88 
89  $("div#friends-picker-navigation" + iterator).append("<br />");
90  });
91 };
i
Definition: admin.php:47
elgg form settings
Definition: admin.php:562
function elgg combo checkbox click(function(){if($(this).is(':checked')){$(this).prev().attr('disabled', true);$(this).prev().val('');}else{$(this).prev().attr('disabled', false);}})
margin left
Definition: admin.php:210
friends picker friends picker container
Definition: admin.php:719