Skip to content

Commit

Permalink
Merge pull request oswaldoacauan#68 from yangpro/yangpro
Browse files Browse the repository at this point in the history
Reset Disqus width on mobile orientation change
  • Loading branch information
oswaldoacauan committed Apr 28, 2014
2 parents c583731 + b819fd4 commit 1938823
Showing 1 changed file with 29 additions and 13 deletions.
42 changes: 29 additions & 13 deletions src/assets/js/scripts.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* global FastClick: false, DISQUS: false, DISQUSWIDGETS: false, disqus_identifier:false, ga:false, Drawer: false, ImageLoader: false, NProgress: false, Prism: false */
/* global FastClick: false, DISQUS: false, DISQUSWIDGETS: true, disqus_identifier:false, ga:false, Drawer: false, ImageLoader: false, NProgress: false, Prism: false */
(function ($, window, document, undefined) {

'use strict';
Expand Down Expand Up @@ -39,6 +39,27 @@

_prismHandler();

// Reset DISQUS
// =================
var _resetDisqus = function() {
if(typeof DISQUS === 'object' && $('#disqus_thread').length) {
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = disqus_identifier;
}
});
}

if(typeof DISQUSWIDGETS === 'object') {
DISQUSWIDGETS = undefined;
var countjs = $html.find('head script[src*="disqus.com/count.js"]').remove();
$('<script async type="text/javascript">').attr({
src: countjs.attr('src')
}).appendTo('head');
}
};

// PJax bindings
// =================
if ($.support.pjax) {
Expand All @@ -53,18 +74,7 @@
ga('send', 'pageview');
}

if(typeof DISQUS === 'object' && $('#disqus_thread').length) {
DISQUS.reset({
reload: true,
config: function () {
this.page.identifier = disqus_identifier;
}
});
}

if(typeof DISQUSWIDGETS === 'object') {
DISQUSWIDGETS.getCount();
}
_resetDisqus();

$('[data-load-image]', $content).each(function() {
ImageLoader.load($(this));
Expand Down Expand Up @@ -184,6 +194,12 @@
$('.wrapper').eq(0).focus();
}

// Fix DISQUS iframe does not resize on mobile orientation change
// =================
$window.on('orientationchange', function(e) {
_resetDisqus();
});

});

})(jQuery, window, document);

0 comments on commit 1938823

Please sign in to comment.