");
var numToLoad=this.options.loadCount;
var count=this.options.loadCount;
$element.find(".pagination").css({"display":"none"});
if($element.find(listType+" .page").length==numToLoad){
$('
< Previous
'+thisPlugin.options.buttonLabel+'
').insertAfter($element.find(listType));
$element.find("#lazyLoad").css({display: "block", "padding": "0px"});
$element.find("#lazyLoadInnerNext").css({"background-image" : "none"});
}
$element.find("#lazyLoadInnerNext").live("click", function(){
if(optionListType=="grid"){
var currPos = parseInt($element.find(".gridSlide.active").attr("id").replace("pos",""))+parseInt(1);
}
if($element.find(".gridSlide#pos"+currPos).size()){
$element.find(".gridSlide").removeClass("active");
$element.find(".gridSlide#pos"+currPos).delay(200).queue(function(next){
$(this).addClass("active");
next();
});
thisPlugin.options.clickCount++;
}else{
$(this).css({"background-image": "url(/content/dam/www/news/news-search/loading.gif)"});
var searchHref= thisPlugin.options.listPath+count;
//jQuery(this).lazyLoad(searchHref);
thisPlugin._lazyLoad(searchHref);
count +=numToLoad;
}
$element.find("#lazyLoadInnerPrev").addClass("active");
});
$element.find("#lazyLoadInnerPrev").live("click", function(){
if(optionListType=="grid"){
var currPos = $element.find(".gridSlide.active").attr("id").replace("pos","")-1;
}
$element.find("#lazyLoadInnerNext").removeClass("disabled").html("More >");
if(currPos > -1){
$element.find(".gridSlide").removeClass("active");
$element.find(".gridSlide#pos"+currPos).delay( 530 ).queue(function(next) {
$(this).addClass("active");
next();
});
thisPlugin.options.clickCount--;
}
if(currPos==0){
$element.find("#lazyLoadInnerPrev").removeClass("active");
}
});
//LazyLoad function for search results
//var llResults = "";
this._updateTheme();
},
_setOption: function (key, value) {
switch (key) {
case 'theme':
this.options.theme = value;
this._updateTheme();
break;
case 'listPath':
this.options.listPath = value;
break;
}
},
_lazyLoad: function (url){
var $element = this.element;
var thisPlugin = this;
var optionListType= this.options.listType;
var listType= ".list-style-teaser-grid";
if(this.options.listType == 'list'){
listType = '.link-list';
} else if(this.options.listType == 'no-image-list') {
listType = '.list-style-teaser-no-image';
}
jQuery.get(url, function(data) {
var moreNews = $("
" + data + "
");
$(moreNews).find(".list-style-teaser-grid>.clear").remove();
$(moreNews).find(".list-style-teaser-grid").wrapInner("
");
moreNews = $(moreNews).find(listType);
if (moreNews.find(".page").length == 0) {
$element.find("#lazyLoadInnerNext").addClass("disabled").html(thisPlugin.options.buttonEmptyLabel);
$element.find("#lazyLoadInnerNext").unbind("click");
} else {
$element.find(".gridSlide").removeClass("active");
var jqMoreNews = $(moreNews).html();
$(jqMoreNews).appendTo($element.find(".list-style-teaser-news"));
$(jqMoreNews).appendTo($element.find(listType));
$element.find("#pos" + thisPlugin.options.clickCount).delay( 200 ).queue(function(next) {
$(this).addClass("active");
next();
});
thisPlugin.options.clickCount++;
}
if ($element.find('.list-style-teaser-grid').size()) {
moreNews.find(".img-140 span").each(function() {
var imgW = 140;
var imgH = 88;
$(this).attr('data-src', $(this).attr('data-src').replace('60.60', imgW + '.' + imgH));
});
}
$element.find("#lazyLoadInnerNext").css({
"background-image" : "none"
});
if ($element.find('.list-style-teaser-news').size()) {
thisPlugin._makePicFill($element.find('.list-style-teaser-news .teaser-block'));
} else if ($element.find('.list-style-teaser-grid').size()) {
thisPlugin._makePicFill($element.find('.list-style-teaser-grid .teaser-block'));
}
if(thisPlugin.options.getTags){
getTags($element.find(".list-style-teaser-grid .newspage.page .teaser"));
}
});
},
// private methods
_updateTheme: function () {
var $element = this.element;
$element.addClass(this.options.theme);
$element.addClass('load-stage');
},
_makePicFill: function (thisEl) {
var ps = thisEl.find( "span" );
// Loop the pictures
for( var i = 0, il = ps.length; i < il; i++ ){
if( ps[ i ].getAttribute( "data-picture" ) !== null ){
var sources = ps[ i ].getElementsByTagName( "span" ),
matches = [];
// See if which sources match
for( var j = 0, jl = sources.length; j < jl; j++ ){
var media = sources[ j ].getAttribute( "data-media" );
// if there's no media specified, OR w.matchMedia is supported
if( !media ){
matches.push( sources[ j ] );
}
}
// Find any existing img element in the picture element
var picImg = ps[ i ].getElementsByTagName( "img" )[ 0 ];
if( matches.length ){
var matchedEl = matches.pop();
if( !picImg || picImg.parentNode.nodeName === "NOSCRIPT" ){
picImg = document.createElement( "img" );
picImg.alt = ps[ i ].getAttribute( "data-alt" );
}
picImg.src = matchedEl.getAttribute( "data-src" );
matchedEl.appendChild( picImg );
}
else if( picImg ){
picImg.parentNode.removeChild( picImg );
}
}
}
},
// example of a public function
// call this like $('#widget').titlewidget('makeItGreen');
expandGrid: function (e) {
e.preventDefault();
var $element = this.element;
},
// Use the destroy method to clean up any modifications your widget has made to the DOM
destroy: function () {
$.Widget.prototype.destroy.call(this);
var $element = this.element;
var themeType = this.options.theme;
}
});
}(jQuery));