applicious_utils 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +4 -0
- data/Rakefile +2 -0
- data/app/assets/javascripts/applicious_utils/Applicious/applicious.coffee +9 -0
- data/app/assets/javascripts/applicious_utils/Applicious/facebook.coffee +12 -0
- data/app/assets/javascripts/applicious_utils/FbMultiFriendSelector/README.md +122 -0
- data/app/assets/javascripts/applicious_utils/FbMultiFriendSelector/index.html +100 -0
- data/app/assets/javascripts/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select-list.css +158 -0
- data/app/assets/javascripts/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select.css +160 -0
- data/app/assets/javascripts/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select.js +366 -0
- data/app/assets/javascripts/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select.min.js +11 -0
- data/app/assets/javascripts/applicious_utils/LightboxMe/LICENSE +11 -0
- data/app/assets/javascripts/applicious_utils/LightboxMe/README.markdown +44 -0
- data/app/assets/javascripts/applicious_utils/LightboxMe/jquery.lightbox_me.js +250 -0
- data/app/assets/javascripts/applicious_utils/index.js +4 -0
- data/app/assets/stylesheets/applicious_utils/Applicious/applicious.css +0 -0
- data/app/assets/stylesheets/applicious_utils/FbMultiFriendSelector/README.md +122 -0
- data/app/assets/stylesheets/applicious_utils/FbMultiFriendSelector/index.html +100 -0
- data/app/assets/stylesheets/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select-list.css +158 -0
- data/app/assets/stylesheets/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select.css +160 -0
- data/app/assets/stylesheets/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select.js +366 -0
- data/app/assets/stylesheets/applicious_utils/FbMultiFriendSelector/jquery.facebook.multifriend.select.min.js +11 -0
- data/app/assets/stylesheets/applicious_utils/index.css +9 -0
- data/applicious_utils-0.0.1.gem +0 -0
- data/applicious_utils-0.0.2.gem +0 -0
- data/applicious_utils-0.0.3.gem +0 -0
- data/applicious_utils-0.0.4.gem +0 -0
- data/applicious_utils-0.0.5.gem +0 -0
- data/applicious_utils.gemspec +22 -0
- data/lib/applicious_utils/applicious_railtie.rb +11 -0
- data/lib/applicious_utils/engine.rb +5 -0
- data/lib/applicious_utils/version.rb +3 -0
- data/lib/applicious_utils/view_helpers.rb +16 -0
- data/lib/applicious_utils.rb +4 -0
- data/pkg/applicious_utils-0.0.4.gem +0 -0
- metadata +81 -0
@@ -0,0 +1,160 @@
|
|
1
|
+
/*
|
2
|
+
Copyright 2010 Mike Brevoort http://mike.brevoort.com @mbrevoort
|
3
|
+
|
4
|
+
v1.0 jquery-facebook-multi-friend-selector
|
5
|
+
|
6
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
+
you may not use this file except in compliance with the License.
|
8
|
+
You may obtain a copy of the License at
|
9
|
+
|
10
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
11
|
+
|
12
|
+
Unless required by applicable law or agreed to in writing, software
|
13
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
+
See the License for the specific language governing permissions and
|
16
|
+
limitations under the License.
|
17
|
+
*/
|
18
|
+
|
19
|
+
#jfmfs-friend-selector input {
|
20
|
+
background-color: #fcfcfc;
|
21
|
+
border: 1px solid #ccc;
|
22
|
+
font: 11px verdana, arial, helvetica, sans-serif;
|
23
|
+
margin: 2px 0;
|
24
|
+
padding: 2px 4px;
|
25
|
+
}
|
26
|
+
.jfmfs-friend {
|
27
|
+
cursor:pointer;
|
28
|
+
display:block;
|
29
|
+
float:left;
|
30
|
+
height:56px;
|
31
|
+
margin:3px;
|
32
|
+
padding:4px;
|
33
|
+
width:126px;
|
34
|
+
border: 1px solid #FFFFFF;
|
35
|
+
-moz-border-radius: 5px;
|
36
|
+
-webkit-border-radius: 5px;
|
37
|
+
-webkit-user-select:none;
|
38
|
+
-moz-user-select:none;
|
39
|
+
overflow:hidden;
|
40
|
+
}
|
41
|
+
|
42
|
+
.jfmfs-friend img {
|
43
|
+
border: 1px solid #CCC;
|
44
|
+
float:left;
|
45
|
+
margin:0;
|
46
|
+
}
|
47
|
+
|
48
|
+
.jfmfs-friend.selected img {
|
49
|
+
border: 1px solid #233E75;
|
50
|
+
}
|
51
|
+
|
52
|
+
.jfmfs-friend div {
|
53
|
+
color:#111111;
|
54
|
+
font-size:11px;
|
55
|
+
overflow:hidden;
|
56
|
+
padding:2px 0 0 6px;
|
57
|
+
}
|
58
|
+
|
59
|
+
#jfmfs-friend-container {
|
60
|
+
overflow:scroll;
|
61
|
+
overflow-x: hidden;
|
62
|
+
-ms-overflow-x: hidden;
|
63
|
+
width:100%;
|
64
|
+
height:400px;
|
65
|
+
font-family: 'lucida grande', tahoma, verdana, arial, sans-serif;
|
66
|
+
color: #333;
|
67
|
+
font-size: 12px;
|
68
|
+
}
|
69
|
+
|
70
|
+
#jfmfs-friend-selector {
|
71
|
+
width:725px;
|
72
|
+
height:376px;
|
73
|
+
overflow-y:hidden;
|
74
|
+
}
|
75
|
+
|
76
|
+
#jfmfs-inner-header {
|
77
|
+
background:none repeat scroll 0 0 #F7F7F7;
|
78
|
+
border-bottom:1px solid #CCCCCC;
|
79
|
+
color:#3B5998;
|
80
|
+
font-size:11px;
|
81
|
+
font-weight:bold;
|
82
|
+
height:25px;
|
83
|
+
padding:2px;
|
84
|
+
}
|
85
|
+
|
86
|
+
.jfmfs-friend.selected {
|
87
|
+
background-color: #3B5998;
|
88
|
+
border: 1px solid #3B5998;
|
89
|
+
|
90
|
+
background: #6D84B4; /* for non-css3 browsers */
|
91
|
+
|
92
|
+
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#233E75', endColorstr='#6D84B4'); /* for IE */
|
93
|
+
background: -webkit-gradient(linear, left top, left bottom, from(#233E75), to(#6D84B4)); /* for webkit browsers */
|
94
|
+
background: -moz-linear-gradient(top, #233E75, #6D84B4); /* for firefox 3.6+ */
|
95
|
+
}
|
96
|
+
|
97
|
+
.jfmfs-friend.selected div {
|
98
|
+
color: #FFFFFF;
|
99
|
+
}
|
100
|
+
|
101
|
+
.hover {
|
102
|
+
background-color: #EFF2F7;
|
103
|
+
}
|
104
|
+
|
105
|
+
.hide-non-selected, .hide-filtered {
|
106
|
+
display: none;
|
107
|
+
}
|
108
|
+
|
109
|
+
div.jfmfs-button {
|
110
|
+
background:none repeat scroll 0 0 #6D84B4;
|
111
|
+
border:1px solid #3B5998;
|
112
|
+
color:white;
|
113
|
+
cursor:pointer;
|
114
|
+
margin:4px 5px 0 4px;
|
115
|
+
padding:2px 5px;
|
116
|
+
text-decoration:none;
|
117
|
+
}
|
118
|
+
|
119
|
+
#jfmfs-friend-selector a.filter-link:link, a.filter-link:visited {
|
120
|
+
font-weight: bold;
|
121
|
+
text-decoration: none;
|
122
|
+
}
|
123
|
+
|
124
|
+
#jfmfs-friend-selector a.filter-link:hover, #jfmfs-friend-selector a.selected {
|
125
|
+
background-color: #6D84B4;
|
126
|
+
-moz-border-radius: 5px;
|
127
|
+
-webkit-border-radius: 5px;
|
128
|
+
color: #FFFFFF;
|
129
|
+
}
|
130
|
+
|
131
|
+
#jfmfs-friend-selector .filter-link {
|
132
|
+
margin:4px 5px 4px 5px;
|
133
|
+
padding:3px 5px 3px 5px;
|
134
|
+
}
|
135
|
+
|
136
|
+
#jfmfs-inner-header .filter-link {
|
137
|
+
float:right;
|
138
|
+
}
|
139
|
+
|
140
|
+
#jfmfs-inner-header div.jfmfs-button-hover {
|
141
|
+
text-decoration: underline;
|
142
|
+
}
|
143
|
+
|
144
|
+
|
145
|
+
#jfmfs-friend-filter-text {
|
146
|
+
height: 23px;
|
147
|
+
}
|
148
|
+
|
149
|
+
|
150
|
+
#jfmfs-inner-header span.jfmfs-title {
|
151
|
+
color: #333333;
|
152
|
+
font-weight: bold;
|
153
|
+
margin: 3px 0 2px;
|
154
|
+
}
|
155
|
+
|
156
|
+
#jfmfs-max-selected-wrapper {
|
157
|
+
float: right;
|
158
|
+
margin:4px 5px 4px 5px;
|
159
|
+
padding:3px 5px 3px 5px;
|
160
|
+
}
|
@@ -0,0 +1,366 @@
|
|
1
|
+
// Copyright 2010 Mike Brevoort http://mike.brevoort.com @mbrevoort
|
2
|
+
//
|
3
|
+
// v1.0 jquery-facebook-multi-friend-selector
|
4
|
+
//
|
5
|
+
// Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
// you may not use this file except in compliance with the License.
|
7
|
+
// You may obtain a copy of the License at
|
8
|
+
//
|
9
|
+
// http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
//
|
11
|
+
// Unless required by applicable law or agreed to in writing, software
|
12
|
+
// distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
// See the License for the specific language governing permissions and
|
15
|
+
// limitations under the License.
|
16
|
+
|
17
|
+
(function($) {
|
18
|
+
var JFMFS = function(element, options) {
|
19
|
+
var elem = $(element),
|
20
|
+
obj = this,
|
21
|
+
uninitializedImagefriendElements = [], // for images that are initialized
|
22
|
+
keyUpTimer,
|
23
|
+
friends_per_row = 0,
|
24
|
+
friend_height_px = 0,
|
25
|
+
first_element_offset_px;
|
26
|
+
|
27
|
+
var settings = $.extend({
|
28
|
+
max_selected: -1,
|
29
|
+
max_selected_message: "{0} of {1} selected",
|
30
|
+
pre_selected_friends: [],
|
31
|
+
exclude_friends: [],
|
32
|
+
friend_fields: "id,name",
|
33
|
+
sorter: function(a, b) {
|
34
|
+
var x = a.name.toLowerCase();
|
35
|
+
var y = b.name.toLowerCase();
|
36
|
+
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
|
37
|
+
},
|
38
|
+
labels: {
|
39
|
+
selected: "Selected",
|
40
|
+
filter_default: "Start typing a name",
|
41
|
+
filter_title: "Find Friends:",
|
42
|
+
all: "All",
|
43
|
+
max_selected_message: "{0} of {1} selected"
|
44
|
+
}
|
45
|
+
}, options || {});
|
46
|
+
var lastSelected; // used when shift-click is performed to know where to start from to select multiple elements
|
47
|
+
|
48
|
+
var arrayToObjectGraph = function(a) {
|
49
|
+
var o = {};
|
50
|
+
for(var i=0, l=a.length; i<l; i++){
|
51
|
+
o[a[i]]='';
|
52
|
+
}
|
53
|
+
return o;
|
54
|
+
};
|
55
|
+
|
56
|
+
// ----------+----------+----------+----------+----------+----------+----------+
|
57
|
+
// Initialization of container
|
58
|
+
// ----------+----------+----------+----------+----------+----------+----------+
|
59
|
+
elem.html(
|
60
|
+
"<div id='jfmfs-friend-selector'>" +
|
61
|
+
" <div id='jfmfs-inner-header'>" +
|
62
|
+
" <span class='jfmfs-title'>" + settings.labels.filter_title + " </span><input type='text' id='jfmfs-friend-filter-text' value='" + settings.labels.filter_default + "'/>" +
|
63
|
+
" <a class='filter-link selected' id='jfmfs-filter-all' href='#'>" + settings.labels.all + "</a>" +
|
64
|
+
" <a class='filter-link' id='jfmfs-filter-selected' href='#'>" + settings.labels.selected + " (<span id='jfmfs-selected-count'>0</span>)</a>" +
|
65
|
+
((settings.max_selected > 0) ? "<div id='jfmfs-max-selected-wrapper'></div>" : "") +
|
66
|
+
" </div>" +
|
67
|
+
" <div id='jfmfs-friend-container'></div>" +
|
68
|
+
"</div>"
|
69
|
+
);
|
70
|
+
|
71
|
+
var friend_container = $("#jfmfs-friend-container"),
|
72
|
+
container = $("#jfmfs-friend-selector"),
|
73
|
+
preselected_friends_graph = arrayToObjectGraph(settings.pre_selected_friends),
|
74
|
+
excluded_friends_graph = arrayToObjectGraph(settings.exclude_friends),
|
75
|
+
all_friends;
|
76
|
+
|
77
|
+
FB.api('/me/friends?fields=' + settings.friend_fields, function(response) {
|
78
|
+
var sortedFriendData = response.data.sort(settings.sorter),
|
79
|
+
preselectedFriends = {},
|
80
|
+
buffer = [],
|
81
|
+
selectedClass = "";
|
82
|
+
|
83
|
+
$.each(sortedFriendData, function(i, friend) {
|
84
|
+
if(! (friend.id in excluded_friends_graph)) {
|
85
|
+
selectedClass = (friend.id in preselected_friends_graph) ? "selected" : "";
|
86
|
+
buffer.push("<div class='jfmfs-friend " + selectedClass + " ' id='" + friend.id +"'><img/><div class='friend-name'>" + friend.name + "</div></div>");
|
87
|
+
}
|
88
|
+
});
|
89
|
+
friend_container.append(buffer.join(""));
|
90
|
+
|
91
|
+
uninitializedImagefriendElements = $(".jfmfs-friend", elem);
|
92
|
+
uninitializedImagefriendElements.bind('inview', function (event, visible) {
|
93
|
+
if( $(this).attr('src') === undefined) {
|
94
|
+
$("img", $(this)).attr("src", "//graph.facebook.com/" + this.id + "/picture");
|
95
|
+
}
|
96
|
+
$(this).unbind('inview');
|
97
|
+
});
|
98
|
+
|
99
|
+
init();
|
100
|
+
});
|
101
|
+
|
102
|
+
|
103
|
+
// ----------+----------+----------+----------+----------+----------+----------+
|
104
|
+
// Public functions
|
105
|
+
// ----------+----------+----------+----------+----------+----------+----------+
|
106
|
+
|
107
|
+
this.getSelectedIds = function() {
|
108
|
+
var ids = [];
|
109
|
+
$.each(elem.find(".jfmfs-friend.selected"), function(i, friend) {
|
110
|
+
ids.push($(friend).attr("id"));
|
111
|
+
});
|
112
|
+
return ids;
|
113
|
+
};
|
114
|
+
|
115
|
+
this.getSelectedIdsAndNames = function() {
|
116
|
+
var selected = [];
|
117
|
+
$.each(elem.find(".jfmfs-friend.selected"), function(i, friend) {
|
118
|
+
selected.push( {id: $(friend).attr("id"), name: $(friend).find(".friend-name").text()});
|
119
|
+
});
|
120
|
+
return selected;
|
121
|
+
};
|
122
|
+
|
123
|
+
this.clearSelected = function () {
|
124
|
+
all_friends.removeClass("selected");
|
125
|
+
};
|
126
|
+
|
127
|
+
// ----------+----------+----------+----------+----------+----------+----------+
|
128
|
+
// Private functions
|
129
|
+
// ----------+----------+----------+----------+----------+----------+----------+
|
130
|
+
|
131
|
+
var init = function() {
|
132
|
+
all_friends = $(".jfmfs-friend", elem);
|
133
|
+
|
134
|
+
// calculate friends per row
|
135
|
+
first_element_offset_px = all_friends.first().offset().top;
|
136
|
+
for(var i=0, l=all_friends.length; i < l; i++ ) {
|
137
|
+
if($(all_friends[i]).offset().top === first_element_offset_px) {
|
138
|
+
friends_per_row++;
|
139
|
+
} else {
|
140
|
+
friend_height_px = $(all_friends[i]).offset().top - first_element_offset_px;
|
141
|
+
break;
|
142
|
+
}
|
143
|
+
}
|
144
|
+
|
145
|
+
// handle when a friend is clicked for selection
|
146
|
+
elem.delegate(".jfmfs-friend", 'click', function(event) {
|
147
|
+
|
148
|
+
// if the element is being selected, test if the max number of items have
|
149
|
+
// already been selected, if so, just return
|
150
|
+
if(!$(this).hasClass("selected") &&
|
151
|
+
maxSelectedEnabled() &&
|
152
|
+
$(".jfmfs-friend.selected").length >= settings.max_selected &&
|
153
|
+
settings.max_selected != 1) {
|
154
|
+
return;
|
155
|
+
}
|
156
|
+
|
157
|
+
// if the max is 1 then unselect the current and select the new
|
158
|
+
if(settings.max_selected == 1) {
|
159
|
+
elem.find(".selected").removeClass("selected");
|
160
|
+
}
|
161
|
+
|
162
|
+
$(this).toggleClass("selected");
|
163
|
+
$(this).removeClass("hover");
|
164
|
+
|
165
|
+
// support shift-click operations to select multiple items at a time
|
166
|
+
if( $(this).hasClass("selected")) {
|
167
|
+
if ( !lastSelected ) {
|
168
|
+
lastSelected = $(this);
|
169
|
+
}
|
170
|
+
else {
|
171
|
+
if( event.shiftKey ) {
|
172
|
+
var selIndex = $(this).index();
|
173
|
+
var lastIndex = lastSelected.index();
|
174
|
+
var end = Math.max(selIndex,lastIndex);
|
175
|
+
var start = Math.min(selIndex,lastIndex);
|
176
|
+
for(var i=start; i<=end; i++) {
|
177
|
+
var aFriend = $( all_friends[i] );
|
178
|
+
if(!aFriend.hasClass("hide-non-selected") && !aFriend.hasClass("hide-filtered")) {
|
179
|
+
if( maxSelectedEnabled() && $(".jfmfs-friend.selected").length < settings.max_selected ) {
|
180
|
+
$( all_friends[i] ).addClass("selected");
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
}
|
186
|
+
}
|
187
|
+
|
188
|
+
// keep track of last selected, this is used for the shift-select functionality
|
189
|
+
lastSelected = $(this);
|
190
|
+
|
191
|
+
// update the count of the total number selected
|
192
|
+
updateSelectedCount();
|
193
|
+
|
194
|
+
if( maxSelectedEnabled() ) {
|
195
|
+
updateMaxSelectedMessage();
|
196
|
+
}
|
197
|
+
elem.trigger("jfmfs.selection.changed", [obj.getSelectedIdsAndNames()]);
|
198
|
+
});
|
199
|
+
|
200
|
+
// filter by selected, hide all non-selected
|
201
|
+
$("#jfmfs-filter-selected").click(function(event) {
|
202
|
+
event.preventDefault();
|
203
|
+
all_friends.not(".selected").addClass("hide-non-selected");
|
204
|
+
$(".filter-link").removeClass("selected");
|
205
|
+
$(this).addClass("selected");
|
206
|
+
});
|
207
|
+
|
208
|
+
// remove filter, show all
|
209
|
+
$("#jfmfs-filter-all").click(function(event) {
|
210
|
+
event.preventDefault();
|
211
|
+
all_friends.removeClass("hide-non-selected");
|
212
|
+
$(".filter-link").removeClass("selected");
|
213
|
+
$(this).addClass("selected");
|
214
|
+
});
|
215
|
+
|
216
|
+
// hover effect on friends
|
217
|
+
elem.find(".jfmfs-friend:not(.selected)").live(
|
218
|
+
'hover', function (ev) {
|
219
|
+
if (ev.type == 'mouseover') {
|
220
|
+
$(this).addClass("hover");
|
221
|
+
}
|
222
|
+
if (ev.type == 'mouseout') {
|
223
|
+
$(this).removeClass("hover");
|
224
|
+
}
|
225
|
+
});
|
226
|
+
|
227
|
+
// filter as you type
|
228
|
+
elem.find("#jfmfs-friend-filter-text")
|
229
|
+
.keyup( function() {
|
230
|
+
var filter = $(this).val();
|
231
|
+
clearTimeout(keyUpTimer);
|
232
|
+
keyUpTimer = setTimeout( function() {
|
233
|
+
if(filter == '') {
|
234
|
+
all_friends.removeClass("hide-filtered");
|
235
|
+
}
|
236
|
+
else {
|
237
|
+
container.find(".friend-name:not(:Contains(" + filter +"))").parent().addClass("hide-filtered");
|
238
|
+
container.find(".friend-name:Contains(" + filter +")").parent().removeClass("hide-filtered");
|
239
|
+
}
|
240
|
+
showImagesInViewPort();
|
241
|
+
}, 400);
|
242
|
+
})
|
243
|
+
.focus( function() {
|
244
|
+
if($.trim($(this).val()) == 'Start typing a name') {
|
245
|
+
$(this).val('');
|
246
|
+
}
|
247
|
+
})
|
248
|
+
.blur(function() {
|
249
|
+
if($.trim($(this).val()) == '') {
|
250
|
+
$(this).val('Start typing a name');
|
251
|
+
}
|
252
|
+
});
|
253
|
+
|
254
|
+
// hover states on the buttons
|
255
|
+
elem.find(".jfmfs-button").hover(
|
256
|
+
function(){ $(this).addClass("jfmfs-button-hover");} ,
|
257
|
+
function(){ $(this).removeClass("jfmfs-button-hover");}
|
258
|
+
);
|
259
|
+
|
260
|
+
// manages lazy loading of images
|
261
|
+
var getViewportHeight = function() {
|
262
|
+
var height = window.innerHeight; // Safari, Opera
|
263
|
+
var mode = document.compatMode;
|
264
|
+
|
265
|
+
if ( (mode || !$.support.boxModel) ) { // IE, Gecko
|
266
|
+
height = (mode == 'CSS1Compat') ?
|
267
|
+
document.documentElement.clientHeight : // Standards
|
268
|
+
document.body.clientHeight; // Quirks
|
269
|
+
}
|
270
|
+
|
271
|
+
return height;
|
272
|
+
};
|
273
|
+
|
274
|
+
var showImagesInViewPort = function() {
|
275
|
+
var container_height_px = friend_container.innerHeight(),
|
276
|
+
scroll_top_px = friend_container.scrollTop(),
|
277
|
+
container_offset_px = friend_container.offset().top,
|
278
|
+
$el, top_px,
|
279
|
+
elementVisitedCount = 0,
|
280
|
+
foundVisible = false,
|
281
|
+
allVisibleFriends = $(".jfmfs-friend:not(.hide-filtered )");
|
282
|
+
|
283
|
+
$.each(allVisibleFriends, function(i, $el){
|
284
|
+
elementVisitedCount++;
|
285
|
+
if($el !== null) {
|
286
|
+
$el = $(allVisibleFriends[i]);
|
287
|
+
top_px = (first_element_offset_px + (friend_height_px * Math.ceil(elementVisitedCount/friends_per_row))) - scroll_top_px - container_offset_px;
|
288
|
+
if (top_px + friend_height_px >= -10 &&
|
289
|
+
top_px - friend_height_px < container_height_px) { // give some extra padding for broser differences
|
290
|
+
$el.data('inview', true);
|
291
|
+
$el.trigger('inview', [ true ]);
|
292
|
+
foundVisible = true;
|
293
|
+
}
|
294
|
+
else {
|
295
|
+
if(foundVisible) {
|
296
|
+
return false;
|
297
|
+
}
|
298
|
+
}
|
299
|
+
}
|
300
|
+
});
|
301
|
+
};
|
302
|
+
|
303
|
+
var updateSelectedCount = function() {
|
304
|
+
$("#jfmfs-selected-count").html( selectedCount() );
|
305
|
+
};
|
306
|
+
|
307
|
+
friend_container.bind('scroll', $.debounce( 250, showImagesInViewPort ));
|
308
|
+
|
309
|
+
updateMaxSelectedMessage();
|
310
|
+
showImagesInViewPort();
|
311
|
+
updateSelectedCount();
|
312
|
+
elem.trigger("jfmfs.friendload.finished");
|
313
|
+
};
|
314
|
+
|
315
|
+
var selectedCount = function() {
|
316
|
+
return $(".jfmfs-friend.selected").length;
|
317
|
+
};
|
318
|
+
|
319
|
+
var maxSelectedEnabled = function () {
|
320
|
+
return settings.max_selected > 0;
|
321
|
+
};
|
322
|
+
|
323
|
+
var updateMaxSelectedMessage = function() {
|
324
|
+
var message = settings.labels.max_selected_message.replace("{0}", selectedCount()).replace("{1}", settings.max_selected);
|
325
|
+
$("#jfmfs-max-selected-wrapper").html( message );
|
326
|
+
};
|
327
|
+
|
328
|
+
};
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
$.fn.jfmfs = function(options) {
|
333
|
+
return this.each(function() {
|
334
|
+
var element = $(this);
|
335
|
+
|
336
|
+
// Return early if this element already has a plugin instance
|
337
|
+
if (element.data('jfmfs')) { return; }
|
338
|
+
|
339
|
+
// pass options to plugin constructor
|
340
|
+
var jfmfs = new JFMFS(this, options);
|
341
|
+
|
342
|
+
// Store plugin object in this element's data
|
343
|
+
element.data('jfmfs', jfmfs);
|
344
|
+
|
345
|
+
});
|
346
|
+
};
|
347
|
+
|
348
|
+
// todo, make this more ambiguous
|
349
|
+
jQuery.expr[':'].Contains = function(a, i, m) {
|
350
|
+
return jQuery(a).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0;
|
351
|
+
};
|
352
|
+
|
353
|
+
|
354
|
+
})(jQuery);
|
355
|
+
|
356
|
+
if($.debounce === undefined) {
|
357
|
+
/*
|
358
|
+
* jQuery throttle / debounce - v1.1 - 3/7/2010
|
359
|
+
* http://benalman.com/projects/jquery-throttle-debounce-plugin/
|
360
|
+
*
|
361
|
+
* Copyright (c) 2010 "Cowboy" Ben Alman
|
362
|
+
* Dual licensed under the MIT and GPL licenses.
|
363
|
+
* http://benalman.com/about/license/
|
364
|
+
*/
|
365
|
+
(function(b,c){var $=b.jQuery||b.Cowboy||(b.Cowboy={}),a;$.throttle=a=function(e,f,j,i){var h,d=0;if(typeof f!=="boolean"){i=j;j=f;f=c}function g(){var o=this,m=+new Date()-d,n=arguments;function l(){d=+new Date();j.apply(o,n)}function k(){h=c}if(i&&!h){l()}h&&clearTimeout(h);if(i===c&&m>e){l()}else{if(f!==true){h=setTimeout(i?k:l,i===c?e-m:e)}}}if($.guid){g.guid=j.guid=j.guid||$.guid++}return g};$.debounce=function(d,e,f){return f===c?a(d,e,false):a(d,f,e!==false)}})(this);
|
366
|
+
}
|
@@ -0,0 +1,11 @@
|
|
1
|
+
(function(a){var t=function(j,l){var b=a(j),m=this,g=[],o,v=0,k=0,r,c=a.extend({max_selected:-1,max_selected_message:"{0} of {1} selected",pre_selected_friends:[],exclude_friends:[],friend_fields:"id,name",sorter:function(d,h){var f=d.name.toLowerCase(),p=h.name.toLowerCase();return f<p?-1:f>p?1:0},labels:{selected:"Selected",filter_default:"Start typing a name",filter_title:"Find Friends:",all:"All",max_selected_message:"{0} of {1} selected"}},l||{}),u,w=function(d){for(var h={},f=0,p=d.length;f<
|
2
|
+
p;f++)h[d[f]]="";return h};b.html("<div id='jfmfs-friend-selector'> <div id='jfmfs-inner-header'> <span class='jfmfs-title'>"+c.labels.filter_title+" </span><input type='text' id='jfmfs-friend-filter-text' value='"+c.labels.filter_default+"'/> <a class='filter-link selected' id='jfmfs-filter-all' href='#'>"+c.labels.all+"</a> <a class='filter-link' id='jfmfs-filter-selected' href='#'>"+c.labels.selected+" (<span id='jfmfs-selected-count'>0</span>)</a>"+(c.max_selected>0?"<div id='jfmfs-max-selected-wrapper'></div>":
|
3
|
+
"")+" </div> <div id='jfmfs-friend-container'></div></div>");var q=a("#jfmfs-friend-container"),x=a("#jfmfs-friend-selector"),F=w(c.pre_selected_friends),G=w(c.exclude_friends),i;FB.api("/me/friends?fields="+c.friend_fields,function(d){d=d.data.sort(c.sorter);var h=[],f="";a.each(d,function(p,e){if(!(e.id in G)){f=e.id in F?"selected":"";h.push("<div class='jfmfs-friend "+f+" ' id='"+e.id+"'><img/><div class='friend-name'>"+e.name+"</div></div>")}});q.append(h.join(""));g=a(".jfmfs-friend",
|
4
|
+
b);g.bind("inview",function(){a(this).attr("src")===undefined&&a("img",a(this)).attr("src","//graph.facebook.com/"+this.id+"/picture");a(this).unbind("inview")});H()});this.getSelectedIds=function(){var d=[];a.each(b.find(".jfmfs-friend.selected"),function(h,f){d.push(a(f).attr("id"))});return d};this.getSelectedIdsAndNames=function(){var d=[];a.each(b.find(".jfmfs-friend.selected"),function(h,f){d.push({id:a(f).attr("id"),name:a(f).find(".friend-name").text()})});return d};this.clearSelected=function(){i.removeClass("selected")};
|
5
|
+
var H=function(){i=a(".jfmfs-friend",b);r=i.first().offset().top;for(var d=0,h=i.length;d<h;d++)if(a(i[d]).offset().top===r)v++;else{k=a(i[d]).offset().top-r;break}b.delegate(".jfmfs-friend","click",function(e){if(!(!a(this).hasClass("selected")&&c.max_selected>0&&a(".jfmfs-friend.selected").length>=c.max_selected&&c.max_selected!=1)){c.max_selected==1&&b.find(".selected").removeClass("selected");a(this).toggleClass("selected");a(this).removeClass("hover");if(a(this).hasClass("selected"))if(u){if(e.shiftKey){var n=
|
6
|
+
a(this).index(),s=u.index();e=Math.max(n,s);for(n=Math.min(n,s);n<=e;n++){s=a(i[n]);!s.hasClass("hide-non-selected")&&!s.hasClass("hide-filtered")&&c.max_selected>0&&a(".jfmfs-friend.selected").length<c.max_selected&&a(i[n]).addClass("selected")}}}else u=a(this);u=a(this);p();c.max_selected>0&&A();b.trigger("jfmfs.selection.changed",[m.getSelectedIdsAndNames()])}});a("#jfmfs-filter-selected").click(function(e){e.preventDefault();i.not(".selected").addClass("hide-non-selected");a(".filter-link").removeClass("selected");
|
7
|
+
a(this).addClass("selected")});a("#jfmfs-filter-all").click(function(e){e.preventDefault();i.removeClass("hide-non-selected");a(".filter-link").removeClass("selected");a(this).addClass("selected")});b.find(".jfmfs-friend:not(.selected)").live("hover",function(e){e.type=="mouseover"&&a(this).addClass("hover");e.type=="mouseout"&&a(this).removeClass("hover")});b.find("#jfmfs-friend-filter-text").keyup(function(){var e=a(this).val();clearTimeout(o);o=setTimeout(function(){if(e=="")i.removeClass("hide-filtered");
|
8
|
+
else{x.find(".friend-name:not(:Contains("+e+"))").parent().addClass("hide-filtered");x.find(".friend-name:Contains("+e+")").parent().removeClass("hide-filtered")}f()},400)}).focus(function(){a.trim(a(this).val())=="Start typing a name"&&a(this).val("")}).blur(function(){a.trim(a(this).val())==""&&a(this).val("Start typing a name")});b.find(".jfmfs-button").hover(function(){a(this).addClass("jfmfs-button-hover")},function(){a(this).removeClass("jfmfs-button-hover")});var f=function(){var e=q.innerHeight(),
|
9
|
+
n=q.scrollTop(),s=q.offset().top,z,B=0,C=false,D=a(".jfmfs-friend:not(.hide-filtered )");a.each(D,function(I,y){B++;if(y!==null){y=a(D[I]);z=r+k*Math.ceil(B/v)-n-s;if(z+k>=-10&&z-k<e){y.data("inview",true);y.trigger("inview",[true]);C=true}else if(C)return false}})},p=function(){a("#jfmfs-selected-count").html(E())};q.bind("scroll",a.debounce(250,f));A();f();p();b.trigger("jfmfs.friendload.finished")},E=function(){return a(".jfmfs-friend.selected").length},A=function(){var d=c.labels.max_selected_message.replace("{0}",
|
10
|
+
E()).replace("{1}",c.max_selected);a("#jfmfs-max-selected-wrapper").html(d)}};a.fn.jfmfs=function(j){return this.each(function(){var l=a(this);if(!l.data("jfmfs")){var b=new t(this,j);l.data("jfmfs",b)}})};jQuery.expr[":"].Contains=function(j,l,b){return jQuery(j).text().toUpperCase().indexOf(b[3].toUpperCase())>=0}})(jQuery);
|
11
|
+
$.debounce===undefined&&function(a,t){var j=a.jQuery||a.Cowboy||(a.Cowboy={}),l;j.throttle=l=function(b,m,g,o){function v(){function c(){r=+new Date;g.apply(w,x)}function u(){k=t}var w=this,q=+new Date-r,x=arguments;o&&!k&&c();k&&clearTimeout(k);if(o===t&&q>b)c();else if(m!==true)k=setTimeout(o?u:c,o===t?b-q:b)}var k,r=0;if(typeof m!=="boolean"){o=g;g=m;m=t}if(j.guid)v.guid=g.guid=g.guid||j.guid++;return v};j.debounce=function(b,m,g){return g===t?l(b,m,false):l(b,g,m!==false)}}(this);
|
@@ -0,0 +1,9 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll automatically include all the stylesheets available in this directory
|
3
|
+
* and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
|
4
|
+
* the top of the compiled file, but it's generally better to create a new file per style scope.
|
5
|
+
*require_self
|
6
|
+
*require_tree .
|
7
|
+
*= require ./FbMultiFriendSelector/jquery.facebook.multifriend.select.css
|
8
|
+
*= require ./Applicious/applicious.css
|
9
|
+
*/
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "applicious_utils/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "applicious_utils"
|
7
|
+
s.version = AppliciousUtils::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Applicious"]
|
10
|
+
s.email = ["mail@appliciousagency.com"]
|
11
|
+
s.homepage = "http://appliciousagency.com"
|
12
|
+
s.summary = %q{Applicious Utilities}
|
13
|
+
s.description = %q{Helper JS & Ruby Functions}
|
14
|
+
|
15
|
+
s.rubyforge_project = "applicious_utils"
|
16
|
+
|
17
|
+
#s.files = `git ls-files`.split("\n")
|
18
|
+
s.files = Dir['**/*'].reject {|fn| File.directory?(fn) }
|
19
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
20
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
21
|
+
s.require_paths = ["lib"]
|
22
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module AppliciousUtils
|
2
|
+
module ViewHelpers
|
3
|
+
|
4
|
+
def applicious_assets
|
5
|
+
asset_tags = ''
|
6
|
+
#asset_tags << javascript_include_tag "applicious_utils"
|
7
|
+
#asset_tags << stylesheet_link_tag "applicious_utils"
|
8
|
+
return asset_tags
|
9
|
+
end
|
10
|
+
|
11
|
+
def pre(text)
|
12
|
+
content_tag :pre, text
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
Binary file
|