-
Notifications
You must be signed in to change notification settings - Fork 1
/
facebook-embed.js
164 lines (113 loc) · 3.47 KB
/
facebook-embed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
window.fbAsyncInit = function() {
function dayOfWeekAsString(dayIndex) {
return ["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"][dayIndex];
}
function monthAsString(monthIndex) {
return ["January","February","March","April","May","June","July","August","September","October","November","December"][monthIndex];
}
FB.init({
appId : '1744135619181438',//add your app ID
xfbml : true,
version : 'v2.7'
});
FB.AppEvents.logPageView();
function getFeed (callback) {
FB.api(
'13803164549/feed',//or use your feed ID
{access_token: '1744135619181438|OItwAPAv2d8-p32E-sSqHXQR4vE'},//add your access token
function(feedResponse) {
if (callback) {
callback(feedResponse);
}
}
);
}
function writeFeed(callback) {
getFeed(function (feedResponse) {
var div = $('<div/>')
.addClass('grid-sizer')
.appendTo('#facebook');
var postID;
var postEmbedURL;
var k = 1
var l = 1
$.each(feedResponse.data, function(key, value) {
l++
postID = $(this.id).selector.split("_")[1];
postEmbedURL ="https://www.facebook.com/plugins/post.php?href=https%3A%2F%2Fwww.facebook.com%2FBCLawLib%2Fposts%2F"+postID+"&width=350"
if (k==1) {
firstPostID = postID
k++
}
var div = $('<div/>')
.attr('id', postID)
.addClass('facebookPost')
.addClass('grid-item')
.appendTo('#facebook');
var fbInner = $('<div>')
.addClass('fbInner')
.appendTo(div);
var more = $('<div>')
.addClass('fbMore')
.addClass('fbToggle')
.text('More')
.appendTo(fbInner);
var less = $('<div>')
.addClass('fbLess')
.addClass('fbToggle')
.text('Less')
.appendTo(fbInner);
var frame = $('<iframe>')
.attr('src', postEmbedURL)
.attr({"height":"800px","scrolling":"no", "frameborder":"0", "allowTransparency":"true", "allow":"encrypted-media"})
.appendTo(fbInner);
});
$('#fb-feed-container').show();
// init Masonry
var $grid = $('.grid').masonry({
// options...
columnWidth: '.grid-sizer',
itemSelector: '.grid-item',
percentPosition:true,
transitionDuration: '2.0s'
});
//layout Masonry after each image loads
$grid.imagesLoaded().progress( function() {
$grid.masonry('layout');
});
$('.fbMore').click(function() {
$(this)
.hide()
.parent()
.toggleClass('open')
.animate({height: "500px"},300, function(){$grid.masonry('layout')})
.parent()
.toggleClass('open')
.find('.fbLess')
.show();
});
$('.fbLess').click(function() {
$(this)
.hide()
.parent()
.toggleClass('open')
.animate({height: "200px"},300, function(){$grid.masonry('layout')})
.parent()
.toggleClass('open')
.find('.fbMore')
.show();
});
});
};
writeFeed(function() {
});
};
(function(d, s, id){
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) {return;}
js = d.createElement(s); js.id = id;
js.src = "https://connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
$( document ).ready(function() {
});