{"id":337,"date":"2013-08-13T13:49:37","date_gmt":"2013-08-13T11:49:37","guid":{"rendered":"http:\/\/dev.flauschig.ch\/wordpress\/?p=337"},"modified":"2013-08-13T13:49:37","modified_gmt":"2013-08-13T11:49:37","slug":"facebook-sliding-like-box-script","status":"publish","type":"post","link":"http:\/\/dev.flauschig.ch\/wordpress\/?p=337","title":{"rendered":"Facebook Sliding Like Box Script"},"content":{"rendered":"<p>Facebook provides a <a href=\"https:\/\/developers.facebook.com\/docs\/reference\/plugins\/like-box\/\">Like Box<\/a> to show on your Website, what&#8217;s going on on your facebook page.<\/p>\n<p>A nice way to show this box is by a simple tab on the left or right which (on mouseover) slides in this box.<\/p>\n<p>Here&#8217;s an easy script to implement this on your page.<\/p>\n<p>Following steps are needed to implement this:<\/p>\n<p>1. Upload the Images for the Facebook Text-Logo<br \/>\n<a href=\"http:\/\/dev.flauschig.ch\/wordpress\/wp-content\/uploads\/2013\/08\/fbtext_left.png\">Image Left<\/a><br \/>\n<a href=\"http:\/\/dev.flauschig.ch\/wordpress\/wp-content\/uploads\/2013\/08\/fbtext_right.png\">Image Right<\/a><\/p>\n<p>2. Add the jQuery Script to your page<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;script src=&quot;https:\/\/ajax.googleapis.com\/ajax\/libs\/jquery\/1.8.2\/jquery.min.js&quot;&gt;&lt;\/script&gt;\r\n<\/pre>\n<p>3. Add the CSS Styles<\/p>\n<pre class=\"brush: css; title: ; notranslate\" title=\"\">\r\n&lt;style type='text\/css'&gt;\r\n\/*&lt;!&#x5B;CDATA&#x5B;*\/\r\n#fbplikebox {\r\n\tdisplay: block;\r\n\tpadding: 0;\r\n\tz-index: 99999;\r\n\tposition: fixed;\r\n}\r\n.fbplbadgeright {\r\n\tbackground-color:#3B5998;\r\n\tdisplay: block;\r\n\theight: 150px;\r\n\ttop: 50%;\r\n\tmargin-top: -75px;\r\n\tposition: absolute;\r\n\tleft: -47px;\r\n\twidth: 47px;\r\n\tbackground-image: url('fbtext_right.png');\r\n\tbackground-repeat: no-repeat;\r\n\toverflow: hidden;\r\n\t-webkit-border-top-left-radius: 8px;\r\n\t-webkit-border-bottom-left-radius: 8px;\r\n\t-moz-border-radius-topleft: 8px;\r\n\t-moz-border-radius-bottomleft: 8px;\r\n\tborder-top-left-radius: 8px;\r\n\tborder-bottom-left-radius: 8px;\r\n}\r\n.fbplbadgeleft {\r\n\tbackground-color:#3B5998;\r\n\tdisplay: block;\r\n\theight: 150px;\r\n\ttop: 50%;\r\n\tmargin-top: -75px;\r\n\tposition: absolute;\r\n\tright: -47px;\r\n\twidth: 47px;\r\n\tbackground-image: url('fbtext_left.png');\r\n\tbackground-repeat: no-repeat;\r\n\toverflow: hidden;\r\n\t-webkit-border-top-right-radius: 8px;\r\n\t-webkit-border-bottom-right-radius: 8px;\r\n\t-moz-border-radius-topright: 8px;\r\n\t-moz-border-radius-bottomright: 8px;\r\n\tborder-top-right-radius: 8px;\r\n\tborder-bottom-right-radius: 8px;\r\n}\r\n\/*]]&gt;*\/\r\n&lt;\/style&gt;\r\n<\/pre>\n<p>4. Add the Javascript<\/p>\n<pre class=\"brush: jscript; title: ; notranslate\" title=\"\">\r\n&lt;script type='text\/javascript'&gt;\r\n\/*&lt;!&#x5B;CDATA&#x5B;*\/\r\n    (function(w2b){\r\n        w2b(document).ready(function(){\r\n\t\t\tvar fromRight = false;\r\n\t\t\tvar topPosition = 50;\r\n\t\t\tvar logoPosition = 150;\r\n\t\t\tvar elementWidth = 292;\r\n            var $dur = 'medium';\r\n\t\t\t\r\n\t\t\t\/\/ Set the Tab Position\r\n\t\t\t$(&quot;#fbplikeboxlogo&quot;).css(&quot;top&quot;, logoPosition);\r\n\t\t\t\r\n\t\t\tif (fromRight) {\r\n\t\t\t\t$(&quot;#fbplikeboxlogo&quot;).addClass(&quot;fbplbadgeright&quot;);\r\n\t\t\t\tw2b('#fbplikebox').css({right: -elementWidth, 'top' : topPosition })\r\n\t\t\t\tw2b('#fbplikebox').hover(function () {\r\n\t\t\t\t\tw2b(this).stop().animate({\r\n\t\t\t\t\t\tright: 0\r\n\t\t\t\t\t}, $dur);\r\n\t\t\t\t}, function () {\r\n\t\t\t\t\tw2b(this).stop().animate({\r\n\t\t\t\t\t\tright: -elementWidth\r\n\t\t\t\t\t}, $dur);\r\n\t\t\t\t});\r\n\t\t\t} else {\r\n\t\t\t\t$(&quot;#fbplikeboxlogo&quot;).addClass(&quot;fbplbadgeleft&quot;);\r\n\t\t\t\tw2b('#fbplikebox').css({left: -elementWidth, 'top' : topPosition })\r\n\t\t\t\tw2b('#fbplikebox').hover(function () {\r\n\t\t\t\t\tw2b(this).stop().animate({\r\n\t\t\t\t\t\tleft: 0\r\n\t\t\t\t\t}, $dur);\r\n\t\t\t\t}, function () {\r\n\t\t\t\t\tw2b(this).stop().animate({\r\n\t\t\t\t\t\tleft: -elementWidth\r\n\t\t\t\t\t}, $dur);\r\n\t\t\t\t});\r\n\t\t\t}\r\n\t\t\tw2b('#fbplikebox').show();\r\n        });\r\n    })(jQuery);\r\n\/*]]&gt;*\/\r\n&lt;\/script&gt;\r\n<\/pre>\n<p>5. Add the Content<\/p>\n<pre class=\"brush: xml; title: ; notranslate\" title=\"\">\r\n&lt;div id='fbplikebox' style='display:none;'&gt;\r\n    &lt;div id='fbplikeboxlogo'&gt;&lt;\/div&gt; \r\n\t&lt;iframe src=&quot;http:\/\/www.facebook.com\/plugins\/likebox.php?href=https%3A%2F%2Fwww.facebook.com%2FFacebookDevelopers&amp;amp;width=292&amp;amp;height=590&amp;amp;colorscheme=light&amp;amp;show_faces=true&amp;amp;header=true&amp;amp;stream=true&amp;amp;show_border=true&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;border:none; overflow:hidden; width:292px; height:590px; background:#FFFFFF;&quot; allowTransparency=&quot;true&quot;&gt;&lt;\/iframe&gt;\r\n&lt;\/div&gt;\r\n<\/pre>\n<p>There you go, that is all. Here&#8217;s a working examle:<br \/>\n<a href=\"http:\/\/dev.flauschig.ch\/wordpress\/wp-content\/uploads\/2013\/08\/facebookslide.html\" target=\"_blank\">facebookslide<\/a><\/p>\n<p>There are some configuration variables at the top of the javascript:<\/p>\n<table>\n<tr>\n<td>Name<\/td>\n<td>Function<\/td>\n<\/tr>\n<tr>\n<td>fromRight<\/td>\n<td>Defines if the tab is on the left or on the right<\/td>\n<\/tr>\n<tr>\n<td>topPosition<\/td>\n<td>The space from the top of the page before the box starts<\/td>\n<\/tr>\n<tr>\n<td>logoPosition<\/td>\n<td>The space from the top where the tab appears<\/td>\n<\/tr>\n<tr>\n<td>elementWidth<\/td>\n<td>The width of the facebook box<\/td>\n<\/tr>\n<\/table>\n","protected":false},"excerpt":{"rendered":"<p>Facebook provides a Like Box to show on your Website, what&#8217;s going on on your facebook page. A nice way to show this box is by a simple tab on the left or right which (on mouseover) slides in this box. Here&#8217;s an easy script to implement this on your page. Following steps are needed &hellip; <\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[13,3],"tags":[],"class_list":{"0":"entry","1":"post","2":"publish","3":"author-roemer","4":"post-337","6":"format-standard","7":"category-html-css","8":"category-programming"},"acf":[],"views":11826,"_links":{"self":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/337"}],"collection":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=337"}],"version-history":[{"count":0,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=\/wp\/v2\/posts\/337\/revisions"}],"wp:attachment":[{"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=337"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=337"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/dev.flauschig.ch\/wordpress\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=337"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}