User:BryghtShadow/WikiaArticleComments.js

(function( window, $ ) {

// This file is included on every page. // If we aren't on an article page, halt execution here. // TODO: revisit this at some point when we have dependency loading. if ( !window.wgIsArticle ) { return; }

var $window = $(window);

if (ArticleComments.loadOnDemand) { $(function {		//NO article comment on this page lets just skip 		if( $('#WikiaArticleComments').length == 0 ) {			return true;		}		var content,			hash = window.location.hash,			permalink = /^#comm-/.test(hash),			// TODO: we should be able to load it this way			//styleAssets.push($.getAssetManagerGroupUrl('articlecomments' + (ArticleComments.miniEditorEnabled ? '_mini_editor' : '') + '_scss'));			styleAssets = [$.getSassCommonURL('skins/oasis/css/core/ArticleComments.scss')],			$comments = $('#WikiaArticleComments');

var belowTheFold = function { return $comments.offset.top >= ($window.scrollTop + $window.height); };

if (ArticleComments.miniEditorEnabled) { styleAssets.push($.getSassCommonURL('extensions/wikia/MiniEditor/css/MiniEditor.scss')); styleAssets.push($.getSassCommonURL('extensions/wikia/MiniEditor/css/ArticleComments/ArticleComments.scss')); }

var loadAssets = function { $.when(				$.getResources(styleAssets),				$.nirvana.sendRequest({ controller: 'ArticleCommentsController', method: 'Content', format: 'html', type: 'GET', data: { articleId: window.wgArticleId, page: $comments.data('page'), skin: true },					callback: function(response) { content = response; }				})			).then(function {				$comments.removeClass('loading').html(content);

ArticleComments.init;

if (permalink) { ArticleComments.scrollToElement(hash); }			});		};

// Eager loading comments loadAssets; });

} else { wgAfterContentAndJS.push(ArticleComments.init); }

console.log("Should be eagerly loading Article Comments now...");

})( this, jQuery );