Skip to content

Commit

Permalink
Added facebook comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Dec 26, 2015
1 parent 2f5a665 commit 8273a90
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 53 deletions.
92 changes: 48 additions & 44 deletions assets/js/src/main.js
Original file line number Diff line number Diff line change
@@ -1,58 +1,62 @@
/*globals jQuery, document */
(function ($) {
"use strict";

$(document).ready(function(){
$(".post-content").fitVids();
});

// When all content is loaded, resize dem images
$(window).load(function() {

function casperFullImg() {
$("img").each( function() {
var contentWidth = $(".post-content").outerWidth(); // Width of the content
var imageWidth = $(this)[0].naturalWidth; // Original image resolution

if (imageWidth >= contentWidth) {
$(this).addClass('full-img');
} else {
$(this).removeClass('full-img');
}
});
};
casperFullImg();
$(window).smartresize(casperFullImg);
});
(function($) {
"use strict";

$(document).ready(function() {
$(".post-content").fitVids();
});

// When all content is loaded, resize dem images
$(window).load(function() {

function casperFullImg() {
$("img").each(function() {
var contentWidth = $(".post-content").outerWidth(); // Width of the content
var imageWidth = $(this)[0].naturalWidth; // Original image resolution

if (imageWidth >= contentWidth) {
$(this).addClass('full-img');
} else {
$(this).removeClass('full-img');
}
});
};

casperFullImg();
$(window).smartresize(casperFullImg);
});


}(jQuery));

(function($,sr){
(function($, sr) {

// debouncing function from John Hann
// http://unscriptable.com/index.php/2009/03/20/debouncing-javascript-methods/
var debounce = function (func, threshold, execAsap) {
var debounce = function(func, threshold, execAsap) {
var timeout;

return function debounced () {
var obj = this, args = arguments;
function delayed () {
if (!execAsap)
func.apply(obj, args);
timeout = null;
};
return function debounced() {
var obj = this,
args = arguments;

function delayed() {
if (!execAsap)
func.apply(obj, args);
timeout = null;
};

if (timeout)
clearTimeout(timeout);
else if (execAsap)
func.apply(obj, args);
if (timeout)
clearTimeout(timeout);
else if (execAsap)
func.apply(obj, args);

timeout = setTimeout(delayed, threshold || 100);
timeout = setTimeout(delayed, threshold || 100);
};
}
// smartresize
jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };
}
// smartresize
jQuery.fn[sr] = function(fn) {
return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr);
};

})(jQuery,'smartresize');
})(jQuery, 'smartresize');
9 changes: 9 additions & 0 deletions assets/scss/global.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1316,3 +1316,12 @@ li.nav-enviar-noticia > a {
margin: 15px 0 !important;
}
}

/* Facebook Comments */

.fb_iframe_widget,
.fb_iframe_widget span,
.fb_iframe_widget span iframe[style] {
min-width: 100% !important;
width: 100% !important;
}
16 changes: 16 additions & 0 deletions partials/comments.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<div id="fb-root"></div>
<script>(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 = "//connect.facebook.net/es_ES/sdk.js#xfbml=1&version=v2.4&appId=1704459529784952";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>

<div
class="fb-comments"
data-href="{{@blog.url}}/{{slug}}"
data-colorscheme="light"
data-numposts="10"
data-width="100%">
</div>
10 changes: 1 addition & 9 deletions post.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,7 @@
</footer>

<section class="comments">
<div id="disqus_thread"></div>
<script type="text/javascript">
var disqus_identifier = 'ghost-{{id}}';
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
{{> comments}}
</section>

{{/post}}
Expand Down

0 comments on commit 8273a90

Please sign in to comment.